documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. /**
  1465. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  1871. /** viewport left coordinate */
  1872. x: number,
  1873. /** viewport top coordinate */
  1874. y: number,
  1875. /**viewport width */
  1876. width: number,
  1877. /** viewport height */
  1878. height: number);
  1879. /**
  1880. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Class representing a vector containing 2 coordinates
  1918. */
  1919. export class Vector2 {
  1920. /** defines the first coordinate */
  1921. x: number;
  1922. /** defines the second coordinate */
  1923. y: number;
  1924. /**
  1925. * Creates a new Vector2 from the given x and y coordinates
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. */
  1929. constructor(
  1930. /** defines the first coordinate */
  1931. x?: number,
  1932. /** defines the second coordinate */
  1933. y?: number);
  1934. /**
  1935. * Gets a string with the Vector2 coordinates
  1936. * @returns a string with the Vector2 coordinates
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Gets class name
  1941. * @returns the string "Vector2"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Gets current vector hash code
  1946. * @returns the Vector2 hash code as a number
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1951. * @param array defines the source array
  1952. * @param index defines the offset in source array
  1953. * @returns the current Vector2
  1954. */
  1955. toArray(array: FloatArray, index?: number): Vector2;
  1956. /**
  1957. * Copy the current vector to an array
  1958. * @returns a new array with 2 elements: the Vector2 coordinates.
  1959. */
  1960. asArray(): number[];
  1961. /**
  1962. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1963. * @param source defines the source Vector2
  1964. * @returns the current updated Vector2
  1965. */
  1966. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1967. /**
  1968. * Sets the Vector2 coordinates with the given floats
  1969. * @param x defines the first coordinate
  1970. * @param y defines the second coordinate
  1971. * @returns the current updated Vector2
  1972. */
  1973. copyFromFloats(x: number, y: number): Vector2;
  1974. /**
  1975. * Sets the Vector2 coordinates with the given floats
  1976. * @param x defines the first coordinate
  1977. * @param y defines the second coordinate
  1978. * @returns the current updated Vector2
  1979. */
  1980. set(x: number, y: number): Vector2;
  1981. /**
  1982. * Add another vector with the current one
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1985. */
  1986. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2
  2004. */
  2005. addVector3(otherVector: Vector3): Vector2;
  2006. /**
  2007. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. subtract(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Multiplies in place the current Vector2 coordinates by the given ones
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2033. * @param otherVector defines the other vector
  2034. * @returns a new Vector2
  2035. */
  2036. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @param result defines the target vector
  2041. * @returns the unmodified current Vector2
  2042. */
  2043. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2044. /**
  2045. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2046. * @param x defines the first coordinate
  2047. * @param y defines the second coordinate
  2048. * @returns a new Vector2
  2049. */
  2050. multiplyByFloats(x: number, y: number): Vector2;
  2051. /**
  2052. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2053. * @param otherVector defines the other vector
  2054. * @returns a new Vector2
  2055. */
  2056. divide(otherVector: Vector2): Vector2;
  2057. /**
  2058. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @param result defines the target vector
  2061. * @returns the unmodified current Vector2
  2062. */
  2063. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2064. /**
  2065. * Divides the current Vector2 coordinates by the given ones
  2066. * @param otherVector defines the other vector
  2067. * @returns the current updated Vector2
  2068. */
  2069. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2070. /**
  2071. * Gets a new Vector2 with current Vector2 negated coordinates
  2072. * @returns a new Vector2
  2073. */
  2074. negate(): Vector2;
  2075. /**
  2076. * Negate this vector in place
  2077. * @returns this
  2078. */
  2079. negateInPlace(): Vector2;
  2080. /**
  2081. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2082. * @param result defines the Vector3 object where to store the result
  2083. * @returns the current Vector2
  2084. */
  2085. negateToRef(result: Vector2): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Class used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Negate this vector in place
  2439. * @returns this
  2440. */
  2441. negateInPlace(): Vector3;
  2442. /**
  2443. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2444. * @param result defines the Vector3 object where to store the result
  2445. * @returns the current Vector3
  2446. */
  2447. negateToRef(result: Vector3): Vector3;
  2448. /**
  2449. * Multiplies the Vector3 coordinates by the float "scale"
  2450. * @param scale defines the multiplier factor
  2451. * @returns the current updated Vector3
  2452. */
  2453. scaleInPlace(scale: number): Vector3;
  2454. /**
  2455. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2456. * @param scale defines the multiplier factor
  2457. * @returns a new Vector3
  2458. */
  2459. scale(scale: number): Vector3;
  2460. /**
  2461. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2462. * @param scale defines the multiplier factor
  2463. * @param result defines the Vector3 object where to store the result
  2464. * @returns the current Vector3
  2465. */
  2466. scaleToRef(scale: number, result: Vector3): Vector3;
  2467. /**
  2468. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2469. * @param scale defines the scale factor
  2470. * @param result defines the Vector3 object where to store the result
  2471. * @returns the unmodified current Vector3
  2472. */
  2473. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2474. /**
  2475. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2476. * @param otherVector defines the second operand
  2477. * @returns true if both vectors are equals
  2478. */
  2479. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2480. /**
  2481. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2482. * @param otherVector defines the second operand
  2483. * @param epsilon defines the minimal distance to define values as equals
  2484. * @returns true if both vectors are distant less than epsilon
  2485. */
  2486. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2487. /**
  2488. * Returns true if the current Vector3 coordinates equals the given floats
  2489. * @param x defines the x coordinate of the operand
  2490. * @param y defines the y coordinate of the operand
  2491. * @param z defines the z coordinate of the operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equalsToFloats(x: number, y: number, z: number): boolean;
  2495. /**
  2496. * Multiplies the current Vector3 coordinates by the given ones
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2503. * @param otherVector defines the second operand
  2504. * @returns the new Vector3
  2505. */
  2506. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2524. * @param otherVector defines the second operand
  2525. * @returns the new Vector3
  2526. */
  2527. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2528. /**
  2529. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2530. * @param otherVector defines the second operand
  2531. * @param result defines the Vector3 object where to store the result
  2532. * @returns the current Vector3
  2533. */
  2534. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2535. /**
  2536. * Divides the current Vector3 coordinates by the given ones.
  2537. * @param otherVector defines the second operand
  2538. * @returns the current updated Vector3
  2539. */
  2540. divideInPlace(otherVector: Vector3): Vector3;
  2541. /**
  2542. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2543. * @param other defines the second operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2549. * @param other defines the second operand
  2550. * @returns the current updated Vector3
  2551. */
  2552. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2553. /**
  2554. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2555. * @param x defines the x coordinate of the operand
  2556. * @param y defines the y coordinate of the operand
  2557. * @param z defines the z coordinate of the operand
  2558. * @returns the current updated Vector3
  2559. */
  2560. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2561. /**
  2562. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2571. * Check if is non uniform within a certain amount of decimal places to account for this
  2572. * @param epsilon the amount the values can differ
  2573. * @returns if the the vector is non uniform to a certain number of decimal places
  2574. */
  2575. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2576. /**
  2577. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2578. */
  2579. get isNonUniform(): boolean;
  2580. /**
  2581. * Gets a new Vector3 from current Vector3 floored values
  2582. * @returns a new Vector3
  2583. */
  2584. floor(): Vector3;
  2585. /**
  2586. * Gets a new Vector3 from current Vector3 floored values
  2587. * @returns a new Vector3
  2588. */
  2589. fract(): Vector3;
  2590. /**
  2591. * Gets the length of the Vector3
  2592. * @returns the length of the Vector3
  2593. */
  2594. length(): number;
  2595. /**
  2596. * Gets the squared length of the Vector3
  2597. * @returns squared length of the Vector3
  2598. */
  2599. lengthSquared(): number;
  2600. /**
  2601. * Normalize the current Vector3.
  2602. * Please note that this is an in place operation.
  2603. * @returns the current updated Vector3
  2604. */
  2605. normalize(): Vector3;
  2606. /**
  2607. * Reorders the x y z properties of the vector in place
  2608. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2609. * @returns the current updated vector
  2610. */
  2611. reorderInPlace(order: string): this;
  2612. /**
  2613. * Rotates the vector around 0,0,0 by a quaternion
  2614. * @param quaternion the rotation quaternion
  2615. * @param result vector to store the result
  2616. * @returns the resulting vector
  2617. */
  2618. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2619. /**
  2620. * Rotates a vector around a given point
  2621. * @param quaternion the rotation quaternion
  2622. * @param point the point to rotate around
  2623. * @param result vector to store the result
  2624. * @returns the resulting vector
  2625. */
  2626. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2629. * The cross product is then orthogonal to both current and "other"
  2630. * @param other defines the right operand
  2631. * @returns the cross product
  2632. */
  2633. cross(other: Vector3): Vector3;
  2634. /**
  2635. * Normalize the current Vector3 with the given input length.
  2636. * Please note that this is an in place operation.
  2637. * @param len the length of the vector
  2638. * @returns the current updated Vector3
  2639. */
  2640. normalizeFromLength(len: number): Vector3;
  2641. /**
  2642. * Normalize the current Vector3 to a new vector
  2643. * @returns the new Vector3
  2644. */
  2645. normalizeToNew(): Vector3;
  2646. /**
  2647. * Normalize the current Vector3 to the reference
  2648. * @param reference define the Vector3 to update
  2649. * @returns the updated Vector3
  2650. */
  2651. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Creates a new Vector3 copied from the current Vector3
  2654. * @returns the new Vector3
  2655. */
  2656. clone(): Vector3;
  2657. /**
  2658. * Copies the given vector coordinates to the current Vector3 ones
  2659. * @param source defines the source Vector3
  2660. * @returns the current updated Vector3
  2661. */
  2662. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2663. /**
  2664. * Copies the given floats to the current Vector3 coordinates
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the current updated Vector3
  2669. */
  2670. copyFromFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Copies the given floats to the current Vector3 coordinates
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. set(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Copies the given float to the current Vector3 coordinates
  2681. * @param v defines the x, y and z coordinates of the operand
  2682. * @returns the current updated Vector3
  2683. */
  2684. setAll(v: number): Vector3;
  2685. /**
  2686. * Get the clip factor between two vectors
  2687. * @param vector0 defines the first operand
  2688. * @param vector1 defines the second operand
  2689. * @param axis defines the axis to use
  2690. * @param size defines the size along the axis
  2691. * @returns the clip factor
  2692. */
  2693. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2694. /**
  2695. * Get angle between two vectors
  2696. * @param vector0 angle between vector0 and vector1
  2697. * @param vector1 angle between vector0 and vector1
  2698. * @param normal direction of the normal
  2699. * @return the angle between vector0 and vector1
  2700. */
  2701. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2702. /**
  2703. * Returns a new Vector3 set from the index "offset" of the given array
  2704. * @param array defines the source array
  2705. * @param offset defines the offset in the source array
  2706. * @returns the new Vector3
  2707. */
  2708. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2711. * @param array defines the source array
  2712. * @param offset defines the offset in the source array
  2713. * @returns the new Vector3
  2714. * @deprecated Please use FromArray instead.
  2715. */
  2716. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2717. /**
  2718. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @param result defines the Vector3 where to store the result
  2722. */
  2723. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2724. /**
  2725. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @param result defines the Vector3 where to store the result
  2729. * @deprecated Please use FromArrayToRef instead.
  2730. */
  2731. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2732. /**
  2733. * Sets the given vector "result" with the given floats.
  2734. * @param x defines the x coordinate of the source
  2735. * @param y defines the y coordinate of the source
  2736. * @param z defines the z coordinate of the source
  2737. * @param result defines the Vector3 where to store the result
  2738. */
  2739. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2740. /**
  2741. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2742. * @returns a new empty Vector3
  2743. */
  2744. static Zero(): Vector3;
  2745. /**
  2746. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2747. * @returns a new unit Vector3
  2748. */
  2749. static One(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2752. * @returns a new up Vector3
  2753. */
  2754. static Up(): Vector3;
  2755. /**
  2756. * Gets a up Vector3 that must not be updated
  2757. */
  2758. static get UpReadOnly(): DeepImmutable<Vector3>;
  2759. /**
  2760. * Gets a zero Vector3 that must not be updated
  2761. */
  2762. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2765. * @returns a new down Vector3
  2766. */
  2767. static Down(): Vector3;
  2768. /**
  2769. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2770. * @returns a new forward Vector3
  2771. */
  2772. static Forward(): Vector3;
  2773. /**
  2774. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2775. * @returns a new forward Vector3
  2776. */
  2777. static Backward(): Vector3;
  2778. /**
  2779. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2780. * @returns a new right Vector3
  2781. */
  2782. static Right(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2785. * @returns a new left Vector3
  2786. */
  2787. static Left(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2790. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2791. * @param vector defines the Vector3 to transform
  2792. * @param transformation defines the transformation matrix
  2793. * @returns the transformed Vector3
  2794. */
  2795. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2796. /**
  2797. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2798. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @param result defines the Vector3 where to store the result
  2802. */
  2803. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2804. /**
  2805. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2806. * This method computes tranformed coordinates only, not transformed direction vectors
  2807. * @param x define the x coordinate of the source vector
  2808. * @param y define the y coordinate of the source vector
  2809. * @param z define the z coordinate of the source vector
  2810. * @param transformation defines the transformation matrix
  2811. * @param result defines the Vector3 where to store the result
  2812. */
  2813. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2814. /**
  2815. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2816. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2817. * @param vector defines the Vector3 to transform
  2818. * @param transformation defines the transformation matrix
  2819. * @returns the new Vector3
  2820. */
  2821. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2822. /**
  2823. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2824. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @param result defines the Vector3 where to store the result
  2828. */
  2829. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2830. /**
  2831. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2832. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2833. * @param x define the x coordinate of the source vector
  2834. * @param y define the y coordinate of the source vector
  2835. * @param z define the z coordinate of the source vector
  2836. * @param transformation defines the transformation matrix
  2837. * @param result defines the Vector3 where to store the result
  2838. */
  2839. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2840. /**
  2841. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2842. * @param value1 defines the first control point
  2843. * @param value2 defines the second control point
  2844. * @param value3 defines the third control point
  2845. * @param value4 defines the fourth control point
  2846. * @param amount defines the amount on the spline to use
  2847. * @returns the new Vector3
  2848. */
  2849. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2850. /**
  2851. * 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"
  2852. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2853. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2854. * @param value defines the current value
  2855. * @param min defines the lower range value
  2856. * @param max defines the upper range value
  2857. * @returns the new Vector3
  2858. */
  2859. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2860. /**
  2861. * 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"
  2862. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2863. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2864. * @param value defines the current value
  2865. * @param min defines the lower range value
  2866. * @param max defines the upper range value
  2867. * @param result defines the Vector3 where to store the result
  2868. */
  2869. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2870. /**
  2871. * Checks if a given vector is inside a specific range
  2872. * @param v defines the vector to test
  2873. * @param min defines the minimum range
  2874. * @param max defines the maximum range
  2875. */
  2876. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2877. /**
  2878. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2879. * @param value1 defines the first control point
  2880. * @param tangent1 defines the first tangent vector
  2881. * @param value2 defines the second control point
  2882. * @param tangent2 defines the second tangent vector
  2883. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2884. * @returns the new Vector3
  2885. */
  2886. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2887. /**
  2888. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2889. * @param start defines the start value
  2890. * @param end defines the end value
  2891. * @param amount max defines amount between both (between 0 and 1)
  2892. * @returns the new Vector3
  2893. */
  2894. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2895. /**
  2896. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2897. * @param start defines the start value
  2898. * @param end defines the end value
  2899. * @param amount max defines amount between both (between 0 and 1)
  2900. * @param result defines the Vector3 where to store the result
  2901. */
  2902. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2903. /**
  2904. * Returns the dot product (float) between the vectors "left" and "right"
  2905. * @param left defines the left operand
  2906. * @param right defines the right operand
  2907. * @returns the dot product
  2908. */
  2909. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2910. /**
  2911. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2912. * The cross product is then orthogonal to both "left" and "right"
  2913. * @param left defines the left operand
  2914. * @param right defines the right operand
  2915. * @returns the cross product
  2916. */
  2917. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2918. /**
  2919. * Sets the given vector "result" with the cross product of "left" and "right"
  2920. * The cross product is then orthogonal to both "left" and "right"
  2921. * @param left defines the left operand
  2922. * @param right defines the right operand
  2923. * @param result defines the Vector3 where to store the result
  2924. */
  2925. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2926. /**
  2927. * Returns a new Vector3 as the normalization of the given vector
  2928. * @param vector defines the Vector3 to normalize
  2929. * @returns the new Vector3
  2930. */
  2931. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the normalization of the given first vector
  2934. * @param vector defines the Vector3 to normalize
  2935. * @param result defines the Vector3 where to store the result
  2936. */
  2937. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2938. /**
  2939. * Project a Vector3 onto screen space
  2940. * @param vector defines the Vector3 to project
  2941. * @param world defines the world matrix to use
  2942. * @param transform defines the transform (view x projection) matrix to use
  2943. * @param viewport defines the screen viewport to use
  2944. * @returns the new Vector3
  2945. */
  2946. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2947. /** @hidden */
  2948. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2949. /**
  2950. * Unproject from screen space to object space
  2951. * @param source defines the screen space Vector3 to use
  2952. * @param viewportWidth defines the current width of the viewport
  2953. * @param viewportHeight defines the current height of the viewport
  2954. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2955. * @param transform defines the transform (view x projection) matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @returns the new Vector3
  2968. */
  2969. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param source defines the screen space Vector3 to use
  2973. * @param viewportWidth defines the current width of the viewport
  2974. * @param viewportHeight defines the current height of the viewport
  2975. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2976. * @param view defines the view matrix to use
  2977. * @param projection defines the projection matrix to use
  2978. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Unproject from screen space to object space
  2983. * @param sourceX defines the screen space x coordinate to use
  2984. * @param sourceY defines the screen space y coordinate to use
  2985. * @param sourceZ defines the screen space z coordinate to use
  2986. * @param viewportWidth defines the current width of the viewport
  2987. * @param viewportHeight defines the current height of the viewport
  2988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2989. * @param view defines the view matrix to use
  2990. * @param projection defines the projection matrix to use
  2991. * @param result defines the Vector3 where to store the result
  2992. */
  2993. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2994. /**
  2995. * Gets the minimal coordinate values between two Vector3
  2996. * @param left defines the first operand
  2997. * @param right defines the second operand
  2998. * @returns the new Vector3
  2999. */
  3000. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3001. /**
  3002. * Gets the maximal coordinate values between two Vector3
  3003. * @param left defines the first operand
  3004. * @param right defines the second operand
  3005. * @returns the new Vector3
  3006. */
  3007. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3008. /**
  3009. * Returns the distance between the vectors "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the distance
  3013. */
  3014. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3015. /**
  3016. * Returns the squared distance between the vectors "value1" and "value2"
  3017. * @param value1 defines the first operand
  3018. * @param value2 defines the second operand
  3019. * @returns the squared distance
  3020. */
  3021. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3022. /**
  3023. * Returns a new Vector3 located at the center between "value1" and "value2"
  3024. * @param value1 defines the first operand
  3025. * @param value2 defines the second operand
  3026. * @returns the new Vector3
  3027. */
  3028. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3031. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3032. * to something in order to rotate it from its local system to the given target system
  3033. * Note: axis1, axis2 and axis3 are normalized during this operation
  3034. * @param axis1 defines the first axis
  3035. * @param axis2 defines the second axis
  3036. * @param axis3 defines the third axis
  3037. * @returns a new Vector3
  3038. */
  3039. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3040. /**
  3041. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3042. * @param axis1 defines the first axis
  3043. * @param axis2 defines the second axis
  3044. * @param axis3 defines the third axis
  3045. * @param ref defines the Vector3 where to store the result
  3046. */
  3047. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3048. }
  3049. /**
  3050. * Vector4 class created for EulerAngle class conversion to Quaternion
  3051. */
  3052. export class Vector4 {
  3053. /** x value of the vector */
  3054. x: number;
  3055. /** y value of the vector */
  3056. y: number;
  3057. /** z value of the vector */
  3058. z: number;
  3059. /** w value of the vector */
  3060. w: number;
  3061. /**
  3062. * Creates a Vector4 object from the given floats.
  3063. * @param x x value of the vector
  3064. * @param y y value of the vector
  3065. * @param z z value of the vector
  3066. * @param w w value of the vector
  3067. */
  3068. constructor(
  3069. /** x value of the vector */
  3070. x: number,
  3071. /** y value of the vector */
  3072. y: number,
  3073. /** z value of the vector */
  3074. z: number,
  3075. /** w value of the vector */
  3076. w: number);
  3077. /**
  3078. * Returns the string with the Vector4 coordinates.
  3079. * @returns a string containing all the vector values
  3080. */
  3081. toString(): string;
  3082. /**
  3083. * Returns the string "Vector4".
  3084. * @returns "Vector4"
  3085. */
  3086. getClassName(): string;
  3087. /**
  3088. * Returns the Vector4 hash code.
  3089. * @returns a unique hash code
  3090. */
  3091. getHashCode(): number;
  3092. /**
  3093. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3094. * @returns the resulting array
  3095. */
  3096. asArray(): number[];
  3097. /**
  3098. * Populates the given array from the given index with the Vector4 coordinates.
  3099. * @param array array to populate
  3100. * @param index index of the array to start at (default: 0)
  3101. * @returns the Vector4.
  3102. */
  3103. toArray(array: FloatArray, index?: number): Vector4;
  3104. /**
  3105. * Adds the given vector to the current Vector4.
  3106. * @param otherVector the vector to add
  3107. * @returns the updated Vector4.
  3108. */
  3109. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3112. * @param otherVector the vector to add
  3113. * @returns the resulting vector
  3114. */
  3115. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3116. /**
  3117. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3118. * @param otherVector the vector to add
  3119. * @param result the vector to store the result
  3120. * @returns the current Vector4.
  3121. */
  3122. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3123. /**
  3124. * Subtract in place the given vector from the current Vector4.
  3125. * @param otherVector the vector to subtract
  3126. * @returns the updated Vector4.
  3127. */
  3128. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3131. * @param otherVector the vector to add
  3132. * @returns the new vector with the result
  3133. */
  3134. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3135. /**
  3136. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3137. * @param otherVector the vector to subtract
  3138. * @param result the vector to store the result
  3139. * @returns the current Vector4.
  3140. */
  3141. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3142. /**
  3143. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3144. */
  3145. /**
  3146. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @returns new vector containing the result
  3152. */
  3153. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3154. /**
  3155. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3156. * @param x value to subtract
  3157. * @param y value to subtract
  3158. * @param z value to subtract
  3159. * @param w value to subtract
  3160. * @param result the vector to store the result in
  3161. * @returns the current Vector4.
  3162. */
  3163. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3166. * @returns a new vector with the negated values
  3167. */
  3168. negate(): Vector4;
  3169. /**
  3170. * Negate this vector in place
  3171. * @returns this
  3172. */
  3173. negateInPlace(): Vector4;
  3174. /**
  3175. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3176. * @param result defines the Vector3 object where to store the result
  3177. * @returns the current Vector4
  3178. */
  3179. negateToRef(result: Vector4): Vector4;
  3180. /**
  3181. * Multiplies the current Vector4 coordinates by scale (float).
  3182. * @param scale the number to scale with
  3183. * @returns the updated Vector4.
  3184. */
  3185. scaleInPlace(scale: number): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns a new vector with the result
  3190. */
  3191. scale(scale: number): Vector4;
  3192. /**
  3193. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @param result a vector to store the result in
  3196. * @returns the current Vector4.
  3197. */
  3198. scaleToRef(scale: number, result: Vector4): Vector4;
  3199. /**
  3200. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3201. * @param scale defines the scale factor
  3202. * @param result defines the Vector4 object where to store the result
  3203. * @returns the unmodified current Vector4
  3204. */
  3205. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3206. /**
  3207. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3208. * @param otherVector the vector to compare against
  3209. * @returns true if they are equal
  3210. */
  3211. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3214. * @param otherVector vector to compare against
  3215. * @param epsilon (Default: very small number)
  3216. * @returns true if they are equal
  3217. */
  3218. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3219. /**
  3220. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3221. * @param x x value to compare against
  3222. * @param y y value to compare against
  3223. * @param z z value to compare against
  3224. * @param w w value to compare against
  3225. * @returns true if equal
  3226. */
  3227. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3228. /**
  3229. * Multiplies in place the current Vector4 by the given one.
  3230. * @param otherVector vector to multiple with
  3231. * @returns the updated Vector4.
  3232. */
  3233. multiplyInPlace(otherVector: Vector4): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns resulting new vector
  3238. */
  3239. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3249. * @param x x value multiply with
  3250. * @param y y value multiply with
  3251. * @param z z value multiply with
  3252. * @param w w value multiply with
  3253. * @returns resulting new vector
  3254. */
  3255. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3256. /**
  3257. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3258. * @param otherVector vector to devide with
  3259. * @returns resulting new vector
  3260. */
  3261. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @param result vector to store the result
  3266. * @returns the current Vector4.
  3267. */
  3268. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3269. /**
  3270. * Divides the current Vector3 coordinates by the given ones.
  3271. * @param otherVector vector to devide with
  3272. * @returns the updated Vector3.
  3273. */
  3274. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3277. * @param other defines the second operand
  3278. * @returns the current updated Vector4
  3279. */
  3280. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Gets a new Vector4 from current Vector4 floored values
  3289. * @returns a new Vector4
  3290. */
  3291. floor(): Vector4;
  3292. /**
  3293. * Gets a new Vector4 from current Vector3 floored values
  3294. * @returns a new Vector4
  3295. */
  3296. fract(): Vector4;
  3297. /**
  3298. * Returns the Vector4 length (float).
  3299. * @returns the length
  3300. */
  3301. length(): number;
  3302. /**
  3303. * Returns the Vector4 squared length (float).
  3304. * @returns the length squared
  3305. */
  3306. lengthSquared(): number;
  3307. /**
  3308. * Normalizes in place the Vector4.
  3309. * @returns the updated Vector4.
  3310. */
  3311. normalize(): Vector4;
  3312. /**
  3313. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3314. * @returns this converted to a new vector3
  3315. */
  3316. toVector3(): Vector3;
  3317. /**
  3318. * Returns a new Vector4 copied from the current one.
  3319. * @returns the new cloned vector
  3320. */
  3321. clone(): Vector4;
  3322. /**
  3323. * Updates the current Vector4 with the given one coordinates.
  3324. * @param source the source vector to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to copy from
  3331. * @param y float to copy from
  3332. * @param z float to copy from
  3333. * @param w float to copy from
  3334. * @returns the updated Vector4.
  3335. */
  3336. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Updates the current Vector4 coordinates with the given floats.
  3339. * @param x float to set from
  3340. * @param y float to set from
  3341. * @param z float to set from
  3342. * @param w float to set from
  3343. * @returns the updated Vector4.
  3344. */
  3345. set(x: number, y: number, z: number, w: number): Vector4;
  3346. /**
  3347. * Copies the given float to the current Vector3 coordinates
  3348. * @param v defines the x, y, z and w coordinates of the operand
  3349. * @returns the current updated Vector3
  3350. */
  3351. setAll(v: number): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set from the starting index of the given array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @returns the new vector
  3357. */
  3358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3359. /**
  3360. * Updates the given vector "result" from the starting index of the given array.
  3361. * @param array the array to pull values from
  3362. * @param offset the offset into the array to start at
  3363. * @param result the vector to store the result in
  3364. */
  3365. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3366. /**
  3367. * Updates the given vector "result" from the starting index of the given Float32Array.
  3368. * @param array the array to pull values from
  3369. * @param offset the offset into the array to start at
  3370. * @param result the vector to store the result in
  3371. */
  3372. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3373. /**
  3374. * Updates the given vector "result" coordinates from the given floats.
  3375. * @param x float to set from
  3376. * @param y float to set from
  3377. * @param z float to set from
  3378. * @param w float to set from
  3379. * @param result the vector to the floats in
  3380. */
  3381. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3382. /**
  3383. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3384. * @returns the new vector
  3385. */
  3386. static Zero(): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3389. * @returns the new vector
  3390. */
  3391. static One(): Vector4;
  3392. /**
  3393. * Returns a new normalized Vector4 from the given one.
  3394. * @param vector the vector to normalize
  3395. * @returns the vector
  3396. */
  3397. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the given vector "result" from the normalization of the given one.
  3400. * @param vector the vector to normalize
  3401. * @param result the vector to store the result in
  3402. */
  3403. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3404. /**
  3405. * Returns a vector with the minimum values from the left and right vectors
  3406. * @param left left vector to minimize
  3407. * @param right right vector to minimize
  3408. * @returns a new vector with the minimum of the left and right vector values
  3409. */
  3410. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns a vector with the maximum values from the left and right vectors
  3413. * @param left left vector to maximize
  3414. * @param right right vector to maximize
  3415. * @returns a new vector with the maximum of the left and right vector values
  3416. */
  3417. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3418. /**
  3419. * Returns the distance (float) between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the distance between
  3421. * @param value2 value to calulate the distance between
  3422. * @return the distance between the two vectors
  3423. */
  3424. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3425. /**
  3426. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3427. * @param value1 value to calulate the distance between
  3428. * @param value2 value to calulate the distance between
  3429. * @return the distance between the two vectors squared
  3430. */
  3431. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3432. /**
  3433. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3434. * @param value1 value to calulate the center between
  3435. * @param value2 value to calulate the center between
  3436. * @return the center between the two vectors
  3437. */
  3438. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3441. * This methods computes transformed normalized direction vectors only.
  3442. * @param vector the vector to transform
  3443. * @param transformation the transformation matrix to apply
  3444. * @returns the new vector
  3445. */
  3446. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3447. /**
  3448. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3449. * This methods computes transformed normalized direction vectors only.
  3450. * @param vector the vector to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @param result the vector to store the result in
  3453. */
  3454. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3455. /**
  3456. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3457. * This methods computes transformed normalized direction vectors only.
  3458. * @param x value to transform
  3459. * @param y value to transform
  3460. * @param z value to transform
  3461. * @param w value to transform
  3462. * @param transformation the transformation matrix to apply
  3463. * @param result the vector to store the results in
  3464. */
  3465. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3466. /**
  3467. * Creates a new Vector4 from a Vector3
  3468. * @param source defines the source data
  3469. * @param w defines the 4th component (default is 0)
  3470. * @returns a new Vector4
  3471. */
  3472. static FromVector3(source: Vector3, w?: number): Vector4;
  3473. }
  3474. /**
  3475. * Class used to store quaternion data
  3476. * @see https://en.wikipedia.org/wiki/Quaternion
  3477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3478. */
  3479. export class Quaternion {
  3480. /** defines the first component (0 by default) */
  3481. x: number;
  3482. /** defines the second component (0 by default) */
  3483. y: number;
  3484. /** defines the third component (0 by default) */
  3485. z: number;
  3486. /** defines the fourth component (1.0 by default) */
  3487. w: number;
  3488. /**
  3489. * Creates a new Quaternion from the given floats
  3490. * @param x defines the first component (0 by default)
  3491. * @param y defines the second component (0 by default)
  3492. * @param z defines the third component (0 by default)
  3493. * @param w defines the fourth component (1.0 by default)
  3494. */
  3495. constructor(
  3496. /** defines the first component (0 by default) */
  3497. x?: number,
  3498. /** defines the second component (0 by default) */
  3499. y?: number,
  3500. /** defines the third component (0 by default) */
  3501. z?: number,
  3502. /** defines the fourth component (1.0 by default) */
  3503. w?: number);
  3504. /**
  3505. * Gets a string representation for the current quaternion
  3506. * @returns a string with the Quaternion coordinates
  3507. */
  3508. toString(): string;
  3509. /**
  3510. * Gets the class name of the quaternion
  3511. * @returns the string "Quaternion"
  3512. */
  3513. getClassName(): string;
  3514. /**
  3515. * Gets a hash code for this quaternion
  3516. * @returns the quaternion hash code
  3517. */
  3518. getHashCode(): number;
  3519. /**
  3520. * Copy the quaternion to an array
  3521. * @returns a new array populated with 4 elements from the quaternion coordinates
  3522. */
  3523. asArray(): number[];
  3524. /**
  3525. * Check if two quaternions are equals
  3526. * @param otherQuaternion defines the second operand
  3527. * @return true if the current quaternion and the given one coordinates are strictly equals
  3528. */
  3529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3530. /**
  3531. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3532. * @param otherQuaternion defines the other quaternion
  3533. * @param epsilon defines the minimal distance to consider equality
  3534. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3535. */
  3536. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3537. /**
  3538. * Clone the current quaternion
  3539. * @returns a new quaternion copied from the current one
  3540. */
  3541. clone(): Quaternion;
  3542. /**
  3543. * Copy a quaternion to the current one
  3544. * @param other defines the other quaternion
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Updates the current quaternion with the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Updates the current quaternion from the given float coordinates
  3559. * @param x defines the x coordinate
  3560. * @param y defines the y coordinate
  3561. * @param z defines the z coordinate
  3562. * @param w defines the w coordinate
  3563. * @returns the updated current quaternion
  3564. */
  3565. set(x: number, y: number, z: number, w: number): Quaternion;
  3566. /**
  3567. * Adds two quaternions
  3568. * @param other defines the second operand
  3569. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3570. */
  3571. add(other: DeepImmutable<Quaternion>): Quaternion;
  3572. /**
  3573. * Add a quaternion to the current one
  3574. * @param other defines the quaternion to add
  3575. * @returns the current quaternion
  3576. */
  3577. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Subtract two quaternions
  3580. * @param other defines the second operand
  3581. * @returns a new quaternion as the subtraction result of the given one from the current one
  3582. */
  3583. subtract(other: Quaternion): Quaternion;
  3584. /**
  3585. * Multiplies the current quaternion by a scale factor
  3586. * @param value defines the scale factor
  3587. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3588. */
  3589. scale(value: number): Quaternion;
  3590. /**
  3591. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3592. * @param scale defines the scale factor
  3593. * @param result defines the Quaternion object where to store the result
  3594. * @returns the unmodified current quaternion
  3595. */
  3596. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3597. /**
  3598. * Multiplies in place the current quaternion by a scale factor
  3599. * @param value defines the scale factor
  3600. * @returns the current modified quaternion
  3601. */
  3602. scaleInPlace(value: number): Quaternion;
  3603. /**
  3604. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3605. * @param scale defines the scale factor
  3606. * @param result defines the Quaternion object where to store the result
  3607. * @returns the unmodified current quaternion
  3608. */
  3609. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3610. /**
  3611. * Multiplies two quaternions
  3612. * @param q1 defines the second operand
  3613. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3614. */
  3615. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3616. /**
  3617. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3618. * @param q1 defines the second operand
  3619. * @param result defines the target quaternion
  3620. * @returns the current quaternion
  3621. */
  3622. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3623. /**
  3624. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3625. * @param q1 defines the second operand
  3626. * @returns the currentupdated quaternion
  3627. */
  3628. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3629. /**
  3630. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3631. * @param ref defines the target quaternion
  3632. * @returns the current quaternion
  3633. */
  3634. conjugateToRef(ref: Quaternion): Quaternion;
  3635. /**
  3636. * Conjugates in place (1-q) the current quaternion
  3637. * @returns the current updated quaternion
  3638. */
  3639. conjugateInPlace(): Quaternion;
  3640. /**
  3641. * Conjugates in place (1-q) the current quaternion
  3642. * @returns a new quaternion
  3643. */
  3644. conjugate(): Quaternion;
  3645. /**
  3646. * Gets length of current quaternion
  3647. * @returns the quaternion length (float)
  3648. */
  3649. length(): number;
  3650. /**
  3651. * Normalize in place the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. normalize(): Quaternion;
  3655. /**
  3656. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3657. * @param order is a reserved parameter and is ignore for now
  3658. * @returns a new Vector3 containing the Euler angles
  3659. */
  3660. toEulerAngles(order?: string): Vector3;
  3661. /**
  3662. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3663. * @param result defines the vector which will be filled with the Euler angles
  3664. * @param order is a reserved parameter and is ignore for now
  3665. * @returns the current unchanged quaternion
  3666. */
  3667. toEulerAnglesToRef(result: Vector3): Quaternion;
  3668. /**
  3669. * Updates the given rotation matrix with the current quaternion values
  3670. * @param result defines the target matrix
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toRotationMatrix(result: Matrix): Quaternion;
  3674. /**
  3675. * Updates the current quaternion from the given rotation matrix values
  3676. * @param matrix defines the source matrix
  3677. * @returns the current updated quaternion
  3678. */
  3679. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3680. /**
  3681. * Creates a new quaternion from a rotation matrix
  3682. * @param matrix defines the source matrix
  3683. * @returns a new quaternion created from the given rotation matrix values
  3684. */
  3685. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Updates the given quaternion with the given rotation matrix values
  3688. * @param matrix defines the source matrix
  3689. * @param result defines the target quaternion
  3690. */
  3691. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3692. /**
  3693. * Returns the dot product (float) between the quaternions "left" and "right"
  3694. * @param left defines the left operand
  3695. * @param right defines the right operand
  3696. * @returns the dot product
  3697. */
  3698. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3699. /**
  3700. * Checks if the two quaternions are close to each other
  3701. * @param quat0 defines the first quaternion to check
  3702. * @param quat1 defines the second quaternion to check
  3703. * @returns true if the two quaternions are close to each other
  3704. */
  3705. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates an empty quaternion
  3708. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3709. */
  3710. static Zero(): Quaternion;
  3711. /**
  3712. * Inverse a given quaternion
  3713. * @param q defines the source quaternion
  3714. * @returns a new quaternion as the inverted current quaternion
  3715. */
  3716. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @param result the quaternion the result will be stored in
  3721. * @returns the result quaternion
  3722. */
  3723. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3724. /**
  3725. * Creates an identity quaternion
  3726. * @returns the identity quaternion
  3727. */
  3728. static Identity(): Quaternion;
  3729. /**
  3730. * Gets a boolean indicating if the given quaternion is identity
  3731. * @param quaternion defines the quaternion to check
  3732. * @returns true if the quaternion is identity
  3733. */
  3734. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3735. /**
  3736. * Creates a quaternion from a rotation around an axis
  3737. * @param axis defines the axis to use
  3738. * @param angle defines the angle to use
  3739. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3740. */
  3741. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3742. /**
  3743. * Creates a rotation around an axis and stores it into the given quaternion
  3744. * @param axis defines the axis to use
  3745. * @param angle defines the angle to use
  3746. * @param result defines the target quaternion
  3747. * @returns the target quaternion
  3748. */
  3749. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3750. /**
  3751. * Creates a new quaternion from data stored into an array
  3752. * @param array defines the data source
  3753. * @param offset defines the offset in the source array where the data starts
  3754. * @returns a new quaternion
  3755. */
  3756. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3757. /**
  3758. * Create a quaternion from Euler rotation angles
  3759. * @param x Pitch
  3760. * @param y Yaw
  3761. * @param z Roll
  3762. * @returns the new Quaternion
  3763. */
  3764. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3765. /**
  3766. * Updates a quaternion from Euler rotation angles
  3767. * @param x Pitch
  3768. * @param y Yaw
  3769. * @param z Roll
  3770. * @param result the quaternion to store the result
  3771. * @returns the updated quaternion
  3772. */
  3773. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3774. /**
  3775. * Create a quaternion from Euler rotation vector
  3776. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3777. * @returns the new Quaternion
  3778. */
  3779. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3780. /**
  3781. * Updates a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @param result the quaternion to store the result
  3784. * @returns the updated quaternion
  3785. */
  3786. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3789. * @param yaw defines the rotation around Y axis
  3790. * @param pitch defines the rotation around X axis
  3791. * @param roll defines the rotation around Z axis
  3792. * @returns the new quaternion
  3793. */
  3794. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3795. /**
  3796. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3797. * @param yaw defines the rotation around Y axis
  3798. * @param pitch defines the rotation around X axis
  3799. * @param roll defines the rotation around Z axis
  3800. * @param result defines the target quaternion
  3801. */
  3802. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3803. /**
  3804. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3805. * @param alpha defines the rotation around first axis
  3806. * @param beta defines the rotation around second axis
  3807. * @param gamma defines the rotation around third axis
  3808. * @returns the new quaternion
  3809. */
  3810. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3811. /**
  3812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3813. * @param alpha defines the rotation around first axis
  3814. * @param beta defines the rotation around second axis
  3815. * @param gamma defines the rotation around third axis
  3816. * @param result defines the target quaternion
  3817. */
  3818. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3819. /**
  3820. * 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)
  3821. * @param axis1 defines the first axis
  3822. * @param axis2 defines the second axis
  3823. * @param axis3 defines the third axis
  3824. * @returns the new quaternion
  3825. */
  3826. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3827. /**
  3828. * 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
  3829. * @param axis1 defines the first axis
  3830. * @param axis2 defines the second axis
  3831. * @param axis3 defines the third axis
  3832. * @param ref defines the target quaternion
  3833. */
  3834. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3835. /**
  3836. * Interpolates between two quaternions
  3837. * @param left defines first quaternion
  3838. * @param right defines second quaternion
  3839. * @param amount defines the gradient to use
  3840. * @returns the new interpolated quaternion
  3841. */
  3842. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3843. /**
  3844. * Interpolates between two quaternions and stores it into a target quaternion
  3845. * @param left defines first quaternion
  3846. * @param right defines second quaternion
  3847. * @param amount defines the gradient to use
  3848. * @param result defines the target quaternion
  3849. */
  3850. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3851. /**
  3852. * Interpolate between two quaternions using Hermite interpolation
  3853. * @param value1 defines first quaternion
  3854. * @param tangent1 defines the incoming tangent
  3855. * @param value2 defines second quaternion
  3856. * @param tangent2 defines the outgoing tangent
  3857. * @param amount defines the target quaternion
  3858. * @returns the new interpolated quaternion
  3859. */
  3860. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3861. }
  3862. /**
  3863. * Class used to store matrix data (4x4)
  3864. */
  3865. export class Matrix {
  3866. private static _updateFlagSeed;
  3867. private static _identityReadOnly;
  3868. private _isIdentity;
  3869. private _isIdentityDirty;
  3870. private _isIdentity3x2;
  3871. private _isIdentity3x2Dirty;
  3872. /**
  3873. * Gets the update flag of the matrix which is an unique number for the matrix.
  3874. * It will be incremented every time the matrix data change.
  3875. * You can use it to speed the comparison between two versions of the same matrix.
  3876. */
  3877. updateFlag: number;
  3878. private readonly _m;
  3879. /**
  3880. * Gets the internal data of the matrix
  3881. */
  3882. get m(): DeepImmutable<Float32Array>;
  3883. /** @hidden */
  3884. _markAsUpdated(): void;
  3885. /** @hidden */
  3886. private _updateIdentityStatus;
  3887. /**
  3888. * Creates an empty matrix (filled with zeros)
  3889. */
  3890. constructor();
  3891. /**
  3892. * Check if the current matrix is identity
  3893. * @returns true is the matrix is the identity matrix
  3894. */
  3895. isIdentity(): boolean;
  3896. /**
  3897. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3898. * @returns true is the matrix is the identity matrix
  3899. */
  3900. isIdentityAs3x2(): boolean;
  3901. /**
  3902. * Gets the determinant of the matrix
  3903. * @returns the matrix determinant
  3904. */
  3905. determinant(): number;
  3906. /**
  3907. * Returns the matrix as a Float32Array
  3908. * @returns the matrix underlying array
  3909. */
  3910. toArray(): DeepImmutable<Float32Array>;
  3911. /**
  3912. * Returns the matrix as a Float32Array
  3913. * @returns the matrix underlying array.
  3914. */
  3915. asArray(): DeepImmutable<Float32Array>;
  3916. /**
  3917. * Inverts the current matrix in place
  3918. * @returns the current inverted matrix
  3919. */
  3920. invert(): Matrix;
  3921. /**
  3922. * Sets all the matrix elements to zero
  3923. * @returns the current matrix
  3924. */
  3925. reset(): Matrix;
  3926. /**
  3927. * Adds the current matrix with a second one
  3928. * @param other defines the matrix to add
  3929. * @returns a new matrix as the addition of the current matrix and the given one
  3930. */
  3931. add(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3934. * @param other defines the matrix to add
  3935. * @param result defines the target matrix
  3936. * @returns the current matrix
  3937. */
  3938. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3939. /**
  3940. * Adds in place the given matrix to the current matrix
  3941. * @param other defines the second operand
  3942. * @returns the current updated matrix
  3943. */
  3944. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3945. /**
  3946. * Sets the given matrix to the current inverted Matrix
  3947. * @param other defines the target matrix
  3948. * @returns the unmodified current matrix
  3949. */
  3950. invertToRef(other: Matrix): Matrix;
  3951. /**
  3952. * add a value at the specified position in the current Matrix
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. addAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * mutiply the specified position in the current Matrix by a value
  3960. * @param index the index of the value within the matrix. between 0 and 15.
  3961. * @param value the value to be added
  3962. * @returns the current updated matrix
  3963. */
  3964. multiplyAtIndex(index: number, value: number): Matrix;
  3965. /**
  3966. * Inserts the translation vector (using 3 floats) in the current matrix
  3967. * @param x defines the 1st component of the translation
  3968. * @param y defines the 2nd component of the translation
  3969. * @param z defines the 3rd component of the translation
  3970. * @returns the current updated matrix
  3971. */
  3972. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3973. /**
  3974. * Adds the translation vector (using 3 floats) in the current matrix
  3975. * @param x defines the 1st component of the translation
  3976. * @param y defines the 2nd component of the translation
  3977. * @param z defines the 3rd component of the translation
  3978. * @returns the current updated matrix
  3979. */
  3980. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3981. /**
  3982. * Inserts the translation vector in the current matrix
  3983. * @param vector3 defines the translation to insert
  3984. * @returns the current updated matrix
  3985. */
  3986. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3987. /**
  3988. * Gets the translation value of the current matrix
  3989. * @returns a new Vector3 as the extracted translation from the matrix
  3990. */
  3991. getTranslation(): Vector3;
  3992. /**
  3993. * Fill a Vector3 with the extracted translation from the matrix
  3994. * @param result defines the Vector3 where to store the translation
  3995. * @returns the current matrix
  3996. */
  3997. getTranslationToRef(result: Vector3): Matrix;
  3998. /**
  3999. * Remove rotation and scaling part from the matrix
  4000. * @returns the updated matrix
  4001. */
  4002. removeRotationAndScaling(): Matrix;
  4003. /**
  4004. * Multiply two matrices
  4005. * @param other defines the second operand
  4006. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4007. */
  4008. multiply(other: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Copy the current matrix from the given one
  4011. * @param other defines the source matrix
  4012. * @returns the current updated matrix
  4013. */
  4014. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Populates the given array from the starting index with the current matrix values
  4017. * @param array defines the target array
  4018. * @param offset defines the offset in the target array where to start storing values
  4019. * @returns the current matrix
  4020. */
  4021. copyToArray(array: Float32Array, offset?: number): Matrix;
  4022. /**
  4023. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the matrix where to store the multiplication
  4026. * @returns the current matrix
  4027. */
  4028. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4029. /**
  4030. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4031. * @param other defines the second operand
  4032. * @param result defines the array where to store the multiplication
  4033. * @param offset defines the offset in the target array where to start storing values
  4034. * @returns the current matrix
  4035. */
  4036. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4037. /**
  4038. * Check equality between this matrix and a second one
  4039. * @param value defines the second matrix to compare
  4040. * @returns true is the current matrix and the given one values are strictly equal
  4041. */
  4042. equals(value: DeepImmutable<Matrix>): boolean;
  4043. /**
  4044. * Clone the current matrix
  4045. * @returns a new matrix from the current matrix
  4046. */
  4047. clone(): Matrix;
  4048. /**
  4049. * Returns the name of the current matrix class
  4050. * @returns the string "Matrix"
  4051. */
  4052. getClassName(): string;
  4053. /**
  4054. * Gets the hash code of the current matrix
  4055. * @returns the hash code
  4056. */
  4057. getHashCode(): number;
  4058. /**
  4059. * Decomposes the current Matrix into a translation, rotation and scaling components
  4060. * @param scale defines the scale vector3 given as a reference to update
  4061. * @param rotation defines the rotation quaternion given as a reference to update
  4062. * @param translation defines the translation vector3 given as a reference to update
  4063. * @returns true if operation was successful
  4064. */
  4065. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4066. /**
  4067. * Gets specific row of the matrix
  4068. * @param index defines the number of the row to get
  4069. * @returns the index-th row of the current matrix as a new Vector4
  4070. */
  4071. getRow(index: number): Nullable<Vector4>;
  4072. /**
  4073. * Sets the index-th row of the current matrix to the vector4 values
  4074. * @param index defines the number of the row to set
  4075. * @param row defines the target vector4
  4076. * @returns the updated current matrix
  4077. */
  4078. setRow(index: number, row: Vector4): Matrix;
  4079. /**
  4080. * Compute the transpose of the matrix
  4081. * @returns the new transposed matrix
  4082. */
  4083. transpose(): Matrix;
  4084. /**
  4085. * Compute the transpose of the matrix and store it in a given matrix
  4086. * @param result defines the target matrix
  4087. * @returns the current matrix
  4088. */
  4089. transposeToRef(result: Matrix): Matrix;
  4090. /**
  4091. * Sets the index-th row of the current matrix with the given 4 x float values
  4092. * @param index defines the row index
  4093. * @param x defines the x component to set
  4094. * @param y defines the y component to set
  4095. * @param z defines the z component to set
  4096. * @param w defines the w component to set
  4097. * @returns the updated current matrix
  4098. */
  4099. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4100. /**
  4101. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4102. * @param scale defines the scale factor
  4103. * @returns a new matrix
  4104. */
  4105. scale(scale: number): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor to a given result matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Scale the current matrix values by a factor and add the result to a given matrix
  4115. * @param scale defines the scale factor
  4116. * @param result defines the Matrix to store the result
  4117. * @returns the current matrix
  4118. */
  4119. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4120. /**
  4121. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4122. * @param ref matrix to store the result
  4123. */
  4124. toNormalMatrix(ref: Matrix): void;
  4125. /**
  4126. * Gets only rotation part of the current matrix
  4127. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4128. */
  4129. getRotationMatrix(): Matrix;
  4130. /**
  4131. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4132. * @param result defines the target matrix to store data to
  4133. * @returns the current matrix
  4134. */
  4135. getRotationMatrixToRef(result: Matrix): Matrix;
  4136. /**
  4137. * Toggles model matrix from being right handed to left handed in place and vice versa
  4138. */
  4139. toggleModelMatrixHandInPlace(): void;
  4140. /**
  4141. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleProjectionMatrixHandInPlace(): void;
  4144. /**
  4145. * Creates a matrix from an array
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @returns a new Matrix set from the starting index of the given array
  4149. */
  4150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4151. /**
  4152. * Copy the content of an array into a given matrix
  4153. * @param array defines the source array
  4154. * @param offset defines an offset in the source array
  4155. * @param result defines the target matrix
  4156. */
  4157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4158. /**
  4159. * Stores an array into a matrix after having multiplied each component by a given factor
  4160. * @param array defines the source array
  4161. * @param offset defines the offset in the source array
  4162. * @param scale defines the scaling factor
  4163. * @param result defines the target matrix
  4164. */
  4165. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4166. /**
  4167. * Gets an identity matrix that must not be updated
  4168. */
  4169. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4170. /**
  4171. * Stores a list of values (16) inside a given matrix
  4172. * @param initialM11 defines 1st value of 1st row
  4173. * @param initialM12 defines 2nd value of 1st row
  4174. * @param initialM13 defines 3rd value of 1st row
  4175. * @param initialM14 defines 4th value of 1st row
  4176. * @param initialM21 defines 1st value of 2nd row
  4177. * @param initialM22 defines 2nd value of 2nd row
  4178. * @param initialM23 defines 3rd value of 2nd row
  4179. * @param initialM24 defines 4th value of 2nd row
  4180. * @param initialM31 defines 1st value of 3rd row
  4181. * @param initialM32 defines 2nd value of 3rd row
  4182. * @param initialM33 defines 3rd value of 3rd row
  4183. * @param initialM34 defines 4th value of 3rd row
  4184. * @param initialM41 defines 1st value of 4th row
  4185. * @param initialM42 defines 2nd value of 4th row
  4186. * @param initialM43 defines 3rd value of 4th row
  4187. * @param initialM44 defines 4th value of 4th row
  4188. * @param result defines the target matrix
  4189. */
  4190. 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;
  4191. /**
  4192. * Creates new matrix from a list of values (16)
  4193. * @param initialM11 defines 1st value of 1st row
  4194. * @param initialM12 defines 2nd value of 1st row
  4195. * @param initialM13 defines 3rd value of 1st row
  4196. * @param initialM14 defines 4th value of 1st row
  4197. * @param initialM21 defines 1st value of 2nd row
  4198. * @param initialM22 defines 2nd value of 2nd row
  4199. * @param initialM23 defines 3rd value of 2nd row
  4200. * @param initialM24 defines 4th value of 2nd row
  4201. * @param initialM31 defines 1st value of 3rd row
  4202. * @param initialM32 defines 2nd value of 3rd row
  4203. * @param initialM33 defines 3rd value of 3rd row
  4204. * @param initialM34 defines 4th value of 3rd row
  4205. * @param initialM41 defines 1st value of 4th row
  4206. * @param initialM42 defines 2nd value of 4th row
  4207. * @param initialM43 defines 3rd value of 4th row
  4208. * @param initialM44 defines 4th value of 4th row
  4209. * @returns the new matrix
  4210. */
  4211. 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;
  4212. /**
  4213. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4214. * @param scale defines the scale vector3
  4215. * @param rotation defines the rotation quaternion
  4216. * @param translation defines the translation vector3
  4217. * @returns a new matrix
  4218. */
  4219. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4220. /**
  4221. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4222. * @param scale defines the scale vector3
  4223. * @param rotation defines the rotation quaternion
  4224. * @param translation defines the translation vector3
  4225. * @param result defines the target matrix
  4226. */
  4227. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4228. /**
  4229. * Creates a new identity matrix
  4230. * @returns a new identity matrix
  4231. */
  4232. static Identity(): Matrix;
  4233. /**
  4234. * Creates a new identity matrix and stores the result in a given matrix
  4235. * @param result defines the target matrix
  4236. */
  4237. static IdentityToRef(result: Matrix): void;
  4238. /**
  4239. * Creates a new zero matrix
  4240. * @returns a new zero matrix
  4241. */
  4242. static Zero(): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the X axis
  4245. * @param angle defines the angle (in radians) to use
  4246. * @return the new matrix
  4247. */
  4248. static RotationX(angle: number): Matrix;
  4249. /**
  4250. * Creates a new matrix as the invert of a given matrix
  4251. * @param source defines the source matrix
  4252. * @returns the new matrix
  4253. */
  4254. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationXToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the Y axis
  4263. * @param angle defines the angle (in radians) to use
  4264. * @return the new matrix
  4265. */
  4266. static RotationY(angle: number): Matrix;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4269. * @param angle defines the angle (in radians) to use
  4270. * @param result defines the target matrix
  4271. */
  4272. static RotationYToRef(angle: number, result: Matrix): void;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Z axis
  4275. * @param angle defines the angle (in radians) to use
  4276. * @return the new matrix
  4277. */
  4278. static RotationZ(angle: number): Matrix;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4281. * @param angle defines the angle (in radians) to use
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationZToRef(angle: number, result: Matrix): void;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @return the new matrix
  4290. */
  4291. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4292. /**
  4293. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4294. * @param axis defines the axis to use
  4295. * @param angle defines the angle (in radians) to use
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4299. /**
  4300. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4301. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4302. * @param from defines the vector to align
  4303. * @param to defines the vector to align to
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4307. /**
  4308. * Creates a rotation matrix
  4309. * @param yaw defines the yaw angle in radians (Y axis)
  4310. * @param pitch defines the pitch angle in radians (X axis)
  4311. * @param roll defines the roll angle in radians (X axis)
  4312. * @returns the new rotation matrix
  4313. */
  4314. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4315. /**
  4316. * Creates a rotation matrix and stores it in a given matrix
  4317. * @param yaw defines the yaw angle in radians (Y axis)
  4318. * @param pitch defines the pitch angle in radians (X axis)
  4319. * @param roll defines the roll angle in radians (X axis)
  4320. * @param result defines the target matrix
  4321. */
  4322. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4323. /**
  4324. * Creates a scaling matrix
  4325. * @param x defines the scale factor on X axis
  4326. * @param y defines the scale factor on Y axis
  4327. * @param z defines the scale factor on Z axis
  4328. * @returns the new matrix
  4329. */
  4330. static Scaling(x: number, y: number, z: number): Matrix;
  4331. /**
  4332. * Creates a scaling matrix and stores it in a given matrix
  4333. * @param x defines the scale factor on X axis
  4334. * @param y defines the scale factor on Y axis
  4335. * @param z defines the scale factor on Z axis
  4336. * @param result defines the target matrix
  4337. */
  4338. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4339. /**
  4340. * Creates a translation matrix
  4341. * @param x defines the translation on X axis
  4342. * @param y defines the translation on Y axis
  4343. * @param z defines the translationon Z axis
  4344. * @returns the new matrix
  4345. */
  4346. static Translation(x: number, y: number, z: number): Matrix;
  4347. /**
  4348. * Creates a translation matrix and stores it in a given matrix
  4349. * @param x defines the translation on X axis
  4350. * @param y defines the translation on Y axis
  4351. * @param z defines the translationon Z axis
  4352. * @param result defines the target matrix
  4353. */
  4354. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4355. /**
  4356. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4357. * @param startValue defines the start value
  4358. * @param endValue defines the end value
  4359. * @param gradient defines the gradient factor
  4360. * @returns the new matrix
  4361. */
  4362. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4363. /**
  4364. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4365. * @param startValue defines the start value
  4366. * @param endValue defines the end value
  4367. * @param gradient defines the gradient factor
  4368. * @param result defines the Matrix object where to store data
  4369. */
  4370. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * Builds a new matrix whose values are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @returns the new matrix
  4380. */
  4381. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4382. /**
  4383. * Update a matrix to values which are computed by:
  4384. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4385. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4386. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4387. * @param startValue defines the first matrix
  4388. * @param endValue defines the second matrix
  4389. * @param gradient defines the gradient between the two matrices
  4390. * @param result defines the target matrix
  4391. */
  4392. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * 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"
  4395. * This function works in left handed mode
  4396. * @param eye defines the final position of the entity
  4397. * @param target defines where the entity should look at
  4398. * @param up defines the up vector for the entity
  4399. * @returns the new matrix
  4400. */
  4401. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4402. /**
  4403. * 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".
  4404. * This function works in left handed mode
  4405. * @param eye defines the final position of the entity
  4406. * @param target defines where the entity should look at
  4407. * @param up defines the up vector for the entity
  4408. * @param result defines the target matrix
  4409. */
  4410. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4411. /**
  4412. * 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"
  4413. * This function works in right handed mode
  4414. * @param eye defines the final position of the entity
  4415. * @param target defines where the entity should look at
  4416. * @param up defines the up vector for the entity
  4417. * @returns the new matrix
  4418. */
  4419. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4420. /**
  4421. * 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".
  4422. * This function works in right handed mode
  4423. * @param eye defines the final position of the entity
  4424. * @param target defines where the entity should look at
  4425. * @param up defines the up vector for the entity
  4426. * @param result defines the target matrix
  4427. */
  4428. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Create a left-handed orthographic projection matrix
  4431. * @param width defines the viewport width
  4432. * @param height defines the viewport height
  4433. * @param znear defines the near clip plane
  4434. * @param zfar defines the far clip plane
  4435. * @returns a new matrix as a left-handed orthographic projection matrix
  4436. */
  4437. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4438. /**
  4439. * Store a left-handed orthographic projection to a given matrix
  4440. * @param width defines the viewport width
  4441. * @param height defines the viewport height
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Create a left-handed orthographic projection matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @returns a new matrix as a left-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a left-handed orthographic projection into a given matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a right-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a right-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a right-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a left-handed perspective projection matrix
  4493. * @param width defines the viewport width
  4494. * @param height defines the viewport height
  4495. * @param znear defines the near clip plane
  4496. * @param zfar defines the far clip plane
  4497. * @returns a new matrix as a left-handed perspective projection matrix
  4498. */
  4499. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4500. /**
  4501. * Creates a left-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a left-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a left-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Creates a right-handed perspective projection matrix
  4531. * @param fov defines the horizontal field of view
  4532. * @param aspect defines the aspect ratio
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @returns a new matrix as a right-handed perspective projection matrix
  4536. */
  4537. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4538. /**
  4539. * Stores a right-handed perspective projection into a given matrix
  4540. * @param fov defines the horizontal field of view
  4541. * @param aspect defines the aspect ratio
  4542. * @param znear defines the near clip plane
  4543. * @param zfar defines the far clip plane
  4544. * @param result defines the target matrix
  4545. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4546. */
  4547. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4548. /**
  4549. * Stores a right-handed perspective projection into a given matrix
  4550. * @param fov defines the horizontal field of view
  4551. * @param aspect defines the aspect ratio
  4552. * @param znear defines the near clip plane
  4553. * @param zfar not used as infinity is used as far clip
  4554. * @param result defines the target matrix
  4555. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4556. */
  4557. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4558. /**
  4559. * Stores a perspective projection for WebVR info a given matrix
  4560. * @param fov defines the field of view
  4561. * @param znear defines the near clip plane
  4562. * @param zfar defines the far clip plane
  4563. * @param result defines the target matrix
  4564. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4565. */
  4566. static PerspectiveFovWebVRToRef(fov: {
  4567. upDegrees: number;
  4568. downDegrees: number;
  4569. leftDegrees: number;
  4570. rightDegrees: number;
  4571. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4572. /**
  4573. * Computes a complete transformation matrix
  4574. * @param viewport defines the viewport to use
  4575. * @param world defines the world matrix
  4576. * @param view defines the view matrix
  4577. * @param projection defines the projection matrix
  4578. * @param zmin defines the near clip plane
  4579. * @param zmax defines the far clip plane
  4580. * @returns the transformation matrix
  4581. */
  4582. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4583. /**
  4584. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4585. * @param matrix defines the matrix to use
  4586. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4587. */
  4588. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4589. /**
  4590. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Compute the transpose of a given matrix
  4597. * @param matrix defines the matrix to transpose
  4598. * @returns the new matrix
  4599. */
  4600. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4601. /**
  4602. * Compute the transpose of a matrix and store it in a target matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @param result defines the target matrix
  4605. */
  4606. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4607. /**
  4608. * Computes a reflection matrix from a plane
  4609. * @param plane defines the reflection plane
  4610. * @returns a new matrix
  4611. */
  4612. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @param result defines the target matrix
  4617. */
  4618. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4619. /**
  4620. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4621. * @param xaxis defines the value of the 1st axis
  4622. * @param yaxis defines the value of the 2nd axis
  4623. * @param zaxis defines the value of the 3rd axis
  4624. * @param result defines the target matrix
  4625. */
  4626. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4627. /**
  4628. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4629. * @param quat defines the quaternion to use
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4633. }
  4634. /**
  4635. * @hidden
  4636. */
  4637. export class TmpVectors {
  4638. static Vector2: Vector2[];
  4639. static Vector3: Vector3[];
  4640. static Vector4: Vector4[];
  4641. static Quaternion: Quaternion[];
  4642. static Matrix: Matrix[];
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. /**
  4647. * Defines potential orientation for back face culling
  4648. */
  4649. export enum Orientation {
  4650. /**
  4651. * Clockwise
  4652. */
  4653. CW = 0,
  4654. /** Counter clockwise */
  4655. CCW = 1
  4656. }
  4657. /** Class used to represent a Bezier curve */
  4658. export class BezierCurve {
  4659. /**
  4660. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4661. * @param t defines the time
  4662. * @param x1 defines the left coordinate on X axis
  4663. * @param y1 defines the left coordinate on Y axis
  4664. * @param x2 defines the right coordinate on X axis
  4665. * @param y2 defines the right coordinate on Y axis
  4666. * @returns the interpolated value
  4667. */
  4668. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4669. }
  4670. /**
  4671. * Defines angle representation
  4672. */
  4673. export class Angle {
  4674. private _radians;
  4675. /**
  4676. * Creates an Angle object of "radians" radians (float).
  4677. * @param radians the angle in radians
  4678. */
  4679. constructor(radians: number);
  4680. /**
  4681. * Get value in degrees
  4682. * @returns the Angle value in degrees (float)
  4683. */
  4684. degrees(): number;
  4685. /**
  4686. * Get value in radians
  4687. * @returns the Angle value in radians (float)
  4688. */
  4689. radians(): number;
  4690. /**
  4691. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4692. * @param a defines first vector
  4693. * @param b defines second vector
  4694. * @returns a new Angle
  4695. */
  4696. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4697. /**
  4698. * Gets a new Angle object from the given float in radians
  4699. * @param radians defines the angle value in radians
  4700. * @returns a new Angle
  4701. */
  4702. static FromRadians(radians: number): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in degrees
  4705. * @param degrees defines the angle value in degrees
  4706. * @returns a new Angle
  4707. */
  4708. static FromDegrees(degrees: number): Angle;
  4709. }
  4710. /**
  4711. * This represents an arc in a 2d space.
  4712. */
  4713. export class Arc2 {
  4714. /** Defines the start point of the arc */
  4715. startPoint: Vector2;
  4716. /** Defines the mid point of the arc */
  4717. midPoint: Vector2;
  4718. /** Defines the end point of the arc */
  4719. endPoint: Vector2;
  4720. /**
  4721. * Defines the center point of the arc.
  4722. */
  4723. centerPoint: Vector2;
  4724. /**
  4725. * Defines the radius of the arc.
  4726. */
  4727. radius: number;
  4728. /**
  4729. * Defines the angle of the arc (from mid point to end point).
  4730. */
  4731. angle: Angle;
  4732. /**
  4733. * Defines the start angle of the arc (from start point to middle point).
  4734. */
  4735. startAngle: Angle;
  4736. /**
  4737. * Defines the orientation of the arc (clock wise/counter clock wise).
  4738. */
  4739. orientation: Orientation;
  4740. /**
  4741. * Creates an Arc object from the three given points : start, middle and end.
  4742. * @param startPoint Defines the start point of the arc
  4743. * @param midPoint Defines the midlle point of the arc
  4744. * @param endPoint Defines the end point of the arc
  4745. */
  4746. constructor(
  4747. /** Defines the start point of the arc */
  4748. startPoint: Vector2,
  4749. /** Defines the mid point of the arc */
  4750. midPoint: Vector2,
  4751. /** Defines the end point of the arc */
  4752. endPoint: Vector2);
  4753. }
  4754. /**
  4755. * Represents a 2D path made up of multiple 2D points
  4756. */
  4757. export class Path2 {
  4758. private _points;
  4759. private _length;
  4760. /**
  4761. * If the path start and end point are the same
  4762. */
  4763. closed: boolean;
  4764. /**
  4765. * Creates a Path2 object from the starting 2D coordinates x and y.
  4766. * @param x the starting points x value
  4767. * @param y the starting points y value
  4768. */
  4769. constructor(x: number, y: number);
  4770. /**
  4771. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4772. * @param x the added points x value
  4773. * @param y the added points y value
  4774. * @returns the updated Path2.
  4775. */
  4776. addLineTo(x: number, y: number): Path2;
  4777. /**
  4778. * 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.
  4779. * @param midX middle point x value
  4780. * @param midY middle point y value
  4781. * @param endX end point x value
  4782. * @param endY end point y value
  4783. * @param numberOfSegments (default: 36)
  4784. * @returns the updated Path2.
  4785. */
  4786. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4787. /**
  4788. * Closes the Path2.
  4789. * @returns the Path2.
  4790. */
  4791. close(): Path2;
  4792. /**
  4793. * Gets the sum of the distance between each sequential point in the path
  4794. * @returns the Path2 total length (float).
  4795. */
  4796. length(): number;
  4797. /**
  4798. * Gets the points which construct the path
  4799. * @returns the Path2 internal array of points.
  4800. */
  4801. getPoints(): Vector2[];
  4802. /**
  4803. * Retreives the point at the distance aways from the starting point
  4804. * @param normalizedLengthPosition the length along the path to retreive the point from
  4805. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4806. */
  4807. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4808. /**
  4809. * Creates a new path starting from an x and y position
  4810. * @param x starting x value
  4811. * @param y starting y value
  4812. * @returns a new Path2 starting at the coordinates (x, y).
  4813. */
  4814. static StartingAt(x: number, y: number): Path2;
  4815. }
  4816. /**
  4817. * Represents a 3D path made up of multiple 3D points
  4818. */
  4819. export class Path3D {
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[];
  4824. private _curve;
  4825. private _distances;
  4826. private _tangents;
  4827. private _normals;
  4828. private _binormals;
  4829. private _raw;
  4830. private _alignTangentsWithPath;
  4831. private readonly _pointAtData;
  4832. /**
  4833. * new Path3D(path, normal, raw)
  4834. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4835. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4836. * @param path an array of Vector3, the curve axis of the Path3D
  4837. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4838. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4839. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4840. */
  4841. constructor(
  4842. /**
  4843. * an array of Vector3, the curve axis of the Path3D
  4844. */
  4845. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4846. /**
  4847. * Returns the Path3D array of successive Vector3 designing its curve.
  4848. * @returns the Path3D array of successive Vector3 designing its curve.
  4849. */
  4850. getCurve(): Vector3[];
  4851. /**
  4852. * Returns the Path3D array of successive Vector3 designing its curve.
  4853. * @returns the Path3D array of successive Vector3 designing its curve.
  4854. */
  4855. getPoints(): Vector3[];
  4856. /**
  4857. * @returns the computed length (float) of the path.
  4858. */
  4859. length(): number;
  4860. /**
  4861. * Returns an array populated with tangent vectors on each Path3D curve point.
  4862. * @returns an array populated with tangent vectors on each Path3D curve point.
  4863. */
  4864. getTangents(): Vector3[];
  4865. /**
  4866. * Returns an array populated with normal vectors on each Path3D curve point.
  4867. * @returns an array populated with normal vectors on each Path3D curve point.
  4868. */
  4869. getNormals(): Vector3[];
  4870. /**
  4871. * Returns an array populated with binormal vectors on each Path3D curve point.
  4872. * @returns an array populated with binormal vectors on each Path3D curve point.
  4873. */
  4874. getBinormals(): Vector3[];
  4875. /**
  4876. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4877. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4878. */
  4879. getDistances(): number[];
  4880. /**
  4881. * Returns an interpolated point along this path
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns a new Vector3 as the point
  4884. */
  4885. getPointAt(position: number): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4890. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4891. */
  4892. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4897. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4898. */
  4899. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4904. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4905. */
  4906. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4907. /**
  4908. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4909. * @param position the position of the point along this path, from 0.0 to 1.0
  4910. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4911. */
  4912. getDistanceAt(position: number): number;
  4913. /**
  4914. * Returns the array index of the previous point of an interpolated point along this path
  4915. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4916. * @returns the array index
  4917. */
  4918. getPreviousPointIndexAt(position: number): number;
  4919. /**
  4920. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the sub position
  4923. */
  4924. getSubPositionAt(position: number): number;
  4925. /**
  4926. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4927. * @param target the vector of which to get the closest position to
  4928. * @returns the position of the closest virtual point on this path to the target vector
  4929. */
  4930. getClosestPositionTo(target: Vector3): number;
  4931. /**
  4932. * Returns a sub path (slice) of this path
  4933. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4934. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4935. * @returns a sub path (slice) of this path
  4936. */
  4937. slice(start?: number, end?: number): Path3D;
  4938. /**
  4939. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4940. * @param path path which all values are copied into the curves points
  4941. * @param firstNormal which should be projected onto the curve
  4942. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4943. * @returns the same object updated.
  4944. */
  4945. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4946. private _compute;
  4947. private _getFirstNonNullVector;
  4948. private _getLastNonNullVector;
  4949. private _normalVector;
  4950. /**
  4951. * Updates the point at data for an interpolated point along this curve
  4952. * @param position the position of the point along this curve, from 0.0 to 1.0
  4953. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4954. * @returns the (updated) point at data
  4955. */
  4956. private _updatePointAtData;
  4957. /**
  4958. * Updates the point at data from the specified parameters
  4959. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4960. * @param point the interpolated point
  4961. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4962. */
  4963. private _setPointAtData;
  4964. /**
  4965. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4966. */
  4967. private _updateInterpolationMatrix;
  4968. }
  4969. /**
  4970. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4971. * A Curve3 is designed from a series of successive Vector3.
  4972. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4973. */
  4974. export class Curve3 {
  4975. private _points;
  4976. private _length;
  4977. /**
  4978. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4979. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4980. * @param v1 (Vector3) the control point
  4981. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4988. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4989. * @param v1 (Vector3) the first control point
  4990. * @param v2 (Vector3) the second control point
  4991. * @param v3 (Vector3) the end point of the Cubic Bezier
  4992. * @param nbPoints (integer) the wanted number of points in the curve
  4993. * @returns the created Curve3
  4994. */
  4995. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4996. /**
  4997. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4998. * @param p1 (Vector3) the origin point of the Hermite Spline
  4999. * @param t1 (Vector3) the tangent vector at the origin point
  5000. * @param p2 (Vector3) the end point of the Hermite Spline
  5001. * @param t2 (Vector3) the tangent vector at the end point
  5002. * @param nbPoints (integer) the wanted number of points in the curve
  5003. * @returns the created Curve3
  5004. */
  5005. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5006. /**
  5007. * Returns a Curve3 object along a CatmullRom Spline curve :
  5008. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5009. * @param nbPoints (integer) the wanted number of points between each curve control points
  5010. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5014. /**
  5015. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5016. * A Curve3 is designed from a series of successive Vector3.
  5017. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5018. * @param points points which make up the curve
  5019. */
  5020. constructor(points: Vector3[]);
  5021. /**
  5022. * @returns the Curve3 stored array of successive Vector3
  5023. */
  5024. getPoints(): Vector3[];
  5025. /**
  5026. * @returns the computed length (float) of the curve.
  5027. */
  5028. length(): number;
  5029. /**
  5030. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5031. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5032. * curveA and curveB keep unchanged.
  5033. * @param curve the curve to continue from this curve
  5034. * @returns the newly constructed curve
  5035. */
  5036. continue(curve: DeepImmutable<Curve3>): Curve3;
  5037. private _computeLength;
  5038. }
  5039. }
  5040. declare module BABYLON {
  5041. /**
  5042. * This represents the main contract an easing function should follow.
  5043. * Easing functions are used throughout the animation system.
  5044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5045. */
  5046. export interface IEasingFunction {
  5047. /**
  5048. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5049. * of the easing function.
  5050. * The link below provides some of the most common examples of easing functions.
  5051. * @see https://easings.net/
  5052. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5053. * @returns the corresponding value on the curve defined by the easing function
  5054. */
  5055. ease(gradient: number): number;
  5056. }
  5057. /**
  5058. * Base class used for every default easing function.
  5059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5060. */
  5061. export class EasingFunction implements IEasingFunction {
  5062. /**
  5063. * Interpolation follows the mathematical formula associated with the easing function.
  5064. */
  5065. static readonly EASINGMODE_EASEIN: number;
  5066. /**
  5067. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5068. */
  5069. static readonly EASINGMODE_EASEOUT: number;
  5070. /**
  5071. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5072. */
  5073. static readonly EASINGMODE_EASEINOUT: number;
  5074. private _easingMode;
  5075. /**
  5076. * Sets the easing mode of the current function.
  5077. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5078. */
  5079. setEasingMode(easingMode: number): void;
  5080. /**
  5081. * Gets the current easing mode.
  5082. * @returns the easing mode
  5083. */
  5084. getEasingMode(): number;
  5085. /**
  5086. * @hidden
  5087. */
  5088. easeInCore(gradient: number): number;
  5089. /**
  5090. * Given an input gradient between 0 and 1, this returns the corresponding value
  5091. * of the easing function.
  5092. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5093. * @returns the corresponding value on the curve defined by the easing function
  5094. */
  5095. ease(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a circle shape (see link below).
  5099. * @see https://easings.net/#easeInCirc
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CircleEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with a ease back shape (see link below).
  5108. * @see https://easings.net/#easeInBack
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class BackEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the amplitude of the function */
  5113. amplitude: number;
  5114. /**
  5115. * Instantiates a back ease easing
  5116. * @see https://easings.net/#easeInBack
  5117. * @param amplitude Defines the amplitude of the function
  5118. */
  5119. constructor(
  5120. /** Defines the amplitude of the function */
  5121. amplitude?: number);
  5122. /** @hidden */
  5123. easeInCore(gradient: number): number;
  5124. }
  5125. /**
  5126. * Easing function with a bouncing shape (see link below).
  5127. * @see https://easings.net/#easeInBounce
  5128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5129. */
  5130. export class BounceEase extends EasingFunction implements IEasingFunction {
  5131. /** Defines the number of bounces */
  5132. bounces: number;
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness: number;
  5135. /**
  5136. * Instantiates a bounce easing
  5137. * @see https://easings.net/#easeInBounce
  5138. * @param bounces Defines the number of bounces
  5139. * @param bounciness Defines the amplitude of the bounce
  5140. */
  5141. constructor(
  5142. /** Defines the number of bounces */
  5143. bounces?: number,
  5144. /** Defines the amplitude of the bounce */
  5145. bounciness?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power of 3 shape (see link below).
  5151. * @see https://easings.net/#easeInCubic
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class CubicEase extends EasingFunction implements IEasingFunction {
  5155. /** @hidden */
  5156. easeInCore(gradient: number): number;
  5157. }
  5158. /**
  5159. * Easing function with an elastic shape (see link below).
  5160. * @see https://easings.net/#easeInElastic
  5161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5162. */
  5163. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5164. /** Defines the number of oscillations*/
  5165. oscillations: number;
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness: number;
  5168. /**
  5169. * Instantiates an elastic easing function
  5170. * @see https://easings.net/#easeInElastic
  5171. * @param oscillations Defines the number of oscillations
  5172. * @param springiness Defines the amplitude of the oscillations
  5173. */
  5174. constructor(
  5175. /** Defines the number of oscillations*/
  5176. oscillations?: number,
  5177. /** Defines the amplitude of the oscillations*/
  5178. springiness?: number);
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an exponential shape (see link below).
  5184. * @see https://easings.net/#easeInExpo
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the exponent of the function */
  5189. exponent: number;
  5190. /**
  5191. * Instantiates an exponential easing function
  5192. * @see https://easings.net/#easeInExpo
  5193. * @param exponent Defines the exponent of the function
  5194. */
  5195. constructor(
  5196. /** Defines the exponent of the function */
  5197. exponent?: number);
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power shape (see link below).
  5203. * @see https://easings.net/#easeInQuad
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class PowerEase extends EasingFunction implements IEasingFunction {
  5207. /** Defines the power of the function */
  5208. power: number;
  5209. /**
  5210. * Instantiates an power base easing function
  5211. * @see https://easings.net/#easeInQuad
  5212. * @param power Defines the power of the function
  5213. */
  5214. constructor(
  5215. /** Defines the power of the function */
  5216. power?: number);
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a power of 2 shape (see link below).
  5222. * @see https://easings.net/#easeInQuad
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a power of 4 shape (see link below).
  5231. * @see https://easings.net/#easeInQuart
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. /**
  5239. * Easing function with a power of 5 shape (see link below).
  5240. * @see https://easings.net/#easeInQuint
  5241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5242. */
  5243. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a sin shape (see link below).
  5249. * @see https://easings.net/#easeInSine
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class SineEase extends EasingFunction implements IEasingFunction {
  5253. /** @hidden */
  5254. easeInCore(gradient: number): number;
  5255. }
  5256. /**
  5257. * Easing function with a bezier shape (see link below).
  5258. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5260. */
  5261. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5262. /** Defines the x component of the start tangent in the bezier curve */
  5263. x1: number;
  5264. /** Defines the y component of the start tangent in the bezier curve */
  5265. y1: number;
  5266. /** Defines the x component of the end tangent in the bezier curve */
  5267. x2: number;
  5268. /** Defines the y component of the end tangent in the bezier curve */
  5269. y2: number;
  5270. /**
  5271. * Instantiates a bezier function
  5272. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5273. * @param x1 Defines the x component of the start tangent in the bezier curve
  5274. * @param y1 Defines the y component of the start tangent in the bezier curve
  5275. * @param x2 Defines the x component of the end tangent in the bezier curve
  5276. * @param y2 Defines the y component of the end tangent in the bezier curve
  5277. */
  5278. constructor(
  5279. /** Defines the x component of the start tangent in the bezier curve */
  5280. x1?: number,
  5281. /** Defines the y component of the start tangent in the bezier curve */
  5282. y1?: number,
  5283. /** Defines the x component of the end tangent in the bezier curve */
  5284. x2?: number,
  5285. /** Defines the y component of the end tangent in the bezier curve */
  5286. y2?: number);
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. }
  5291. declare module BABYLON {
  5292. /**
  5293. * Class used to hold a RBG color
  5294. */
  5295. export class Color3 {
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r: number;
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g: number;
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b: number;
  5308. /**
  5309. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5310. * @param r defines the red component (between 0 and 1, default is 0)
  5311. * @param g defines the green component (between 0 and 1, default is 0)
  5312. * @param b defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. constructor(
  5315. /**
  5316. * Defines the red component (between 0 and 1, default is 0)
  5317. */
  5318. r?: number,
  5319. /**
  5320. * Defines the green component (between 0 and 1, default is 0)
  5321. */
  5322. g?: number,
  5323. /**
  5324. * Defines the blue component (between 0 and 1, default is 0)
  5325. */
  5326. b?: number);
  5327. /**
  5328. * Creates a string with the Color3 current values
  5329. * @returns the string representation of the Color3 object
  5330. */
  5331. toString(): string;
  5332. /**
  5333. * Returns the string "Color3"
  5334. * @returns "Color3"
  5335. */
  5336. getClassName(): string;
  5337. /**
  5338. * Compute the Color3 hash code
  5339. * @returns an unique number that can be used to hash Color3 objects
  5340. */
  5341. getHashCode(): number;
  5342. /**
  5343. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5344. * @param array defines the array where to store the r,g,b components
  5345. * @param index defines an optional index in the target array to define where to start storing values
  5346. * @returns the current Color3 object
  5347. */
  5348. toArray(array: FloatArray, index?: number): Color3;
  5349. /**
  5350. * Returns a new Color4 object from the current Color3 and the given alpha
  5351. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5352. * @returns a new Color4 object
  5353. */
  5354. toColor4(alpha?: number): Color4;
  5355. /**
  5356. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5357. * @returns the new array
  5358. */
  5359. asArray(): number[];
  5360. /**
  5361. * Returns the luminance value
  5362. * @returns a float value
  5363. */
  5364. toLuminance(): number;
  5365. /**
  5366. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5367. * @param otherColor defines the second operand
  5368. * @returns the new Color3 object
  5369. */
  5370. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5371. /**
  5372. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5373. * @param otherColor defines the second operand
  5374. * @param result defines the Color3 object where to store the result
  5375. * @returns the current Color3
  5376. */
  5377. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5378. /**
  5379. * Determines equality between Color3 objects
  5380. * @param otherColor defines the second operand
  5381. * @returns true if the rgb values are equal to the given ones
  5382. */
  5383. equals(otherColor: DeepImmutable<Color3>): boolean;
  5384. /**
  5385. * Determines equality between the current Color3 object and a set of r,b,g values
  5386. * @param r defines the red component to check
  5387. * @param g defines the green component to check
  5388. * @param b defines the blue component to check
  5389. * @returns true if the rgb values are equal to the given ones
  5390. */
  5391. equalsFloats(r: number, g: number, b: number): boolean;
  5392. /**
  5393. * Multiplies in place each rgb value by scale
  5394. * @param scale defines the scaling factor
  5395. * @returns the updated Color3
  5396. */
  5397. scale(scale: number): Color3;
  5398. /**
  5399. * Multiplies the rgb values by scale and stores the result into "result"
  5400. * @param scale defines the scaling factor
  5401. * @param result defines the Color3 object where to store the result
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Scale the current Color3 values by a factor and add the result to a given Color3
  5407. * @param scale defines the scale factor
  5408. * @param result defines color to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Clamps the rgb values by the min and max values and stores the result into "result"
  5414. * @param min defines minimum clamping value (default is 0)
  5415. * @param max defines maximum clamping value (default is 1)
  5416. * @param result defines color to store the result into
  5417. * @returns the original Color3
  5418. */
  5419. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5420. /**
  5421. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5422. * @param otherColor defines the second operand
  5423. * @returns the new Color3
  5424. */
  5425. add(otherColor: DeepImmutable<Color3>): Color3;
  5426. /**
  5427. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5428. * @param otherColor defines the second operand
  5429. * @param result defines Color3 object to store the result into
  5430. * @returns the unmodified current Color3
  5431. */
  5432. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5433. /**
  5434. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5435. * @param otherColor defines the second operand
  5436. * @returns the new Color3
  5437. */
  5438. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5439. /**
  5440. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5441. * @param otherColor defines the second operand
  5442. * @param result defines Color3 object to store the result into
  5443. * @returns the unmodified current Color3
  5444. */
  5445. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5446. /**
  5447. * Copy the current object
  5448. * @returns a new Color3 copied the current one
  5449. */
  5450. clone(): Color3;
  5451. /**
  5452. * Copies the rgb values from the source in the current Color3
  5453. * @param source defines the source Color3 object
  5454. * @returns the updated Color3 object
  5455. */
  5456. copyFrom(source: DeepImmutable<Color3>): Color3;
  5457. /**
  5458. * Updates the Color3 rgb values from the given floats
  5459. * @param r defines the red component to read from
  5460. * @param g defines the green component to read from
  5461. * @param b defines the blue component to read from
  5462. * @returns the current Color3 object
  5463. */
  5464. copyFromFloats(r: number, g: number, b: number): Color3;
  5465. /**
  5466. * Updates the Color3 rgb values from the given floats
  5467. * @param r defines the red component to read from
  5468. * @param g defines the green component to read from
  5469. * @param b defines the blue component to read from
  5470. * @returns the current Color3 object
  5471. */
  5472. set(r: number, g: number, b: number): Color3;
  5473. /**
  5474. * Compute the Color3 hexadecimal code as a string
  5475. * @returns a string containing the hexadecimal representation of the Color3 object
  5476. */
  5477. toHexString(): string;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to linear space
  5480. * @returns a new Color3 object
  5481. */
  5482. toLinearSpace(): Color3;
  5483. /**
  5484. * Converts current color in rgb space to HSV values
  5485. * @returns a new color3 representing the HSV values
  5486. */
  5487. toHSV(): Color3;
  5488. /**
  5489. * Converts current color in rgb space to HSV values
  5490. * @param result defines the Color3 where to store the HSV values
  5491. */
  5492. toHSVToRef(result: Color3): void;
  5493. /**
  5494. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the linear space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5499. /**
  5500. * Computes a new Color3 converted from the current one to gamma space
  5501. * @returns a new Color3 object
  5502. */
  5503. toGammaSpace(): Color3;
  5504. /**
  5505. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5506. * @param convertedColor defines the Color3 object where to store the gamma space version
  5507. * @returns the unmodified Color3
  5508. */
  5509. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5510. private static _BlackReadOnly;
  5511. /**
  5512. * Convert Hue, saturation and value to a Color3 (RGB)
  5513. * @param hue defines the hue
  5514. * @param saturation defines the saturation
  5515. * @param value defines the value
  5516. * @param result defines the Color3 where to store the RGB values
  5517. */
  5518. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5519. /**
  5520. * Creates a new Color3 from the string containing valid hexadecimal values
  5521. * @param hex defines a string containing valid hexadecimal values
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromHexString(hex: string): Color3;
  5525. /**
  5526. * Creates a new Color3 from the starting index of the given array
  5527. * @param array defines the source array
  5528. * @param offset defines an offset in the source array
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5532. /**
  5533. * Creates a new Color3 from integer values (< 256)
  5534. * @param r defines the red component to read from (value between 0 and 255)
  5535. * @param g defines the green component to read from (value between 0 and 255)
  5536. * @param b defines the blue component to read from (value between 0 and 255)
  5537. * @returns a new Color3 object
  5538. */
  5539. static FromInts(r: number, g: number, b: number): Color3;
  5540. /**
  5541. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5542. * @param start defines the start Color3 value
  5543. * @param end defines the end Color3 value
  5544. * @param amount defines the gradient value between start and end
  5545. * @returns a new Color3 object
  5546. */
  5547. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5548. /**
  5549. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5550. * @param left defines the start value
  5551. * @param right defines the end value
  5552. * @param amount defines the gradient factor
  5553. * @param result defines the Color3 object where to store the result
  5554. */
  5555. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5556. /**
  5557. * Returns a Color3 value containing a red color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Red(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a green color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Green(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a blue color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Blue(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a black color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Black(): Color3;
  5576. /**
  5577. * Gets a Color3 value containing a black color that must not be updated
  5578. */
  5579. static get BlackReadOnly(): DeepImmutable<Color3>;
  5580. /**
  5581. * Returns a Color3 value containing a white color
  5582. * @returns a new Color3 object
  5583. */
  5584. static White(): Color3;
  5585. /**
  5586. * Returns a Color3 value containing a purple color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Purple(): Color3;
  5590. /**
  5591. * Returns a Color3 value containing a magenta color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Magenta(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a yellow color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Yellow(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a gray color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Gray(): Color3;
  5605. /**
  5606. * Returns a Color3 value containing a teal color
  5607. * @returns a new Color3 object
  5608. */
  5609. static Teal(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a random color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Random(): Color3;
  5615. }
  5616. /**
  5617. * Class used to hold a RBGA color
  5618. */
  5619. export class Color4 {
  5620. /**
  5621. * Defines the red component (between 0 and 1, default is 0)
  5622. */
  5623. r: number;
  5624. /**
  5625. * Defines the green component (between 0 and 1, default is 0)
  5626. */
  5627. g: number;
  5628. /**
  5629. * Defines the blue component (between 0 and 1, default is 0)
  5630. */
  5631. b: number;
  5632. /**
  5633. * Defines the alpha component (between 0 and 1, default is 1)
  5634. */
  5635. a: number;
  5636. /**
  5637. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5638. * @param r defines the red component (between 0 and 1, default is 0)
  5639. * @param g defines the green component (between 0 and 1, default is 0)
  5640. * @param b defines the blue component (between 0 and 1, default is 0)
  5641. * @param a defines the alpha component (between 0 and 1, default is 1)
  5642. */
  5643. constructor(
  5644. /**
  5645. * Defines the red component (between 0 and 1, default is 0)
  5646. */
  5647. r?: number,
  5648. /**
  5649. * Defines the green component (between 0 and 1, default is 0)
  5650. */
  5651. g?: number,
  5652. /**
  5653. * Defines the blue component (between 0 and 1, default is 0)
  5654. */
  5655. b?: number,
  5656. /**
  5657. * Defines the alpha component (between 0 and 1, default is 1)
  5658. */
  5659. a?: number);
  5660. /**
  5661. * Adds in place the given Color4 values to the current Color4 object
  5662. * @param right defines the second operand
  5663. * @returns the current updated Color4 object
  5664. */
  5665. addInPlace(right: DeepImmutable<Color4>): Color4;
  5666. /**
  5667. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5668. * @returns the new array
  5669. */
  5670. asArray(): number[];
  5671. /**
  5672. * Stores from the starting index in the given array the Color4 successive values
  5673. * @param array defines the array where to store the r,g,b components
  5674. * @param index defines an optional index in the target array to define where to start storing values
  5675. * @returns the current Color4 object
  5676. */
  5677. toArray(array: number[], index?: number): Color4;
  5678. /**
  5679. * Determines equality between Color4 objects
  5680. * @param otherColor defines the second operand
  5681. * @returns true if the rgba values are equal to the given ones
  5682. */
  5683. equals(otherColor: DeepImmutable<Color4>): boolean;
  5684. /**
  5685. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5686. * @param right defines the second operand
  5687. * @returns a new Color4 object
  5688. */
  5689. add(right: DeepImmutable<Color4>): Color4;
  5690. /**
  5691. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5692. * @param right defines the second operand
  5693. * @returns a new Color4 object
  5694. */
  5695. subtract(right: DeepImmutable<Color4>): Color4;
  5696. /**
  5697. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5698. * @param right defines the second operand
  5699. * @param result defines the Color4 object where to store the result
  5700. * @returns the current Color4 object
  5701. */
  5702. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5703. /**
  5704. * Creates a new Color4 with the current Color4 values multiplied by scale
  5705. * @param scale defines the scaling factor to apply
  5706. * @returns a new Color4 object
  5707. */
  5708. scale(scale: number): Color4;
  5709. /**
  5710. * Multiplies the current Color4 values by scale and stores the result in "result"
  5711. * @param scale defines the scaling factor to apply
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the current unmodified Color4
  5714. */
  5715. scaleToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Scale the current Color4 values by a factor and add the result to a given Color4
  5718. * @param scale defines the scale factor
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the unmodified current Color4
  5721. */
  5722. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Clamps the rgb values by the min and max values and stores the result into "result"
  5725. * @param min defines minimum clamping value (default is 0)
  5726. * @param max defines maximum clamping value (default is 1)
  5727. * @param result defines color to store the result into.
  5728. * @returns the cuurent Color4
  5729. */
  5730. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5731. /**
  5732. * Multipy an Color4 value by another and return a new Color4 object
  5733. * @param color defines the Color4 value to multiply by
  5734. * @returns a new Color4 object
  5735. */
  5736. multiply(color: Color4): Color4;
  5737. /**
  5738. * Multipy a Color4 value by another and push the result in a reference value
  5739. * @param color defines the Color4 value to multiply by
  5740. * @param result defines the Color4 to fill the result in
  5741. * @returns the result Color4
  5742. */
  5743. multiplyToRef(color: Color4, result: Color4): Color4;
  5744. /**
  5745. * Creates a string with the Color4 current values
  5746. * @returns the string representation of the Color4 object
  5747. */
  5748. toString(): string;
  5749. /**
  5750. * Returns the string "Color4"
  5751. * @returns "Color4"
  5752. */
  5753. getClassName(): string;
  5754. /**
  5755. * Compute the Color4 hash code
  5756. * @returns an unique number that can be used to hash Color4 objects
  5757. */
  5758. getHashCode(): number;
  5759. /**
  5760. * Creates a new Color4 copied from the current one
  5761. * @returns a new Color4 object
  5762. */
  5763. clone(): Color4;
  5764. /**
  5765. * Copies the given Color4 values into the current one
  5766. * @param source defines the source Color4 object
  5767. * @returns the current updated Color4 object
  5768. */
  5769. copyFrom(source: Color4): Color4;
  5770. /**
  5771. * Copies the given float values into the current one
  5772. * @param r defines the red component to read from
  5773. * @param g defines the green component to read from
  5774. * @param b defines the blue component to read from
  5775. * @param a defines the alpha component to read from
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. set(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Compute the Color4 hexadecimal code as a string
  5790. * @returns a string containing the hexadecimal representation of the Color4 object
  5791. */
  5792. toHexString(): string;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to linear space
  5795. * @returns a new Color4 object
  5796. */
  5797. toLinearSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the linear space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Computes a new Color4 converted from the current one to gamma space
  5806. * @returns a new Color4 object
  5807. */
  5808. toGammaSpace(): Color4;
  5809. /**
  5810. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5811. * @param convertedColor defines the Color4 object where to store the gamma space version
  5812. * @returns the unmodified Color4
  5813. */
  5814. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5815. /**
  5816. * Creates a new Color4 from the string containing valid hexadecimal values
  5817. * @param hex defines a string containing valid hexadecimal values
  5818. * @returns a new Color4 object
  5819. */
  5820. static FromHexString(hex: string): Color4;
  5821. /**
  5822. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5823. * @param left defines the start value
  5824. * @param right defines the end value
  5825. * @param amount defines the gradient factor
  5826. * @returns a new Color4 object
  5827. */
  5828. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5829. /**
  5830. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5831. * @param left defines the start value
  5832. * @param right defines the end value
  5833. * @param amount defines the gradient factor
  5834. * @param result defines the Color4 object where to store data
  5835. */
  5836. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5837. /**
  5838. * Creates a new Color4 from a Color3 and an alpha value
  5839. * @param color3 defines the source Color3 to read from
  5840. * @param alpha defines the alpha component (1.0 by default)
  5841. * @returns a new Color4 object
  5842. */
  5843. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5844. /**
  5845. * Creates a new Color4 from the starting index element of the given array
  5846. * @param array defines the source array to read from
  5847. * @param offset defines the offset in the source array
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5851. /**
  5852. * Creates a new Color3 from integer values (< 256)
  5853. * @param r defines the red component to read from (value between 0 and 255)
  5854. * @param g defines the green component to read from (value between 0 and 255)
  5855. * @param b defines the blue component to read from (value between 0 and 255)
  5856. * @param a defines the alpha component to read from (value between 0 and 255)
  5857. * @returns a new Color3 object
  5858. */
  5859. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5860. /**
  5861. * Check the content of a given array and convert it to an array containing RGBA data
  5862. * If the original array was already containing count * 4 values then it is returned directly
  5863. * @param colors defines the array to check
  5864. * @param count defines the number of RGBA data to expect
  5865. * @returns an array containing count * 4 values (RGBA)
  5866. */
  5867. static CheckColors4(colors: number[], count: number): number[];
  5868. }
  5869. /**
  5870. * @hidden
  5871. */
  5872. export class TmpColors {
  5873. static Color3: Color3[];
  5874. static Color4: Color4[];
  5875. }
  5876. }
  5877. declare module BABYLON {
  5878. /**
  5879. * Defines an interface which represents an animation key frame
  5880. */
  5881. export interface IAnimationKey {
  5882. /**
  5883. * Frame of the key frame
  5884. */
  5885. frame: number;
  5886. /**
  5887. * Value at the specifies key frame
  5888. */
  5889. value: any;
  5890. /**
  5891. * The input tangent for the cubic hermite spline
  5892. */
  5893. inTangent?: any;
  5894. /**
  5895. * The output tangent for the cubic hermite spline
  5896. */
  5897. outTangent?: any;
  5898. /**
  5899. * The animation interpolation type
  5900. */
  5901. interpolation?: AnimationKeyInterpolation;
  5902. }
  5903. /**
  5904. * Enum for the animation key frame interpolation type
  5905. */
  5906. export enum AnimationKeyInterpolation {
  5907. /**
  5908. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5909. */
  5910. STEP = 1
  5911. }
  5912. }
  5913. declare module BABYLON {
  5914. /**
  5915. * Represents the range of an animation
  5916. */
  5917. export class AnimationRange {
  5918. /**The name of the animation range**/
  5919. name: string;
  5920. /**The starting frame of the animation */
  5921. from: number;
  5922. /**The ending frame of the animation*/
  5923. to: number;
  5924. /**
  5925. * Initializes the range of an animation
  5926. * @param name The name of the animation range
  5927. * @param from The starting frame of the animation
  5928. * @param to The ending frame of the animation
  5929. */
  5930. constructor(
  5931. /**The name of the animation range**/
  5932. name: string,
  5933. /**The starting frame of the animation */
  5934. from: number,
  5935. /**The ending frame of the animation*/
  5936. to: number);
  5937. /**
  5938. * Makes a copy of the animation range
  5939. * @returns A copy of the animation range
  5940. */
  5941. clone(): AnimationRange;
  5942. }
  5943. }
  5944. declare module BABYLON {
  5945. /**
  5946. * Composed of a frame, and an action function
  5947. */
  5948. export class AnimationEvent {
  5949. /** The frame for which the event is triggered **/
  5950. frame: number;
  5951. /** The event to perform when triggered **/
  5952. action: (currentFrame: number) => void;
  5953. /** Specifies if the event should be triggered only once**/
  5954. onlyOnce?: boolean | undefined;
  5955. /**
  5956. * Specifies if the animation event is done
  5957. */
  5958. isDone: boolean;
  5959. /**
  5960. * Initializes the animation event
  5961. * @param frame The frame for which the event is triggered
  5962. * @param action The event to perform when triggered
  5963. * @param onlyOnce Specifies if the event should be triggered only once
  5964. */
  5965. constructor(
  5966. /** The frame for which the event is triggered **/
  5967. frame: number,
  5968. /** The event to perform when triggered **/
  5969. action: (currentFrame: number) => void,
  5970. /** Specifies if the event should be triggered only once**/
  5971. onlyOnce?: boolean | undefined);
  5972. /** @hidden */
  5973. _clone(): AnimationEvent;
  5974. }
  5975. }
  5976. declare module BABYLON {
  5977. /**
  5978. * Interface used to define a behavior
  5979. */
  5980. export interface Behavior<T> {
  5981. /** gets or sets behavior's name */
  5982. name: string;
  5983. /**
  5984. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5985. */
  5986. init(): void;
  5987. /**
  5988. * Called when the behavior is attached to a target
  5989. * @param target defines the target where the behavior is attached to
  5990. */
  5991. attach(target: T): void;
  5992. /**
  5993. * Called when the behavior is detached from its target
  5994. */
  5995. detach(): void;
  5996. }
  5997. /**
  5998. * Interface implemented by classes supporting behaviors
  5999. */
  6000. export interface IBehaviorAware<T> {
  6001. /**
  6002. * Attach a behavior
  6003. * @param behavior defines the behavior to attach
  6004. * @returns the current host
  6005. */
  6006. addBehavior(behavior: Behavior<T>): T;
  6007. /**
  6008. * Remove a behavior from the current object
  6009. * @param behavior defines the behavior to detach
  6010. * @returns the current host
  6011. */
  6012. removeBehavior(behavior: Behavior<T>): T;
  6013. /**
  6014. * Gets a behavior using its name to search
  6015. * @param name defines the name to search
  6016. * @returns the behavior or null if not found
  6017. */
  6018. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6019. }
  6020. }
  6021. declare module BABYLON {
  6022. /**
  6023. * Defines an array and its length.
  6024. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6025. */
  6026. export interface ISmartArrayLike<T> {
  6027. /**
  6028. * The data of the array.
  6029. */
  6030. data: Array<T>;
  6031. /**
  6032. * The active length of the array.
  6033. */
  6034. length: number;
  6035. }
  6036. /**
  6037. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6038. */
  6039. export class SmartArray<T> implements ISmartArrayLike<T> {
  6040. /**
  6041. * The full set of data from the array.
  6042. */
  6043. data: Array<T>;
  6044. /**
  6045. * The active length of the array.
  6046. */
  6047. length: number;
  6048. protected _id: number;
  6049. /**
  6050. * Instantiates a Smart Array.
  6051. * @param capacity defines the default capacity of the array.
  6052. */
  6053. constructor(capacity: number);
  6054. /**
  6055. * Pushes a value at the end of the active data.
  6056. * @param value defines the object to push in the array.
  6057. */
  6058. push(value: T): void;
  6059. /**
  6060. * Iterates over the active data and apply the lambda to them.
  6061. * @param func defines the action to apply on each value.
  6062. */
  6063. forEach(func: (content: T) => void): void;
  6064. /**
  6065. * Sorts the full sets of data.
  6066. * @param compareFn defines the comparison function to apply.
  6067. */
  6068. sort(compareFn: (a: T, b: T) => number): void;
  6069. /**
  6070. * Resets the active data to an empty array.
  6071. */
  6072. reset(): void;
  6073. /**
  6074. * Releases all the data from the array as well as the array.
  6075. */
  6076. dispose(): void;
  6077. /**
  6078. * Concats the active data with a given array.
  6079. * @param array defines the data to concatenate with.
  6080. */
  6081. concat(array: any): void;
  6082. /**
  6083. * Returns the position of a value in the active data.
  6084. * @param value defines the value to find the index for
  6085. * @returns the index if found in the active data otherwise -1
  6086. */
  6087. indexOf(value: T): number;
  6088. /**
  6089. * Returns whether an element is part of the active data.
  6090. * @param value defines the value to look for
  6091. * @returns true if found in the active data otherwise false
  6092. */
  6093. contains(value: T): boolean;
  6094. private static _GlobalId;
  6095. }
  6096. /**
  6097. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6098. * The data in this array can only be present once
  6099. */
  6100. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6101. private _duplicateId;
  6102. /**
  6103. * Pushes a value at the end of the active data.
  6104. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6105. * @param value defines the object to push in the array.
  6106. */
  6107. push(value: T): void;
  6108. /**
  6109. * Pushes a value at the end of the active data.
  6110. * If the data is already present, it won t be added again
  6111. * @param value defines the object to push in the array.
  6112. * @returns true if added false if it was already present
  6113. */
  6114. pushNoDuplicate(value: T): boolean;
  6115. /**
  6116. * Resets the active data to an empty array.
  6117. */
  6118. reset(): void;
  6119. /**
  6120. * Concats the active data with a given array.
  6121. * This ensures no dupplicate will be present in the result.
  6122. * @param array defines the data to concatenate with.
  6123. */
  6124. concatWithNoDuplicate(array: any): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. /**
  6129. * @ignore
  6130. * This is a list of all the different input types that are available in the application.
  6131. * Fo instance: ArcRotateCameraGamepadInput...
  6132. */
  6133. export var CameraInputTypes: {};
  6134. /**
  6135. * This is the contract to implement in order to create a new input class.
  6136. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6137. */
  6138. export interface ICameraInput<TCamera extends Camera> {
  6139. /**
  6140. * Defines the camera the input is attached to.
  6141. */
  6142. camera: Nullable<TCamera>;
  6143. /**
  6144. * Gets the class name of the current intput.
  6145. * @returns the class name
  6146. */
  6147. getClassName(): string;
  6148. /**
  6149. * Get the friendly name associated with the input class.
  6150. * @returns the input friendly name
  6151. */
  6152. getSimpleName(): string;
  6153. /**
  6154. * Attach the input controls to a specific dom element to get the input from.
  6155. * @param element Defines the element the controls should be listened from
  6156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6159. /**
  6160. * Detach the current controls from the specified dom element.
  6161. * @param element Defines the element to stop listening the inputs from
  6162. */
  6163. detachControl(element: Nullable<HTMLElement>): void;
  6164. /**
  6165. * Update the current camera state depending on the inputs that have been used this frame.
  6166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6167. */
  6168. checkInputs?: () => void;
  6169. }
  6170. /**
  6171. * Represents a map of input types to input instance or input index to input instance.
  6172. */
  6173. export interface CameraInputsMap<TCamera extends Camera> {
  6174. /**
  6175. * Accessor to the input by input type.
  6176. */
  6177. [name: string]: ICameraInput<TCamera>;
  6178. /**
  6179. * Accessor to the input by input index.
  6180. */
  6181. [idx: number]: ICameraInput<TCamera>;
  6182. }
  6183. /**
  6184. * This represents the input manager used within a camera.
  6185. * It helps dealing with all the different kind of input attached to a camera.
  6186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6187. */
  6188. export class CameraInputsManager<TCamera extends Camera> {
  6189. /**
  6190. * Defines the list of inputs attahed to the camera.
  6191. */
  6192. attached: CameraInputsMap<TCamera>;
  6193. /**
  6194. * Defines the dom element the camera is collecting inputs from.
  6195. * This is null if the controls have not been attached.
  6196. */
  6197. attachedElement: Nullable<HTMLElement>;
  6198. /**
  6199. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6200. */
  6201. noPreventDefault: boolean;
  6202. /**
  6203. * Defined the camera the input manager belongs to.
  6204. */
  6205. camera: TCamera;
  6206. /**
  6207. * Update the current camera state depending on the inputs that have been used this frame.
  6208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6209. */
  6210. checkInputs: () => void;
  6211. /**
  6212. * Instantiate a new Camera Input Manager.
  6213. * @param camera Defines the camera the input manager blongs to
  6214. */
  6215. constructor(camera: TCamera);
  6216. /**
  6217. * Add an input method to a camera
  6218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6219. * @param input camera input method
  6220. */
  6221. add(input: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Remove a specific input method from a camera
  6224. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6225. * @param inputToRemove camera input method
  6226. */
  6227. remove(inputToRemove: ICameraInput<TCamera>): void;
  6228. /**
  6229. * Remove a specific input type from a camera
  6230. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6231. * @param inputType the type of the input to remove
  6232. */
  6233. removeByType(inputType: string): void;
  6234. private _addCheckInputs;
  6235. /**
  6236. * Attach the input controls to the currently attached dom element to listen the events from.
  6237. * @param input Defines the input to attach
  6238. */
  6239. attachInput(input: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6242. * @param element Defines the dom element to collect the events from
  6243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6244. */
  6245. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6246. /**
  6247. * Detach the current manager inputs controls from a specific dom element.
  6248. * @param element Defines the dom element to collect the events from
  6249. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6250. */
  6251. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6252. /**
  6253. * Rebuild the dynamic inputCheck function from the current list of
  6254. * defined inputs in the manager.
  6255. */
  6256. rebuildInputCheck(): void;
  6257. /**
  6258. * Remove all attached input methods from a camera
  6259. */
  6260. clear(): void;
  6261. /**
  6262. * Serialize the current input manager attached to a camera.
  6263. * This ensures than once parsed,
  6264. * the input associated to the camera will be identical to the current ones
  6265. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6266. */
  6267. serialize(serializedCamera: any): void;
  6268. /**
  6269. * Parses an input manager serialized JSON to restore the previous list of inputs
  6270. * and states associated to a camera.
  6271. * @param parsedCamera Defines the JSON to parse
  6272. */
  6273. parse(parsedCamera: any): void;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Class used to store data that will be store in GPU memory
  6279. */
  6280. export class Buffer {
  6281. private _engine;
  6282. private _buffer;
  6283. /** @hidden */
  6284. _data: Nullable<DataArray>;
  6285. private _updatable;
  6286. private _instanced;
  6287. private _divisor;
  6288. /**
  6289. * Gets the byte stride.
  6290. */
  6291. readonly byteStride: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this buffer
  6296. * @param updatable whether the data is updatable
  6297. * @param stride the stride (optional)
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param instanced whether the buffer is instanced (optional)
  6300. * @param useBytes set to true if the stride in in bytes (optional)
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. */
  6303. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6304. /**
  6305. * Create a new VertexBuffer based on the current buffer
  6306. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6307. * @param offset defines offset in the buffer (0 by default)
  6308. * @param size defines the size in floats of attributes (position is 3 for instance)
  6309. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6310. * @param instanced defines if the vertex buffer contains indexed data
  6311. * @param useBytes defines if the offset and stride are in bytes *
  6312. * @param divisor sets an optional divisor for instances (1 by default)
  6313. * @returns the new vertex buffer
  6314. */
  6315. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6316. /**
  6317. * Gets a boolean indicating if the Buffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * @returns the stride in float32 units
  6335. * @deprecated Please use byteStride instead.
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6340. * @param data defines the data to store
  6341. */
  6342. create(data?: Nullable<DataArray>): void;
  6343. /** @hidden */
  6344. _rebuild(): void;
  6345. /**
  6346. * Update current buffer data
  6347. * @param data defines the data to store
  6348. */
  6349. update(data: DataArray): void;
  6350. /**
  6351. * Updates the data directly.
  6352. * @param data the new data
  6353. * @param offset the new offset
  6354. * @param vertexCount the vertex count (optional)
  6355. * @param useBytes set to true if the offset is in bytes
  6356. */
  6357. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6358. /**
  6359. * Release all resources
  6360. */
  6361. dispose(): void;
  6362. }
  6363. /**
  6364. * Specialized buffer used to store vertex data
  6365. */
  6366. export class VertexBuffer {
  6367. /** @hidden */
  6368. _buffer: Buffer;
  6369. private _kind;
  6370. private _size;
  6371. private _ownsBuffer;
  6372. private _instanced;
  6373. private _instanceDivisor;
  6374. /**
  6375. * The byte type.
  6376. */
  6377. static readonly BYTE: number;
  6378. /**
  6379. * The unsigned byte type.
  6380. */
  6381. static readonly UNSIGNED_BYTE: number;
  6382. /**
  6383. * The short type.
  6384. */
  6385. static readonly SHORT: number;
  6386. /**
  6387. * The unsigned short type.
  6388. */
  6389. static readonly UNSIGNED_SHORT: number;
  6390. /**
  6391. * The integer type.
  6392. */
  6393. static readonly INT: number;
  6394. /**
  6395. * The unsigned integer type.
  6396. */
  6397. static readonly UNSIGNED_INT: number;
  6398. /**
  6399. * The float type.
  6400. */
  6401. static readonly FLOAT: number;
  6402. /**
  6403. * Gets or sets the instance divisor when in instanced mode
  6404. */
  6405. get instanceDivisor(): number;
  6406. set instanceDivisor(value: number);
  6407. /**
  6408. * Gets the byte stride.
  6409. */
  6410. readonly byteStride: number;
  6411. /**
  6412. * Gets the byte offset.
  6413. */
  6414. readonly byteOffset: number;
  6415. /**
  6416. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6417. */
  6418. readonly normalized: boolean;
  6419. /**
  6420. * Gets the data type of each component in the array.
  6421. */
  6422. readonly type: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this vertex buffer
  6427. * @param kind the vertex buffer kind
  6428. * @param updatable whether the data is updatable
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param stride the stride (optional)
  6431. * @param instanced whether the buffer is instanced (optional)
  6432. * @param offset the offset of the data (optional)
  6433. * @param size the number of components (optional)
  6434. * @param type the type of the component (optional)
  6435. * @param normalized whether the data contains normalized data (optional)
  6436. * @param useBytes set to true if stride and offset are in bytes (optional)
  6437. * @param divisor defines the instance divisor to use (1 by default)
  6438. */
  6439. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6440. /** @hidden */
  6441. _rebuild(): void;
  6442. /**
  6443. * Returns the kind of the VertexBuffer (string)
  6444. * @returns a string
  6445. */
  6446. getKind(): string;
  6447. /**
  6448. * Gets a boolean indicating if the VertexBuffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Returns the offset as a multiple of the type byte length.
  6471. * @returns the offset in bytes
  6472. * @deprecated Please use byteOffset instead.
  6473. */
  6474. getOffset(): number;
  6475. /**
  6476. * Returns the number of components per vertex attribute (integer)
  6477. * @returns the size in float
  6478. */
  6479. getSize(): number;
  6480. /**
  6481. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6482. * @returns true if this buffer is instanced
  6483. */
  6484. getIsInstanced(): boolean;
  6485. /**
  6486. * Returns the instancing divisor, zero for non-instanced (integer).
  6487. * @returns a number
  6488. */
  6489. getInstanceDivisor(): number;
  6490. /**
  6491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6492. * @param data defines the data to store
  6493. */
  6494. create(data?: DataArray): void;
  6495. /**
  6496. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6497. * This function will create a new buffer if the current one is not updatable
  6498. * @param data defines the data to store
  6499. */
  6500. update(data: DataArray): void;
  6501. /**
  6502. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6503. * Returns the directly updated WebGLBuffer.
  6504. * @param data the new data
  6505. * @param offset the new offset
  6506. * @param useBytes set to true if the offset is in bytes
  6507. */
  6508. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6509. /**
  6510. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6511. */
  6512. dispose(): void;
  6513. /**
  6514. * Enumerates each value of this vertex buffer as numbers.
  6515. * @param count the number of values to enumerate
  6516. * @param callback the callback function called for each value
  6517. */
  6518. forEach(count: number, callback: (value: number, index: number) => void): void;
  6519. /**
  6520. * Positions
  6521. */
  6522. static readonly PositionKind: string;
  6523. /**
  6524. * Normals
  6525. */
  6526. static readonly NormalKind: string;
  6527. /**
  6528. * Tangents
  6529. */
  6530. static readonly TangentKind: string;
  6531. /**
  6532. * Texture coordinates
  6533. */
  6534. static readonly UVKind: string;
  6535. /**
  6536. * Texture coordinates 2
  6537. */
  6538. static readonly UV2Kind: string;
  6539. /**
  6540. * Texture coordinates 3
  6541. */
  6542. static readonly UV3Kind: string;
  6543. /**
  6544. * Texture coordinates 4
  6545. */
  6546. static readonly UV4Kind: string;
  6547. /**
  6548. * Texture coordinates 5
  6549. */
  6550. static readonly UV5Kind: string;
  6551. /**
  6552. * Texture coordinates 6
  6553. */
  6554. static readonly UV6Kind: string;
  6555. /**
  6556. * Colors
  6557. */
  6558. static readonly ColorKind: string;
  6559. /**
  6560. * Matrix indices (for bones)
  6561. */
  6562. static readonly MatricesIndicesKind: string;
  6563. /**
  6564. * Matrix weights (for bones)
  6565. */
  6566. static readonly MatricesWeightsKind: string;
  6567. /**
  6568. * Additional matrix indices (for bones)
  6569. */
  6570. static readonly MatricesIndicesExtraKind: string;
  6571. /**
  6572. * Additional matrix weights (for bones)
  6573. */
  6574. static readonly MatricesWeightsExtraKind: string;
  6575. /**
  6576. * Deduces the stride given a kind.
  6577. * @param kind The kind string to deduce
  6578. * @returns The deduced stride
  6579. */
  6580. static DeduceStride(kind: string): number;
  6581. /**
  6582. * Gets the byte length of the given type.
  6583. * @param type the type
  6584. * @returns the number of bytes
  6585. */
  6586. static GetTypeByteLength(type: number): number;
  6587. /**
  6588. * Enumerates each value of the given parameters as numbers.
  6589. * @param data the data to enumerate
  6590. * @param byteOffset the byte offset of the data
  6591. * @param byteStride the byte stride of the data
  6592. * @param componentCount the number of components per element
  6593. * @param componentType the type of the component
  6594. * @param count the number of values to enumerate
  6595. * @param normalized whether the data is normalized
  6596. * @param callback the callback function called for each value
  6597. */
  6598. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6599. private static _GetFloatValue;
  6600. }
  6601. }
  6602. declare module BABYLON {
  6603. /**
  6604. * @hidden
  6605. */
  6606. export class IntersectionInfo {
  6607. bu: Nullable<number>;
  6608. bv: Nullable<number>;
  6609. distance: number;
  6610. faceId: number;
  6611. subMeshId: number;
  6612. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6613. }
  6614. }
  6615. declare module BABYLON {
  6616. /**
  6617. * Represens a plane by the equation ax + by + cz + d = 0
  6618. */
  6619. export class Plane {
  6620. private static _TmpMatrix;
  6621. /**
  6622. * Normal of the plane (a,b,c)
  6623. */
  6624. normal: Vector3;
  6625. /**
  6626. * d component of the plane
  6627. */
  6628. d: number;
  6629. /**
  6630. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6631. * @param a a component of the plane
  6632. * @param b b component of the plane
  6633. * @param c c component of the plane
  6634. * @param d d component of the plane
  6635. */
  6636. constructor(a: number, b: number, c: number, d: number);
  6637. /**
  6638. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6639. */
  6640. asArray(): number[];
  6641. /**
  6642. * @returns a new plane copied from the current Plane.
  6643. */
  6644. clone(): Plane;
  6645. /**
  6646. * @returns the string "Plane".
  6647. */
  6648. getClassName(): string;
  6649. /**
  6650. * @returns the Plane hash code.
  6651. */
  6652. getHashCode(): number;
  6653. /**
  6654. * Normalize the current Plane in place.
  6655. * @returns the updated Plane.
  6656. */
  6657. normalize(): Plane;
  6658. /**
  6659. * Applies a transformation the plane and returns the result
  6660. * @param transformation the transformation matrix to be applied to the plane
  6661. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6662. */
  6663. transform(transformation: DeepImmutable<Matrix>): Plane;
  6664. /**
  6665. * Calcualtte the dot product between the point and the plane normal
  6666. * @param point point to calculate the dot product with
  6667. * @returns the dot product (float) of the point coordinates and the plane normal.
  6668. */
  6669. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6670. /**
  6671. * Updates the current Plane from the plane defined by the three given points.
  6672. * @param point1 one of the points used to contruct the plane
  6673. * @param point2 one of the points used to contruct the plane
  6674. * @param point3 one of the points used to contruct the plane
  6675. * @returns the updated Plane.
  6676. */
  6677. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6678. /**
  6679. * Checks if the plane is facing a given direction
  6680. * @param direction the direction to check if the plane is facing
  6681. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6682. * @returns True is the vector "direction" is the same side than the plane normal.
  6683. */
  6684. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6685. /**
  6686. * Calculates the distance to a point
  6687. * @param point point to calculate distance to
  6688. * @returns the signed distance (float) from the given point to the Plane.
  6689. */
  6690. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6691. /**
  6692. * Creates a plane from an array
  6693. * @param array the array to create a plane from
  6694. * @returns a new Plane from the given array.
  6695. */
  6696. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6697. /**
  6698. * Creates a plane from three points
  6699. * @param point1 point used to create the plane
  6700. * @param point2 point used to create the plane
  6701. * @param point3 point used to create the plane
  6702. * @returns a new Plane defined by the three given points.
  6703. */
  6704. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6705. /**
  6706. * Creates a plane from an origin point and a normal
  6707. * @param origin origin of the plane to be constructed
  6708. * @param normal normal of the plane to be constructed
  6709. * @returns a new Plane the normal vector to this plane at the given origin point.
  6710. * Note : the vector "normal" is updated because normalized.
  6711. */
  6712. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6713. /**
  6714. * Calculates the distance from a plane and a point
  6715. * @param origin origin of the plane to be constructed
  6716. * @param normal normal of the plane to be constructed
  6717. * @param point point to calculate distance to
  6718. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6719. */
  6720. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6721. }
  6722. }
  6723. declare module BABYLON {
  6724. /**
  6725. * Class used to store bounding sphere information
  6726. */
  6727. export class BoundingSphere {
  6728. /**
  6729. * Gets the center of the bounding sphere in local space
  6730. */
  6731. readonly center: Vector3;
  6732. /**
  6733. * Radius of the bounding sphere in local space
  6734. */
  6735. radius: number;
  6736. /**
  6737. * Gets the center of the bounding sphere in world space
  6738. */
  6739. readonly centerWorld: Vector3;
  6740. /**
  6741. * Radius of the bounding sphere in world space
  6742. */
  6743. radiusWorld: number;
  6744. /**
  6745. * Gets the minimum vector in local space
  6746. */
  6747. readonly minimum: Vector3;
  6748. /**
  6749. * Gets the maximum vector in local space
  6750. */
  6751. readonly maximum: Vector3;
  6752. private _worldMatrix;
  6753. private static readonly TmpVector3;
  6754. /**
  6755. * Creates a new bounding sphere
  6756. * @param min defines the minimum vector (in local space)
  6757. * @param max defines the maximum vector (in local space)
  6758. * @param worldMatrix defines the new world matrix
  6759. */
  6760. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6761. /**
  6762. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6763. * @param min defines the new minimum vector (in local space)
  6764. * @param max defines the new maximum vector (in local space)
  6765. * @param worldMatrix defines the new world matrix
  6766. */
  6767. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6768. /**
  6769. * Scale the current bounding sphere by applying a scale factor
  6770. * @param factor defines the scale factor to apply
  6771. * @returns the current bounding box
  6772. */
  6773. scale(factor: number): BoundingSphere;
  6774. /**
  6775. * Gets the world matrix of the bounding box
  6776. * @returns a matrix
  6777. */
  6778. getWorldMatrix(): DeepImmutable<Matrix>;
  6779. /** @hidden */
  6780. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6781. /**
  6782. * Tests if the bounding sphere is intersecting the frustum planes
  6783. * @param frustumPlanes defines the frustum planes to test
  6784. * @returns true if there is an intersection
  6785. */
  6786. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6787. /**
  6788. * Tests if the bounding sphere center is in between the frustum planes.
  6789. * Used for optimistic fast inclusion.
  6790. * @param frustumPlanes defines the frustum planes to test
  6791. * @returns true if the sphere center is in between the frustum planes
  6792. */
  6793. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6794. /**
  6795. * Tests if a point is inside the bounding sphere
  6796. * @param point defines the point to test
  6797. * @returns true if the point is inside the bounding sphere
  6798. */
  6799. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6800. /**
  6801. * Checks if two sphere intersct
  6802. * @param sphere0 sphere 0
  6803. * @param sphere1 sphere 1
  6804. * @returns true if the speres intersect
  6805. */
  6806. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6807. }
  6808. }
  6809. declare module BABYLON {
  6810. /**
  6811. * Class used to store bounding box information
  6812. */
  6813. export class BoundingBox implements ICullable {
  6814. /**
  6815. * Gets the 8 vectors representing the bounding box in local space
  6816. */
  6817. readonly vectors: Vector3[];
  6818. /**
  6819. * Gets the center of the bounding box in local space
  6820. */
  6821. readonly center: Vector3;
  6822. /**
  6823. * Gets the center of the bounding box in world space
  6824. */
  6825. readonly centerWorld: Vector3;
  6826. /**
  6827. * Gets the extend size in local space
  6828. */
  6829. readonly extendSize: Vector3;
  6830. /**
  6831. * Gets the extend size in world space
  6832. */
  6833. readonly extendSizeWorld: Vector3;
  6834. /**
  6835. * Gets the OBB (object bounding box) directions
  6836. */
  6837. readonly directions: Vector3[];
  6838. /**
  6839. * Gets the 8 vectors representing the bounding box in world space
  6840. */
  6841. readonly vectorsWorld: Vector3[];
  6842. /**
  6843. * Gets the minimum vector in world space
  6844. */
  6845. readonly minimumWorld: Vector3;
  6846. /**
  6847. * Gets the maximum vector in world space
  6848. */
  6849. readonly maximumWorld: Vector3;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * @hidden
  6862. */
  6863. _tag: number;
  6864. /**
  6865. * Creates a new bounding box
  6866. * @param min defines the minimum vector (in local space)
  6867. * @param max defines the maximum vector (in local space)
  6868. * @param worldMatrix defines the new world matrix
  6869. */
  6870. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6871. /**
  6872. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6873. * @param min defines the new minimum vector (in local space)
  6874. * @param max defines the new maximum vector (in local space)
  6875. * @param worldMatrix defines the new world matrix
  6876. */
  6877. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6878. /**
  6879. * Scale the current bounding box by applying a scale factor
  6880. * @param factor defines the scale factor to apply
  6881. * @returns the current bounding box
  6882. */
  6883. scale(factor: number): BoundingBox;
  6884. /**
  6885. * Gets the world matrix of the bounding box
  6886. * @returns a matrix
  6887. */
  6888. getWorldMatrix(): DeepImmutable<Matrix>;
  6889. /** @hidden */
  6890. _update(world: DeepImmutable<Matrix>): void;
  6891. /**
  6892. * Tests if the bounding box is intersecting the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an intersection
  6895. */
  6896. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if the bounding box is entirely inside the frustum planes
  6899. * @param frustumPlanes defines the frustum planes to test
  6900. * @returns true if there is an inclusion
  6901. */
  6902. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6903. /**
  6904. * Tests if a point is inside the bounding box
  6905. * @param point defines the point to test
  6906. * @returns true if the point is inside the bounding box
  6907. */
  6908. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a bounding sphere
  6911. * @param sphere defines the sphere to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6915. /**
  6916. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6917. * @param min defines the min vector to use
  6918. * @param max defines the max vector to use
  6919. * @returns true if there is an intersection
  6920. */
  6921. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6922. /**
  6923. * Tests if two bounding boxes are intersections
  6924. * @param box0 defines the first box to test
  6925. * @param box1 defines the second box to test
  6926. * @returns true if there is an intersection
  6927. */
  6928. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6929. /**
  6930. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6931. * @param minPoint defines the minimum vector of the bounding box
  6932. * @param maxPoint defines the maximum vector of the bounding box
  6933. * @param sphereCenter defines the sphere center
  6934. * @param sphereRadius defines the sphere radius
  6935. * @returns true if there is an intersection
  6936. */
  6937. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6938. /**
  6939. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6940. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @return true if there is an inclusion
  6943. */
  6944. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6947. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @return true if there is an intersection
  6950. */
  6951. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. }
  6953. }
  6954. declare module BABYLON {
  6955. /** @hidden */
  6956. export class Collider {
  6957. /** Define if a collision was found */
  6958. collisionFound: boolean;
  6959. /**
  6960. * Define last intersection point in local space
  6961. */
  6962. intersectionPoint: Vector3;
  6963. /**
  6964. * Define last collided mesh
  6965. */
  6966. collidedMesh: Nullable<AbstractMesh>;
  6967. private _collisionPoint;
  6968. private _planeIntersectionPoint;
  6969. private _tempVector;
  6970. private _tempVector2;
  6971. private _tempVector3;
  6972. private _tempVector4;
  6973. private _edge;
  6974. private _baseToVertex;
  6975. private _destinationPoint;
  6976. private _slidePlaneNormal;
  6977. private _displacementVector;
  6978. /** @hidden */
  6979. _radius: Vector3;
  6980. /** @hidden */
  6981. _retry: number;
  6982. private _velocity;
  6983. private _basePoint;
  6984. private _epsilon;
  6985. /** @hidden */
  6986. _velocityWorldLength: number;
  6987. /** @hidden */
  6988. _basePointWorld: Vector3;
  6989. private _velocityWorld;
  6990. private _normalizedVelocity;
  6991. /** @hidden */
  6992. _initialVelocity: Vector3;
  6993. /** @hidden */
  6994. _initialPosition: Vector3;
  6995. private _nearestDistance;
  6996. private _collisionMask;
  6997. get collisionMask(): number;
  6998. set collisionMask(mask: number);
  6999. /**
  7000. * Gets the plane normal used to compute the sliding response (in local space)
  7001. */
  7002. get slidePlaneNormal(): Vector3;
  7003. /** @hidden */
  7004. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7005. /** @hidden */
  7006. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7007. /** @hidden */
  7008. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7009. /** @hidden */
  7010. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7011. /** @hidden */
  7012. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7013. /** @hidden */
  7014. _getResponse(pos: Vector3, vel: Vector3): void;
  7015. }
  7016. }
  7017. declare module BABYLON {
  7018. /**
  7019. * Interface for cullable objects
  7020. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7021. */
  7022. export interface ICullable {
  7023. /**
  7024. * Checks if the object or part of the object is in the frustum
  7025. * @param frustumPlanes Camera near/planes
  7026. * @returns true if the object is in frustum otherwise false
  7027. */
  7028. isInFrustum(frustumPlanes: Plane[]): boolean;
  7029. /**
  7030. * Checks if a cullable object (mesh...) is in the camera frustum
  7031. * Unlike isInFrustum this cheks the full bounding box
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7036. }
  7037. /**
  7038. * Info for a bounding data of a mesh
  7039. */
  7040. export class BoundingInfo implements ICullable {
  7041. /**
  7042. * Bounding box for the mesh
  7043. */
  7044. readonly boundingBox: BoundingBox;
  7045. /**
  7046. * Bounding sphere for the mesh
  7047. */
  7048. readonly boundingSphere: BoundingSphere;
  7049. private _isLocked;
  7050. private static readonly TmpVector3;
  7051. /**
  7052. * Constructs bounding info
  7053. * @param minimum min vector of the bounding box/sphere
  7054. * @param maximum max vector of the bounding box/sphere
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * min vector of the bounding box/sphere
  7067. */
  7068. get minimum(): Vector3;
  7069. /**
  7070. * max vector of the bounding box/sphere
  7071. */
  7072. get maximum(): Vector3;
  7073. /**
  7074. * If the info is locked and won't be updated to avoid perf overhead
  7075. */
  7076. get isLocked(): boolean;
  7077. set isLocked(value: boolean);
  7078. /**
  7079. * Updates the bounding sphere and box
  7080. * @param world world matrix to be used to update
  7081. */
  7082. update(world: DeepImmutable<Matrix>): void;
  7083. /**
  7084. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7085. * @param center New center of the bounding info
  7086. * @param extend New extend of the bounding info
  7087. * @returns the current bounding info
  7088. */
  7089. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7090. /**
  7091. * Scale the current bounding info by applying a scale factor
  7092. * @param factor defines the scale factor to apply
  7093. * @returns the current bounding info
  7094. */
  7095. scale(factor: number): BoundingInfo;
  7096. /**
  7097. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7098. * @param frustumPlanes defines the frustum to test
  7099. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7100. * @returns true if the bounding info is in the frustum planes
  7101. */
  7102. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7103. /**
  7104. * Gets the world distance between the min and max points of the bounding box
  7105. */
  7106. get diagonalLength(): number;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. /** @hidden */
  7115. _checkCollision(collider: Collider): boolean;
  7116. /**
  7117. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7118. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7119. * @param point the point to check intersection with
  7120. * @returns if the point intersects
  7121. */
  7122. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7123. /**
  7124. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7125. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7126. * @param boundingInfo the bounding info to check intersection with
  7127. * @param precise if the intersection should be done using OBB
  7128. * @returns if the bounding info intersects
  7129. */
  7130. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7131. }
  7132. }
  7133. declare module BABYLON {
  7134. /**
  7135. * Extracts minimum and maximum values from a list of indexed positions
  7136. * @param positions defines the positions to use
  7137. * @param indices defines the indices to the positions
  7138. * @param indexStart defines the start index
  7139. * @param indexCount defines the end index
  7140. * @param bias defines bias value to add to the result
  7141. * @return minimum and maximum values
  7142. */
  7143. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7144. minimum: Vector3;
  7145. maximum: Vector3;
  7146. };
  7147. /**
  7148. * Extracts minimum and maximum values from a list of positions
  7149. * @param positions defines the positions to use
  7150. * @param start defines the start index in the positions array
  7151. * @param count defines the number of positions to handle
  7152. * @param bias defines bias value to add to the result
  7153. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7154. * @return minimum and maximum values
  7155. */
  7156. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7157. minimum: Vector3;
  7158. maximum: Vector3;
  7159. };
  7160. }
  7161. declare module BABYLON {
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. get underlyingResource(): any;
  7167. }
  7168. }
  7169. declare module BABYLON {
  7170. /** @hidden */
  7171. export class WebGLPipelineContext implements IPipelineContext {
  7172. engine: ThinEngine;
  7173. program: Nullable<WebGLProgram>;
  7174. context?: WebGLRenderingContext;
  7175. vertexShader?: WebGLShader;
  7176. fragmentShader?: WebGLShader;
  7177. isParallelCompiled: boolean;
  7178. onCompiled?: () => void;
  7179. transformFeedback?: WebGLTransformFeedback | null;
  7180. vertexCompilationError: Nullable<string>;
  7181. fragmentCompilationError: Nullable<string>;
  7182. programLinkError: Nullable<string>;
  7183. programValidationError: Nullable<string>;
  7184. get isAsync(): boolean;
  7185. get isReady(): boolean;
  7186. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7187. }
  7188. }
  7189. declare module BABYLON {
  7190. interface ThinEngine {
  7191. /**
  7192. * Create an uniform buffer
  7193. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7194. * @param elements defines the content of the uniform buffer
  7195. * @returns the webGL uniform buffer
  7196. */
  7197. createUniformBuffer(elements: FloatArray): DataBuffer;
  7198. /**
  7199. * Create a dynamic uniform buffer
  7200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7201. * @param elements defines the content of the uniform buffer
  7202. * @returns the webGL uniform buffer
  7203. */
  7204. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7205. /**
  7206. * Update an existing uniform buffer
  7207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7208. * @param uniformBuffer defines the target uniform buffer
  7209. * @param elements defines the content to update
  7210. * @param offset defines the offset in the uniform buffer where update should start
  7211. * @param count defines the size of the data to update
  7212. */
  7213. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7214. /**
  7215. * Bind an uniform buffer to the current webGL context
  7216. * @param buffer defines the buffer to bind
  7217. */
  7218. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7219. /**
  7220. * Bind a buffer to the current webGL context at a given location
  7221. * @param buffer defines the buffer to bind
  7222. * @param location defines the index where to bind the buffer
  7223. */
  7224. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7225. /**
  7226. * Bind a specific block at a given index in a specific shader program
  7227. * @param pipelineContext defines the pipeline context to use
  7228. * @param blockName defines the block name
  7229. * @param index defines the index where to bind the block
  7230. */
  7231. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7232. }
  7233. }
  7234. declare module BABYLON {
  7235. /**
  7236. * Uniform buffer objects.
  7237. *
  7238. * Handles blocks of uniform on the GPU.
  7239. *
  7240. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7241. *
  7242. * For more information, please refer to :
  7243. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7244. */
  7245. export class UniformBuffer {
  7246. private _engine;
  7247. private _buffer;
  7248. private _data;
  7249. private _bufferData;
  7250. private _dynamic?;
  7251. private _uniformLocations;
  7252. private _uniformSizes;
  7253. private _uniformLocationPointer;
  7254. private _needSync;
  7255. private _noUBO;
  7256. private _currentEffect;
  7257. /** @hidden */
  7258. _alreadyBound: boolean;
  7259. private static _MAX_UNIFORM_SIZE;
  7260. private static _tempBuffer;
  7261. /**
  7262. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7263. * This is dynamic to allow compat with webgl 1 and 2.
  7264. * You will need to pass the name of the uniform as well as the value.
  7265. */
  7266. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7267. /**
  7268. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7269. * This is dynamic to allow compat with webgl 1 and 2.
  7270. * You will need to pass the name of the uniform as well as the value.
  7271. */
  7272. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7273. /**
  7274. * Lambda to Update a single float in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateFloat: (name: string, x: number) => void;
  7279. /**
  7280. * Lambda to Update a vec2 of float in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7285. /**
  7286. * Lambda to Update a vec3 of float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7291. /**
  7292. * Lambda to Update a vec4 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateMatrix: (name: string, mat: Matrix) => void;
  7303. /**
  7304. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateVector3: (name: string, vector: Vector3) => void;
  7309. /**
  7310. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateVector4: (name: string, vector: Vector4) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7327. /**
  7328. * Instantiates a new Uniform buffer objects.
  7329. *
  7330. * Handles blocks of uniform on the GPU.
  7331. *
  7332. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7333. *
  7334. * For more information, please refer to :
  7335. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7336. * @param engine Define the engine the buffer is associated with
  7337. * @param data Define the data contained in the buffer
  7338. * @param dynamic Define if the buffer is updatable
  7339. */
  7340. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7341. /**
  7342. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7343. * or just falling back on setUniformXXX calls.
  7344. */
  7345. get useUbo(): boolean;
  7346. /**
  7347. * Indicates if the WebGL underlying uniform buffer is in sync
  7348. * with the javascript cache data.
  7349. */
  7350. get isSync(): boolean;
  7351. /**
  7352. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7353. * Also, a dynamic UniformBuffer will disable cache verification and always
  7354. * update the underlying WebGL uniform buffer to the GPU.
  7355. * @returns if Dynamic, otherwise false
  7356. */
  7357. isDynamic(): boolean;
  7358. /**
  7359. * The data cache on JS side.
  7360. * @returns the underlying data as a float array
  7361. */
  7362. getData(): Float32Array;
  7363. /**
  7364. * The underlying WebGL Uniform buffer.
  7365. * @returns the webgl buffer
  7366. */
  7367. getBuffer(): Nullable<DataBuffer>;
  7368. /**
  7369. * std140 layout specifies how to align data within an UBO structure.
  7370. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7371. * for specs.
  7372. */
  7373. private _fillAlignment;
  7374. /**
  7375. * Adds an uniform in the buffer.
  7376. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7377. * for the layout to be correct !
  7378. * @param name Name of the uniform, as used in the uniform block in the shader.
  7379. * @param size Data size, or data directly.
  7380. */
  7381. addUniform(name: string, size: number | number[]): void;
  7382. /**
  7383. * Adds a Matrix 4x4 to the uniform buffer.
  7384. * @param name Name of the uniform, as used in the uniform block in the shader.
  7385. * @param mat A 4x4 matrix.
  7386. */
  7387. addMatrix(name: string, mat: Matrix): void;
  7388. /**
  7389. * Adds a vec2 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param x Define the x component value of the vec2
  7392. * @param y Define the y component value of the vec2
  7393. */
  7394. addFloat2(name: string, x: number, y: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param x Define the x component value of the vec3
  7399. * @param y Define the y component value of the vec3
  7400. * @param z Define the z component value of the vec3
  7401. */
  7402. addFloat3(name: string, x: number, y: number, z: number): void;
  7403. /**
  7404. * Adds a vec3 to the uniform buffer.
  7405. * @param name Name of the uniform, as used in the uniform block in the shader.
  7406. * @param color Define the vec3 from a Color
  7407. */
  7408. addColor3(name: string, color: Color3): void;
  7409. /**
  7410. * Adds a vec4 to the uniform buffer.
  7411. * @param name Name of the uniform, as used in the uniform block in the shader.
  7412. * @param color Define the rgb components from a Color
  7413. * @param alpha Define the a component of the vec4
  7414. */
  7415. addColor4(name: string, color: Color3, alpha: number): void;
  7416. /**
  7417. * Adds a vec3 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. * @param vector Define the vec3 components from a Vector
  7420. */
  7421. addVector3(name: string, vector: Vector3): void;
  7422. /**
  7423. * Adds a Matrix 3x3 to the uniform buffer.
  7424. * @param name Name of the uniform, as used in the uniform block in the shader.
  7425. */
  7426. addMatrix3x3(name: string): void;
  7427. /**
  7428. * Adds a Matrix 2x2 to the uniform buffer.
  7429. * @param name Name of the uniform, as used in the uniform block in the shader.
  7430. */
  7431. addMatrix2x2(name: string): void;
  7432. /**
  7433. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7434. */
  7435. create(): void;
  7436. /** @hidden */
  7437. _rebuild(): void;
  7438. /**
  7439. * Updates the WebGL Uniform Buffer on the GPU.
  7440. * If the `dynamic` flag is set to true, no cache comparison is done.
  7441. * Otherwise, the buffer will be updated only if the cache differs.
  7442. */
  7443. update(): void;
  7444. /**
  7445. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7446. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7447. * @param data Define the flattened data
  7448. * @param size Define the size of the data.
  7449. */
  7450. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7451. private _valueCache;
  7452. private _cacheMatrix;
  7453. private _updateMatrix3x3ForUniform;
  7454. private _updateMatrix3x3ForEffect;
  7455. private _updateMatrix2x2ForEffect;
  7456. private _updateMatrix2x2ForUniform;
  7457. private _updateFloatForEffect;
  7458. private _updateFloatForUniform;
  7459. private _updateFloat2ForEffect;
  7460. private _updateFloat2ForUniform;
  7461. private _updateFloat3ForEffect;
  7462. private _updateFloat3ForUniform;
  7463. private _updateFloat4ForEffect;
  7464. private _updateFloat4ForUniform;
  7465. private _updateMatrixForEffect;
  7466. private _updateMatrixForUniform;
  7467. private _updateVector3ForEffect;
  7468. private _updateVector3ForUniform;
  7469. private _updateVector4ForEffect;
  7470. private _updateVector4ForUniform;
  7471. private _updateColor3ForEffect;
  7472. private _updateColor3ForUniform;
  7473. private _updateColor4ForEffect;
  7474. private _updateColor4ForUniform;
  7475. /**
  7476. * Sets a sampler uniform on the effect.
  7477. * @param name Define the name of the sampler.
  7478. * @param texture Define the texture to set in the sampler
  7479. */
  7480. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7481. /**
  7482. * Directly updates the value of the uniform in the cache AND on the GPU.
  7483. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7484. * @param data Define the flattened data
  7485. */
  7486. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7487. /**
  7488. * Binds this uniform buffer to an effect.
  7489. * @param effect Define the effect to bind the buffer to
  7490. * @param name Name of the uniform block in the shader.
  7491. */
  7492. bindToEffect(effect: Effect, name: string): void;
  7493. /**
  7494. * Disposes the uniform buffer.
  7495. */
  7496. dispose(): void;
  7497. }
  7498. }
  7499. declare module BABYLON {
  7500. /**
  7501. * Enum that determines the text-wrapping mode to use.
  7502. */
  7503. export enum InspectableType {
  7504. /**
  7505. * Checkbox for booleans
  7506. */
  7507. Checkbox = 0,
  7508. /**
  7509. * Sliders for numbers
  7510. */
  7511. Slider = 1,
  7512. /**
  7513. * Vector3
  7514. */
  7515. Vector3 = 2,
  7516. /**
  7517. * Quaternions
  7518. */
  7519. Quaternion = 3,
  7520. /**
  7521. * Color3
  7522. */
  7523. Color3 = 4,
  7524. /**
  7525. * String
  7526. */
  7527. String = 5
  7528. }
  7529. /**
  7530. * Interface used to define custom inspectable properties.
  7531. * This interface is used by the inspector to display custom property grids
  7532. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7533. */
  7534. export interface IInspectable {
  7535. /**
  7536. * Gets the label to display
  7537. */
  7538. label: string;
  7539. /**
  7540. * Gets the name of the property to edit
  7541. */
  7542. propertyName: string;
  7543. /**
  7544. * Gets the type of the editor to use
  7545. */
  7546. type: InspectableType;
  7547. /**
  7548. * Gets the minimum value of the property when using in "slider" mode
  7549. */
  7550. min?: number;
  7551. /**
  7552. * Gets the maximum value of the property when using in "slider" mode
  7553. */
  7554. max?: number;
  7555. /**
  7556. * Gets the setp to use when using in "slider" mode
  7557. */
  7558. step?: number;
  7559. }
  7560. }
  7561. declare module BABYLON {
  7562. /**
  7563. * Class used to provide helper for timing
  7564. */
  7565. export class TimingTools {
  7566. /**
  7567. * Polyfill for setImmediate
  7568. * @param action defines the action to execute after the current execution block
  7569. */
  7570. static SetImmediate(action: () => void): void;
  7571. }
  7572. }
  7573. declare module BABYLON {
  7574. /**
  7575. * Class used to enable instatition of objects by class name
  7576. */
  7577. export class InstantiationTools {
  7578. /**
  7579. * Use this object to register external classes like custom textures or material
  7580. * to allow the laoders to instantiate them
  7581. */
  7582. static RegisteredExternalClasses: {
  7583. [key: string]: Object;
  7584. };
  7585. /**
  7586. * Tries to instantiate a new object from a given class name
  7587. * @param className defines the class name to instantiate
  7588. * @returns the new object or null if the system was not able to do the instantiation
  7589. */
  7590. static Instantiate(className: string): any;
  7591. }
  7592. }
  7593. declare module BABYLON {
  7594. /**
  7595. * Define options used to create a depth texture
  7596. */
  7597. export class DepthTextureCreationOptions {
  7598. /** Specifies whether or not a stencil should be allocated in the texture */
  7599. generateStencil?: boolean;
  7600. /** Specifies whether or not bilinear filtering is enable on the texture */
  7601. bilinearFiltering?: boolean;
  7602. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7603. comparisonFunction?: number;
  7604. /** Specifies if the created texture is a cube texture */
  7605. isCube?: boolean;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. interface ThinEngine {
  7610. /**
  7611. * Creates a depth stencil cube texture.
  7612. * This is only available in WebGL 2.
  7613. * @param size The size of face edge in the cube texture.
  7614. * @param options The options defining the cube texture.
  7615. * @returns The cube texture
  7616. */
  7617. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7618. /**
  7619. * Creates a cube texture
  7620. * @param rootUrl defines the url where the files to load is located
  7621. * @param scene defines the current scene
  7622. * @param files defines the list of files to load (1 per face)
  7623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7624. * @param onLoad defines an optional callback raised when the texture is loaded
  7625. * @param onError defines an optional callback raised if there is an issue to load the texture
  7626. * @param format defines the format of the data
  7627. * @param forcedExtension defines the extension to use to pick the right loader
  7628. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7629. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7630. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7631. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7632. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. 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;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. 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;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. set boundingBoxSize(value: Vector3);
  7703. /**
  7704. * Returns the bounding box size
  7705. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7706. */
  7707. get boundingBoxSize(): Vector3;
  7708. protected _rotationY: number;
  7709. /**
  7710. * Sets texture matrix rotation angle around Y axis in radians.
  7711. */
  7712. set rotationY(value: number);
  7713. /**
  7714. * Gets texture matrix rotation angle around Y axis radians.
  7715. */
  7716. get rotationY(): number;
  7717. /**
  7718. * Are mip maps generated for this texture or not.
  7719. */
  7720. get noMipmap(): boolean;
  7721. private _noMipmap;
  7722. private _files;
  7723. protected _forcedExtension: Nullable<string>;
  7724. private _extensions;
  7725. private _textureMatrix;
  7726. private _format;
  7727. private _createPolynomials;
  7728. /** @hidden */
  7729. _prefiltered: boolean;
  7730. /**
  7731. * Creates a cube texture from an array of image urls
  7732. * @param files defines an array of image urls
  7733. * @param scene defines the hosting scene
  7734. * @param noMipmap specifies if mip maps are not used
  7735. * @returns a cube texture
  7736. */
  7737. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7738. /**
  7739. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7740. * @param url defines the url of the prefiltered texture
  7741. * @param scene defines the scene the texture is attached to
  7742. * @param forcedExtension defines the extension of the file if different from the url
  7743. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7744. * @return the prefiltered texture
  7745. */
  7746. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7747. /**
  7748. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7749. * as prefiltered data.
  7750. * @param rootUrl defines the url of the texture or the root name of the six images
  7751. * @param scene defines the scene the texture is attached to
  7752. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7753. * @param noMipmap defines if mipmaps should be created or not
  7754. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7755. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7756. * @param onError defines a callback triggered in case of error during load
  7757. * @param format defines the internal format to use for the texture once loaded
  7758. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7759. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7760. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7761. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7762. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7763. * @return the cube texture
  7764. */
  7765. 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);
  7766. /**
  7767. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7768. */
  7769. get isPrefiltered(): boolean;
  7770. /**
  7771. * Get the current class name of the texture useful for serialization or dynamic coding.
  7772. * @returns "CubeTexture"
  7773. */
  7774. getClassName(): string;
  7775. /**
  7776. * Update the url (and optional buffer) of this texture if url was null during construction.
  7777. * @param url the url of the texture
  7778. * @param forcedExtension defines the extension to use
  7779. * @param onLoad callback called when the texture is loaded (defaults to null)
  7780. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7781. */
  7782. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7783. /**
  7784. * Delays loading of the cube texture
  7785. * @param forcedExtension defines the extension to use
  7786. */
  7787. delayLoad(forcedExtension?: string): void;
  7788. /**
  7789. * Returns the reflection texture matrix
  7790. * @returns the reflection texture matrix
  7791. */
  7792. getReflectionTextureMatrix(): Matrix;
  7793. /**
  7794. * Sets the reflection texture matrix
  7795. * @param value Reflection texture matrix
  7796. */
  7797. setReflectionTextureMatrix(value: Matrix): void;
  7798. /**
  7799. * Parses text to create a cube texture
  7800. * @param parsedTexture define the serialized text to read from
  7801. * @param scene defines the hosting scene
  7802. * @param rootUrl defines the root url of the cube texture
  7803. * @returns a cube texture
  7804. */
  7805. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7806. /**
  7807. * Makes a clone, or deep copy, of the cube texture
  7808. * @returns a new cube texture
  7809. */
  7810. clone(): CubeTexture;
  7811. }
  7812. }
  7813. declare module BABYLON {
  7814. /**
  7815. * Manages the defines for the Material
  7816. */
  7817. export class MaterialDefines {
  7818. /** @hidden */
  7819. protected _keys: string[];
  7820. private _isDirty;
  7821. /** @hidden */
  7822. _renderId: number;
  7823. /** @hidden */
  7824. _areLightsDirty: boolean;
  7825. /** @hidden */
  7826. _areLightsDisposed: boolean;
  7827. /** @hidden */
  7828. _areAttributesDirty: boolean;
  7829. /** @hidden */
  7830. _areTexturesDirty: boolean;
  7831. /** @hidden */
  7832. _areFresnelDirty: boolean;
  7833. /** @hidden */
  7834. _areMiscDirty: boolean;
  7835. /** @hidden */
  7836. _areImageProcessingDirty: boolean;
  7837. /** @hidden */
  7838. _normals: boolean;
  7839. /** @hidden */
  7840. _uvs: boolean;
  7841. /** @hidden */
  7842. _needNormals: boolean;
  7843. /** @hidden */
  7844. _needUVs: boolean;
  7845. [id: string]: any;
  7846. /**
  7847. * Specifies if the material needs to be re-calculated
  7848. */
  7849. get isDirty(): boolean;
  7850. /**
  7851. * Marks the material to indicate that it has been re-calculated
  7852. */
  7853. markAsProcessed(): void;
  7854. /**
  7855. * Marks the material to indicate that it needs to be re-calculated
  7856. */
  7857. markAsUnprocessed(): void;
  7858. /**
  7859. * Marks the material to indicate all of its defines need to be re-calculated
  7860. */
  7861. markAllAsDirty(): void;
  7862. /**
  7863. * Marks the material to indicate that image processing needs to be re-calculated
  7864. */
  7865. markAsImageProcessingDirty(): void;
  7866. /**
  7867. * Marks the material to indicate the lights need to be re-calculated
  7868. * @param disposed Defines whether the light is dirty due to dispose or not
  7869. */
  7870. markAsLightDirty(disposed?: boolean): void;
  7871. /**
  7872. * Marks the attribute state as changed
  7873. */
  7874. markAsAttributesDirty(): void;
  7875. /**
  7876. * Marks the texture state as changed
  7877. */
  7878. markAsTexturesDirty(): void;
  7879. /**
  7880. * Marks the fresnel state as changed
  7881. */
  7882. markAsFresnelDirty(): void;
  7883. /**
  7884. * Marks the misc state as changed
  7885. */
  7886. markAsMiscDirty(): void;
  7887. /**
  7888. * Rebuilds the material defines
  7889. */
  7890. rebuild(): void;
  7891. /**
  7892. * Specifies if two material defines are equal
  7893. * @param other - A material define instance to compare to
  7894. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7895. */
  7896. isEqual(other: MaterialDefines): boolean;
  7897. /**
  7898. * Clones this instance's defines to another instance
  7899. * @param other - material defines to clone values to
  7900. */
  7901. cloneTo(other: MaterialDefines): void;
  7902. /**
  7903. * Resets the material define values
  7904. */
  7905. reset(): void;
  7906. /**
  7907. * Converts the material define values to a string
  7908. * @returns - String of material define information
  7909. */
  7910. toString(): string;
  7911. }
  7912. }
  7913. declare module BABYLON {
  7914. /**
  7915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7917. * 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;
  7918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7919. */
  7920. export class ColorCurves {
  7921. private _dirty;
  7922. private _tempColor;
  7923. private _globalCurve;
  7924. private _highlightsCurve;
  7925. private _midtonesCurve;
  7926. private _shadowsCurve;
  7927. private _positiveCurve;
  7928. private _negativeCurve;
  7929. private _globalHue;
  7930. private _globalDensity;
  7931. private _globalSaturation;
  7932. private _globalExposure;
  7933. /**
  7934. * Gets the global Hue value.
  7935. * 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).
  7936. */
  7937. get globalHue(): number;
  7938. /**
  7939. * Sets the global Hue value.
  7940. * 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).
  7941. */
  7942. set globalHue(value: number);
  7943. /**
  7944. * Gets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. get globalDensity(): number;
  7949. /**
  7950. * Sets the global Density value.
  7951. * 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.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. set globalDensity(value: number);
  7955. /**
  7956. * Gets the global Saturation value.
  7957. * 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.
  7958. */
  7959. get globalSaturation(): number;
  7960. /**
  7961. * Sets the global Saturation value.
  7962. * 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.
  7963. */
  7964. set globalSaturation(value: number);
  7965. /**
  7966. * Gets the global Exposure value.
  7967. * 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.
  7968. */
  7969. get globalExposure(): number;
  7970. /**
  7971. * Sets the global Exposure value.
  7972. * 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.
  7973. */
  7974. set globalExposure(value: number);
  7975. private _highlightsHue;
  7976. private _highlightsDensity;
  7977. private _highlightsSaturation;
  7978. private _highlightsExposure;
  7979. /**
  7980. * Gets the highlights Hue value.
  7981. * 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).
  7982. */
  7983. get highlightsHue(): number;
  7984. /**
  7985. * Sets the highlights Hue value.
  7986. * 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).
  7987. */
  7988. set highlightsHue(value: number);
  7989. /**
  7990. * Gets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. get highlightsDensity(): number;
  7995. /**
  7996. * Sets the highlights Density value.
  7997. * 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.
  7998. * Values less than zero provide a filter of opposite hue.
  7999. */
  8000. set highlightsDensity(value: number);
  8001. /**
  8002. * Gets the highlights Saturation value.
  8003. * 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.
  8004. */
  8005. get highlightsSaturation(): number;
  8006. /**
  8007. * Sets the highlights Saturation value.
  8008. * 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.
  8009. */
  8010. set highlightsSaturation(value: number);
  8011. /**
  8012. * Gets the highlights Exposure value.
  8013. * 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.
  8014. */
  8015. get highlightsExposure(): number;
  8016. /**
  8017. * Sets the highlights Exposure value.
  8018. * 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.
  8019. */
  8020. set highlightsExposure(value: number);
  8021. private _midtonesHue;
  8022. private _midtonesDensity;
  8023. private _midtonesSaturation;
  8024. private _midtonesExposure;
  8025. /**
  8026. * Gets the midtones Hue value.
  8027. * 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).
  8028. */
  8029. get midtonesHue(): number;
  8030. /**
  8031. * Sets the midtones Hue value.
  8032. * 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).
  8033. */
  8034. set midtonesHue(value: number);
  8035. /**
  8036. * Gets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. get midtonesDensity(): number;
  8041. /**
  8042. * Sets the midtones Density value.
  8043. * 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.
  8044. * Values less than zero provide a filter of opposite hue.
  8045. */
  8046. set midtonesDensity(value: number);
  8047. /**
  8048. * Gets the midtones Saturation value.
  8049. * 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.
  8050. */
  8051. get midtonesSaturation(): number;
  8052. /**
  8053. * Sets the midtones Saturation value.
  8054. * 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.
  8055. */
  8056. set midtonesSaturation(value: number);
  8057. /**
  8058. * Gets the midtones Exposure value.
  8059. * 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.
  8060. */
  8061. get midtonesExposure(): number;
  8062. /**
  8063. * Sets the midtones Exposure value.
  8064. * 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.
  8065. */
  8066. set midtonesExposure(value: number);
  8067. private _shadowsHue;
  8068. private _shadowsDensity;
  8069. private _shadowsSaturation;
  8070. private _shadowsExposure;
  8071. /**
  8072. * Gets the shadows Hue value.
  8073. * 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).
  8074. */
  8075. get shadowsHue(): number;
  8076. /**
  8077. * Sets the shadows Hue value.
  8078. * 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).
  8079. */
  8080. set shadowsHue(value: number);
  8081. /**
  8082. * Gets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. get shadowsDensity(): number;
  8087. /**
  8088. * Sets the shadows Density value.
  8089. * 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.
  8090. * Values less than zero provide a filter of opposite hue.
  8091. */
  8092. set shadowsDensity(value: number);
  8093. /**
  8094. * Gets the shadows Saturation value.
  8095. * 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.
  8096. */
  8097. get shadowsSaturation(): number;
  8098. /**
  8099. * Sets the shadows Saturation value.
  8100. * 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.
  8101. */
  8102. set shadowsSaturation(value: number);
  8103. /**
  8104. * Gets the shadows Exposure value.
  8105. * 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.
  8106. */
  8107. get shadowsExposure(): number;
  8108. /**
  8109. * Sets the shadows Exposure value.
  8110. * 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.
  8111. */
  8112. set shadowsExposure(value: number);
  8113. /**
  8114. * Returns the class name
  8115. * @returns The class name
  8116. */
  8117. getClassName(): string;
  8118. /**
  8119. * Binds the color curves to the shader.
  8120. * @param colorCurves The color curve to bind
  8121. * @param effect The effect to bind to
  8122. * @param positiveUniform The positive uniform shader parameter
  8123. * @param neutralUniform The neutral uniform shader parameter
  8124. * @param negativeUniform The negative uniform shader parameter
  8125. */
  8126. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8127. /**
  8128. * Prepare the list of uniforms associated with the ColorCurves effects.
  8129. * @param uniformsList The list of uniforms used in the effect
  8130. */
  8131. static PrepareUniforms(uniformsList: string[]): void;
  8132. /**
  8133. * Returns color grading data based on a hue, density, saturation and exposure value.
  8134. * @param filterHue The hue of the color filter.
  8135. * @param filterDensity The density of the color filter.
  8136. * @param saturation The saturation.
  8137. * @param exposure The exposure.
  8138. * @param result The result data container.
  8139. */
  8140. private getColorGradingDataToRef;
  8141. /**
  8142. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8143. * @param value The input slider value in range [-100,100].
  8144. * @returns Adjusted value.
  8145. */
  8146. private static applyColorGradingSliderNonlinear;
  8147. /**
  8148. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8149. * @param hue The hue (H) input.
  8150. * @param saturation The saturation (S) input.
  8151. * @param brightness The brightness (B) input.
  8152. * @result An RGBA color represented as Vector4.
  8153. */
  8154. private static fromHSBToRef;
  8155. /**
  8156. * Returns a value clamped between min and max
  8157. * @param value The value to clamp
  8158. * @param min The minimum of value
  8159. * @param max The maximum of value
  8160. * @returns The clamped value.
  8161. */
  8162. private static clamp;
  8163. /**
  8164. * Clones the current color curve instance.
  8165. * @return The cloned curves
  8166. */
  8167. clone(): ColorCurves;
  8168. /**
  8169. * Serializes the current color curve instance to a json representation.
  8170. * @return a JSON representation
  8171. */
  8172. serialize(): any;
  8173. /**
  8174. * Parses the color curve from a json representation.
  8175. * @param source the JSON source to parse
  8176. * @return The parsed curves
  8177. */
  8178. static Parse(source: any): ColorCurves;
  8179. }
  8180. }
  8181. declare module BABYLON {
  8182. /**
  8183. * Interface to follow in your material defines to integrate easily the
  8184. * Image proccessing functions.
  8185. * @hidden
  8186. */
  8187. export interface IImageProcessingConfigurationDefines {
  8188. IMAGEPROCESSING: boolean;
  8189. VIGNETTE: boolean;
  8190. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8191. VIGNETTEBLENDMODEOPAQUE: boolean;
  8192. TONEMAPPING: boolean;
  8193. TONEMAPPING_ACES: boolean;
  8194. CONTRAST: boolean;
  8195. EXPOSURE: boolean;
  8196. COLORCURVES: boolean;
  8197. COLORGRADING: boolean;
  8198. COLORGRADING3D: boolean;
  8199. SAMPLER3DGREENDEPTH: boolean;
  8200. SAMPLER3DBGRMAP: boolean;
  8201. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8202. }
  8203. /**
  8204. * @hidden
  8205. */
  8206. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8207. IMAGEPROCESSING: boolean;
  8208. VIGNETTE: boolean;
  8209. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8210. VIGNETTEBLENDMODEOPAQUE: boolean;
  8211. TONEMAPPING: boolean;
  8212. TONEMAPPING_ACES: boolean;
  8213. CONTRAST: boolean;
  8214. COLORCURVES: boolean;
  8215. COLORGRADING: boolean;
  8216. COLORGRADING3D: boolean;
  8217. SAMPLER3DGREENDEPTH: boolean;
  8218. SAMPLER3DBGRMAP: boolean;
  8219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8220. EXPOSURE: boolean;
  8221. constructor();
  8222. }
  8223. /**
  8224. * This groups together the common properties used for image processing either in direct forward pass
  8225. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8226. * or not.
  8227. */
  8228. export class ImageProcessingConfiguration {
  8229. /**
  8230. * Default tone mapping applied in BabylonJS.
  8231. */
  8232. static readonly TONEMAPPING_STANDARD: number;
  8233. /**
  8234. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8235. * to other engines rendering to increase portability.
  8236. */
  8237. static readonly TONEMAPPING_ACES: number;
  8238. /**
  8239. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8240. */
  8241. colorCurves: Nullable<ColorCurves>;
  8242. private _colorCurvesEnabled;
  8243. /**
  8244. * Gets wether the color curves effect is enabled.
  8245. */
  8246. get colorCurvesEnabled(): boolean;
  8247. /**
  8248. * Sets wether the color curves effect is enabled.
  8249. */
  8250. set colorCurvesEnabled(value: boolean);
  8251. private _colorGradingTexture;
  8252. /**
  8253. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8254. */
  8255. get colorGradingTexture(): Nullable<BaseTexture>;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. set colorGradingTexture(value: Nullable<BaseTexture>);
  8260. private _colorGradingEnabled;
  8261. /**
  8262. * Gets wether the color grading effect is enabled.
  8263. */
  8264. get colorGradingEnabled(): boolean;
  8265. /**
  8266. * Sets wether the color grading effect is enabled.
  8267. */
  8268. set colorGradingEnabled(value: boolean);
  8269. private _colorGradingWithGreenDepth;
  8270. /**
  8271. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8272. */
  8273. get colorGradingWithGreenDepth(): boolean;
  8274. /**
  8275. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. set colorGradingWithGreenDepth(value: boolean);
  8278. private _colorGradingBGR;
  8279. /**
  8280. * Gets wether the color grading texture contains BGR values.
  8281. */
  8282. get colorGradingBGR(): boolean;
  8283. /**
  8284. * Sets wether the color grading texture contains BGR values.
  8285. */
  8286. set colorGradingBGR(value: boolean);
  8287. /** @hidden */
  8288. _exposure: number;
  8289. /**
  8290. * Gets the Exposure used in the effect.
  8291. */
  8292. get exposure(): number;
  8293. /**
  8294. * Sets the Exposure used in the effect.
  8295. */
  8296. set exposure(value: number);
  8297. private _toneMappingEnabled;
  8298. /**
  8299. * Gets wether the tone mapping effect is enabled.
  8300. */
  8301. get toneMappingEnabled(): boolean;
  8302. /**
  8303. * Sets wether the tone mapping effect is enabled.
  8304. */
  8305. set toneMappingEnabled(value: boolean);
  8306. private _toneMappingType;
  8307. /**
  8308. * Gets the type of tone mapping effect.
  8309. */
  8310. get toneMappingType(): number;
  8311. /**
  8312. * Sets the type of tone mapping effect used in BabylonJS.
  8313. */
  8314. set toneMappingType(value: number);
  8315. protected _contrast: number;
  8316. /**
  8317. * Gets the contrast used in the effect.
  8318. */
  8319. get contrast(): number;
  8320. /**
  8321. * Sets the contrast used in the effect.
  8322. */
  8323. set contrast(value: number);
  8324. /**
  8325. * Vignette stretch size.
  8326. */
  8327. vignetteStretch: number;
  8328. /**
  8329. * Vignette centre X Offset.
  8330. */
  8331. vignetteCentreX: number;
  8332. /**
  8333. * Vignette centre Y Offset.
  8334. */
  8335. vignetteCentreY: number;
  8336. /**
  8337. * Vignette weight or intensity of the vignette effect.
  8338. */
  8339. vignetteWeight: number;
  8340. /**
  8341. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8342. * if vignetteEnabled is set to true.
  8343. */
  8344. vignetteColor: Color4;
  8345. /**
  8346. * Camera field of view used by the Vignette effect.
  8347. */
  8348. vignetteCameraFov: number;
  8349. private _vignetteBlendMode;
  8350. /**
  8351. * Gets the vignette blend mode allowing different kind of effect.
  8352. */
  8353. get vignetteBlendMode(): number;
  8354. /**
  8355. * Sets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. set vignetteBlendMode(value: number);
  8358. private _vignetteEnabled;
  8359. /**
  8360. * Gets wether the vignette effect is enabled.
  8361. */
  8362. get vignetteEnabled(): boolean;
  8363. /**
  8364. * Sets wether the vignette effect is enabled.
  8365. */
  8366. set vignetteEnabled(value: boolean);
  8367. private _applyByPostProcess;
  8368. /**
  8369. * Gets wether the image processing is applied through a post process or not.
  8370. */
  8371. get applyByPostProcess(): boolean;
  8372. /**
  8373. * Sets wether the image processing is applied through a post process or not.
  8374. */
  8375. set applyByPostProcess(value: boolean);
  8376. private _isEnabled;
  8377. /**
  8378. * Gets wether the image processing is enabled or not.
  8379. */
  8380. get isEnabled(): boolean;
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. set isEnabled(value: boolean);
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static get VIGNETTEMODE_MULTIPLY(): number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_OPAQUE(): number;
  8453. }
  8454. }
  8455. declare module BABYLON {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module BABYLON {
  8463. interface ThinEngine {
  8464. /**
  8465. * Creates a new render target texture
  8466. * @param size defines the size of the texture
  8467. * @param options defines the options used to create the texture
  8468. * @returns a new render target texture stored in an InternalTexture
  8469. */
  8470. createRenderTargetTexture(size: number | {
  8471. width: number;
  8472. height: number;
  8473. layers?: number;
  8474. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8475. /**
  8476. * Creates a depth stencil texture.
  8477. * This is only available in WebGL 2 or with the depth texture extension available.
  8478. * @param size The size of face edge in the texture.
  8479. * @param options The options defining the texture.
  8480. * @returns The texture
  8481. */
  8482. createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. /** @hidden */
  8488. _createDepthStencilTexture(size: number | {
  8489. width: number;
  8490. height: number;
  8491. layers?: number;
  8492. }, options: DepthTextureCreationOptions): InternalTexture;
  8493. }
  8494. }
  8495. declare module BABYLON {
  8496. /** Defines supported spaces */
  8497. export enum Space {
  8498. /** Local (object) space */
  8499. LOCAL = 0,
  8500. /** World space */
  8501. WORLD = 1,
  8502. /** Bone space */
  8503. BONE = 2
  8504. }
  8505. /** Defines the 3 main axes */
  8506. export class Axis {
  8507. /** X axis */
  8508. static X: Vector3;
  8509. /** Y axis */
  8510. static Y: Vector3;
  8511. /** Z axis */
  8512. static Z: Vector3;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /**
  8517. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8518. * This is the base of the follow, arc rotate cameras and Free camera
  8519. * @see http://doc.babylonjs.com/features/cameras
  8520. */
  8521. export class TargetCamera extends Camera {
  8522. private static _RigCamTransformMatrix;
  8523. private static _TargetTransformMatrix;
  8524. private static _TargetFocalPoint;
  8525. /**
  8526. * Define the current direction the camera is moving to
  8527. */
  8528. cameraDirection: Vector3;
  8529. /**
  8530. * Define the current rotation the camera is rotating to
  8531. */
  8532. cameraRotation: Vector2;
  8533. /**
  8534. * When set, the up vector of the camera will be updated by the rotation of the camera
  8535. */
  8536. updateUpVectorFromRotation: boolean;
  8537. private _tmpQuaternion;
  8538. /**
  8539. * Define the current rotation of the camera
  8540. */
  8541. rotation: Vector3;
  8542. /**
  8543. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8544. */
  8545. rotationQuaternion: Quaternion;
  8546. /**
  8547. * Define the current speed of the camera
  8548. */
  8549. speed: number;
  8550. /**
  8551. * Add constraint to the camera to prevent it to move freely in all directions and
  8552. * around all axis.
  8553. */
  8554. noRotationConstraint: boolean;
  8555. /**
  8556. * Define the current target of the camera as an object or a position.
  8557. */
  8558. lockedTarget: any;
  8559. /** @hidden */
  8560. _currentTarget: Vector3;
  8561. /** @hidden */
  8562. _initialFocalDistance: number;
  8563. /** @hidden */
  8564. _viewMatrix: Matrix;
  8565. /** @hidden */
  8566. _camMatrix: Matrix;
  8567. /** @hidden */
  8568. _cameraTransformMatrix: Matrix;
  8569. /** @hidden */
  8570. _cameraRotationMatrix: Matrix;
  8571. /** @hidden */
  8572. _referencePoint: Vector3;
  8573. /** @hidden */
  8574. _transformedReferencePoint: Vector3;
  8575. protected _globalCurrentTarget: Vector3;
  8576. protected _globalCurrentUpVector: Vector3;
  8577. /** @hidden */
  8578. _reset: () => void;
  8579. private _defaultUp;
  8580. /**
  8581. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8582. * This is the base of the follow, arc rotate cameras and Free camera
  8583. * @see http://doc.babylonjs.com/features/cameras
  8584. * @param name Defines the name of the camera in the scene
  8585. * @param position Defines the start position of the camera in the scene
  8586. * @param scene Defines the scene the camera belongs to
  8587. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8588. */
  8589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8590. /**
  8591. * Gets the position in front of the camera at a given distance.
  8592. * @param distance The distance from the camera we want the position to be
  8593. * @returns the position
  8594. */
  8595. getFrontPosition(distance: number): Vector3;
  8596. /** @hidden */
  8597. _getLockedTargetPosition(): Nullable<Vector3>;
  8598. private _storedPosition;
  8599. private _storedRotation;
  8600. private _storedRotationQuaternion;
  8601. /**
  8602. * Store current camera state of the camera (fov, position, rotation, etc..)
  8603. * @returns the camera
  8604. */
  8605. storeState(): Camera;
  8606. /**
  8607. * Restored camera state. You must call storeState() first
  8608. * @returns whether it was successful or not
  8609. * @hidden
  8610. */
  8611. _restoreStateValues(): boolean;
  8612. /** @hidden */
  8613. _initCache(): void;
  8614. /** @hidden */
  8615. _updateCache(ignoreParentClass?: boolean): void;
  8616. /** @hidden */
  8617. _isSynchronizedViewMatrix(): boolean;
  8618. /** @hidden */
  8619. _computeLocalCameraSpeed(): number;
  8620. /**
  8621. * Defines the target the camera should look at.
  8622. * @param target Defines the new target as a Vector or a mesh
  8623. */
  8624. setTarget(target: Vector3): void;
  8625. /**
  8626. * Return the current target position of the camera. This value is expressed in local space.
  8627. * @returns the target position
  8628. */
  8629. getTarget(): Vector3;
  8630. /** @hidden */
  8631. _decideIfNeedsToMove(): boolean;
  8632. /** @hidden */
  8633. _updatePosition(): void;
  8634. /** @hidden */
  8635. _checkInputs(): void;
  8636. protected _updateCameraRotationMatrix(): void;
  8637. /**
  8638. * 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)
  8639. * @returns the current camera
  8640. */
  8641. private _rotateUpVectorWithCameraRotationMatrix;
  8642. private _cachedRotationZ;
  8643. private _cachedQuaternionRotationZ;
  8644. /** @hidden */
  8645. _getViewMatrix(): Matrix;
  8646. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8647. /**
  8648. * @hidden
  8649. */
  8650. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8651. /**
  8652. * @hidden
  8653. */
  8654. _updateRigCameras(): void;
  8655. private _getRigCamPositionAndTarget;
  8656. /**
  8657. * Gets the current object class name.
  8658. * @return the class name
  8659. */
  8660. getClassName(): string;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /**
  8665. * Gather the list of keyboard event types as constants.
  8666. */
  8667. export class KeyboardEventTypes {
  8668. /**
  8669. * The keydown event is fired when a key becomes active (pressed).
  8670. */
  8671. static readonly KEYDOWN: number;
  8672. /**
  8673. * The keyup event is fired when a key has been released.
  8674. */
  8675. static readonly KEYUP: number;
  8676. }
  8677. /**
  8678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8679. */
  8680. export class KeyboardInfo {
  8681. /**
  8682. * Defines the type of event (KeyboardEventTypes)
  8683. */
  8684. type: number;
  8685. /**
  8686. * Defines the related dom event
  8687. */
  8688. event: KeyboardEvent;
  8689. /**
  8690. * Instantiates a new keyboard info.
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. * @param type Defines the type of event (KeyboardEventTypes)
  8693. * @param event Defines the related dom event
  8694. */
  8695. constructor(
  8696. /**
  8697. * Defines the type of event (KeyboardEventTypes)
  8698. */
  8699. type: number,
  8700. /**
  8701. * Defines the related dom event
  8702. */
  8703. event: KeyboardEvent);
  8704. }
  8705. /**
  8706. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8707. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8708. */
  8709. export class KeyboardInfoPre extends KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8720. */
  8721. skipOnPointerObservable: boolean;
  8722. /**
  8723. * Instantiates a new keyboard pre info.
  8724. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8725. * @param type Defines the type of event (KeyboardEventTypes)
  8726. * @param event Defines the related dom event
  8727. */
  8728. constructor(
  8729. /**
  8730. * Defines the type of event (KeyboardEventTypes)
  8731. */
  8732. type: number,
  8733. /**
  8734. * Defines the related dom event
  8735. */
  8736. event: KeyboardEvent);
  8737. }
  8738. }
  8739. declare module BABYLON {
  8740. /**
  8741. * Manage the keyboard inputs to control the movement of a free camera.
  8742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8743. */
  8744. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8745. /**
  8746. * Defines the camera the input is attached to.
  8747. */
  8748. camera: FreeCamera;
  8749. /**
  8750. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8751. */
  8752. keysUp: number[];
  8753. /**
  8754. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8755. */
  8756. keysDown: number[];
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8759. */
  8760. keysLeft: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8763. */
  8764. keysRight: number[];
  8765. private _keys;
  8766. private _onCanvasBlurObserver;
  8767. private _onKeyboardObserver;
  8768. private _engine;
  8769. private _scene;
  8770. /**
  8771. * Attach the input controls to a specific dom element to get the input from.
  8772. * @param element Defines the element the controls should be listened from
  8773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8774. */
  8775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8776. /**
  8777. * Detach the current controls from the specified dom element.
  8778. * @param element Defines the element to stop listening the inputs from
  8779. */
  8780. detachControl(element: Nullable<HTMLElement>): void;
  8781. /**
  8782. * Update the current camera state depending on the inputs that have been used this frame.
  8783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8784. */
  8785. checkInputs(): void;
  8786. /**
  8787. * Gets the class name of the current intput.
  8788. * @returns the class name
  8789. */
  8790. getClassName(): string;
  8791. /** @hidden */
  8792. _onLostFocus(): void;
  8793. /**
  8794. * Get the friendly name associated with the input class.
  8795. * @returns the input friendly name
  8796. */
  8797. getSimpleName(): string;
  8798. }
  8799. }
  8800. declare module BABYLON {
  8801. /**
  8802. * Interface describing all the common properties and methods a shadow light needs to implement.
  8803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8804. * as well as binding the different shadow properties to the effects.
  8805. */
  8806. export interface IShadowLight extends Light {
  8807. /**
  8808. * The light id in the scene (used in scene.findLighById for instance)
  8809. */
  8810. id: string;
  8811. /**
  8812. * The position the shdow will be casted from.
  8813. */
  8814. position: Vector3;
  8815. /**
  8816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8817. */
  8818. direction: Vector3;
  8819. /**
  8820. * The transformed position. Position of the light in world space taking parenting in account.
  8821. */
  8822. transformedPosition: Vector3;
  8823. /**
  8824. * The transformed direction. Direction of the light in world space taking parenting in account.
  8825. */
  8826. transformedDirection: Vector3;
  8827. /**
  8828. * The friendly name of the light in the scene.
  8829. */
  8830. name: string;
  8831. /**
  8832. * Defines the shadow projection clipping minimum z value.
  8833. */
  8834. shadowMinZ: number;
  8835. /**
  8836. * Defines the shadow projection clipping maximum z value.
  8837. */
  8838. shadowMaxZ: number;
  8839. /**
  8840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8842. */
  8843. computeTransformedInformation(): boolean;
  8844. /**
  8845. * Gets the scene the light belongs to.
  8846. * @returns The scene
  8847. */
  8848. getScene(): Scene;
  8849. /**
  8850. * Callback defining a custom Projection Matrix Builder.
  8851. * This can be used to override the default projection matrix computation.
  8852. */
  8853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8854. /**
  8855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8856. * @param matrix The materix to updated with the projection information
  8857. * @param viewMatrix The transform matrix of the light
  8858. * @param renderList The list of mesh to render in the map
  8859. * @returns The current light
  8860. */
  8861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8862. /**
  8863. * Gets the current depth scale used in ESM.
  8864. * @returns The scale
  8865. */
  8866. getDepthScale(): number;
  8867. /**
  8868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8869. * @returns true if a cube texture needs to be use
  8870. */
  8871. needCube(): boolean;
  8872. /**
  8873. * Detects if the projection matrix requires to be recomputed this frame.
  8874. * @returns true if it requires to be recomputed otherwise, false.
  8875. */
  8876. needProjectionMatrixCompute(): boolean;
  8877. /**
  8878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8879. */
  8880. forceProjectionMatrixCompute(): void;
  8881. /**
  8882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8885. */
  8886. getShadowDirection(faceIndex?: number): Vector3;
  8887. /**
  8888. * Gets the minZ used for shadow according to both the scene and the light.
  8889. * @param activeCamera The camera we are returning the min for
  8890. * @returns the depth min z
  8891. */
  8892. getDepthMinZ(activeCamera: Camera): number;
  8893. /**
  8894. * Gets the maxZ used for shadow according to both the scene and the light.
  8895. * @param activeCamera The camera we are returning the max for
  8896. * @returns the depth max z
  8897. */
  8898. getDepthMaxZ(activeCamera: Camera): number;
  8899. }
  8900. /**
  8901. * Base implementation IShadowLight
  8902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8903. */
  8904. export abstract class ShadowLight extends Light implements IShadowLight {
  8905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8906. protected _position: Vector3;
  8907. protected _setPosition(value: Vector3): void;
  8908. /**
  8909. * Sets the position the shadow will be casted from. Also use as the light position for both
  8910. * point and spot lights.
  8911. */
  8912. get position(): Vector3;
  8913. /**
  8914. * Sets the position the shadow will be casted from. Also use as the light position for both
  8915. * point and spot lights.
  8916. */
  8917. set position(value: Vector3);
  8918. protected _direction: Vector3;
  8919. protected _setDirection(value: Vector3): void;
  8920. /**
  8921. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8922. * Also use as the light direction on spot and directional lights.
  8923. */
  8924. get direction(): Vector3;
  8925. /**
  8926. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8927. * Also use as the light direction on spot and directional lights.
  8928. */
  8929. set direction(value: Vector3);
  8930. protected _shadowMinZ: number;
  8931. /**
  8932. * Gets the shadow projection clipping minimum z value.
  8933. */
  8934. get shadowMinZ(): number;
  8935. /**
  8936. * Sets the shadow projection clipping minimum z value.
  8937. */
  8938. set shadowMinZ(value: number);
  8939. protected _shadowMaxZ: number;
  8940. /**
  8941. * Sets the shadow projection clipping maximum z value.
  8942. */
  8943. get shadowMaxZ(): number;
  8944. /**
  8945. * Gets the shadow projection clipping maximum z value.
  8946. */
  8947. set shadowMaxZ(value: number);
  8948. /**
  8949. * Callback defining a custom Projection Matrix Builder.
  8950. * This can be used to override the default projection matrix computation.
  8951. */
  8952. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8953. /**
  8954. * The transformed position. Position of the light in world space taking parenting in account.
  8955. */
  8956. transformedPosition: Vector3;
  8957. /**
  8958. * The transformed direction. Direction of the light in world space taking parenting in account.
  8959. */
  8960. transformedDirection: Vector3;
  8961. private _needProjectionMatrixCompute;
  8962. /**
  8963. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8964. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8965. */
  8966. computeTransformedInformation(): boolean;
  8967. /**
  8968. * Return the depth scale used for the shadow map.
  8969. * @returns the depth scale.
  8970. */
  8971. getDepthScale(): number;
  8972. /**
  8973. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8974. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8975. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8976. */
  8977. getShadowDirection(faceIndex?: number): Vector3;
  8978. /**
  8979. * Returns the ShadowLight absolute position in the World.
  8980. * @returns the position vector in world space
  8981. */
  8982. getAbsolutePosition(): Vector3;
  8983. /**
  8984. * Sets the ShadowLight direction toward the passed target.
  8985. * @param target The point to target in local space
  8986. * @returns the updated ShadowLight direction
  8987. */
  8988. setDirectionToTarget(target: Vector3): Vector3;
  8989. /**
  8990. * Returns the light rotation in euler definition.
  8991. * @returns the x y z rotation in local space.
  8992. */
  8993. getRotation(): Vector3;
  8994. /**
  8995. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8996. * @returns true if a cube texture needs to be use
  8997. */
  8998. needCube(): boolean;
  8999. /**
  9000. * Detects if the projection matrix requires to be recomputed this frame.
  9001. * @returns true if it requires to be recomputed otherwise, false.
  9002. */
  9003. needProjectionMatrixCompute(): boolean;
  9004. /**
  9005. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9006. */
  9007. forceProjectionMatrixCompute(): void;
  9008. /** @hidden */
  9009. _initCache(): void;
  9010. /** @hidden */
  9011. _isSynchronized(): boolean;
  9012. /**
  9013. * Computes the world matrix of the node
  9014. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9015. * @returns the world matrix
  9016. */
  9017. computeWorldMatrix(force?: boolean): Matrix;
  9018. /**
  9019. * Gets the minZ used for shadow according to both the scene and the light.
  9020. * @param activeCamera The camera we are returning the min for
  9021. * @returns the depth min z
  9022. */
  9023. getDepthMinZ(activeCamera: Camera): number;
  9024. /**
  9025. * Gets the maxZ used for shadow according to both the scene and the light.
  9026. * @param activeCamera The camera we are returning the max for
  9027. * @returns the depth max z
  9028. */
  9029. getDepthMaxZ(activeCamera: Camera): number;
  9030. /**
  9031. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9032. * @param matrix The materix to updated with the projection information
  9033. * @param viewMatrix The transform matrix of the light
  9034. * @param renderList The list of mesh to render in the map
  9035. * @returns The current light
  9036. */
  9037. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9038. }
  9039. }
  9040. declare module BABYLON {
  9041. /**
  9042. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9043. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9044. */
  9045. export class EffectFallbacks implements IEffectFallbacks {
  9046. private _defines;
  9047. private _currentRank;
  9048. private _maxRank;
  9049. private _mesh;
  9050. /**
  9051. * Removes the fallback from the bound mesh.
  9052. */
  9053. unBindMesh(): void;
  9054. /**
  9055. * Adds a fallback on the specified property.
  9056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9057. * @param define The name of the define in the shader
  9058. */
  9059. addFallback(rank: number, define: string): void;
  9060. /**
  9061. * Sets the mesh to use CPU skinning when needing to fallback.
  9062. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9063. * @param mesh The mesh to use the fallbacks.
  9064. */
  9065. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9066. /**
  9067. * Checks to see if more fallbacks are still availible.
  9068. */
  9069. get hasMoreFallbacks(): boolean;
  9070. /**
  9071. * Removes the defines that should be removed when falling back.
  9072. * @param currentDefines defines the current define statements for the shader.
  9073. * @param effect defines the current effect we try to compile
  9074. * @returns The resulting defines with defines of the current rank removed.
  9075. */
  9076. reduce(currentDefines: string, effect: Effect): string;
  9077. }
  9078. }
  9079. declare module BABYLON {
  9080. /**
  9081. * "Static Class" containing the most commonly used helper while dealing with material for
  9082. * rendering purpose.
  9083. *
  9084. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9085. *
  9086. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9087. */
  9088. export class MaterialHelper {
  9089. /**
  9090. * Bind the current view position to an effect.
  9091. * @param effect The effect to be bound
  9092. * @param scene The scene the eyes position is used from
  9093. */
  9094. static BindEyePosition(effect: Effect, scene: Scene): void;
  9095. /**
  9096. * Helps preparing the defines values about the UVs in used in the effect.
  9097. * UVs are shared as much as we can accross channels in the shaders.
  9098. * @param texture The texture we are preparing the UVs for
  9099. * @param defines The defines to update
  9100. * @param key The channel key "diffuse", "specular"... used in the shader
  9101. */
  9102. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9103. /**
  9104. * Binds a texture matrix value to its corrsponding uniform
  9105. * @param texture The texture to bind the matrix for
  9106. * @param uniformBuffer The uniform buffer receivin the data
  9107. * @param key The channel key "diffuse", "specular"... used in the shader
  9108. */
  9109. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9110. /**
  9111. * Gets the current status of the fog (should it be enabled?)
  9112. * @param mesh defines the mesh to evaluate for fog support
  9113. * @param scene defines the hosting scene
  9114. * @returns true if fog must be enabled
  9115. */
  9116. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9117. /**
  9118. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9119. * @param mesh defines the current mesh
  9120. * @param scene defines the current scene
  9121. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9122. * @param pointsCloud defines if point cloud rendering has to be turned on
  9123. * @param fogEnabled defines if fog has to be turned on
  9124. * @param alphaTest defines if alpha testing has to be turned on
  9125. * @param defines defines the current list of defines
  9126. */
  9127. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9128. /**
  9129. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9130. * @param scene defines the current scene
  9131. * @param engine defines the current engine
  9132. * @param defines specifies the list of active defines
  9133. * @param useInstances defines if instances have to be turned on
  9134. * @param useClipPlane defines if clip plane have to be turned on
  9135. */
  9136. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9137. /**
  9138. * Prepares the defines for bones
  9139. * @param mesh The mesh containing the geometry data we will draw
  9140. * @param defines The defines to update
  9141. */
  9142. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9143. /**
  9144. * Prepares the defines for morph targets
  9145. * @param mesh The mesh containing the geometry data we will draw
  9146. * @param defines The defines to update
  9147. */
  9148. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9149. /**
  9150. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9151. * @param mesh The mesh containing the geometry data we will draw
  9152. * @param defines The defines to update
  9153. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9154. * @param useBones Precise whether bones should be used or not (override mesh info)
  9155. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9156. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9157. * @returns false if defines are considered not dirty and have not been checked
  9158. */
  9159. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9160. /**
  9161. * Prepares the defines related to multiview
  9162. * @param scene The scene we are intending to draw
  9163. * @param defines The defines to update
  9164. */
  9165. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9166. /**
  9167. * Prepares the defines related to the light information passed in parameter
  9168. * @param scene The scene we are intending to draw
  9169. * @param mesh The mesh the effect is compiling for
  9170. * @param light The light the effect is compiling for
  9171. * @param lightIndex The index of the light
  9172. * @param defines The defines to update
  9173. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9174. * @param state Defines the current state regarding what is needed (normals, etc...)
  9175. */
  9176. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9177. needNormals: boolean;
  9178. needRebuild: boolean;
  9179. shadowEnabled: boolean;
  9180. specularEnabled: boolean;
  9181. lightmapMode: boolean;
  9182. }): void;
  9183. /**
  9184. * Prepares the defines related to the light information passed in parameter
  9185. * @param scene The scene we are intending to draw
  9186. * @param mesh The mesh the effect is compiling for
  9187. * @param defines The defines to update
  9188. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9189. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9190. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9191. * @returns true if normals will be required for the rest of the effect
  9192. */
  9193. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9194. /**
  9195. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9196. * @param lightIndex defines the light index
  9197. * @param uniformsList The uniform list
  9198. * @param samplersList The sampler list
  9199. * @param projectedLightTexture defines if projected texture must be used
  9200. * @param uniformBuffersList defines an optional list of uniform buffers
  9201. */
  9202. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9203. /**
  9204. * Prepares the uniforms and samplers list to be used in the effect
  9205. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9206. * @param samplersList The sampler list
  9207. * @param defines The defines helping in the list generation
  9208. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9209. */
  9210. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9211. /**
  9212. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9213. * @param defines The defines to update while falling back
  9214. * @param fallbacks The authorized effect fallbacks
  9215. * @param maxSimultaneousLights The maximum number of lights allowed
  9216. * @param rank the current rank of the Effect
  9217. * @returns The newly affected rank
  9218. */
  9219. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9220. private static _TmpMorphInfluencers;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param influencers The number of influencers
  9226. */
  9227. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9228. /**
  9229. * Prepares the list of attributes required for morph targets according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the morph targets attributes for
  9232. * @param defines The current Defines of the effect
  9233. */
  9234. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9235. /**
  9236. * Prepares the list of attributes required for bones according to the effect defines.
  9237. * @param attribs The current list of supported attribs
  9238. * @param mesh The mesh to prepare the bones attributes for
  9239. * @param defines The current Defines of the effect
  9240. * @param fallbacks The current efffect fallback strategy
  9241. */
  9242. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9243. /**
  9244. * Check and prepare the list of attributes required for instances according to the effect defines.
  9245. * @param attribs The current list of supported attribs
  9246. * @param defines The current MaterialDefines of the effect
  9247. */
  9248. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9249. /**
  9250. * Add the list of attributes required for instances to the attribs array.
  9251. * @param attribs The current list of supported attribs
  9252. */
  9253. static PushAttributesForInstances(attribs: string[]): void;
  9254. /**
  9255. * Binds the light information to the effect.
  9256. * @param light The light containing the generator
  9257. * @param effect The effect we are binding the data to
  9258. * @param lightIndex The light index in the effect used to render
  9259. */
  9260. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9261. /**
  9262. * Binds the lights information from the scene to the effect for the given mesh.
  9263. * @param light Light to bind
  9264. * @param lightIndex Light index
  9265. * @param scene The scene where the light belongs to
  9266. * @param effect The effect we are binding the data to
  9267. * @param useSpecular Defines if specular is supported
  9268. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9269. */
  9270. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9271. /**
  9272. * Binds the lights information from the scene to the effect for the given mesh.
  9273. * @param scene The scene the lights belongs to
  9274. * @param mesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. * @param defines The generated defines for the effect
  9277. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9278. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9279. */
  9280. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9281. private static _tempFogColor;
  9282. /**
  9283. * Binds the fog information from the scene to the effect for the given mesh.
  9284. * @param scene The scene the lights belongs to
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. * @param linearSpace Defines if the fog effect is applied in linear space
  9288. */
  9289. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9290. /**
  9291. * Binds the bones information from the mesh to the effect.
  9292. * @param mesh The mesh we are binding the information to render
  9293. * @param effect The effect we are binding the data to
  9294. */
  9295. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9296. /**
  9297. * Binds the morph targets information from the mesh to the effect.
  9298. * @param abstractMesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9302. /**
  9303. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9304. * @param defines The generated defines used in the effect
  9305. * @param effect The effect we are binding the data to
  9306. * @param scene The scene we are willing to render with logarithmic scale for
  9307. */
  9308. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9309. /**
  9310. * Binds the clip plane information from the scene to the effect.
  9311. * @param scene The scene the clip plane information are extracted from
  9312. * @param effect The effect we are binding the data to
  9313. */
  9314. static BindClipPlane(effect: Effect, scene: Scene): void;
  9315. }
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var packingFunctions: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var clipPlaneFragmentDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var clipPlaneFragment: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var shadowMapPixelShader: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var bonesDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var morphTargetsVertexGlobalDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var morphTargetsVertexDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var instancesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var helperFunctions: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var clipPlaneVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var morphTargetsVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var instancesVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var bonesVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var clipPlaneVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapVertexShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var depthBoxBlurPixelShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /**
  9431. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9432. */
  9433. export interface ICustomShaderOptions {
  9434. /**
  9435. * Gets or sets the custom shader name to use
  9436. */
  9437. shaderName: string;
  9438. /**
  9439. * The list of attribute names used in the shader
  9440. */
  9441. attributes?: string[];
  9442. /**
  9443. * The list of unifrom names used in the shader
  9444. */
  9445. uniforms?: string[];
  9446. /**
  9447. * The list of sampler names used in the shader
  9448. */
  9449. samplers?: string[];
  9450. /**
  9451. * The list of defines used in the shader
  9452. */
  9453. defines?: string[];
  9454. }
  9455. /**
  9456. * Interface to implement to create a shadow generator compatible with BJS.
  9457. */
  9458. export interface IShadowGenerator {
  9459. /**
  9460. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9461. * @returns The render target texture if present otherwise, null
  9462. */
  9463. getShadowMap(): Nullable<RenderTargetTexture>;
  9464. /**
  9465. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9466. * @param subMesh The submesh we want to render in the shadow map
  9467. * @param useInstances Defines wether will draw in the map using instances
  9468. * @returns true if ready otherwise, false
  9469. */
  9470. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9471. /**
  9472. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9473. * @param defines Defines of the material we want to update
  9474. * @param lightIndex Index of the light in the enabled light list of the material
  9475. */
  9476. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9477. /**
  9478. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9479. * defined in the generator but impacting the effect).
  9480. * It implies the unifroms available on the materials are the standard BJS ones.
  9481. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9482. * @param effect The effect we are binfing the information for
  9483. */
  9484. bindShadowLight(lightIndex: string, effect: Effect): void;
  9485. /**
  9486. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9487. * (eq to shadow prjection matrix * light transform matrix)
  9488. * @returns The transform matrix used to create the shadow map
  9489. */
  9490. getTransformMatrix(): Matrix;
  9491. /**
  9492. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9493. * Cube and 2D textures for instance.
  9494. */
  9495. recreateShadowMap(): void;
  9496. /**
  9497. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9498. * @param onCompiled Callback triggered at the and of the effects compilation
  9499. * @param options Sets of optional options forcing the compilation with different modes
  9500. */
  9501. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9502. useInstances: boolean;
  9503. }>): void;
  9504. /**
  9505. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9506. * @param options Sets of optional options forcing the compilation with different modes
  9507. * @returns A promise that resolves when the compilation completes
  9508. */
  9509. forceCompilationAsync(options?: Partial<{
  9510. useInstances: boolean;
  9511. }>): Promise<void>;
  9512. /**
  9513. * Serializes the shadow generator setup to a json object.
  9514. * @returns The serialized JSON object
  9515. */
  9516. serialize(): any;
  9517. /**
  9518. * Disposes the Shadow map and related Textures and effects.
  9519. */
  9520. dispose(): void;
  9521. }
  9522. /**
  9523. * Default implementation IShadowGenerator.
  9524. * This is the main object responsible of generating shadows in the framework.
  9525. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9526. */
  9527. export class ShadowGenerator implements IShadowGenerator {
  9528. /**
  9529. * Name of the shadow generator class
  9530. */
  9531. static CLASSNAME: string;
  9532. /**
  9533. * Shadow generator mode None: no filtering applied.
  9534. */
  9535. static readonly FILTER_NONE: number;
  9536. /**
  9537. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9538. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9539. */
  9540. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9541. /**
  9542. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9543. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9544. */
  9545. static readonly FILTER_POISSONSAMPLING: number;
  9546. /**
  9547. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9548. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9549. */
  9550. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9551. /**
  9552. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9553. * edge artifacts on steep falloff.
  9554. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9555. */
  9556. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9557. /**
  9558. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9559. * edge artifacts on steep falloff.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode PCF: Percentage Closer Filtering
  9565. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9566. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9567. */
  9568. static readonly FILTER_PCF: number;
  9569. /**
  9570. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9571. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9572. * Contact Hardening
  9573. */
  9574. static readonly FILTER_PCSS: number;
  9575. /**
  9576. * Reserved for PCF and PCSS
  9577. * Highest Quality.
  9578. *
  9579. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9580. *
  9581. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9582. */
  9583. static readonly QUALITY_HIGH: number;
  9584. /**
  9585. * Reserved for PCF and PCSS
  9586. * Good tradeoff for quality/perf cross devices
  9587. *
  9588. * Execute PCF on a 3*3 kernel.
  9589. *
  9590. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9591. */
  9592. static readonly QUALITY_MEDIUM: number;
  9593. /**
  9594. * Reserved for PCF and PCSS
  9595. * The lowest quality but the fastest.
  9596. *
  9597. * Execute PCF on a 1*1 kernel.
  9598. *
  9599. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9600. */
  9601. static readonly QUALITY_LOW: number;
  9602. /** Gets or sets the custom shader name to use */
  9603. customShaderOptions: ICustomShaderOptions;
  9604. /**
  9605. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9606. */
  9607. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9608. /**
  9609. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9610. */
  9611. onAfterShadowMapRenderObservable: Observable<Effect>;
  9612. /**
  9613. * Observable triggered before a mesh is rendered in the shadow map.
  9614. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9615. */
  9616. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9617. /**
  9618. * Observable triggered after a mesh is rendered in the shadow map.
  9619. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9620. */
  9621. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9622. protected _bias: number;
  9623. /**
  9624. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9625. */
  9626. get bias(): number;
  9627. /**
  9628. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9629. */
  9630. set bias(bias: number);
  9631. protected _normalBias: number;
  9632. /**
  9633. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9634. */
  9635. get normalBias(): number;
  9636. /**
  9637. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9638. */
  9639. set normalBias(normalBias: number);
  9640. protected _blurBoxOffset: number;
  9641. /**
  9642. * Gets the blur box offset: offset applied during the blur pass.
  9643. * Only useful if useKernelBlur = false
  9644. */
  9645. get blurBoxOffset(): number;
  9646. /**
  9647. * Sets the blur box offset: offset applied during the blur pass.
  9648. * Only useful if useKernelBlur = false
  9649. */
  9650. set blurBoxOffset(value: number);
  9651. protected _blurScale: number;
  9652. /**
  9653. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9654. * 2 means half of the size.
  9655. */
  9656. get blurScale(): number;
  9657. /**
  9658. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9659. * 2 means half of the size.
  9660. */
  9661. set blurScale(value: number);
  9662. protected _blurKernel: number;
  9663. /**
  9664. * Gets the blur kernel: kernel size of the blur pass.
  9665. * Only useful if useKernelBlur = true
  9666. */
  9667. get blurKernel(): number;
  9668. /**
  9669. * Sets the blur kernel: kernel size of the blur pass.
  9670. * Only useful if useKernelBlur = true
  9671. */
  9672. set blurKernel(value: number);
  9673. protected _useKernelBlur: boolean;
  9674. /**
  9675. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9676. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9677. */
  9678. get useKernelBlur(): boolean;
  9679. /**
  9680. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9681. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9682. */
  9683. set useKernelBlur(value: boolean);
  9684. protected _depthScale: number;
  9685. /**
  9686. * Gets the depth scale used in ESM mode.
  9687. */
  9688. get depthScale(): number;
  9689. /**
  9690. * Sets the depth scale used in ESM mode.
  9691. * This can override the scale stored on the light.
  9692. */
  9693. set depthScale(value: number);
  9694. protected _validateFilter(filter: number): number;
  9695. protected _filter: number;
  9696. /**
  9697. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9698. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9699. */
  9700. get filter(): number;
  9701. /**
  9702. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9703. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9704. */
  9705. set filter(value: number);
  9706. /**
  9707. * Gets if the current filter is set to Poisson Sampling.
  9708. */
  9709. get usePoissonSampling(): boolean;
  9710. /**
  9711. * Sets the current filter to Poisson Sampling.
  9712. */
  9713. set usePoissonSampling(value: boolean);
  9714. /**
  9715. * Gets if the current filter is set to ESM.
  9716. */
  9717. get useExponentialShadowMap(): boolean;
  9718. /**
  9719. * Sets the current filter is to ESM.
  9720. */
  9721. set useExponentialShadowMap(value: boolean);
  9722. /**
  9723. * Gets if the current filter is set to filtered ESM.
  9724. */
  9725. get useBlurExponentialShadowMap(): boolean;
  9726. /**
  9727. * Gets if the current filter is set to filtered ESM.
  9728. */
  9729. set useBlurExponentialShadowMap(value: boolean);
  9730. /**
  9731. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9732. * exponential to prevent steep falloff artifacts).
  9733. */
  9734. get useCloseExponentialShadowMap(): boolean;
  9735. /**
  9736. * Sets the current filter to "close ESM" (using the inverse of the
  9737. * exponential to prevent steep falloff artifacts).
  9738. */
  9739. set useCloseExponentialShadowMap(value: boolean);
  9740. /**
  9741. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. get useBlurCloseExponentialShadowMap(): boolean;
  9745. /**
  9746. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. set useBlurCloseExponentialShadowMap(value: boolean);
  9750. /**
  9751. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9752. */
  9753. get usePercentageCloserFiltering(): boolean;
  9754. /**
  9755. * Sets the current filter to "PCF" (percentage closer filtering).
  9756. */
  9757. set usePercentageCloserFiltering(value: boolean);
  9758. protected _filteringQuality: number;
  9759. /**
  9760. * Gets the PCF or PCSS Quality.
  9761. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9762. */
  9763. get filteringQuality(): number;
  9764. /**
  9765. * Sets the PCF or PCSS Quality.
  9766. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9767. */
  9768. set filteringQuality(filteringQuality: number);
  9769. /**
  9770. * Gets if the current filter is set to "PCSS" (contact hardening).
  9771. */
  9772. get useContactHardeningShadow(): boolean;
  9773. /**
  9774. * Sets the current filter to "PCSS" (contact hardening).
  9775. */
  9776. set useContactHardeningShadow(value: boolean);
  9777. protected _contactHardeningLightSizeUVRatio: number;
  9778. /**
  9779. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9780. * Using a ratio helps keeping shape stability independently of the map size.
  9781. *
  9782. * It does not account for the light projection as it was having too much
  9783. * instability during the light setup or during light position changes.
  9784. *
  9785. * Only valid if useContactHardeningShadow is true.
  9786. */
  9787. get contactHardeningLightSizeUVRatio(): number;
  9788. /**
  9789. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9790. * Using a ratio helps keeping shape stability independently of the map size.
  9791. *
  9792. * It does not account for the light projection as it was having too much
  9793. * instability during the light setup or during light position changes.
  9794. *
  9795. * Only valid if useContactHardeningShadow is true.
  9796. */
  9797. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9798. protected _darkness: number;
  9799. /** Gets or sets the actual darkness of a shadow */
  9800. get darkness(): number;
  9801. set darkness(value: number);
  9802. /**
  9803. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9804. * 0 means strongest and 1 would means no shadow.
  9805. * @returns the darkness.
  9806. */
  9807. getDarkness(): number;
  9808. /**
  9809. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9810. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9811. * @returns the shadow generator allowing fluent coding.
  9812. */
  9813. setDarkness(darkness: number): ShadowGenerator;
  9814. protected _transparencyShadow: boolean;
  9815. /** Gets or sets the ability to have transparent shadow */
  9816. get transparencyShadow(): boolean;
  9817. set transparencyShadow(value: boolean);
  9818. /**
  9819. * Sets the ability to have transparent shadow (boolean).
  9820. * @param transparent True if transparent else False
  9821. * @returns the shadow generator allowing fluent coding
  9822. */
  9823. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9824. protected _shadowMap: Nullable<RenderTargetTexture>;
  9825. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9826. /**
  9827. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9828. * @returns The render target texture if present otherwise, null
  9829. */
  9830. getShadowMap(): Nullable<RenderTargetTexture>;
  9831. /**
  9832. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9833. * @returns The render target texture if the shadow map is present otherwise, null
  9834. */
  9835. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9836. /**
  9837. * Gets the class name of that object
  9838. * @returns "ShadowGenerator"
  9839. */
  9840. getClassName(): string;
  9841. /**
  9842. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9843. * @param mesh Mesh to add
  9844. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9845. * @returns the Shadow Generator itself
  9846. */
  9847. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9848. /**
  9849. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9850. * @param mesh Mesh to remove
  9851. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9852. * @returns the Shadow Generator itself
  9853. */
  9854. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9855. /**
  9856. * Controls the extent to which the shadows fade out at the edge of the frustum
  9857. */
  9858. frustumEdgeFalloff: number;
  9859. protected _light: IShadowLight;
  9860. /**
  9861. * Returns the associated light object.
  9862. * @returns the light generating the shadow
  9863. */
  9864. getLight(): IShadowLight;
  9865. /**
  9866. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9867. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9868. * It might on the other hand introduce peter panning.
  9869. */
  9870. forceBackFacesOnly: boolean;
  9871. protected _scene: Scene;
  9872. protected _lightDirection: Vector3;
  9873. protected _effect: Effect;
  9874. protected _viewMatrix: Matrix;
  9875. protected _projectionMatrix: Matrix;
  9876. protected _transformMatrix: Matrix;
  9877. protected _cachedPosition: Vector3;
  9878. protected _cachedDirection: Vector3;
  9879. protected _cachedDefines: string;
  9880. protected _currentRenderID: number;
  9881. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9882. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9883. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9884. protected _blurPostProcesses: PostProcess[];
  9885. protected _mapSize: number;
  9886. protected _currentFaceIndex: number;
  9887. protected _currentFaceIndexCache: number;
  9888. protected _textureType: number;
  9889. protected _defaultTextureMatrix: Matrix;
  9890. protected _storedUniqueId: Nullable<number>;
  9891. /** @hidden */
  9892. static _SceneComponentInitialization: (scene: Scene) => void;
  9893. /**
  9894. * Creates a ShadowGenerator object.
  9895. * A ShadowGenerator is the required tool to use the shadows.
  9896. * Each light casting shadows needs to use its own ShadowGenerator.
  9897. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9898. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9899. * @param light The light object generating the shadows.
  9900. * @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.
  9901. */
  9902. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9903. protected _initializeGenerator(): void;
  9904. protected _createTargetRenderTexture(): void;
  9905. protected _initializeShadowMap(): void;
  9906. protected _initializeBlurRTTAndPostProcesses(): void;
  9907. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  9908. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  9909. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  9910. protected _applyFilterValues(): void;
  9911. /**
  9912. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9913. * @param onCompiled Callback triggered at the and of the effects compilation
  9914. * @param options Sets of optional options forcing the compilation with different modes
  9915. */
  9916. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9917. useInstances: boolean;
  9918. }>): void;
  9919. /**
  9920. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9921. * @param options Sets of optional options forcing the compilation with different modes
  9922. * @returns A promise that resolves when the compilation completes
  9923. */
  9924. forceCompilationAsync(options?: Partial<{
  9925. useInstances: boolean;
  9926. }>): Promise<void>;
  9927. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. protected _disposeBlurPostProcesses(): void;
  9960. protected _disposeRTTandPostProcesses(): void;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  9976. * @returns The parsed shadow generator
  9977. */
  9978. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  9979. }
  9980. }
  9981. declare module BABYLON {
  9982. /**
  9983. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9984. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9985. * 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.
  9986. */
  9987. export abstract class Light extends Node {
  9988. /**
  9989. * Falloff Default: light is falling off following the material specification:
  9990. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9991. */
  9992. static readonly FALLOFF_DEFAULT: number;
  9993. /**
  9994. * Falloff Physical: light is falling off following the inverse squared distance law.
  9995. */
  9996. static readonly FALLOFF_PHYSICAL: number;
  9997. /**
  9998. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9999. * to enhance interoperability with other engines.
  10000. */
  10001. static readonly FALLOFF_GLTF: number;
  10002. /**
  10003. * Falloff Standard: light is falling off like in the standard material
  10004. * to enhance interoperability with other materials.
  10005. */
  10006. static readonly FALLOFF_STANDARD: number;
  10007. /**
  10008. * If every light affecting the material is in this lightmapMode,
  10009. * material.lightmapTexture adds or multiplies
  10010. * (depends on material.useLightmapAsShadowmap)
  10011. * after every other light calculations.
  10012. */
  10013. static readonly LIGHTMAP_DEFAULT: number;
  10014. /**
  10015. * material.lightmapTexture as only diffuse lighting from this light
  10016. * adds only specular lighting from this light
  10017. * adds dynamic shadows
  10018. */
  10019. static readonly LIGHTMAP_SPECULAR: number;
  10020. /**
  10021. * material.lightmapTexture as only lighting
  10022. * no light calculation from this light
  10023. * only adds dynamic shadows from this light
  10024. */
  10025. static readonly LIGHTMAP_SHADOWSONLY: number;
  10026. /**
  10027. * Each light type uses the default quantity according to its type:
  10028. * point/spot lights use luminous intensity
  10029. * directional lights use illuminance
  10030. */
  10031. static readonly INTENSITYMODE_AUTOMATIC: number;
  10032. /**
  10033. * lumen (lm)
  10034. */
  10035. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10036. /**
  10037. * candela (lm/sr)
  10038. */
  10039. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10040. /**
  10041. * lux (lm/m^2)
  10042. */
  10043. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10044. /**
  10045. * nit (cd/m^2)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINANCE: number;
  10048. /**
  10049. * Light type const id of the point light.
  10050. */
  10051. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10052. /**
  10053. * Light type const id of the directional light.
  10054. */
  10055. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10056. /**
  10057. * Light type const id of the spot light.
  10058. */
  10059. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10060. /**
  10061. * Light type const id of the hemispheric light.
  10062. */
  10063. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10064. /**
  10065. * Diffuse gives the basic color to an object.
  10066. */
  10067. diffuse: Color3;
  10068. /**
  10069. * Specular produces a highlight color on an object.
  10070. * Note: This is note affecting PBR materials.
  10071. */
  10072. specular: Color3;
  10073. /**
  10074. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10075. * falling off base on range or angle.
  10076. * This can be set to any values in Light.FALLOFF_x.
  10077. *
  10078. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10079. * other types of materials.
  10080. */
  10081. falloffType: number;
  10082. /**
  10083. * Strength of the light.
  10084. * Note: By default it is define in the framework own unit.
  10085. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10086. */
  10087. intensity: number;
  10088. private _range;
  10089. protected _inverseSquaredRange: number;
  10090. /**
  10091. * Defines how far from the source the light is impacting in scene units.
  10092. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10093. */
  10094. get range(): number;
  10095. /**
  10096. * Defines how far from the source the light is impacting in scene units.
  10097. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10098. */
  10099. set range(value: number);
  10100. /**
  10101. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10102. * of light.
  10103. */
  10104. private _photometricScale;
  10105. private _intensityMode;
  10106. /**
  10107. * Gets the photometric scale used to interpret the intensity.
  10108. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10109. */
  10110. get intensityMode(): number;
  10111. /**
  10112. * Sets the photometric scale used to interpret the intensity.
  10113. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10114. */
  10115. set intensityMode(value: number);
  10116. private _radius;
  10117. /**
  10118. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10119. */
  10120. get radius(): number;
  10121. /**
  10122. * sets the light radius used by PBR Materials to simulate soft area lights.
  10123. */
  10124. set radius(value: number);
  10125. private _renderPriority;
  10126. /**
  10127. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10128. * exceeding the number allowed of the materials.
  10129. */
  10130. renderPriority: number;
  10131. private _shadowEnabled;
  10132. /**
  10133. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10134. * the current shadow generator.
  10135. */
  10136. get shadowEnabled(): boolean;
  10137. /**
  10138. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. set shadowEnabled(value: boolean);
  10142. private _includedOnlyMeshes;
  10143. /**
  10144. * Gets the only meshes impacted by this light.
  10145. */
  10146. get includedOnlyMeshes(): AbstractMesh[];
  10147. /**
  10148. * Sets the only meshes impacted by this light.
  10149. */
  10150. set includedOnlyMeshes(value: AbstractMesh[]);
  10151. private _excludedMeshes;
  10152. /**
  10153. * Gets the meshes not impacted by this light.
  10154. */
  10155. get excludedMeshes(): AbstractMesh[];
  10156. /**
  10157. * Sets the meshes not impacted by this light.
  10158. */
  10159. set excludedMeshes(value: AbstractMesh[]);
  10160. private _excludeWithLayerMask;
  10161. /**
  10162. * Gets the layer id use to find what meshes are not impacted by the light.
  10163. * Inactive if 0
  10164. */
  10165. get excludeWithLayerMask(): number;
  10166. /**
  10167. * Sets the layer id use to find what meshes are not impacted by the light.
  10168. * Inactive if 0
  10169. */
  10170. set excludeWithLayerMask(value: number);
  10171. private _includeOnlyWithLayerMask;
  10172. /**
  10173. * Gets the layer id use to find what meshes are impacted by the light.
  10174. * Inactive if 0
  10175. */
  10176. get includeOnlyWithLayerMask(): number;
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. set includeOnlyWithLayerMask(value: number);
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. get lightmapMode(): number;
  10187. /**
  10188. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10189. */
  10190. set lightmapMode(value: number);
  10191. /**
  10192. * Shadow generator associted to the light.
  10193. * @hidden Internal use only.
  10194. */
  10195. _shadowGenerator: Nullable<IShadowGenerator>;
  10196. /**
  10197. * @hidden Internal use only.
  10198. */
  10199. _excludedMeshesIds: string[];
  10200. /**
  10201. * @hidden Internal use only.
  10202. */
  10203. _includedOnlyMeshesIds: string[];
  10204. /**
  10205. * The current light unifom buffer.
  10206. * @hidden Internal use only.
  10207. */
  10208. _uniformBuffer: UniformBuffer;
  10209. /** @hidden */
  10210. _renderId: number;
  10211. /**
  10212. * Creates a Light object in the scene.
  10213. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10214. * @param name The firendly name of the light
  10215. * @param scene The scene the light belongs too
  10216. */
  10217. constructor(name: string, scene: Scene);
  10218. protected abstract _buildUniformLayout(): void;
  10219. /**
  10220. * Sets the passed Effect "effect" with the Light information.
  10221. * @param effect The effect to update
  10222. * @param lightIndex The index of the light in the effect to update
  10223. * @returns The light
  10224. */
  10225. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10226. /**
  10227. * Sets the passed Effect "effect" with the Light textures.
  10228. * @param effect The effect to update
  10229. * @param lightIndex The index of the light in the effect to update
  10230. * @returns The light
  10231. */
  10232. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10233. /**
  10234. * Binds the lights information from the scene to the effect for the given mesh.
  10235. * @param lightIndex Light index
  10236. * @param scene The scene where the light belongs to
  10237. * @param effect The effect we are binding the data to
  10238. * @param useSpecular Defines if specular is supported
  10239. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10240. */
  10241. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10242. /**
  10243. * Sets the passed Effect "effect" with the Light information.
  10244. * @param effect The effect to update
  10245. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10246. * @returns The light
  10247. */
  10248. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10249. /**
  10250. * Returns the string "Light".
  10251. * @returns the class name
  10252. */
  10253. getClassName(): string;
  10254. /** @hidden */
  10255. readonly _isLight: boolean;
  10256. /**
  10257. * Converts the light information to a readable string for debug purpose.
  10258. * @param fullDetails Supports for multiple levels of logging within scene loading
  10259. * @returns the human readable light info
  10260. */
  10261. toString(fullDetails?: boolean): string;
  10262. /** @hidden */
  10263. protected _syncParentEnabledState(): void;
  10264. /**
  10265. * Set the enabled state of this node.
  10266. * @param value - the new enabled state
  10267. */
  10268. setEnabled(value: boolean): void;
  10269. /**
  10270. * Returns the Light associated shadow generator if any.
  10271. * @return the associated shadow generator.
  10272. */
  10273. getShadowGenerator(): Nullable<IShadowGenerator>;
  10274. /**
  10275. * Returns a Vector3, the absolute light position in the World.
  10276. * @returns the world space position of the light
  10277. */
  10278. getAbsolutePosition(): Vector3;
  10279. /**
  10280. * Specifies if the light will affect the passed mesh.
  10281. * @param mesh The mesh to test against the light
  10282. * @return true the mesh is affected otherwise, false.
  10283. */
  10284. canAffectMesh(mesh: AbstractMesh): boolean;
  10285. /**
  10286. * Sort function to order lights for rendering.
  10287. * @param a First Light object to compare to second.
  10288. * @param b Second Light object to compare first.
  10289. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10290. */
  10291. static CompareLightsPriority(a: Light, b: Light): number;
  10292. /**
  10293. * Releases resources associated with this node.
  10294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10296. */
  10297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10298. /**
  10299. * Returns the light type ID (integer).
  10300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10301. */
  10302. getTypeID(): number;
  10303. /**
  10304. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10305. * @returns the scaled intensity in intensity mode unit
  10306. */
  10307. getScaledIntensity(): number;
  10308. /**
  10309. * Returns a new Light object, named "name", from the current one.
  10310. * @param name The name of the cloned light
  10311. * @returns the new created light
  10312. */
  10313. clone(name: string): Nullable<Light>;
  10314. /**
  10315. * Serializes the current light into a Serialization object.
  10316. * @returns the serialized object.
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10321. * This new light is named "name" and added to the passed scene.
  10322. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10323. * @param name The friendly name of the light
  10324. * @param scene The scene the new light will belong to
  10325. * @returns the constructor function
  10326. */
  10327. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10328. /**
  10329. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10330. * @param parsedLight The JSON representation of the light
  10331. * @param scene The scene to create the parsed light in
  10332. * @returns the created light after parsing
  10333. */
  10334. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10335. private _hookArrayForExcluded;
  10336. private _hookArrayForIncludedOnly;
  10337. private _resyncMeshes;
  10338. /**
  10339. * Forces the meshes to update their light related information in their rendering used effects
  10340. * @hidden Internal Use Only
  10341. */
  10342. _markMeshesAsLightDirty(): void;
  10343. /**
  10344. * Recomputes the cached photometric scale if needed.
  10345. */
  10346. private _computePhotometricScale;
  10347. /**
  10348. * Returns the Photometric Scale according to the light type and intensity mode.
  10349. */
  10350. private _getPhotometricScale;
  10351. /**
  10352. * Reorder the light in the scene according to their defined priority.
  10353. * @hidden Internal Use Only
  10354. */
  10355. _reorderLightsInScene(): void;
  10356. /**
  10357. * Prepares the list of defines specific to the light type.
  10358. * @param defines the list of defines
  10359. * @param lightIndex defines the index of the light for the effect
  10360. */
  10361. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10362. }
  10363. }
  10364. declare module BABYLON {
  10365. /**
  10366. * Interface used to define Action
  10367. */
  10368. export interface IAction {
  10369. /**
  10370. * Trigger for the action
  10371. */
  10372. trigger: number;
  10373. /** Options of the trigger */
  10374. triggerOptions: any;
  10375. /**
  10376. * Gets the trigger parameters
  10377. * @returns the trigger parameters
  10378. */
  10379. getTriggerParameter(): any;
  10380. /**
  10381. * Internal only - executes current action event
  10382. * @hidden
  10383. */
  10384. _executeCurrent(evt?: ActionEvent): void;
  10385. /**
  10386. * Serialize placeholder for child classes
  10387. * @param parent of child
  10388. * @returns the serialized object
  10389. */
  10390. serialize(parent: any): any;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. _prepare(): void;
  10396. /**
  10397. * Internal only - manager for action
  10398. * @hidden
  10399. */
  10400. _actionManager: AbstractActionManager;
  10401. /**
  10402. * Adds action to chain of actions, may be a DoNothingAction
  10403. * @param action defines the next action to execute
  10404. * @returns The action passed in
  10405. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10406. */
  10407. then(action: IAction): IAction;
  10408. }
  10409. /**
  10410. * The action to be carried out following a trigger
  10411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10412. */
  10413. export class Action implements IAction {
  10414. /** the trigger, with or without parameters, for the action */
  10415. triggerOptions: any;
  10416. /**
  10417. * Trigger for the action
  10418. */
  10419. trigger: number;
  10420. /**
  10421. * Internal only - manager for action
  10422. * @hidden
  10423. */
  10424. _actionManager: ActionManager;
  10425. private _nextActiveAction;
  10426. private _child;
  10427. private _condition?;
  10428. private _triggerParameter;
  10429. /**
  10430. * An event triggered prior to action being executed.
  10431. */
  10432. onBeforeExecuteObservable: Observable<Action>;
  10433. /**
  10434. * Creates a new Action
  10435. * @param triggerOptions the trigger, with or without parameters, for the action
  10436. * @param condition an optional determinant of action
  10437. */
  10438. constructor(
  10439. /** the trigger, with or without parameters, for the action */
  10440. triggerOptions: any, condition?: Condition);
  10441. /**
  10442. * Internal only
  10443. * @hidden
  10444. */
  10445. _prepare(): void;
  10446. /**
  10447. * Gets the trigger parameters
  10448. * @returns the trigger parameters
  10449. */
  10450. getTriggerParameter(): any;
  10451. /**
  10452. * Internal only - executes current action event
  10453. * @hidden
  10454. */
  10455. _executeCurrent(evt?: ActionEvent): void;
  10456. /**
  10457. * Execute placeholder for child classes
  10458. * @param evt optional action event
  10459. */
  10460. execute(evt?: ActionEvent): void;
  10461. /**
  10462. * Skips to next active action
  10463. */
  10464. skipToNextActiveAction(): void;
  10465. /**
  10466. * Adds action to chain of actions, may be a DoNothingAction
  10467. * @param action defines the next action to execute
  10468. * @returns The action passed in
  10469. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10470. */
  10471. then(action: Action): Action;
  10472. /**
  10473. * Internal only
  10474. * @hidden
  10475. */
  10476. _getProperty(propertyPath: string): string;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getEffectiveTarget(target: any, propertyPath: string): any;
  10482. /**
  10483. * Serialize placeholder for child classes
  10484. * @param parent of child
  10485. * @returns the serialized object
  10486. */
  10487. serialize(parent: any): any;
  10488. /**
  10489. * Internal only called by serialize
  10490. * @hidden
  10491. */
  10492. protected _serialize(serializedAction: any, parent?: any): any;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. static _SerializeValueAsString: (value: any) => string;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. static _GetTargetProperty: (target: Node | Scene) => {
  10503. name: string;
  10504. targetType: string;
  10505. value: string;
  10506. };
  10507. }
  10508. }
  10509. declare module BABYLON {
  10510. /**
  10511. * A Condition applied to an Action
  10512. */
  10513. export class Condition {
  10514. /**
  10515. * Internal only - manager for action
  10516. * @hidden
  10517. */
  10518. _actionManager: ActionManager;
  10519. /**
  10520. * Internal only
  10521. * @hidden
  10522. */
  10523. _evaluationId: number;
  10524. /**
  10525. * Internal only
  10526. * @hidden
  10527. */
  10528. _currentResult: boolean;
  10529. /**
  10530. * Creates a new Condition
  10531. * @param actionManager the manager of the action the condition is applied to
  10532. */
  10533. constructor(actionManager: ActionManager);
  10534. /**
  10535. * Check if the current condition is valid
  10536. * @returns a boolean
  10537. */
  10538. isValid(): boolean;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _getProperty(propertyPath: string): string;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. _getEffectiveTarget(target: any, propertyPath: string): any;
  10549. /**
  10550. * Serialize placeholder for child classes
  10551. * @returns the serialized object
  10552. */
  10553. serialize(): any;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. protected _serialize(serializedCondition: any): any;
  10559. }
  10560. /**
  10561. * Defines specific conditional operators as extensions of Condition
  10562. */
  10563. export class ValueCondition extends Condition {
  10564. /** path to specify the property of the target the conditional operator uses */
  10565. propertyPath: string;
  10566. /** the value compared by the conditional operator against the current value of the property */
  10567. value: any;
  10568. /** the conditional operator, default ValueCondition.IsEqual */
  10569. operator: number;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. private static _IsEqual;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. private static _IsDifferent;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private static _IsGreater;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private static _IsLesser;
  10590. /**
  10591. * returns the number for IsEqual
  10592. */
  10593. static get IsEqual(): number;
  10594. /**
  10595. * Returns the number for IsDifferent
  10596. */
  10597. static get IsDifferent(): number;
  10598. /**
  10599. * Returns the number for IsGreater
  10600. */
  10601. static get IsGreater(): number;
  10602. /**
  10603. * Returns the number for IsLesser
  10604. */
  10605. static get IsLesser(): number;
  10606. /**
  10607. * Internal only The action manager for the condition
  10608. * @hidden
  10609. */
  10610. _actionManager: ActionManager;
  10611. /**
  10612. * Internal only
  10613. * @hidden
  10614. */
  10615. private _target;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. private _effectiveTarget;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. private _property;
  10626. /**
  10627. * Creates a new ValueCondition
  10628. * @param actionManager manager for the action the condition applies to
  10629. * @param target for the action
  10630. * @param propertyPath path to specify the property of the target the conditional operator uses
  10631. * @param value the value compared by the conditional operator against the current value of the property
  10632. * @param operator the conditional operator, default ValueCondition.IsEqual
  10633. */
  10634. constructor(actionManager: ActionManager, target: any,
  10635. /** path to specify the property of the target the conditional operator uses */
  10636. propertyPath: string,
  10637. /** the value compared by the conditional operator against the current value of the property */
  10638. value: any,
  10639. /** the conditional operator, default ValueCondition.IsEqual */
  10640. operator?: number);
  10641. /**
  10642. * Compares the given value with the property value for the specified conditional operator
  10643. * @returns the result of the comparison
  10644. */
  10645. isValid(): boolean;
  10646. /**
  10647. * Serialize the ValueCondition into a JSON compatible object
  10648. * @returns serialization object
  10649. */
  10650. serialize(): any;
  10651. /**
  10652. * Gets the name of the conditional operator for the ValueCondition
  10653. * @param operator the conditional operator
  10654. * @returns the name
  10655. */
  10656. static GetOperatorName(operator: number): string;
  10657. }
  10658. /**
  10659. * Defines a predicate condition as an extension of Condition
  10660. */
  10661. export class PredicateCondition extends Condition {
  10662. /** defines the predicate function used to validate the condition */
  10663. predicate: () => boolean;
  10664. /**
  10665. * Internal only - manager for action
  10666. * @hidden
  10667. */
  10668. _actionManager: ActionManager;
  10669. /**
  10670. * Creates a new PredicateCondition
  10671. * @param actionManager manager for the action the condition applies to
  10672. * @param predicate defines the predicate function used to validate the condition
  10673. */
  10674. constructor(actionManager: ActionManager,
  10675. /** defines the predicate function used to validate the condition */
  10676. predicate: () => boolean);
  10677. /**
  10678. * @returns the validity of the predicate condition
  10679. */
  10680. isValid(): boolean;
  10681. }
  10682. /**
  10683. * Defines a state condition as an extension of Condition
  10684. */
  10685. export class StateCondition extends Condition {
  10686. /** Value to compare with target state */
  10687. value: string;
  10688. /**
  10689. * Internal only - manager for action
  10690. * @hidden
  10691. */
  10692. _actionManager: ActionManager;
  10693. /**
  10694. * Internal only
  10695. * @hidden
  10696. */
  10697. private _target;
  10698. /**
  10699. * Creates a new StateCondition
  10700. * @param actionManager manager for the action the condition applies to
  10701. * @param target of the condition
  10702. * @param value to compare with target state
  10703. */
  10704. constructor(actionManager: ActionManager, target: any,
  10705. /** Value to compare with target state */
  10706. value: string);
  10707. /**
  10708. * Gets a boolean indicating if the current condition is met
  10709. * @returns the validity of the state
  10710. */
  10711. isValid(): boolean;
  10712. /**
  10713. * Serialize the StateCondition into a JSON compatible object
  10714. * @returns serialization object
  10715. */
  10716. serialize(): any;
  10717. }
  10718. }
  10719. declare module BABYLON {
  10720. /**
  10721. * This defines an action responsible to toggle a boolean once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class SwitchBooleanAction extends Action {
  10725. /**
  10726. * The path to the boolean property in the target object
  10727. */
  10728. propertyPath: string;
  10729. private _target;
  10730. private _effectiveTarget;
  10731. private _property;
  10732. /**
  10733. * Instantiate the action
  10734. * @param triggerOptions defines the trigger options
  10735. * @param target defines the object containing the boolean
  10736. * @param propertyPath defines the path to the boolean property in the target object
  10737. * @param condition defines the trigger related conditions
  10738. */
  10739. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10740. /** @hidden */
  10741. _prepare(): void;
  10742. /**
  10743. * Execute the action toggle the boolean value.
  10744. */
  10745. execute(): void;
  10746. /**
  10747. * Serializes the actions and its related information.
  10748. * @param parent defines the object to serialize in
  10749. * @returns the serialized object
  10750. */
  10751. serialize(parent: any): any;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set a the state field of the target
  10755. * to a desired value once triggered.
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10757. */
  10758. export class SetStateAction extends Action {
  10759. /**
  10760. * The value to store in the state field.
  10761. */
  10762. value: string;
  10763. private _target;
  10764. /**
  10765. * Instantiate the action
  10766. * @param triggerOptions defines the trigger options
  10767. * @param target defines the object containing the state property
  10768. * @param value defines the value to store in the state field
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10772. /**
  10773. * Execute the action and store the value on the target state property.
  10774. */
  10775. execute(): void;
  10776. /**
  10777. * Serializes the actions and its related information.
  10778. * @param parent defines the object to serialize in
  10779. * @returns the serialized object
  10780. */
  10781. serialize(parent: any): any;
  10782. }
  10783. /**
  10784. * This defines an action responsible to set a property of the target
  10785. * to a desired value once triggered.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10787. */
  10788. export class SetValueAction extends Action {
  10789. /**
  10790. * The path of the property to set in the target.
  10791. */
  10792. propertyPath: string;
  10793. /**
  10794. * The value to set in the property
  10795. */
  10796. value: any;
  10797. private _target;
  10798. private _effectiveTarget;
  10799. private _property;
  10800. /**
  10801. * Instantiate the action
  10802. * @param triggerOptions defines the trigger options
  10803. * @param target defines the object containing the property
  10804. * @param propertyPath defines the path of the property to set in the target
  10805. * @param value defines the value to set in the property
  10806. * @param condition defines the trigger related conditions
  10807. */
  10808. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10809. /** @hidden */
  10810. _prepare(): void;
  10811. /**
  10812. * Execute the action and set the targetted property to the desired value.
  10813. */
  10814. execute(): void;
  10815. /**
  10816. * Serializes the actions and its related information.
  10817. * @param parent defines the object to serialize in
  10818. * @returns the serialized object
  10819. */
  10820. serialize(parent: any): any;
  10821. }
  10822. /**
  10823. * This defines an action responsible to increment the target value
  10824. * to a desired value once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class IncrementValueAction extends Action {
  10828. /**
  10829. * The path of the property to increment in the target.
  10830. */
  10831. propertyPath: string;
  10832. /**
  10833. * The value we should increment the property by.
  10834. */
  10835. value: any;
  10836. private _target;
  10837. private _effectiveTarget;
  10838. private _property;
  10839. /**
  10840. * Instantiate the action
  10841. * @param triggerOptions defines the trigger options
  10842. * @param target defines the object containing the property
  10843. * @param propertyPath defines the path of the property to increment in the target
  10844. * @param value defines the value value we should increment the property by
  10845. * @param condition defines the trigger related conditions
  10846. */
  10847. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10848. /** @hidden */
  10849. _prepare(): void;
  10850. /**
  10851. * Execute the action and increment the target of the value amount.
  10852. */
  10853. execute(): void;
  10854. /**
  10855. * Serializes the actions and its related information.
  10856. * @param parent defines the object to serialize in
  10857. * @returns the serialized object
  10858. */
  10859. serialize(parent: any): any;
  10860. }
  10861. /**
  10862. * This defines an action responsible to start an animation once triggered.
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10864. */
  10865. export class PlayAnimationAction extends Action {
  10866. /**
  10867. * Where the animation should start (animation frame)
  10868. */
  10869. from: number;
  10870. /**
  10871. * Where the animation should stop (animation frame)
  10872. */
  10873. to: number;
  10874. /**
  10875. * Define if the animation should loop or stop after the first play.
  10876. */
  10877. loop?: boolean;
  10878. private _target;
  10879. /**
  10880. * Instantiate the action
  10881. * @param triggerOptions defines the trigger options
  10882. * @param target defines the target animation or animation name
  10883. * @param from defines from where the animation should start (animation frame)
  10884. * @param end defines where the animation should stop (animation frame)
  10885. * @param loop defines if the animation should loop or stop after the first play
  10886. * @param condition defines the trigger related conditions
  10887. */
  10888. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10889. /** @hidden */
  10890. _prepare(): void;
  10891. /**
  10892. * Execute the action and play the animation.
  10893. */
  10894. execute(): void;
  10895. /**
  10896. * Serializes the actions and its related information.
  10897. * @param parent defines the object to serialize in
  10898. * @returns the serialized object
  10899. */
  10900. serialize(parent: any): any;
  10901. }
  10902. /**
  10903. * This defines an action responsible to stop an animation once triggered.
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10905. */
  10906. export class StopAnimationAction extends Action {
  10907. private _target;
  10908. /**
  10909. * Instantiate the action
  10910. * @param triggerOptions defines the trigger options
  10911. * @param target defines the target animation or animation name
  10912. * @param condition defines the trigger related conditions
  10913. */
  10914. constructor(triggerOptions: any, target: any, condition?: Condition);
  10915. /** @hidden */
  10916. _prepare(): void;
  10917. /**
  10918. * Execute the action and stop the animation.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible that does nothing once triggered.
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10931. */
  10932. export class DoNothingAction extends Action {
  10933. /**
  10934. * Instantiate the action
  10935. * @param triggerOptions defines the trigger options
  10936. * @param condition defines the trigger related conditions
  10937. */
  10938. constructor(triggerOptions?: any, condition?: Condition);
  10939. /**
  10940. * Execute the action and do nothing.
  10941. */
  10942. execute(): void;
  10943. /**
  10944. * Serializes the actions and its related information.
  10945. * @param parent defines the object to serialize in
  10946. * @returns the serialized object
  10947. */
  10948. serialize(parent: any): any;
  10949. }
  10950. /**
  10951. * This defines an action responsible to trigger several actions once triggered.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10953. */
  10954. export class CombineAction extends Action {
  10955. /**
  10956. * The list of aggregated animations to run.
  10957. */
  10958. children: Action[];
  10959. /**
  10960. * Instantiate the action
  10961. * @param triggerOptions defines the trigger options
  10962. * @param children defines the list of aggregated animations to run
  10963. * @param condition defines the trigger related conditions
  10964. */
  10965. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10966. /** @hidden */
  10967. _prepare(): void;
  10968. /**
  10969. * Execute the action and executes all the aggregated actions.
  10970. */
  10971. execute(evt: ActionEvent): void;
  10972. /**
  10973. * Serializes the actions and its related information.
  10974. * @param parent defines the object to serialize in
  10975. * @returns the serialized object
  10976. */
  10977. serialize(parent: any): any;
  10978. }
  10979. /**
  10980. * This defines an action responsible to run code (external event) once triggered.
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10982. */
  10983. export class ExecuteCodeAction extends Action {
  10984. /**
  10985. * The callback function to run.
  10986. */
  10987. func: (evt: ActionEvent) => void;
  10988. /**
  10989. * Instantiate the action
  10990. * @param triggerOptions defines the trigger options
  10991. * @param func defines the callback function to run
  10992. * @param condition defines the trigger related conditions
  10993. */
  10994. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10995. /**
  10996. * Execute the action and run the attached code.
  10997. */
  10998. execute(evt: ActionEvent): void;
  10999. }
  11000. /**
  11001. * This defines an action responsible to set the parent property of the target once triggered.
  11002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11003. */
  11004. export class SetParentAction extends Action {
  11005. private _parent;
  11006. private _target;
  11007. /**
  11008. * Instantiate the action
  11009. * @param triggerOptions defines the trigger options
  11010. * @param target defines the target containing the parent property
  11011. * @param parent defines from where the animation should start (animation frame)
  11012. * @param condition defines the trigger related conditions
  11013. */
  11014. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11015. /** @hidden */
  11016. _prepare(): void;
  11017. /**
  11018. * Execute the action and set the parent property.
  11019. */
  11020. execute(): void;
  11021. /**
  11022. * Serializes the actions and its related information.
  11023. * @param parent defines the object to serialize in
  11024. * @returns the serialized object
  11025. */
  11026. serialize(parent: any): any;
  11027. }
  11028. }
  11029. declare module BABYLON {
  11030. /**
  11031. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11032. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11034. */
  11035. export class ActionManager extends AbstractActionManager {
  11036. /**
  11037. * Nothing
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly NothingTrigger: number;
  11041. /**
  11042. * On pick
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnPickTrigger: number;
  11046. /**
  11047. * On left pick
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnLeftPickTrigger: number;
  11051. /**
  11052. * On right pick
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnRightPickTrigger: number;
  11056. /**
  11057. * On center pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnCenterPickTrigger: number;
  11061. /**
  11062. * On pick down
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnPickDownTrigger: number;
  11066. /**
  11067. * On double pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnDoublePickTrigger: number;
  11071. /**
  11072. * On pick up
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickUpTrigger: number;
  11076. /**
  11077. * On pick out.
  11078. * This trigger will only be raised if you also declared a OnPickDown
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnPickOutTrigger: number;
  11082. /**
  11083. * On long press
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnLongPressTrigger: number;
  11087. /**
  11088. * On pointer over
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnPointerOverTrigger: number;
  11092. /**
  11093. * On pointer out
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnPointerOutTrigger: number;
  11097. /**
  11098. * On every frame
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnEveryFrameTrigger: number;
  11102. /**
  11103. * On intersection enter
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnIntersectionEnterTrigger: number;
  11107. /**
  11108. * On intersection exit
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnIntersectionExitTrigger: number;
  11112. /**
  11113. * On key down
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnKeyDownTrigger: number;
  11117. /**
  11118. * On key up
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnKeyUpTrigger: number;
  11122. private _scene;
  11123. /**
  11124. * Creates a new action manager
  11125. * @param scene defines the hosting scene
  11126. */
  11127. constructor(scene: Scene);
  11128. /**
  11129. * Releases all associated resources
  11130. */
  11131. dispose(): void;
  11132. /**
  11133. * Gets hosting scene
  11134. * @returns the hosting scene
  11135. */
  11136. getScene(): Scene;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers
  11139. * @param triggers defines the triggers to be tested
  11140. * @return a boolean indicating whether one (or more) of the triggers is handled
  11141. */
  11142. hasSpecificTriggers(triggers: number[]): boolean;
  11143. /**
  11144. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11145. * speed.
  11146. * @param triggerA defines the trigger to be tested
  11147. * @param triggerB defines the trigger to be tested
  11148. * @return a boolean indicating whether one (or more) of the triggers is handled
  11149. */
  11150. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11151. /**
  11152. * Does this action manager handles actions of a given trigger
  11153. * @param trigger defines the trigger to be tested
  11154. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11155. * @return whether the trigger is handled
  11156. */
  11157. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11158. /**
  11159. * Does this action manager has pointer triggers
  11160. */
  11161. get hasPointerTriggers(): boolean;
  11162. /**
  11163. * Does this action manager has pick triggers
  11164. */
  11165. get hasPickTriggers(): boolean;
  11166. /**
  11167. * Registers an action to this action manager
  11168. * @param action defines the action to be registered
  11169. * @return the action amended (prepared) after registration
  11170. */
  11171. registerAction(action: IAction): Nullable<IAction>;
  11172. /**
  11173. * Unregisters an action to this action manager
  11174. * @param action defines the action to be unregistered
  11175. * @return a boolean indicating whether the action has been unregistered
  11176. */
  11177. unregisterAction(action: IAction): Boolean;
  11178. /**
  11179. * Process a specific trigger
  11180. * @param trigger defines the trigger to process
  11181. * @param evt defines the event details to be processed
  11182. */
  11183. processTrigger(trigger: number, evt?: IActionEvent): void;
  11184. /** @hidden */
  11185. _getEffectiveTarget(target: any, propertyPath: string): any;
  11186. /** @hidden */
  11187. _getProperty(propertyPath: string): string;
  11188. /**
  11189. * Serialize this manager to a JSON object
  11190. * @param name defines the property name to store this manager
  11191. * @returns a JSON representation of this manager
  11192. */
  11193. serialize(name: string): any;
  11194. /**
  11195. * Creates a new ActionManager from a JSON data
  11196. * @param parsedActions defines the JSON data to read from
  11197. * @param object defines the hosting mesh
  11198. * @param scene defines the hosting scene
  11199. */
  11200. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11201. /**
  11202. * Get a trigger name by index
  11203. * @param trigger defines the trigger index
  11204. * @returns a trigger name
  11205. */
  11206. static GetTriggerName(trigger: number): string;
  11207. }
  11208. }
  11209. declare module BABYLON {
  11210. /**
  11211. * Class representing a ray with position and direction
  11212. */
  11213. export class Ray {
  11214. /** origin point */
  11215. origin: Vector3;
  11216. /** direction */
  11217. direction: Vector3;
  11218. /** length of the ray */
  11219. length: number;
  11220. private static readonly TmpVector3;
  11221. private _tmpRay;
  11222. /**
  11223. * Creates a new ray
  11224. * @param origin origin point
  11225. * @param direction direction
  11226. * @param length length of the ray
  11227. */
  11228. constructor(
  11229. /** origin point */
  11230. origin: Vector3,
  11231. /** direction */
  11232. direction: Vector3,
  11233. /** length of the ray */
  11234. length?: number);
  11235. /**
  11236. * Checks if the ray intersects a box
  11237. * @param minimum bound of the box
  11238. * @param maximum bound of the box
  11239. * @param intersectionTreshold extra extend to be added to the box in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * Checks if the ray intersects a box
  11245. * @param box the bounding box to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11247. * @returns if the box was hit
  11248. */
  11249. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a sphere
  11252. * @param sphere the bounding sphere to check
  11253. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11254. * @returns true if it hits the sphere
  11255. */
  11256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11257. /**
  11258. * If the ray hits a triange
  11259. * @param vertex0 triangle vertex
  11260. * @param vertex1 triangle vertex
  11261. * @param vertex2 triangle vertex
  11262. * @returns intersection information if hit
  11263. */
  11264. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11265. /**
  11266. * Checks if ray intersects a plane
  11267. * @param plane the plane to check
  11268. * @returns the distance away it was hit
  11269. */
  11270. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11271. /**
  11272. * Calculate the intercept of a ray on a given axis
  11273. * @param axis to check 'x' | 'y' | 'z'
  11274. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11275. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11276. */
  11277. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11278. /**
  11279. * Checks if ray intersects a mesh
  11280. * @param mesh the mesh to check
  11281. * @param fastCheck if only the bounding box should checked
  11282. * @returns picking info of the intersecton
  11283. */
  11284. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11285. /**
  11286. * Checks if ray intersects a mesh
  11287. * @param meshes the meshes to check
  11288. * @param fastCheck if only the bounding box should checked
  11289. * @param results array to store result in
  11290. * @returns Array of picking infos
  11291. */
  11292. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11293. private _comparePickingInfo;
  11294. private static smallnum;
  11295. private static rayl;
  11296. /**
  11297. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11298. * @param sega the first point of the segment to test the intersection against
  11299. * @param segb the second point of the segment to test the intersection against
  11300. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11301. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11302. */
  11303. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11304. /**
  11305. * Update the ray from viewport position
  11306. * @param x position
  11307. * @param y y position
  11308. * @param viewportWidth viewport width
  11309. * @param viewportHeight viewport height
  11310. * @param world world matrix
  11311. * @param view view matrix
  11312. * @param projection projection matrix
  11313. * @returns this ray updated
  11314. */
  11315. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11316. /**
  11317. * Creates a ray with origin and direction of 0,0,0
  11318. * @returns the new ray
  11319. */
  11320. static Zero(): Ray;
  11321. /**
  11322. * Creates a new ray from screen space and viewport
  11323. * @param x position
  11324. * @param y y position
  11325. * @param viewportWidth viewport width
  11326. * @param viewportHeight viewport height
  11327. * @param world world matrix
  11328. * @param view view matrix
  11329. * @param projection projection matrix
  11330. * @returns new ray
  11331. */
  11332. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11333. /**
  11334. * 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
  11335. * transformed to the given world matrix.
  11336. * @param origin The origin point
  11337. * @param end The end point
  11338. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11339. * @returns the new ray
  11340. */
  11341. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11342. /**
  11343. * Transforms a ray by a matrix
  11344. * @param ray ray to transform
  11345. * @param matrix matrix to apply
  11346. * @returns the resulting new ray
  11347. */
  11348. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11349. /**
  11350. * Transforms a ray by a matrix
  11351. * @param ray ray to transform
  11352. * @param matrix matrix to apply
  11353. * @param result ray to store result in
  11354. */
  11355. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11356. /**
  11357. * Unproject a ray from screen space to object space
  11358. * @param sourceX defines the screen space x coordinate to use
  11359. * @param sourceY defines the screen space y coordinate to use
  11360. * @param viewportWidth defines the current width of the viewport
  11361. * @param viewportHeight defines the current height of the viewport
  11362. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11363. * @param view defines the view matrix to use
  11364. * @param projection defines the projection matrix to use
  11365. */
  11366. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11367. }
  11368. /**
  11369. * Type used to define predicate used to select faces when a mesh intersection is detected
  11370. */
  11371. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11372. interface Scene {
  11373. /** @hidden */
  11374. _tempPickingRay: Nullable<Ray>;
  11375. /** @hidden */
  11376. _cachedRayForTransform: Ray;
  11377. /** @hidden */
  11378. _pickWithRayInverseMatrix: Matrix;
  11379. /** @hidden */
  11380. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11381. /** @hidden */
  11382. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11383. }
  11384. }
  11385. declare module BABYLON {
  11386. /**
  11387. * Groups all the scene component constants in one place to ease maintenance.
  11388. * @hidden
  11389. */
  11390. export class SceneComponentConstants {
  11391. static readonly NAME_EFFECTLAYER: string;
  11392. static readonly NAME_LAYER: string;
  11393. static readonly NAME_LENSFLARESYSTEM: string;
  11394. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11395. static readonly NAME_PARTICLESYSTEM: string;
  11396. static readonly NAME_GAMEPAD: string;
  11397. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11398. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11399. static readonly NAME_DEPTHRENDERER: string;
  11400. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11401. static readonly NAME_SPRITE: string;
  11402. static readonly NAME_OUTLINERENDERER: string;
  11403. static readonly NAME_PROCEDURALTEXTURE: string;
  11404. static readonly NAME_SHADOWGENERATOR: string;
  11405. static readonly NAME_OCTREE: string;
  11406. static readonly NAME_PHYSICSENGINE: string;
  11407. static readonly NAME_AUDIO: string;
  11408. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11409. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11411. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11412. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11413. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11414. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11415. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11416. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11417. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11418. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11419. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11420. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11421. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11422. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11423. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11424. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11425. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11426. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11427. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11428. static readonly STEP_AFTERRENDER_AUDIO: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11432. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11433. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11434. static readonly STEP_POINTERMOVE_SPRITE: number;
  11435. static readonly STEP_POINTERDOWN_SPRITE: number;
  11436. static readonly STEP_POINTERUP_SPRITE: number;
  11437. }
  11438. /**
  11439. * This represents a scene component.
  11440. *
  11441. * This is used to decouple the dependency the scene is having on the different workloads like
  11442. * layers, post processes...
  11443. */
  11444. export interface ISceneComponent {
  11445. /**
  11446. * The name of the component. Each component must have a unique name.
  11447. */
  11448. name: string;
  11449. /**
  11450. * The scene the component belongs to.
  11451. */
  11452. scene: Scene;
  11453. /**
  11454. * Register the component to one instance of a scene.
  11455. */
  11456. register(): void;
  11457. /**
  11458. * Rebuilds the elements related to this component in case of
  11459. * context lost for instance.
  11460. */
  11461. rebuild(): void;
  11462. /**
  11463. * Disposes the component and the associated ressources.
  11464. */
  11465. dispose(): void;
  11466. }
  11467. /**
  11468. * This represents a SERIALIZABLE scene component.
  11469. *
  11470. * This extends Scene Component to add Serialization methods on top.
  11471. */
  11472. export interface ISceneSerializableComponent extends ISceneComponent {
  11473. /**
  11474. * Adds all the elements from the container to the scene
  11475. * @param container the container holding the elements
  11476. */
  11477. addFromContainer(container: AbstractScene): void;
  11478. /**
  11479. * Removes all the elements in the container from the scene
  11480. * @param container contains the elements to remove
  11481. * @param dispose if the removed element should be disposed (default: false)
  11482. */
  11483. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11484. /**
  11485. * Serializes the component data to the specified json object
  11486. * @param serializationObject The object to serialize to
  11487. */
  11488. serialize(serializationObject: any): void;
  11489. }
  11490. /**
  11491. * Strong typing of a Mesh related stage step action
  11492. */
  11493. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11494. /**
  11495. * Strong typing of a Evaluate Sub Mesh related stage step action
  11496. */
  11497. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11498. /**
  11499. * Strong typing of a Active Mesh related stage step action
  11500. */
  11501. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11502. /**
  11503. * Strong typing of a Camera related stage step action
  11504. */
  11505. export type CameraStageAction = (camera: Camera) => void;
  11506. /**
  11507. * Strong typing of a Camera Frame buffer related stage step action
  11508. */
  11509. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11510. /**
  11511. * Strong typing of a Render Target related stage step action
  11512. */
  11513. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11514. /**
  11515. * Strong typing of a RenderingGroup related stage step action
  11516. */
  11517. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11518. /**
  11519. * Strong typing of a Mesh Render related stage step action
  11520. */
  11521. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11522. /**
  11523. * Strong typing of a simple stage step action
  11524. */
  11525. export type SimpleStageAction = () => void;
  11526. /**
  11527. * Strong typing of a render target action.
  11528. */
  11529. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11530. /**
  11531. * Strong typing of a pointer move action.
  11532. */
  11533. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11534. /**
  11535. * Strong typing of a pointer up/down action.
  11536. */
  11537. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11538. /**
  11539. * Representation of a stage in the scene (Basically a list of ordered steps)
  11540. * @hidden
  11541. */
  11542. export class Stage<T extends Function> extends Array<{
  11543. index: number;
  11544. component: ISceneComponent;
  11545. action: T;
  11546. }> {
  11547. /**
  11548. * Hide ctor from the rest of the world.
  11549. * @param items The items to add.
  11550. */
  11551. private constructor();
  11552. /**
  11553. * Creates a new Stage.
  11554. * @returns A new instance of a Stage
  11555. */
  11556. static Create<T extends Function>(): Stage<T>;
  11557. /**
  11558. * Registers a step in an ordered way in the targeted stage.
  11559. * @param index Defines the position to register the step in
  11560. * @param component Defines the component attached to the step
  11561. * @param action Defines the action to launch during the step
  11562. */
  11563. registerStep(index: number, component: ISceneComponent, action: T): void;
  11564. /**
  11565. * Clears all the steps from the stage.
  11566. */
  11567. clear(): void;
  11568. }
  11569. }
  11570. declare module BABYLON {
  11571. interface Scene {
  11572. /** @hidden */
  11573. _pointerOverSprite: Nullable<Sprite>;
  11574. /** @hidden */
  11575. _pickedDownSprite: Nullable<Sprite>;
  11576. /** @hidden */
  11577. _tempSpritePickingRay: Nullable<Ray>;
  11578. /**
  11579. * All of the sprite managers added to this scene
  11580. * @see http://doc.babylonjs.com/babylon101/sprites
  11581. */
  11582. spriteManagers: Array<ISpriteManager>;
  11583. /**
  11584. * An event triggered when sprites rendering is about to start
  11585. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11586. */
  11587. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11588. /**
  11589. * An event triggered when sprites rendering is done
  11590. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11591. */
  11592. onAfterSpritesRenderingObservable: Observable<Scene>;
  11593. /** @hidden */
  11594. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11595. /** Launch a ray to try to pick a sprite in the scene
  11596. * @param x position on screen
  11597. * @param y position on screen
  11598. * @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
  11599. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11600. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo
  11602. */
  11603. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Use the given ray to pick a sprite in the scene
  11605. * @param ray The ray (in world space) to use to pick meshes
  11606. * @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
  11607. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11608. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11609. * @returns a PickingInfo
  11610. */
  11611. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11612. /** @hidden */
  11613. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11614. /** Launch a ray to try to pick sprites in the scene
  11615. * @param x position on screen
  11616. * @param y position on screen
  11617. * @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
  11618. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11619. * @returns a PickingInfo array
  11620. */
  11621. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11622. /** Use the given ray to pick sprites in the scene
  11623. * @param ray The ray (in world space) to use to pick meshes
  11624. * @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
  11625. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11626. * @returns a PickingInfo array
  11627. */
  11628. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11629. /**
  11630. * Force the sprite under the pointer
  11631. * @param sprite defines the sprite to use
  11632. */
  11633. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11634. /**
  11635. * Gets the sprite under the pointer
  11636. * @returns a Sprite or null if no sprite is under the pointer
  11637. */
  11638. getPointerOverSprite(): Nullable<Sprite>;
  11639. }
  11640. /**
  11641. * Defines the sprite scene component responsible to manage sprites
  11642. * in a given scene.
  11643. */
  11644. export class SpriteSceneComponent implements ISceneComponent {
  11645. /**
  11646. * The component name helpfull to identify the component in the list of scene components.
  11647. */
  11648. readonly name: string;
  11649. /**
  11650. * The scene the component belongs to.
  11651. */
  11652. scene: Scene;
  11653. /** @hidden */
  11654. private _spritePredicate;
  11655. /**
  11656. * Creates a new instance of the component for the given scene
  11657. * @param scene Defines the scene to register the component in
  11658. */
  11659. constructor(scene: Scene);
  11660. /**
  11661. * Registers the component in a given scene
  11662. */
  11663. register(): void;
  11664. /**
  11665. * Rebuilds the elements related to this component in case of
  11666. * context lost for instance.
  11667. */
  11668. rebuild(): void;
  11669. /**
  11670. * Disposes the component and the associated ressources.
  11671. */
  11672. dispose(): void;
  11673. private _pickSpriteButKeepRay;
  11674. private _pointerMove;
  11675. private _pointerDown;
  11676. private _pointerUp;
  11677. }
  11678. }
  11679. declare module BABYLON {
  11680. /** @hidden */
  11681. export var fogFragmentDeclaration: {
  11682. name: string;
  11683. shader: string;
  11684. };
  11685. }
  11686. declare module BABYLON {
  11687. /** @hidden */
  11688. export var fogFragment: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module BABYLON {
  11694. /** @hidden */
  11695. export var spritesPixelShader: {
  11696. name: string;
  11697. shader: string;
  11698. };
  11699. }
  11700. declare module BABYLON {
  11701. /** @hidden */
  11702. export var fogVertexDeclaration: {
  11703. name: string;
  11704. shader: string;
  11705. };
  11706. }
  11707. declare module BABYLON {
  11708. /** @hidden */
  11709. export var spritesVertexShader: {
  11710. name: string;
  11711. shader: string;
  11712. };
  11713. }
  11714. declare module BABYLON {
  11715. /**
  11716. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11717. */
  11718. export interface ISpriteManager extends IDisposable {
  11719. /**
  11720. * Restricts the camera to viewing objects with the same layerMask.
  11721. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11722. */
  11723. layerMask: number;
  11724. /**
  11725. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11726. */
  11727. isPickable: boolean;
  11728. /**
  11729. * Specifies the rendering group id for this mesh (0 by default)
  11730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11731. */
  11732. renderingGroupId: number;
  11733. /**
  11734. * Defines the list of sprites managed by the manager.
  11735. */
  11736. sprites: Array<Sprite>;
  11737. /**
  11738. * Tests the intersection of a sprite with a specific ray.
  11739. * @param ray The ray we are sending to test the collision
  11740. * @param camera The camera space we are sending rays in
  11741. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11742. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11743. * @returns picking info or null.
  11744. */
  11745. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11746. /**
  11747. * Intersects the sprites with a ray
  11748. * @param ray defines the ray to intersect with
  11749. * @param camera defines the current active camera
  11750. * @param predicate defines a predicate used to select candidate sprites
  11751. * @returns null if no hit or a PickingInfo array
  11752. */
  11753. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11754. /**
  11755. * Renders the list of sprites on screen.
  11756. */
  11757. render(): void;
  11758. }
  11759. /**
  11760. * Class used to manage multiple sprites on the same spritesheet
  11761. * @see http://doc.babylonjs.com/babylon101/sprites
  11762. */
  11763. export class SpriteManager implements ISpriteManager {
  11764. /** defines the manager's name */
  11765. name: string;
  11766. /** Gets the list of sprites */
  11767. sprites: Sprite[];
  11768. /** Gets or sets the rendering group id (0 by default) */
  11769. renderingGroupId: number;
  11770. /** Gets or sets camera layer mask */
  11771. layerMask: number;
  11772. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11773. fogEnabled: boolean;
  11774. /** Gets or sets a boolean indicating if the sprites are pickable */
  11775. isPickable: boolean;
  11776. /** Defines the default width of a cell in the spritesheet */
  11777. cellWidth: number;
  11778. /** Defines the default height of a cell in the spritesheet */
  11779. cellHeight: number;
  11780. /** Associative array from JSON sprite data file */
  11781. private _cellData;
  11782. /** Array of sprite names from JSON sprite data file */
  11783. private _spriteMap;
  11784. /** True when packed cell data from JSON file is ready*/
  11785. private _packedAndReady;
  11786. /**
  11787. * An event triggered when the manager is disposed.
  11788. */
  11789. onDisposeObservable: Observable<SpriteManager>;
  11790. private _onDisposeObserver;
  11791. /**
  11792. * Callback called when the manager is disposed
  11793. */
  11794. set onDispose(callback: () => void);
  11795. private _capacity;
  11796. private _fromPacked;
  11797. private _spriteTexture;
  11798. private _epsilon;
  11799. private _scene;
  11800. private _vertexData;
  11801. private _buffer;
  11802. private _vertexBuffers;
  11803. private _indexBuffer;
  11804. private _effectBase;
  11805. private _effectFog;
  11806. /**
  11807. * Gets or sets the spritesheet texture
  11808. */
  11809. get texture(): Texture;
  11810. set texture(value: Texture);
  11811. /**
  11812. * Creates a new sprite manager
  11813. * @param name defines the manager's name
  11814. * @param imgUrl defines the sprite sheet url
  11815. * @param capacity defines the maximum allowed number of sprites
  11816. * @param cellSize defines the size of a sprite cell
  11817. * @param scene defines the hosting scene
  11818. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11819. * @param samplingMode defines the smapling mode to use with spritesheet
  11820. * @param fromPacked set to false; do not alter
  11821. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11822. */
  11823. constructor(
  11824. /** defines the manager's name */
  11825. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11826. private _makePacked;
  11827. private _appendSpriteVertex;
  11828. /**
  11829. * Intersects the sprites with a ray
  11830. * @param ray defines the ray to intersect with
  11831. * @param camera defines the current active camera
  11832. * @param predicate defines a predicate used to select candidate sprites
  11833. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11834. * @returns null if no hit or a PickingInfo
  11835. */
  11836. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11837. /**
  11838. * Intersects the sprites with a ray
  11839. * @param ray defines the ray to intersect with
  11840. * @param camera defines the current active camera
  11841. * @param predicate defines a predicate used to select candidate sprites
  11842. * @returns null if no hit or a PickingInfo array
  11843. */
  11844. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11845. /**
  11846. * Render all child sprites
  11847. */
  11848. render(): void;
  11849. /**
  11850. * Release associated resources
  11851. */
  11852. dispose(): void;
  11853. }
  11854. }
  11855. declare module BABYLON {
  11856. /**
  11857. * Class used to represent a sprite
  11858. * @see http://doc.babylonjs.com/babylon101/sprites
  11859. */
  11860. export class Sprite {
  11861. /** defines the name */
  11862. name: string;
  11863. /** Gets or sets the current world position */
  11864. position: Vector3;
  11865. /** Gets or sets the main color */
  11866. color: Color4;
  11867. /** Gets or sets the width */
  11868. width: number;
  11869. /** Gets or sets the height */
  11870. height: number;
  11871. /** Gets or sets rotation angle */
  11872. angle: number;
  11873. /** Gets or sets the cell index in the sprite sheet */
  11874. cellIndex: number;
  11875. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11876. cellRef: string;
  11877. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11878. invertU: number;
  11879. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11880. invertV: number;
  11881. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11882. disposeWhenFinishedAnimating: boolean;
  11883. /** Gets the list of attached animations */
  11884. animations: Animation[];
  11885. /** Gets or sets a boolean indicating if the sprite can be picked */
  11886. isPickable: boolean;
  11887. /**
  11888. * Gets or sets the associated action manager
  11889. */
  11890. actionManager: Nullable<ActionManager>;
  11891. private _animationStarted;
  11892. private _loopAnimation;
  11893. private _fromIndex;
  11894. private _toIndex;
  11895. private _delay;
  11896. private _direction;
  11897. private _manager;
  11898. private _time;
  11899. private _onAnimationEnd;
  11900. /**
  11901. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11902. */
  11903. isVisible: boolean;
  11904. /**
  11905. * Gets or sets the sprite size
  11906. */
  11907. get size(): number;
  11908. set size(value: number);
  11909. /**
  11910. * Creates a new Sprite
  11911. * @param name defines the name
  11912. * @param manager defines the manager
  11913. */
  11914. constructor(
  11915. /** defines the name */
  11916. name: string, manager: ISpriteManager);
  11917. /**
  11918. * Starts an animation
  11919. * @param from defines the initial key
  11920. * @param to defines the end key
  11921. * @param loop defines if the animation must loop
  11922. * @param delay defines the start delay (in ms)
  11923. * @param onAnimationEnd defines a callback to call when animation ends
  11924. */
  11925. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11926. /** Stops current animation (if any) */
  11927. stopAnimation(): void;
  11928. /** @hidden */
  11929. _animate(deltaTime: number): void;
  11930. /** Release associated resources */
  11931. dispose(): void;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Information about the result of picking within a scene
  11937. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11938. */
  11939. export class PickingInfo {
  11940. /** @hidden */
  11941. _pickingUnavailable: boolean;
  11942. /**
  11943. * If the pick collided with an object
  11944. */
  11945. hit: boolean;
  11946. /**
  11947. * Distance away where the pick collided
  11948. */
  11949. distance: number;
  11950. /**
  11951. * The location of pick collision
  11952. */
  11953. pickedPoint: Nullable<Vector3>;
  11954. /**
  11955. * The mesh corresponding the the pick collision
  11956. */
  11957. pickedMesh: Nullable<AbstractMesh>;
  11958. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11959. bu: number;
  11960. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11961. bv: number;
  11962. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11963. faceId: number;
  11964. /** Id of the the submesh that was picked */
  11965. subMeshId: number;
  11966. /** If a sprite was picked, this will be the sprite the pick collided with */
  11967. pickedSprite: Nullable<Sprite>;
  11968. /**
  11969. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11970. */
  11971. originMesh: Nullable<AbstractMesh>;
  11972. /**
  11973. * The ray that was used to perform the picking.
  11974. */
  11975. ray: Nullable<Ray>;
  11976. /**
  11977. * Gets the normal correspodning to the face the pick collided with
  11978. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11979. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11980. * @returns The normal correspodning to the face the pick collided with
  11981. */
  11982. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11983. /**
  11984. * Gets the texture coordinates of where the pick occured
  11985. * @returns the vector containing the coordnates of the texture
  11986. */
  11987. getTextureCoordinates(): Nullable<Vector2>;
  11988. }
  11989. }
  11990. declare module BABYLON {
  11991. /**
  11992. * Gather the list of pointer event types as constants.
  11993. */
  11994. export class PointerEventTypes {
  11995. /**
  11996. * 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.
  11997. */
  11998. static readonly POINTERDOWN: number;
  11999. /**
  12000. * The pointerup event is fired when a pointer is no longer active.
  12001. */
  12002. static readonly POINTERUP: number;
  12003. /**
  12004. * The pointermove event is fired when a pointer changes coordinates.
  12005. */
  12006. static readonly POINTERMOVE: number;
  12007. /**
  12008. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12009. */
  12010. static readonly POINTERWHEEL: number;
  12011. /**
  12012. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12013. */
  12014. static readonly POINTERPICK: number;
  12015. /**
  12016. * The pointertap event is fired when a the object has been touched and released without drag.
  12017. */
  12018. static readonly POINTERTAP: number;
  12019. /**
  12020. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12021. */
  12022. static readonly POINTERDOUBLETAP: number;
  12023. }
  12024. /**
  12025. * Base class of pointer info types.
  12026. */
  12027. export class PointerInfoBase {
  12028. /**
  12029. * Defines the type of event (PointerEventTypes)
  12030. */
  12031. type: number;
  12032. /**
  12033. * Defines the related dom event
  12034. */
  12035. event: PointerEvent | MouseWheelEvent;
  12036. /**
  12037. * Instantiates the base class of pointers info.
  12038. * @param type Defines the type of event (PointerEventTypes)
  12039. * @param event Defines the related dom event
  12040. */
  12041. constructor(
  12042. /**
  12043. * Defines the type of event (PointerEventTypes)
  12044. */
  12045. type: number,
  12046. /**
  12047. * Defines the related dom event
  12048. */
  12049. event: PointerEvent | MouseWheelEvent);
  12050. }
  12051. /**
  12052. * This class is used to store pointer related info for the onPrePointerObservable event.
  12053. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12054. */
  12055. export class PointerInfoPre extends PointerInfoBase {
  12056. /**
  12057. * Ray from a pointer if availible (eg. 6dof controller)
  12058. */
  12059. ray: Nullable<Ray>;
  12060. /**
  12061. * Defines the local position of the pointer on the canvas.
  12062. */
  12063. localPosition: Vector2;
  12064. /**
  12065. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12066. */
  12067. skipOnPointerObservable: boolean;
  12068. /**
  12069. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12070. * @param type Defines the type of event (PointerEventTypes)
  12071. * @param event Defines the related dom event
  12072. * @param localX Defines the local x coordinates of the pointer when the event occured
  12073. * @param localY Defines the local y coordinates of the pointer when the event occured
  12074. */
  12075. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12076. }
  12077. /**
  12078. * This type contains all the data related to a pointer event in Babylon.js.
  12079. * 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.
  12080. */
  12081. export class PointerInfo extends PointerInfoBase {
  12082. /**
  12083. * Defines the picking info associated to the info (if any)\
  12084. */
  12085. pickInfo: Nullable<PickingInfo>;
  12086. /**
  12087. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12088. * @param type Defines the type of event (PointerEventTypes)
  12089. * @param event Defines the related dom event
  12090. * @param pickInfo Defines the picking info associated to the info (if any)\
  12091. */
  12092. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12093. /**
  12094. * Defines the picking info associated to the info (if any)\
  12095. */
  12096. pickInfo: Nullable<PickingInfo>);
  12097. }
  12098. /**
  12099. * Data relating to a touch event on the screen.
  12100. */
  12101. export interface PointerTouch {
  12102. /**
  12103. * X coordinate of touch.
  12104. */
  12105. x: number;
  12106. /**
  12107. * Y coordinate of touch.
  12108. */
  12109. y: number;
  12110. /**
  12111. * Id of touch. Unique for each finger.
  12112. */
  12113. pointerId: number;
  12114. /**
  12115. * Event type passed from DOM.
  12116. */
  12117. type: any;
  12118. }
  12119. }
  12120. declare module BABYLON {
  12121. /**
  12122. * Manage the mouse inputs to control the movement of a free camera.
  12123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12124. */
  12125. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12126. /**
  12127. * Define if touch is enabled in the mouse input
  12128. */
  12129. touchEnabled: boolean;
  12130. /**
  12131. * Defines the camera the input is attached to.
  12132. */
  12133. camera: FreeCamera;
  12134. /**
  12135. * Defines the buttons associated with the input to handle camera move.
  12136. */
  12137. buttons: number[];
  12138. /**
  12139. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12140. */
  12141. angularSensibility: number;
  12142. private _pointerInput;
  12143. private _onMouseMove;
  12144. private _observer;
  12145. private previousPosition;
  12146. /**
  12147. * Observable for when a pointer move event occurs containing the move offset
  12148. */
  12149. onPointerMovedObservable: Observable<{
  12150. offsetX: number;
  12151. offsetY: number;
  12152. }>;
  12153. /**
  12154. * @hidden
  12155. * If the camera should be rotated automatically based on pointer movement
  12156. */
  12157. _allowCameraRotation: boolean;
  12158. /**
  12159. * Manage the mouse inputs to control the movement of a free camera.
  12160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12161. * @param touchEnabled Defines if touch is enabled or not
  12162. */
  12163. constructor(
  12164. /**
  12165. * Define if touch is enabled in the mouse input
  12166. */
  12167. touchEnabled?: boolean);
  12168. /**
  12169. * Attach the input controls to a specific dom element to get the input from.
  12170. * @param element Defines the element the controls should be listened from
  12171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12172. */
  12173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12174. /**
  12175. * Called on JS contextmenu event.
  12176. * Override this method to provide functionality.
  12177. */
  12178. protected onContextMenu(evt: PointerEvent): void;
  12179. /**
  12180. * Detach the current controls from the specified dom element.
  12181. * @param element Defines the element to stop listening the inputs from
  12182. */
  12183. detachControl(element: Nullable<HTMLElement>): void;
  12184. /**
  12185. * Gets the class name of the current intput.
  12186. * @returns the class name
  12187. */
  12188. getClassName(): string;
  12189. /**
  12190. * Get the friendly name associated with the input class.
  12191. * @returns the input friendly name
  12192. */
  12193. getSimpleName(): string;
  12194. }
  12195. }
  12196. declare module BABYLON {
  12197. /**
  12198. * Manage the touch inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. */
  12201. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12202. /**
  12203. * Defines the camera the input is attached to.
  12204. */
  12205. camera: FreeCamera;
  12206. /**
  12207. * Defines the touch sensibility for rotation.
  12208. * The higher the faster.
  12209. */
  12210. touchAngularSensibility: number;
  12211. /**
  12212. * Defines the touch sensibility for move.
  12213. * The higher the faster.
  12214. */
  12215. touchMoveSensibility: number;
  12216. private _offsetX;
  12217. private _offsetY;
  12218. private _pointerPressed;
  12219. private _pointerInput;
  12220. private _observer;
  12221. private _onLostFocus;
  12222. /**
  12223. * Attach the input controls to a specific dom element to get the input from.
  12224. * @param element Defines the element the controls should be listened from
  12225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12226. */
  12227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12228. /**
  12229. * Detach the current controls from the specified dom element.
  12230. * @param element Defines the element to stop listening the inputs from
  12231. */
  12232. detachControl(element: Nullable<HTMLElement>): void;
  12233. /**
  12234. * Update the current camera state depending on the inputs that have been used this frame.
  12235. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12236. */
  12237. checkInputs(): void;
  12238. /**
  12239. * Gets the class name of the current intput.
  12240. * @returns the class name
  12241. */
  12242. getClassName(): string;
  12243. /**
  12244. * Get the friendly name associated with the input class.
  12245. * @returns the input friendly name
  12246. */
  12247. getSimpleName(): string;
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. /**
  12252. * Default Inputs manager for the FreeCamera.
  12253. * It groups all the default supported inputs for ease of use.
  12254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12255. */
  12256. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12257. /**
  12258. * @hidden
  12259. */
  12260. _mouseInput: Nullable<FreeCameraMouseInput>;
  12261. /**
  12262. * Instantiates a new FreeCameraInputsManager.
  12263. * @param camera Defines the camera the inputs belong to
  12264. */
  12265. constructor(camera: FreeCamera);
  12266. /**
  12267. * Add keyboard input support to the input manager.
  12268. * @returns the current input manager
  12269. */
  12270. addKeyboard(): FreeCameraInputsManager;
  12271. /**
  12272. * Add mouse input support to the input manager.
  12273. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12274. * @returns the current input manager
  12275. */
  12276. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12277. /**
  12278. * Removes the mouse input support from the manager
  12279. * @returns the current input manager
  12280. */
  12281. removeMouse(): FreeCameraInputsManager;
  12282. /**
  12283. * Add touch input support to the input manager.
  12284. * @returns the current input manager
  12285. */
  12286. addTouch(): FreeCameraInputsManager;
  12287. /**
  12288. * Remove all attached input methods from a camera
  12289. */
  12290. clear(): void;
  12291. }
  12292. }
  12293. declare module BABYLON {
  12294. /**
  12295. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12296. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12298. */
  12299. export class FreeCamera extends TargetCamera {
  12300. /**
  12301. * Define the collision ellipsoid of the camera.
  12302. * This is helpful to simulate a camera body like the player body around the camera
  12303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12304. */
  12305. ellipsoid: Vector3;
  12306. /**
  12307. * Define an offset for the position of the ellipsoid around the camera.
  12308. * This can be helpful to determine the center of the body near the gravity center of the body
  12309. * instead of its head.
  12310. */
  12311. ellipsoidOffset: Vector3;
  12312. /**
  12313. * Enable or disable collisions of the camera with the rest of the scene objects.
  12314. */
  12315. checkCollisions: boolean;
  12316. /**
  12317. * Enable or disable gravity on the camera.
  12318. */
  12319. applyGravity: boolean;
  12320. /**
  12321. * Define the input manager associated to the camera.
  12322. */
  12323. inputs: FreeCameraInputsManager;
  12324. /**
  12325. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12326. * Higher values reduce sensitivity.
  12327. */
  12328. get angularSensibility(): number;
  12329. /**
  12330. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12331. * Higher values reduce sensitivity.
  12332. */
  12333. set angularSensibility(value: number);
  12334. /**
  12335. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12336. */
  12337. get keysUp(): number[];
  12338. set keysUp(value: number[]);
  12339. /**
  12340. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12341. */
  12342. get keysDown(): number[];
  12343. set keysDown(value: number[]);
  12344. /**
  12345. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12346. */
  12347. get keysLeft(): number[];
  12348. set keysLeft(value: number[]);
  12349. /**
  12350. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12351. */
  12352. get keysRight(): number[];
  12353. set keysRight(value: number[]);
  12354. /**
  12355. * Event raised when the camera collide with a mesh in the scene.
  12356. */
  12357. onCollide: (collidedMesh: AbstractMesh) => void;
  12358. private _collider;
  12359. private _needMoveForGravity;
  12360. private _oldPosition;
  12361. private _diffPosition;
  12362. private _newPosition;
  12363. /** @hidden */
  12364. _localDirection: Vector3;
  12365. /** @hidden */
  12366. _transformedDirection: Vector3;
  12367. /**
  12368. * Instantiates a Free Camera.
  12369. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12370. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12371. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12372. * @param name Define the name of the camera in the scene
  12373. * @param position Define the start position of the camera in the scene
  12374. * @param scene Define the scene the camera belongs to
  12375. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12376. */
  12377. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12378. /**
  12379. * Attached controls to the current camera.
  12380. * @param element Defines the element the controls should be listened from
  12381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12382. */
  12383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12384. /**
  12385. * Detach the current controls from the camera.
  12386. * The camera will stop reacting to inputs.
  12387. * @param element Defines the element to stop listening the inputs from
  12388. */
  12389. detachControl(element: HTMLElement): void;
  12390. private _collisionMask;
  12391. /**
  12392. * Define a collision mask to limit the list of object the camera can collide with
  12393. */
  12394. get collisionMask(): number;
  12395. set collisionMask(mask: number);
  12396. /** @hidden */
  12397. _collideWithWorld(displacement: Vector3): void;
  12398. private _onCollisionPositionChange;
  12399. /** @hidden */
  12400. _checkInputs(): void;
  12401. /** @hidden */
  12402. _decideIfNeedsToMove(): boolean;
  12403. /** @hidden */
  12404. _updatePosition(): void;
  12405. /**
  12406. * Destroy the camera and release the current resources hold by it.
  12407. */
  12408. dispose(): void;
  12409. /**
  12410. * Gets the current object class name.
  12411. * @return the class name
  12412. */
  12413. getClassName(): string;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /**
  12418. * Represents a gamepad control stick position
  12419. */
  12420. export class StickValues {
  12421. /**
  12422. * The x component of the control stick
  12423. */
  12424. x: number;
  12425. /**
  12426. * The y component of the control stick
  12427. */
  12428. y: number;
  12429. /**
  12430. * Initializes the gamepad x and y control stick values
  12431. * @param x The x component of the gamepad control stick value
  12432. * @param y The y component of the gamepad control stick value
  12433. */
  12434. constructor(
  12435. /**
  12436. * The x component of the control stick
  12437. */
  12438. x: number,
  12439. /**
  12440. * The y component of the control stick
  12441. */
  12442. y: number);
  12443. }
  12444. /**
  12445. * An interface which manages callbacks for gamepad button changes
  12446. */
  12447. export interface GamepadButtonChanges {
  12448. /**
  12449. * Called when a gamepad has been changed
  12450. */
  12451. changed: boolean;
  12452. /**
  12453. * Called when a gamepad press event has been triggered
  12454. */
  12455. pressChanged: boolean;
  12456. /**
  12457. * Called when a touch event has been triggered
  12458. */
  12459. touchChanged: boolean;
  12460. /**
  12461. * Called when a value has changed
  12462. */
  12463. valueChanged: boolean;
  12464. }
  12465. /**
  12466. * Represents a gamepad
  12467. */
  12468. export class Gamepad {
  12469. /**
  12470. * The id of the gamepad
  12471. */
  12472. id: string;
  12473. /**
  12474. * The index of the gamepad
  12475. */
  12476. index: number;
  12477. /**
  12478. * The browser gamepad
  12479. */
  12480. browserGamepad: any;
  12481. /**
  12482. * Specifies what type of gamepad this represents
  12483. */
  12484. type: number;
  12485. private _leftStick;
  12486. private _rightStick;
  12487. /** @hidden */
  12488. _isConnected: boolean;
  12489. private _leftStickAxisX;
  12490. private _leftStickAxisY;
  12491. private _rightStickAxisX;
  12492. private _rightStickAxisY;
  12493. /**
  12494. * Triggered when the left control stick has been changed
  12495. */
  12496. private _onleftstickchanged;
  12497. /**
  12498. * Triggered when the right control stick has been changed
  12499. */
  12500. private _onrightstickchanged;
  12501. /**
  12502. * Represents a gamepad controller
  12503. */
  12504. static GAMEPAD: number;
  12505. /**
  12506. * Represents a generic controller
  12507. */
  12508. static GENERIC: number;
  12509. /**
  12510. * Represents an XBox controller
  12511. */
  12512. static XBOX: number;
  12513. /**
  12514. * Represents a pose-enabled controller
  12515. */
  12516. static POSE_ENABLED: number;
  12517. /**
  12518. * Represents an Dual Shock controller
  12519. */
  12520. static DUALSHOCK: number;
  12521. /**
  12522. * Specifies whether the left control stick should be Y-inverted
  12523. */
  12524. protected _invertLeftStickY: boolean;
  12525. /**
  12526. * Specifies if the gamepad has been connected
  12527. */
  12528. get isConnected(): boolean;
  12529. /**
  12530. * Initializes the gamepad
  12531. * @param id The id of the gamepad
  12532. * @param index The index of the gamepad
  12533. * @param browserGamepad The browser gamepad
  12534. * @param leftStickX The x component of the left joystick
  12535. * @param leftStickY The y component of the left joystick
  12536. * @param rightStickX The x component of the right joystick
  12537. * @param rightStickY The y component of the right joystick
  12538. */
  12539. constructor(
  12540. /**
  12541. * The id of the gamepad
  12542. */
  12543. id: string,
  12544. /**
  12545. * The index of the gamepad
  12546. */
  12547. index: number,
  12548. /**
  12549. * The browser gamepad
  12550. */
  12551. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12552. /**
  12553. * Callback triggered when the left joystick has changed
  12554. * @param callback
  12555. */
  12556. onleftstickchanged(callback: (values: StickValues) => void): void;
  12557. /**
  12558. * Callback triggered when the right joystick has changed
  12559. * @param callback
  12560. */
  12561. onrightstickchanged(callback: (values: StickValues) => void): void;
  12562. /**
  12563. * Gets the left joystick
  12564. */
  12565. get leftStick(): StickValues;
  12566. /**
  12567. * Sets the left joystick values
  12568. */
  12569. set leftStick(newValues: StickValues);
  12570. /**
  12571. * Gets the right joystick
  12572. */
  12573. get rightStick(): StickValues;
  12574. /**
  12575. * Sets the right joystick value
  12576. */
  12577. set rightStick(newValues: StickValues);
  12578. /**
  12579. * Updates the gamepad joystick positions
  12580. */
  12581. update(): void;
  12582. /**
  12583. * Disposes the gamepad
  12584. */
  12585. dispose(): void;
  12586. }
  12587. /**
  12588. * Represents a generic gamepad
  12589. */
  12590. export class GenericPad extends Gamepad {
  12591. private _buttons;
  12592. private _onbuttondown;
  12593. private _onbuttonup;
  12594. /**
  12595. * Observable triggered when a button has been pressed
  12596. */
  12597. onButtonDownObservable: Observable<number>;
  12598. /**
  12599. * Observable triggered when a button has been released
  12600. */
  12601. onButtonUpObservable: Observable<number>;
  12602. /**
  12603. * Callback triggered when a button has been pressed
  12604. * @param callback Called when a button has been pressed
  12605. */
  12606. onbuttondown(callback: (buttonPressed: number) => void): void;
  12607. /**
  12608. * Callback triggered when a button has been released
  12609. * @param callback Called when a button has been released
  12610. */
  12611. onbuttonup(callback: (buttonReleased: number) => void): void;
  12612. /**
  12613. * Initializes the generic gamepad
  12614. * @param id The id of the generic gamepad
  12615. * @param index The index of the generic gamepad
  12616. * @param browserGamepad The browser gamepad
  12617. */
  12618. constructor(id: string, index: number, browserGamepad: any);
  12619. private _setButtonValue;
  12620. /**
  12621. * Updates the generic gamepad
  12622. */
  12623. update(): void;
  12624. /**
  12625. * Disposes the generic gamepad
  12626. */
  12627. dispose(): void;
  12628. }
  12629. }
  12630. declare module BABYLON {
  12631. interface Engine {
  12632. /**
  12633. * Creates a raw texture
  12634. * @param data defines the data to store in the texture
  12635. * @param width defines the width of the texture
  12636. * @param height defines the height of the texture
  12637. * @param format defines the format of the data
  12638. * @param generateMipMaps defines if the engine should generate the mip levels
  12639. * @param invertY defines if data must be stored with Y axis inverted
  12640. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12641. * @param compression defines the compression used (null by default)
  12642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12643. * @returns the raw texture inside an InternalTexture
  12644. */
  12645. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12646. /**
  12647. * Update a raw texture
  12648. * @param texture defines the texture to update
  12649. * @param data defines the data to store in the texture
  12650. * @param format defines the format of the data
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. */
  12653. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12654. /**
  12655. * Update a raw texture
  12656. * @param texture defines the texture to update
  12657. * @param data defines the data to store in the texture
  12658. * @param format defines the format of the data
  12659. * @param invertY defines if data must be stored with Y axis inverted
  12660. * @param compression defines the compression used (null by default)
  12661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12662. */
  12663. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12664. /**
  12665. * Creates a new raw cube texture
  12666. * @param data defines the array of data to use to create each face
  12667. * @param size defines the size of the textures
  12668. * @param format defines the format of the data
  12669. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12670. * @param generateMipMaps defines if the engine should generate the mip levels
  12671. * @param invertY defines if data must be stored with Y axis inverted
  12672. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12673. * @param compression defines the compression used (null by default)
  12674. * @returns the cube texture as an InternalTexture
  12675. */
  12676. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12677. /**
  12678. * Update a raw cube texture
  12679. * @param texture defines the texture to udpdate
  12680. * @param data defines the data to store
  12681. * @param format defines the data format
  12682. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12683. * @param invertY defines if data must be stored with Y axis inverted
  12684. */
  12685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12686. /**
  12687. * Update a raw cube texture
  12688. * @param texture defines the texture to udpdate
  12689. * @param data defines the data to store
  12690. * @param format defines the data format
  12691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12692. * @param invertY defines if data must be stored with Y axis inverted
  12693. * @param compression defines the compression used (null by default)
  12694. */
  12695. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12696. /**
  12697. * Update a raw cube texture
  12698. * @param texture defines the texture to udpdate
  12699. * @param data defines the data to store
  12700. * @param format defines the data format
  12701. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12702. * @param invertY defines if data must be stored with Y axis inverted
  12703. * @param compression defines the compression used (null by default)
  12704. * @param level defines which level of the texture to update
  12705. */
  12706. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12707. /**
  12708. * Creates a new raw cube texture from a specified url
  12709. * @param url defines the url where the data is located
  12710. * @param scene defines the current scene
  12711. * @param size defines the size of the textures
  12712. * @param format defines the format of the data
  12713. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12714. * @param noMipmap defines if the engine should avoid generating the mip levels
  12715. * @param callback defines a callback used to extract texture data from loaded data
  12716. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12717. * @param onLoad defines a callback called when texture is loaded
  12718. * @param onError defines a callback called if there is an error
  12719. * @returns the cube texture as an InternalTexture
  12720. */
  12721. 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;
  12722. /**
  12723. * Creates a new raw cube texture from a specified url
  12724. * @param url defines the url where the data is located
  12725. * @param scene defines the current scene
  12726. * @param size defines the size of the textures
  12727. * @param format defines the format of the data
  12728. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12729. * @param noMipmap defines if the engine should avoid generating the mip levels
  12730. * @param callback defines a callback used to extract texture data from loaded data
  12731. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12732. * @param onLoad defines a callback called when texture is loaded
  12733. * @param onError defines a callback called if there is an error
  12734. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12735. * @param invertY defines if data must be stored with Y axis inverted
  12736. * @returns the cube texture as an InternalTexture
  12737. */
  12738. 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;
  12739. /**
  12740. * Creates a new raw 3D texture
  12741. * @param data defines the data used to create the texture
  12742. * @param width defines the width of the texture
  12743. * @param height defines the height of the texture
  12744. * @param depth defines the depth of the texture
  12745. * @param format defines the format of the texture
  12746. * @param generateMipMaps defines if the engine must generate mip levels
  12747. * @param invertY defines if data must be stored with Y axis inverted
  12748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12749. * @param compression defines the compressed used (can be null)
  12750. * @param textureType defines the compressed used (can be null)
  12751. * @returns a new raw 3D texture (stored in an InternalTexture)
  12752. */
  12753. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12754. /**
  12755. * Update a raw 3D texture
  12756. * @param texture defines the texture to update
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param invertY defines if data must be stored with Y axis inverted
  12760. */
  12761. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12762. /**
  12763. * Update a raw 3D texture
  12764. * @param texture defines the texture to update
  12765. * @param data defines the data to store
  12766. * @param format defines the data format
  12767. * @param invertY defines if data must be stored with Y axis inverted
  12768. * @param compression defines the used compression (can be null)
  12769. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12770. */
  12771. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12772. /**
  12773. * Creates a new raw 2D array texture
  12774. * @param data defines the data used to create the texture
  12775. * @param width defines the width of the texture
  12776. * @param height defines the height of the texture
  12777. * @param depth defines the number of layers of the texture
  12778. * @param format defines the format of the texture
  12779. * @param generateMipMaps defines if the engine must generate mip levels
  12780. * @param invertY defines if data must be stored with Y axis inverted
  12781. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12782. * @param compression defines the compressed used (can be null)
  12783. * @param textureType defines the compressed used (can be null)
  12784. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12785. */
  12786. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12787. /**
  12788. * Update a raw 2D array texture
  12789. * @param texture defines the texture to update
  12790. * @param data defines the data to store
  12791. * @param format defines the data format
  12792. * @param invertY defines if data must be stored with Y axis inverted
  12793. */
  12794. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12795. /**
  12796. * Update a raw 2D array texture
  12797. * @param texture defines the texture to update
  12798. * @param data defines the data to store
  12799. * @param format defines the data format
  12800. * @param invertY defines if data must be stored with Y axis inverted
  12801. * @param compression defines the used compression (can be null)
  12802. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12803. */
  12804. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Raw texture can help creating a texture directly from an array of data.
  12810. * This can be super useful if you either get the data from an uncompressed source or
  12811. * if you wish to create your texture pixel by pixel.
  12812. */
  12813. export class RawTexture extends Texture {
  12814. /**
  12815. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12816. */
  12817. format: number;
  12818. private _engine;
  12819. /**
  12820. * Instantiates a new RawTexture.
  12821. * Raw texture can help creating a texture directly from an array of data.
  12822. * This can be super useful if you either get the data from an uncompressed source or
  12823. * if you wish to create your texture pixel by pixel.
  12824. * @param data define the array of data to use to create the texture
  12825. * @param width define the width of the texture
  12826. * @param height define the height of the texture
  12827. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12828. * @param scene define the scene the texture belongs to
  12829. * @param generateMipMaps define whether mip maps should be generated or not
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. */
  12834. constructor(data: ArrayBufferView, width: number, height: number,
  12835. /**
  12836. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12837. */
  12838. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12839. /**
  12840. * Updates the texture underlying data.
  12841. * @param data Define the new data of the texture
  12842. */
  12843. update(data: ArrayBufferView): void;
  12844. /**
  12845. * Creates a luminance texture from some data.
  12846. * @param data Define the texture data
  12847. * @param width Define the width of the texture
  12848. * @param height Define the height of the texture
  12849. * @param scene Define the scene the texture belongs to
  12850. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12851. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12852. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12853. * @returns the luminance texture
  12854. */
  12855. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12856. /**
  12857. * Creates a luminance alpha texture from some data.
  12858. * @param data Define the texture data
  12859. * @param width Define the width of the texture
  12860. * @param height Define the height of the texture
  12861. * @param scene Define the scene the texture belongs to
  12862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12865. * @returns the luminance alpha texture
  12866. */
  12867. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12868. /**
  12869. * Creates an alpha texture from some data.
  12870. * @param data Define the texture data
  12871. * @param width Define the width of the texture
  12872. * @param height Define the height of the texture
  12873. * @param scene Define the scene the texture belongs to
  12874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12877. * @returns the alpha texture
  12878. */
  12879. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12880. /**
  12881. * Creates a RGB texture from some data.
  12882. * @param data Define the texture data
  12883. * @param width Define the width of the texture
  12884. * @param height Define the height of the texture
  12885. * @param scene Define the scene the texture belongs to
  12886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12889. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12890. * @returns the RGB alpha texture
  12891. */
  12892. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12893. /**
  12894. * Creates a RGBA texture from some data.
  12895. * @param data Define the texture data
  12896. * @param width Define the width of the texture
  12897. * @param height Define the height of the texture
  12898. * @param scene Define the scene the texture belongs to
  12899. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12900. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12901. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12902. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12903. * @returns the RGBA texture
  12904. */
  12905. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12906. /**
  12907. * Creates a R texture from some data.
  12908. * @param data Define the texture data
  12909. * @param width Define the width of the texture
  12910. * @param height Define the height of the texture
  12911. * @param scene Define the scene the texture belongs to
  12912. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12913. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12914. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12915. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12916. * @returns the R texture
  12917. */
  12918. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12919. }
  12920. }
  12921. declare module BABYLON {
  12922. /**
  12923. * Interface for the size containing width and height
  12924. */
  12925. export interface ISize {
  12926. /**
  12927. * Width
  12928. */
  12929. width: number;
  12930. /**
  12931. * Heighht
  12932. */
  12933. height: number;
  12934. }
  12935. /**
  12936. * Size containing widht and height
  12937. */
  12938. export class Size implements ISize {
  12939. /**
  12940. * Width
  12941. */
  12942. width: number;
  12943. /**
  12944. * Height
  12945. */
  12946. height: number;
  12947. /**
  12948. * Creates a Size object from the given width and height (floats).
  12949. * @param width width of the new size
  12950. * @param height height of the new size
  12951. */
  12952. constructor(width: number, height: number);
  12953. /**
  12954. * Returns a string with the Size width and height
  12955. * @returns a string with the Size width and height
  12956. */
  12957. toString(): string;
  12958. /**
  12959. * "Size"
  12960. * @returns the string "Size"
  12961. */
  12962. getClassName(): string;
  12963. /**
  12964. * Returns the Size hash code.
  12965. * @returns a hash code for a unique width and height
  12966. */
  12967. getHashCode(): number;
  12968. /**
  12969. * Updates the current size from the given one.
  12970. * @param src the given size
  12971. */
  12972. copyFrom(src: Size): void;
  12973. /**
  12974. * Updates in place the current Size from the given floats.
  12975. * @param width width of the new size
  12976. * @param height height of the new size
  12977. * @returns the updated Size.
  12978. */
  12979. copyFromFloats(width: number, height: number): Size;
  12980. /**
  12981. * Updates in place the current Size from the given floats.
  12982. * @param width width to set
  12983. * @param height height to set
  12984. * @returns the updated Size.
  12985. */
  12986. set(width: number, height: number): Size;
  12987. /**
  12988. * Multiplies the width and height by numbers
  12989. * @param w factor to multiple the width by
  12990. * @param h factor to multiple the height by
  12991. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12992. */
  12993. multiplyByFloats(w: number, h: number): Size;
  12994. /**
  12995. * Clones the size
  12996. * @returns a new Size copied from the given one.
  12997. */
  12998. clone(): Size;
  12999. /**
  13000. * True if the current Size and the given one width and height are strictly equal.
  13001. * @param other the other size to compare against
  13002. * @returns True if the current Size and the given one width and height are strictly equal.
  13003. */
  13004. equals(other: Size): boolean;
  13005. /**
  13006. * The surface of the Size : width * height (float).
  13007. */
  13008. get surface(): number;
  13009. /**
  13010. * Create a new size of zero
  13011. * @returns a new Size set to (0.0, 0.0)
  13012. */
  13013. static Zero(): Size;
  13014. /**
  13015. * Sums the width and height of two sizes
  13016. * @param otherSize size to add to this size
  13017. * @returns a new Size set as the addition result of the current Size and the given one.
  13018. */
  13019. add(otherSize: Size): Size;
  13020. /**
  13021. * Subtracts the width and height of two
  13022. * @param otherSize size to subtract to this size
  13023. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13024. */
  13025. subtract(otherSize: Size): Size;
  13026. /**
  13027. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13028. * @param start starting size to lerp between
  13029. * @param end end size to lerp between
  13030. * @param amount amount to lerp between the start and end values
  13031. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13032. */
  13033. static Lerp(start: Size, end: Size, amount: number): Size;
  13034. }
  13035. }
  13036. declare module BABYLON {
  13037. /**
  13038. * Defines a runtime animation
  13039. */
  13040. export class RuntimeAnimation {
  13041. private _events;
  13042. /**
  13043. * The current frame of the runtime animation
  13044. */
  13045. private _currentFrame;
  13046. /**
  13047. * The animation used by the runtime animation
  13048. */
  13049. private _animation;
  13050. /**
  13051. * The target of the runtime animation
  13052. */
  13053. private _target;
  13054. /**
  13055. * The initiating animatable
  13056. */
  13057. private _host;
  13058. /**
  13059. * The original value of the runtime animation
  13060. */
  13061. private _originalValue;
  13062. /**
  13063. * The original blend value of the runtime animation
  13064. */
  13065. private _originalBlendValue;
  13066. /**
  13067. * The offsets cache of the runtime animation
  13068. */
  13069. private _offsetsCache;
  13070. /**
  13071. * The high limits cache of the runtime animation
  13072. */
  13073. private _highLimitsCache;
  13074. /**
  13075. * Specifies if the runtime animation has been stopped
  13076. */
  13077. private _stopped;
  13078. /**
  13079. * The blending factor of the runtime animation
  13080. */
  13081. private _blendingFactor;
  13082. /**
  13083. * The BabylonJS scene
  13084. */
  13085. private _scene;
  13086. /**
  13087. * The current value of the runtime animation
  13088. */
  13089. private _currentValue;
  13090. /** @hidden */
  13091. _animationState: _IAnimationState;
  13092. /**
  13093. * The active target of the runtime animation
  13094. */
  13095. private _activeTargets;
  13096. private _currentActiveTarget;
  13097. private _directTarget;
  13098. /**
  13099. * The target path of the runtime animation
  13100. */
  13101. private _targetPath;
  13102. /**
  13103. * The weight of the runtime animation
  13104. */
  13105. private _weight;
  13106. /**
  13107. * The ratio offset of the runtime animation
  13108. */
  13109. private _ratioOffset;
  13110. /**
  13111. * The previous delay of the runtime animation
  13112. */
  13113. private _previousDelay;
  13114. /**
  13115. * The previous ratio of the runtime animation
  13116. */
  13117. private _previousRatio;
  13118. private _enableBlending;
  13119. private _keys;
  13120. private _minFrame;
  13121. private _maxFrame;
  13122. private _minValue;
  13123. private _maxValue;
  13124. private _targetIsArray;
  13125. /**
  13126. * Gets the current frame of the runtime animation
  13127. */
  13128. get currentFrame(): number;
  13129. /**
  13130. * Gets the weight of the runtime animation
  13131. */
  13132. get weight(): number;
  13133. /**
  13134. * Gets the current value of the runtime animation
  13135. */
  13136. get currentValue(): any;
  13137. /**
  13138. * Gets the target path of the runtime animation
  13139. */
  13140. get targetPath(): string;
  13141. /**
  13142. * Gets the actual target of the runtime animation
  13143. */
  13144. get target(): any;
  13145. /** @hidden */
  13146. _onLoop: () => void;
  13147. /**
  13148. * Create a new RuntimeAnimation object
  13149. * @param target defines the target of the animation
  13150. * @param animation defines the source animation object
  13151. * @param scene defines the hosting scene
  13152. * @param host defines the initiating Animatable
  13153. */
  13154. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13155. private _preparePath;
  13156. /**
  13157. * Gets the animation from the runtime animation
  13158. */
  13159. get animation(): Animation;
  13160. /**
  13161. * Resets the runtime animation to the beginning
  13162. * @param restoreOriginal defines whether to restore the target property to the original value
  13163. */
  13164. reset(restoreOriginal?: boolean): void;
  13165. /**
  13166. * Specifies if the runtime animation is stopped
  13167. * @returns Boolean specifying if the runtime animation is stopped
  13168. */
  13169. isStopped(): boolean;
  13170. /**
  13171. * Disposes of the runtime animation
  13172. */
  13173. dispose(): void;
  13174. /**
  13175. * Apply the interpolated value to the target
  13176. * @param currentValue defines the value computed by the animation
  13177. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13178. */
  13179. setValue(currentValue: any, weight: number): void;
  13180. private _getOriginalValues;
  13181. private _setValue;
  13182. /**
  13183. * Gets the loop pmode of the runtime animation
  13184. * @returns Loop Mode
  13185. */
  13186. private _getCorrectLoopMode;
  13187. /**
  13188. * Move the current animation to a given frame
  13189. * @param frame defines the frame to move to
  13190. */
  13191. goToFrame(frame: number): void;
  13192. /**
  13193. * @hidden Internal use only
  13194. */
  13195. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13196. /**
  13197. * Execute the current animation
  13198. * @param delay defines the delay to add to the current frame
  13199. * @param from defines the lower bound of the animation range
  13200. * @param to defines the upper bound of the animation range
  13201. * @param loop defines if the current animation must loop
  13202. * @param speedRatio defines the current speed ratio
  13203. * @param weight defines the weight of the animation (default is -1 so no weight)
  13204. * @param onLoop optional callback called when animation loops
  13205. * @returns a boolean indicating if the animation is running
  13206. */
  13207. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13208. }
  13209. }
  13210. declare module BABYLON {
  13211. /**
  13212. * Class used to store an actual running animation
  13213. */
  13214. export class Animatable {
  13215. /** defines the target object */
  13216. target: any;
  13217. /** defines the starting frame number (default is 0) */
  13218. fromFrame: number;
  13219. /** defines the ending frame number (default is 100) */
  13220. toFrame: number;
  13221. /** defines if the animation must loop (default is false) */
  13222. loopAnimation: boolean;
  13223. /** defines a callback to call when animation ends if it is not looping */
  13224. onAnimationEnd?: (() => void) | null | undefined;
  13225. /** defines a callback to call when animation loops */
  13226. onAnimationLoop?: (() => void) | null | undefined;
  13227. private _localDelayOffset;
  13228. private _pausedDelay;
  13229. private _runtimeAnimations;
  13230. private _paused;
  13231. private _scene;
  13232. private _speedRatio;
  13233. private _weight;
  13234. private _syncRoot;
  13235. /**
  13236. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13237. * This will only apply for non looping animation (default is true)
  13238. */
  13239. disposeOnEnd: boolean;
  13240. /**
  13241. * Gets a boolean indicating if the animation has started
  13242. */
  13243. animationStarted: boolean;
  13244. /**
  13245. * Observer raised when the animation ends
  13246. */
  13247. onAnimationEndObservable: Observable<Animatable>;
  13248. /**
  13249. * Observer raised when the animation loops
  13250. */
  13251. onAnimationLoopObservable: Observable<Animatable>;
  13252. /**
  13253. * Gets the root Animatable used to synchronize and normalize animations
  13254. */
  13255. get syncRoot(): Nullable<Animatable>;
  13256. /**
  13257. * Gets the current frame of the first RuntimeAnimation
  13258. * Used to synchronize Animatables
  13259. */
  13260. get masterFrame(): number;
  13261. /**
  13262. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13263. */
  13264. get weight(): number;
  13265. set weight(value: number);
  13266. /**
  13267. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13268. */
  13269. get speedRatio(): number;
  13270. set speedRatio(value: number);
  13271. /**
  13272. * Creates a new Animatable
  13273. * @param scene defines the hosting scene
  13274. * @param target defines the target object
  13275. * @param fromFrame defines the starting frame number (default is 0)
  13276. * @param toFrame defines the ending frame number (default is 100)
  13277. * @param loopAnimation defines if the animation must loop (default is false)
  13278. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13279. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13280. * @param animations defines a group of animation to add to the new Animatable
  13281. * @param onAnimationLoop defines a callback to call when animation loops
  13282. */
  13283. constructor(scene: Scene,
  13284. /** defines the target object */
  13285. target: any,
  13286. /** defines the starting frame number (default is 0) */
  13287. fromFrame?: number,
  13288. /** defines the ending frame number (default is 100) */
  13289. toFrame?: number,
  13290. /** defines if the animation must loop (default is false) */
  13291. loopAnimation?: boolean, speedRatio?: number,
  13292. /** defines a callback to call when animation ends if it is not looping */
  13293. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13294. /** defines a callback to call when animation loops */
  13295. onAnimationLoop?: (() => void) | null | undefined);
  13296. /**
  13297. * Synchronize and normalize current Animatable with a source Animatable
  13298. * This is useful when using animation weights and when animations are not of the same length
  13299. * @param root defines the root Animatable to synchronize with
  13300. * @returns the current Animatable
  13301. */
  13302. syncWith(root: Animatable): Animatable;
  13303. /**
  13304. * Gets the list of runtime animations
  13305. * @returns an array of RuntimeAnimation
  13306. */
  13307. getAnimations(): RuntimeAnimation[];
  13308. /**
  13309. * Adds more animations to the current animatable
  13310. * @param target defines the target of the animations
  13311. * @param animations defines the new animations to add
  13312. */
  13313. appendAnimations(target: any, animations: Animation[]): void;
  13314. /**
  13315. * Gets the source animation for a specific property
  13316. * @param property defines the propertyu to look for
  13317. * @returns null or the source animation for the given property
  13318. */
  13319. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13320. /**
  13321. * Gets the runtime animation for a specific property
  13322. * @param property defines the propertyu to look for
  13323. * @returns null or the runtime animation for the given property
  13324. */
  13325. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13326. /**
  13327. * Resets the animatable to its original state
  13328. */
  13329. reset(): void;
  13330. /**
  13331. * Allows the animatable to blend with current running animations
  13332. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13333. * @param blendingSpeed defines the blending speed to use
  13334. */
  13335. enableBlending(blendingSpeed: number): void;
  13336. /**
  13337. * Disable animation blending
  13338. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13339. */
  13340. disableBlending(): void;
  13341. /**
  13342. * Jump directly to a given frame
  13343. * @param frame defines the frame to jump to
  13344. */
  13345. goToFrame(frame: number): void;
  13346. /**
  13347. * Pause the animation
  13348. */
  13349. pause(): void;
  13350. /**
  13351. * Restart the animation
  13352. */
  13353. restart(): void;
  13354. private _raiseOnAnimationEnd;
  13355. /**
  13356. * Stop and delete the current animation
  13357. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13358. * @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)
  13359. */
  13360. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13361. /**
  13362. * Wait asynchronously for the animation to end
  13363. * @returns a promise which will be fullfilled when the animation ends
  13364. */
  13365. waitAsync(): Promise<Animatable>;
  13366. /** @hidden */
  13367. _animate(delay: number): boolean;
  13368. }
  13369. interface Scene {
  13370. /** @hidden */
  13371. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13372. /** @hidden */
  13373. _processLateAnimationBindingsForMatrices(holder: {
  13374. totalWeight: number;
  13375. animations: RuntimeAnimation[];
  13376. originalValue: Matrix;
  13377. }): any;
  13378. /** @hidden */
  13379. _processLateAnimationBindingsForQuaternions(holder: {
  13380. totalWeight: number;
  13381. animations: RuntimeAnimation[];
  13382. originalValue: Quaternion;
  13383. }, refQuaternion: Quaternion): Quaternion;
  13384. /** @hidden */
  13385. _processLateAnimationBindings(): void;
  13386. /**
  13387. * Will start the animation sequence of a given target
  13388. * @param target defines the target
  13389. * @param from defines from which frame should animation start
  13390. * @param to defines until which frame should animation run.
  13391. * @param weight defines the weight to apply to the animation (1.0 by default)
  13392. * @param loop defines if the animation loops
  13393. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13394. * @param onAnimationEnd defines the function to be executed when the animation ends
  13395. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13396. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13397. * @param onAnimationLoop defines the callback to call when an animation loops
  13398. * @returns the animatable object created for this animation
  13399. */
  13400. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13401. /**
  13402. * Will start the animation sequence of a given target
  13403. * @param target defines the target
  13404. * @param from defines from which frame should animation start
  13405. * @param to defines until which frame should animation run.
  13406. * @param loop defines if the animation loops
  13407. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13408. * @param onAnimationEnd defines the function to be executed when the animation ends
  13409. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13410. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13411. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13412. * @param onAnimationLoop defines the callback to call when an animation loops
  13413. * @returns the animatable object created for this animation
  13414. */
  13415. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13416. /**
  13417. * Will start the animation sequence of a given target and its hierarchy
  13418. * @param target defines the target
  13419. * @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.
  13420. * @param from defines from which frame should animation start
  13421. * @param to defines until which frame should animation run.
  13422. * @param loop defines if the animation loops
  13423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13424. * @param onAnimationEnd defines the function to be executed when the animation ends
  13425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13427. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13428. * @param onAnimationLoop defines the callback to call when an animation loops
  13429. * @returns the list of created animatables
  13430. */
  13431. 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[];
  13432. /**
  13433. * Begin a new animation on a given node
  13434. * @param target defines the target where the animation will take place
  13435. * @param animations defines the list of animations to start
  13436. * @param from defines the initial value
  13437. * @param to defines the final value
  13438. * @param loop defines if you want animation to loop (off by default)
  13439. * @param speedRatio defines the speed ratio to apply to all animations
  13440. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13441. * @param onAnimationLoop defines the callback to call when an animation loops
  13442. * @returns the list of created animatables
  13443. */
  13444. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13445. /**
  13446. * Begin a new animation on a given node and its hierarchy
  13447. * @param target defines the root node where the animation will take place
  13448. * @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.
  13449. * @param animations defines the list of animations to start
  13450. * @param from defines the initial value
  13451. * @param to defines the final value
  13452. * @param loop defines if you want animation to loop (off by default)
  13453. * @param speedRatio defines the speed ratio to apply to all animations
  13454. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13455. * @param onAnimationLoop defines the callback to call when an animation loops
  13456. * @returns the list of animatables created for all nodes
  13457. */
  13458. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13459. /**
  13460. * Gets the animatable associated with a specific target
  13461. * @param target defines the target of the animatable
  13462. * @returns the required animatable if found
  13463. */
  13464. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13465. /**
  13466. * Gets all animatables associated with a given target
  13467. * @param target defines the target to look animatables for
  13468. * @returns an array of Animatables
  13469. */
  13470. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13471. /**
  13472. * Stops and removes all animations that have been applied to the scene
  13473. */
  13474. stopAllAnimations(): void;
  13475. /**
  13476. * Gets the current delta time used by animation engine
  13477. */
  13478. deltaTime: number;
  13479. }
  13480. interface Bone {
  13481. /**
  13482. * Copy an animation range from another bone
  13483. * @param source defines the source bone
  13484. * @param rangeName defines the range name to copy
  13485. * @param frameOffset defines the frame offset
  13486. * @param rescaleAsRequired defines if rescaling must be applied if required
  13487. * @param skelDimensionsRatio defines the scaling ratio
  13488. * @returns true if operation was successful
  13489. */
  13490. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Class used to override all child animations of a given target
  13496. */
  13497. export class AnimationPropertiesOverride {
  13498. /**
  13499. * Gets or sets a value indicating if animation blending must be used
  13500. */
  13501. enableBlending: boolean;
  13502. /**
  13503. * Gets or sets the blending speed to use when enableBlending is true
  13504. */
  13505. blendingSpeed: number;
  13506. /**
  13507. * Gets or sets the default loop mode to use
  13508. */
  13509. loopMode: number;
  13510. }
  13511. }
  13512. declare module BABYLON {
  13513. /**
  13514. * Class used to handle skinning animations
  13515. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13516. */
  13517. export class Skeleton implements IAnimatable {
  13518. /** defines the skeleton name */
  13519. name: string;
  13520. /** defines the skeleton Id */
  13521. id: string;
  13522. /**
  13523. * Defines the list of child bones
  13524. */
  13525. bones: Bone[];
  13526. /**
  13527. * Defines an estimate of the dimension of the skeleton at rest
  13528. */
  13529. dimensionsAtRest: Vector3;
  13530. /**
  13531. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13532. */
  13533. needInitialSkinMatrix: boolean;
  13534. /**
  13535. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13536. */
  13537. overrideMesh: Nullable<AbstractMesh>;
  13538. /**
  13539. * Gets the list of animations attached to this skeleton
  13540. */
  13541. animations: Array<Animation>;
  13542. private _scene;
  13543. private _isDirty;
  13544. private _transformMatrices;
  13545. private _transformMatrixTexture;
  13546. private _meshesWithPoseMatrix;
  13547. private _animatables;
  13548. private _identity;
  13549. private _synchronizedWithMesh;
  13550. private _ranges;
  13551. private _lastAbsoluteTransformsUpdateId;
  13552. private _canUseTextureForBones;
  13553. private _uniqueId;
  13554. /** @hidden */
  13555. _numBonesWithLinkedTransformNode: number;
  13556. /** @hidden */
  13557. _hasWaitingData: Nullable<boolean>;
  13558. /**
  13559. * Specifies if the skeleton should be serialized
  13560. */
  13561. doNotSerialize: boolean;
  13562. private _useTextureToStoreBoneMatrices;
  13563. /**
  13564. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13565. * Please note that this option is not available if the hardware does not support it
  13566. */
  13567. get useTextureToStoreBoneMatrices(): boolean;
  13568. set useTextureToStoreBoneMatrices(value: boolean);
  13569. private _animationPropertiesOverride;
  13570. /**
  13571. * Gets or sets the animation properties override
  13572. */
  13573. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13574. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13575. /**
  13576. * List of inspectable custom properties (used by the Inspector)
  13577. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13578. */
  13579. inspectableCustomProperties: IInspectable[];
  13580. /**
  13581. * An observable triggered before computing the skeleton's matrices
  13582. */
  13583. onBeforeComputeObservable: Observable<Skeleton>;
  13584. /**
  13585. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13586. */
  13587. get isUsingTextureForMatrices(): boolean;
  13588. /**
  13589. * Gets the unique ID of this skeleton
  13590. */
  13591. get uniqueId(): number;
  13592. /**
  13593. * Creates a new skeleton
  13594. * @param name defines the skeleton name
  13595. * @param id defines the skeleton Id
  13596. * @param scene defines the hosting scene
  13597. */
  13598. constructor(
  13599. /** defines the skeleton name */
  13600. name: string,
  13601. /** defines the skeleton Id */
  13602. id: string, scene: Scene);
  13603. /**
  13604. * Gets the current object class name.
  13605. * @return the class name
  13606. */
  13607. getClassName(): string;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13615. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13616. * @returns a Float32Array containing matrices data
  13617. */
  13618. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13619. /**
  13620. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13621. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13622. * @returns a raw texture containing the data
  13623. */
  13624. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13625. /**
  13626. * Gets the current hosting scene
  13627. * @returns a scene object
  13628. */
  13629. getScene(): Scene;
  13630. /**
  13631. * Gets a string representing the current skeleton data
  13632. * @param fullDetails defines a boolean indicating if we want a verbose version
  13633. * @returns a string representing the current skeleton data
  13634. */
  13635. toString(fullDetails?: boolean): string;
  13636. /**
  13637. * Get bone's index searching by name
  13638. * @param name defines bone's name to search for
  13639. * @return the indice of the bone. Returns -1 if not found
  13640. */
  13641. getBoneIndexByName(name: string): number;
  13642. /**
  13643. * Creater a new animation range
  13644. * @param name defines the name of the range
  13645. * @param from defines the start key
  13646. * @param to defines the end key
  13647. */
  13648. createAnimationRange(name: string, from: number, to: number): void;
  13649. /**
  13650. * Delete a specific animation range
  13651. * @param name defines the name of the range
  13652. * @param deleteFrames defines if frames must be removed as well
  13653. */
  13654. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13655. /**
  13656. * Gets a specific animation range
  13657. * @param name defines the name of the range to look for
  13658. * @returns the requested animation range or null if not found
  13659. */
  13660. getAnimationRange(name: string): Nullable<AnimationRange>;
  13661. /**
  13662. * Gets the list of all animation ranges defined on this skeleton
  13663. * @returns an array
  13664. */
  13665. getAnimationRanges(): Nullable<AnimationRange>[];
  13666. /**
  13667. * Copy animation range from a source skeleton.
  13668. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13669. * @param source defines the source skeleton
  13670. * @param name defines the name of the range to copy
  13671. * @param rescaleAsRequired defines if rescaling must be applied if required
  13672. * @returns true if operation was successful
  13673. */
  13674. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13675. /**
  13676. * Forces the skeleton to go to rest pose
  13677. */
  13678. returnToRest(): void;
  13679. private _getHighestAnimationFrame;
  13680. /**
  13681. * Begin a specific animation range
  13682. * @param name defines the name of the range to start
  13683. * @param loop defines if looping must be turned on (false by default)
  13684. * @param speedRatio defines the speed ratio to apply (1 by default)
  13685. * @param onAnimationEnd defines a callback which will be called when animation will end
  13686. * @returns a new animatable
  13687. */
  13688. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13689. /** @hidden */
  13690. _markAsDirty(): void;
  13691. /** @hidden */
  13692. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13693. /** @hidden */
  13694. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13695. private _computeTransformMatrices;
  13696. /**
  13697. * Build all resources required to render a skeleton
  13698. */
  13699. prepare(): void;
  13700. /**
  13701. * Gets the list of animatables currently running for this skeleton
  13702. * @returns an array of animatables
  13703. */
  13704. getAnimatables(): IAnimatable[];
  13705. /**
  13706. * Clone the current skeleton
  13707. * @param name defines the name of the new skeleton
  13708. * @param id defines the id of the new skeleton
  13709. * @returns the new skeleton
  13710. */
  13711. clone(name: string, id?: string): Skeleton;
  13712. /**
  13713. * Enable animation blending for this skeleton
  13714. * @param blendingSpeed defines the blending speed to apply
  13715. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13716. */
  13717. enableBlending(blendingSpeed?: number): void;
  13718. /**
  13719. * Releases all resources associated with the current skeleton
  13720. */
  13721. dispose(): void;
  13722. /**
  13723. * Serialize the skeleton in a JSON object
  13724. * @returns a JSON object
  13725. */
  13726. serialize(): any;
  13727. /**
  13728. * Creates a new skeleton from serialized data
  13729. * @param parsedSkeleton defines the serialized data
  13730. * @param scene defines the hosting scene
  13731. * @returns a new skeleton
  13732. */
  13733. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13734. /**
  13735. * Compute all node absolute transforms
  13736. * @param forceUpdate defines if computation must be done even if cache is up to date
  13737. */
  13738. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13739. /**
  13740. * Gets the root pose matrix
  13741. * @returns a matrix
  13742. */
  13743. getPoseMatrix(): Nullable<Matrix>;
  13744. /**
  13745. * Sorts bones per internal index
  13746. */
  13747. sortBones(): void;
  13748. private _sortBones;
  13749. }
  13750. }
  13751. declare module BABYLON {
  13752. /**
  13753. * Class used to store bone information
  13754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13755. */
  13756. export class Bone extends Node {
  13757. /**
  13758. * defines the bone name
  13759. */
  13760. name: string;
  13761. private static _tmpVecs;
  13762. private static _tmpQuat;
  13763. private static _tmpMats;
  13764. /**
  13765. * Gets the list of child bones
  13766. */
  13767. children: Bone[];
  13768. /** Gets the animations associated with this bone */
  13769. animations: Animation[];
  13770. /**
  13771. * Gets or sets bone length
  13772. */
  13773. length: number;
  13774. /**
  13775. * @hidden Internal only
  13776. * Set this value to map this bone to a different index in the transform matrices
  13777. * Set this value to -1 to exclude the bone from the transform matrices
  13778. */
  13779. _index: Nullable<number>;
  13780. private _skeleton;
  13781. private _localMatrix;
  13782. private _restPose;
  13783. private _baseMatrix;
  13784. private _absoluteTransform;
  13785. private _invertedAbsoluteTransform;
  13786. private _parent;
  13787. private _scalingDeterminant;
  13788. private _worldTransform;
  13789. private _localScaling;
  13790. private _localRotation;
  13791. private _localPosition;
  13792. private _needToDecompose;
  13793. private _needToCompose;
  13794. /** @hidden */
  13795. _linkedTransformNode: Nullable<TransformNode>;
  13796. /** @hidden */
  13797. _waitingTransformNodeId: Nullable<string>;
  13798. /** @hidden */
  13799. get _matrix(): Matrix;
  13800. /** @hidden */
  13801. set _matrix(value: Matrix);
  13802. /**
  13803. * Create a new bone
  13804. * @param name defines the bone name
  13805. * @param skeleton defines the parent skeleton
  13806. * @param parentBone defines the parent (can be null if the bone is the root)
  13807. * @param localMatrix defines the local matrix
  13808. * @param restPose defines the rest pose matrix
  13809. * @param baseMatrix defines the base matrix
  13810. * @param index defines index of the bone in the hiearchy
  13811. */
  13812. constructor(
  13813. /**
  13814. * defines the bone name
  13815. */
  13816. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13817. /**
  13818. * Gets the current object class name.
  13819. * @return the class name
  13820. */
  13821. getClassName(): string;
  13822. /**
  13823. * Gets the parent skeleton
  13824. * @returns a skeleton
  13825. */
  13826. getSkeleton(): Skeleton;
  13827. /**
  13828. * Gets parent bone
  13829. * @returns a bone or null if the bone is the root of the bone hierarchy
  13830. */
  13831. getParent(): Nullable<Bone>;
  13832. /**
  13833. * Returns an array containing the root bones
  13834. * @returns an array containing the root bones
  13835. */
  13836. getChildren(): Array<Bone>;
  13837. /**
  13838. * Gets the node index in matrix array generated for rendering
  13839. * @returns the node index
  13840. */
  13841. getIndex(): number;
  13842. /**
  13843. * Sets the parent bone
  13844. * @param parent defines the parent (can be null if the bone is the root)
  13845. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13846. */
  13847. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13848. /**
  13849. * Gets the local matrix
  13850. * @returns a matrix
  13851. */
  13852. getLocalMatrix(): Matrix;
  13853. /**
  13854. * Gets the base matrix (initial matrix which remains unchanged)
  13855. * @returns a matrix
  13856. */
  13857. getBaseMatrix(): Matrix;
  13858. /**
  13859. * Gets the rest pose matrix
  13860. * @returns a matrix
  13861. */
  13862. getRestPose(): Matrix;
  13863. /**
  13864. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13865. */
  13866. getWorldMatrix(): Matrix;
  13867. /**
  13868. * Sets the local matrix to rest pose matrix
  13869. */
  13870. returnToRest(): void;
  13871. /**
  13872. * Gets the inverse of the absolute transform matrix.
  13873. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13874. * @returns a matrix
  13875. */
  13876. getInvertedAbsoluteTransform(): Matrix;
  13877. /**
  13878. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13879. * @returns a matrix
  13880. */
  13881. getAbsoluteTransform(): Matrix;
  13882. /**
  13883. * Links with the given transform node.
  13884. * The local matrix of this bone is copied from the transform node every frame.
  13885. * @param transformNode defines the transform node to link to
  13886. */
  13887. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13888. /**
  13889. * Gets the node used to drive the bone's transformation
  13890. * @returns a transform node or null
  13891. */
  13892. getTransformNode(): Nullable<TransformNode>;
  13893. /** Gets or sets current position (in local space) */
  13894. get position(): Vector3;
  13895. set position(newPosition: Vector3);
  13896. /** Gets or sets current rotation (in local space) */
  13897. get rotation(): Vector3;
  13898. set rotation(newRotation: Vector3);
  13899. /** Gets or sets current rotation quaternion (in local space) */
  13900. get rotationQuaternion(): Quaternion;
  13901. set rotationQuaternion(newRotation: Quaternion);
  13902. /** Gets or sets current scaling (in local space) */
  13903. get scaling(): Vector3;
  13904. set scaling(newScaling: Vector3);
  13905. /**
  13906. * Gets the animation properties override
  13907. */
  13908. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13909. private _decompose;
  13910. private _compose;
  13911. /**
  13912. * Update the base and local matrices
  13913. * @param matrix defines the new base or local matrix
  13914. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13915. * @param updateLocalMatrix defines if the local matrix should be updated
  13916. */
  13917. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13918. /** @hidden */
  13919. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13920. /**
  13921. * Flag the bone as dirty (Forcing it to update everything)
  13922. */
  13923. markAsDirty(): void;
  13924. /** @hidden */
  13925. _markAsDirtyAndCompose(): void;
  13926. private _markAsDirtyAndDecompose;
  13927. /**
  13928. * Translate the bone in local or world space
  13929. * @param vec The amount to translate the bone
  13930. * @param space The space that the translation is in
  13931. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13932. */
  13933. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13934. /**
  13935. * Set the postion of the bone in local or world space
  13936. * @param position The position to set the bone
  13937. * @param space The space that the position is in
  13938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13939. */
  13940. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13941. /**
  13942. * Set the absolute position of the bone (world space)
  13943. * @param position The position to set the bone
  13944. * @param mesh The mesh that this bone is attached to
  13945. */
  13946. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Scale the bone on the x, y and z axes (in local space)
  13949. * @param x The amount to scale the bone on the x axis
  13950. * @param y The amount to scale the bone on the y axis
  13951. * @param z The amount to scale the bone on the z axis
  13952. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13953. */
  13954. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13955. /**
  13956. * Set the bone scaling in local space
  13957. * @param scale defines the scaling vector
  13958. */
  13959. setScale(scale: Vector3): void;
  13960. /**
  13961. * Gets the current scaling in local space
  13962. * @returns the current scaling vector
  13963. */
  13964. getScale(): Vector3;
  13965. /**
  13966. * Gets the current scaling in local space and stores it in a target vector
  13967. * @param result defines the target vector
  13968. */
  13969. getScaleToRef(result: Vector3): void;
  13970. /**
  13971. * Set the yaw, pitch, and roll of the bone in local or world space
  13972. * @param yaw The rotation of the bone on the y axis
  13973. * @param pitch The rotation of the bone on the x axis
  13974. * @param roll The rotation of the bone on the z axis
  13975. * @param space The space that the axes of rotation are in
  13976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13977. */
  13978. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13979. /**
  13980. * Add a rotation to the bone on an axis in local or world space
  13981. * @param axis The axis to rotate the bone on
  13982. * @param amount The amount to rotate the bone
  13983. * @param space The space that the axis is in
  13984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13985. */
  13986. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13987. /**
  13988. * Set the rotation of the bone to a particular axis angle in local or world space
  13989. * @param axis The axis to rotate the bone on
  13990. * @param angle The angle that the bone should be rotated to
  13991. * @param space The space that the axis is in
  13992. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13993. */
  13994. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13995. /**
  13996. * Set the euler rotation of the bone in local of world space
  13997. * @param rotation The euler rotation that the bone should be set to
  13998. * @param space The space that the rotation is in
  13999. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14000. */
  14001. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14002. /**
  14003. * Set the quaternion rotation of the bone in local of world space
  14004. * @param quat The quaternion rotation that the bone should be set to
  14005. * @param space The space that the rotation is in
  14006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14007. */
  14008. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14009. /**
  14010. * Set the rotation matrix of the bone in local of world space
  14011. * @param rotMat The rotation matrix that the bone should be set to
  14012. * @param space The space that the rotation is in
  14013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14014. */
  14015. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14016. private _rotateWithMatrix;
  14017. private _getNegativeRotationToRef;
  14018. /**
  14019. * Get the position of the bone in local or world space
  14020. * @param space The space that the returned position is in
  14021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14022. * @returns The position of the bone
  14023. */
  14024. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14025. /**
  14026. * Copy the position of the bone to a vector3 in local or world space
  14027. * @param space The space that the returned position is in
  14028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14029. * @param result The vector3 to copy the position to
  14030. */
  14031. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14032. /**
  14033. * Get the absolute position of the bone (world space)
  14034. * @param mesh The mesh that this bone is attached to
  14035. * @returns The absolute position of the bone
  14036. */
  14037. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14038. /**
  14039. * Copy the absolute position of the bone (world space) to the result param
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @param result The vector3 to copy the absolute position to
  14042. */
  14043. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14044. /**
  14045. * Compute the absolute transforms of this bone and its children
  14046. */
  14047. computeAbsoluteTransforms(): void;
  14048. /**
  14049. * Get the world direction from an axis that is in the local space of the bone
  14050. * @param localAxis The local direction that is used to compute the world direction
  14051. * @param mesh The mesh that this bone is attached to
  14052. * @returns The world direction
  14053. */
  14054. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14055. /**
  14056. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14057. * @param localAxis The local direction that is used to compute the world direction
  14058. * @param mesh The mesh that this bone is attached to
  14059. * @param result The vector3 that the world direction will be copied to
  14060. */
  14061. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14062. /**
  14063. * Get the euler rotation of the bone in local or world space
  14064. * @param space The space that the rotation should be in
  14065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14066. * @returns The euler rotation
  14067. */
  14068. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14069. /**
  14070. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14071. * @param space The space that the rotation should be in
  14072. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14073. * @param result The vector3 that the rotation should be copied to
  14074. */
  14075. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14076. /**
  14077. * Get the quaternion rotation of the bone in either local or world space
  14078. * @param space The space that the rotation should be in
  14079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14080. * @returns The quaternion rotation
  14081. */
  14082. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14083. /**
  14084. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14085. * @param space The space that the rotation should be in
  14086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14087. * @param result The quaternion that the rotation should be copied to
  14088. */
  14089. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14090. /**
  14091. * Get the rotation matrix of the bone in local or world space
  14092. * @param space The space that the rotation should be in
  14093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14094. * @returns The rotation matrix
  14095. */
  14096. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14097. /**
  14098. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14099. * @param space The space that the rotation should be in
  14100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14101. * @param result The quaternion that the rotation should be copied to
  14102. */
  14103. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14104. /**
  14105. * Get the world position of a point that is in the local space of the bone
  14106. * @param position The local position
  14107. * @param mesh The mesh that this bone is attached to
  14108. * @returns The world position
  14109. */
  14110. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14111. /**
  14112. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14113. * @param position The local position
  14114. * @param mesh The mesh that this bone is attached to
  14115. * @param result The vector3 that the world position should be copied to
  14116. */
  14117. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14118. /**
  14119. * Get the local position of a point that is in world space
  14120. * @param position The world position
  14121. * @param mesh The mesh that this bone is attached to
  14122. * @returns The local position
  14123. */
  14124. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14125. /**
  14126. * Get the local position of a point that is in world space and copy it to the result param
  14127. * @param position The world position
  14128. * @param mesh The mesh that this bone is attached to
  14129. * @param result The vector3 that the local position should be copied to
  14130. */
  14131. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14132. }
  14133. }
  14134. declare module BABYLON {
  14135. /**
  14136. * 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.
  14137. * @see https://doc.babylonjs.com/how_to/transformnode
  14138. */
  14139. export class TransformNode extends Node {
  14140. /**
  14141. * Object will not rotate to face the camera
  14142. */
  14143. static BILLBOARDMODE_NONE: number;
  14144. /**
  14145. * Object will rotate to face the camera but only on the x axis
  14146. */
  14147. static BILLBOARDMODE_X: number;
  14148. /**
  14149. * Object will rotate to face the camera but only on the y axis
  14150. */
  14151. static BILLBOARDMODE_Y: number;
  14152. /**
  14153. * Object will rotate to face the camera but only on the z axis
  14154. */
  14155. static BILLBOARDMODE_Z: number;
  14156. /**
  14157. * Object will rotate to face the camera
  14158. */
  14159. static BILLBOARDMODE_ALL: number;
  14160. /**
  14161. * Object will rotate to face the camera's position instead of orientation
  14162. */
  14163. static BILLBOARDMODE_USE_POSITION: number;
  14164. private _forward;
  14165. private _forwardInverted;
  14166. private _up;
  14167. private _right;
  14168. private _rightInverted;
  14169. private _position;
  14170. private _rotation;
  14171. private _rotationQuaternion;
  14172. protected _scaling: Vector3;
  14173. protected _isDirty: boolean;
  14174. private _transformToBoneReferal;
  14175. private _isAbsoluteSynced;
  14176. private _billboardMode;
  14177. /**
  14178. * Gets or sets the billboard mode. Default is 0.
  14179. *
  14180. * | Value | Type | Description |
  14181. * | --- | --- | --- |
  14182. * | 0 | BILLBOARDMODE_NONE | |
  14183. * | 1 | BILLBOARDMODE_X | |
  14184. * | 2 | BILLBOARDMODE_Y | |
  14185. * | 4 | BILLBOARDMODE_Z | |
  14186. * | 7 | BILLBOARDMODE_ALL | |
  14187. *
  14188. */
  14189. get billboardMode(): number;
  14190. set billboardMode(value: number);
  14191. private _preserveParentRotationForBillboard;
  14192. /**
  14193. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14194. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14195. */
  14196. get preserveParentRotationForBillboard(): boolean;
  14197. set preserveParentRotationForBillboard(value: boolean);
  14198. /**
  14199. * 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
  14200. */
  14201. scalingDeterminant: number;
  14202. private _infiniteDistance;
  14203. /**
  14204. * Gets or sets the distance of the object to max, often used by skybox
  14205. */
  14206. get infiniteDistance(): boolean;
  14207. set infiniteDistance(value: boolean);
  14208. /**
  14209. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14210. * By default the system will update normals to compensate
  14211. */
  14212. ignoreNonUniformScaling: boolean;
  14213. /**
  14214. * 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
  14215. */
  14216. reIntegrateRotationIntoRotationQuaternion: boolean;
  14217. /** @hidden */
  14218. _poseMatrix: Nullable<Matrix>;
  14219. /** @hidden */
  14220. _localMatrix: Matrix;
  14221. private _usePivotMatrix;
  14222. private _absolutePosition;
  14223. private _absoluteScaling;
  14224. private _absoluteRotationQuaternion;
  14225. private _pivotMatrix;
  14226. private _pivotMatrixInverse;
  14227. protected _postMultiplyPivotMatrix: boolean;
  14228. protected _isWorldMatrixFrozen: boolean;
  14229. /** @hidden */
  14230. _indexInSceneTransformNodesArray: number;
  14231. /**
  14232. * An event triggered after the world matrix is updated
  14233. */
  14234. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14235. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14236. /**
  14237. * Gets a string identifying the name of the class
  14238. * @returns "TransformNode" string
  14239. */
  14240. getClassName(): string;
  14241. /**
  14242. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14243. */
  14244. get position(): Vector3;
  14245. set position(newPosition: Vector3);
  14246. /**
  14247. * 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)).
  14248. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14249. */
  14250. get rotation(): Vector3;
  14251. set rotation(newRotation: Vector3);
  14252. /**
  14253. * 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)).
  14254. */
  14255. get scaling(): Vector3;
  14256. set scaling(newScaling: Vector3);
  14257. /**
  14258. * 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).
  14259. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14260. */
  14261. get rotationQuaternion(): Nullable<Quaternion>;
  14262. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14263. /**
  14264. * The forward direction of that transform in world space.
  14265. */
  14266. get forward(): Vector3;
  14267. /**
  14268. * The up direction of that transform in world space.
  14269. */
  14270. get up(): Vector3;
  14271. /**
  14272. * The right direction of that transform in world space.
  14273. */
  14274. get right(): Vector3;
  14275. /**
  14276. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14277. * @param matrix the matrix to copy the pose from
  14278. * @returns this TransformNode.
  14279. */
  14280. updatePoseMatrix(matrix: Matrix): TransformNode;
  14281. /**
  14282. * Returns the mesh Pose matrix.
  14283. * @returns the pose matrix
  14284. */
  14285. getPoseMatrix(): Matrix;
  14286. /** @hidden */
  14287. _isSynchronized(): boolean;
  14288. /** @hidden */
  14289. _initCache(): void;
  14290. /**
  14291. * Flag the transform node as dirty (Forcing it to update everything)
  14292. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14293. * @returns this transform node
  14294. */
  14295. markAsDirty(property: string): TransformNode;
  14296. /**
  14297. * Returns the current mesh absolute position.
  14298. * Returns a Vector3.
  14299. */
  14300. get absolutePosition(): Vector3;
  14301. /**
  14302. * Returns the current mesh absolute scaling.
  14303. * Returns a Vector3.
  14304. */
  14305. get absoluteScaling(): Vector3;
  14306. /**
  14307. * Returns the current mesh absolute rotation.
  14308. * Returns a Quaternion.
  14309. */
  14310. get absoluteRotationQuaternion(): Quaternion;
  14311. /**
  14312. * Sets a new matrix to apply before all other transformation
  14313. * @param matrix defines the transform matrix
  14314. * @returns the current TransformNode
  14315. */
  14316. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14317. /**
  14318. * Sets a new pivot matrix to the current node
  14319. * @param matrix defines the new pivot matrix to use
  14320. * @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
  14321. * @returns the current TransformNode
  14322. */
  14323. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14324. /**
  14325. * Returns the mesh pivot matrix.
  14326. * Default : Identity.
  14327. * @returns the matrix
  14328. */
  14329. getPivotMatrix(): Matrix;
  14330. /**
  14331. * Instantiate (when possible) or clone that node with its hierarchy
  14332. * @param newParent defines the new parent to use for the instance (or clone)
  14333. * @param options defines options to configure how copy is done
  14334. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14335. * @returns an instance (or a clone) of the current node with its hiearchy
  14336. */
  14337. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14338. doNotInstantiate: boolean;
  14339. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14340. /**
  14341. * Prevents the World matrix to be computed any longer
  14342. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14343. * @returns the TransformNode.
  14344. */
  14345. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14346. /**
  14347. * Allows back the World matrix computation.
  14348. * @returns the TransformNode.
  14349. */
  14350. unfreezeWorldMatrix(): this;
  14351. /**
  14352. * True if the World matrix has been frozen.
  14353. */
  14354. get isWorldMatrixFrozen(): boolean;
  14355. /**
  14356. * Retuns the mesh absolute position in the World.
  14357. * @returns a Vector3.
  14358. */
  14359. getAbsolutePosition(): Vector3;
  14360. /**
  14361. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14362. * @param absolutePosition the absolute position to set
  14363. * @returns the TransformNode.
  14364. */
  14365. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14366. /**
  14367. * Sets the mesh position in its local space.
  14368. * @param vector3 the position to set in localspace
  14369. * @returns the TransformNode.
  14370. */
  14371. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14372. /**
  14373. * Returns the mesh position in the local space from the current World matrix values.
  14374. * @returns a new Vector3.
  14375. */
  14376. getPositionExpressedInLocalSpace(): Vector3;
  14377. /**
  14378. * Translates the mesh along the passed Vector3 in its local space.
  14379. * @param vector3 the distance to translate in localspace
  14380. * @returns the TransformNode.
  14381. */
  14382. locallyTranslate(vector3: Vector3): TransformNode;
  14383. private static _lookAtVectorCache;
  14384. /**
  14385. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14386. * @param targetPoint the position (must be in same space as current mesh) to look at
  14387. * @param yawCor optional yaw (y-axis) correction in radians
  14388. * @param pitchCor optional pitch (x-axis) correction in radians
  14389. * @param rollCor optional roll (z-axis) correction in radians
  14390. * @param space the choosen space of the target
  14391. * @returns the TransformNode.
  14392. */
  14393. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14394. /**
  14395. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14396. * This Vector3 is expressed in the World space.
  14397. * @param localAxis axis to rotate
  14398. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14399. */
  14400. getDirection(localAxis: Vector3): Vector3;
  14401. /**
  14402. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14403. * localAxis is expressed in the mesh local space.
  14404. * result is computed in the Wordl space from the mesh World matrix.
  14405. * @param localAxis axis to rotate
  14406. * @param result the resulting transformnode
  14407. * @returns this TransformNode.
  14408. */
  14409. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14410. /**
  14411. * Sets this transform node rotation to the given local axis.
  14412. * @param localAxis the axis in local space
  14413. * @param yawCor optional yaw (y-axis) correction in radians
  14414. * @param pitchCor optional pitch (x-axis) correction in radians
  14415. * @param rollCor optional roll (z-axis) correction in radians
  14416. * @returns this TransformNode
  14417. */
  14418. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14419. /**
  14420. * Sets a new pivot point to the current node
  14421. * @param point defines the new pivot point to use
  14422. * @param space defines if the point is in world or local space (local by default)
  14423. * @returns the current TransformNode
  14424. */
  14425. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14426. /**
  14427. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14428. * @returns the pivot point
  14429. */
  14430. getPivotPoint(): Vector3;
  14431. /**
  14432. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14433. * @param result the vector3 to store the result
  14434. * @returns this TransformNode.
  14435. */
  14436. getPivotPointToRef(result: Vector3): TransformNode;
  14437. /**
  14438. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14439. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14440. */
  14441. getAbsolutePivotPoint(): Vector3;
  14442. /**
  14443. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14444. * @param result vector3 to store the result
  14445. * @returns this TransformNode.
  14446. */
  14447. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14448. /**
  14449. * Defines the passed node as the parent of the current node.
  14450. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14451. * @see https://doc.babylonjs.com/how_to/parenting
  14452. * @param node the node ot set as the parent
  14453. * @returns this TransformNode.
  14454. */
  14455. setParent(node: Nullable<Node>): TransformNode;
  14456. private _nonUniformScaling;
  14457. /**
  14458. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14459. */
  14460. get nonUniformScaling(): boolean;
  14461. /** @hidden */
  14462. _updateNonUniformScalingState(value: boolean): boolean;
  14463. /**
  14464. * Attach the current TransformNode to another TransformNode associated with a bone
  14465. * @param bone Bone affecting the TransformNode
  14466. * @param affectedTransformNode TransformNode associated with the bone
  14467. * @returns this object
  14468. */
  14469. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14470. /**
  14471. * Detach the transform node if its associated with a bone
  14472. * @returns this object
  14473. */
  14474. detachFromBone(): TransformNode;
  14475. private static _rotationAxisCache;
  14476. /**
  14477. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14478. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14479. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14480. * The passed axis is also normalized.
  14481. * @param axis the axis to rotate around
  14482. * @param amount the amount to rotate in radians
  14483. * @param space Space to rotate in (Default: local)
  14484. * @returns the TransformNode.
  14485. */
  14486. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14487. /**
  14488. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14489. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14490. * The passed axis is also normalized. .
  14491. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14492. * @param point the point to rotate around
  14493. * @param axis the axis to rotate around
  14494. * @param amount the amount to rotate in radians
  14495. * @returns the TransformNode
  14496. */
  14497. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14498. /**
  14499. * Translates the mesh along the axis vector for the passed distance in the given space.
  14500. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14501. * @param axis the axis to translate in
  14502. * @param distance the distance to translate
  14503. * @param space Space to rotate in (Default: local)
  14504. * @returns the TransformNode.
  14505. */
  14506. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14507. /**
  14508. * Adds a rotation step to the mesh current rotation.
  14509. * x, y, z are Euler angles expressed in radians.
  14510. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14511. * This means this rotation is made in the mesh local space only.
  14512. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14513. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14514. * ```javascript
  14515. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14516. * ```
  14517. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14518. * 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.
  14519. * @param x Rotation to add
  14520. * @param y Rotation to add
  14521. * @param z Rotation to add
  14522. * @returns the TransformNode.
  14523. */
  14524. addRotation(x: number, y: number, z: number): TransformNode;
  14525. /**
  14526. * @hidden
  14527. */
  14528. protected _getEffectiveParent(): Nullable<Node>;
  14529. /**
  14530. * Computes the world matrix of the node
  14531. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14532. * @returns the world matrix
  14533. */
  14534. computeWorldMatrix(force?: boolean): Matrix;
  14535. /**
  14536. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14537. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14538. */
  14539. resetLocalMatrix(independentOfChildren?: boolean): void;
  14540. protected _afterComputeWorldMatrix(): void;
  14541. /**
  14542. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14543. * @param func callback function to add
  14544. *
  14545. * @returns the TransformNode.
  14546. */
  14547. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14548. /**
  14549. * Removes a registered callback function.
  14550. * @param func callback function to remove
  14551. * @returns the TransformNode.
  14552. */
  14553. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14554. /**
  14555. * Gets the position of the current mesh in camera space
  14556. * @param camera defines the camera to use
  14557. * @returns a position
  14558. */
  14559. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14560. /**
  14561. * Returns the distance from the mesh to the active camera
  14562. * @param camera defines the camera to use
  14563. * @returns the distance
  14564. */
  14565. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14566. /**
  14567. * Clone the current transform node
  14568. * @param name Name of the new clone
  14569. * @param newParent New parent for the clone
  14570. * @param doNotCloneChildren Do not clone children hierarchy
  14571. * @returns the new transform node
  14572. */
  14573. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14574. /**
  14575. * Serializes the objects information.
  14576. * @param currentSerializationObject defines the object to serialize in
  14577. * @returns the serialized object
  14578. */
  14579. serialize(currentSerializationObject?: any): any;
  14580. /**
  14581. * Returns a new TransformNode object parsed from the source provided.
  14582. * @param parsedTransformNode is the source.
  14583. * @param scene the scne the object belongs to
  14584. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14585. * @returns a new TransformNode object parsed from the source provided.
  14586. */
  14587. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14588. /**
  14589. * Get all child-transformNodes of this node
  14590. * @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
  14591. * @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
  14592. * @returns an array of TransformNode
  14593. */
  14594. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14595. /**
  14596. * Releases resources associated with this transform node.
  14597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14599. */
  14600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14601. /**
  14602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14606. * @returns the current mesh
  14607. */
  14608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14609. private _syncAbsoluteScalingAndRotation;
  14610. }
  14611. }
  14612. declare module BABYLON {
  14613. /**
  14614. * Defines the types of pose enabled controllers that are supported
  14615. */
  14616. export enum PoseEnabledControllerType {
  14617. /**
  14618. * HTC Vive
  14619. */
  14620. VIVE = 0,
  14621. /**
  14622. * Oculus Rift
  14623. */
  14624. OCULUS = 1,
  14625. /**
  14626. * Windows mixed reality
  14627. */
  14628. WINDOWS = 2,
  14629. /**
  14630. * Samsung gear VR
  14631. */
  14632. GEAR_VR = 3,
  14633. /**
  14634. * Google Daydream
  14635. */
  14636. DAYDREAM = 4,
  14637. /**
  14638. * Generic
  14639. */
  14640. GENERIC = 5
  14641. }
  14642. /**
  14643. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14644. */
  14645. export interface MutableGamepadButton {
  14646. /**
  14647. * Value of the button/trigger
  14648. */
  14649. value: number;
  14650. /**
  14651. * If the button/trigger is currently touched
  14652. */
  14653. touched: boolean;
  14654. /**
  14655. * If the button/trigger is currently pressed
  14656. */
  14657. pressed: boolean;
  14658. }
  14659. /**
  14660. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14661. * @hidden
  14662. */
  14663. export interface ExtendedGamepadButton extends GamepadButton {
  14664. /**
  14665. * If the button/trigger is currently pressed
  14666. */
  14667. readonly pressed: boolean;
  14668. /**
  14669. * If the button/trigger is currently touched
  14670. */
  14671. readonly touched: boolean;
  14672. /**
  14673. * Value of the button/trigger
  14674. */
  14675. readonly value: number;
  14676. }
  14677. /** @hidden */
  14678. export interface _GamePadFactory {
  14679. /**
  14680. * Returns whether or not the current gamepad can be created for this type of controller.
  14681. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  14682. * @returns true if it can be created, otherwise false
  14683. */
  14684. canCreate(gamepadInfo: any): boolean;
  14685. /**
  14686. * Creates a new instance of the Gamepad.
  14687. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  14688. * @returns the new gamepad instance
  14689. */
  14690. create(gamepadInfo: any): Gamepad;
  14691. }
  14692. /**
  14693. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14694. */
  14695. export class PoseEnabledControllerHelper {
  14696. /** @hidden */
  14697. static _ControllerFactories: _GamePadFactory[];
  14698. /** @hidden */
  14699. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14700. /**
  14701. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14702. * @param vrGamepad the gamepad to initialized
  14703. * @returns a vr controller of the type the gamepad identified as
  14704. */
  14705. static InitiateController(vrGamepad: any): Gamepad;
  14706. }
  14707. /**
  14708. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14709. */
  14710. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14711. /**
  14712. * If the controller is used in a webXR session
  14713. */
  14714. isXR: boolean;
  14715. private _deviceRoomPosition;
  14716. private _deviceRoomRotationQuaternion;
  14717. /**
  14718. * The device position in babylon space
  14719. */
  14720. devicePosition: Vector3;
  14721. /**
  14722. * The device rotation in babylon space
  14723. */
  14724. deviceRotationQuaternion: Quaternion;
  14725. /**
  14726. * The scale factor of the device in babylon space
  14727. */
  14728. deviceScaleFactor: number;
  14729. /**
  14730. * (Likely devicePosition should be used instead) The device position in its room space
  14731. */
  14732. position: Vector3;
  14733. /**
  14734. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14735. */
  14736. rotationQuaternion: Quaternion;
  14737. /**
  14738. * The type of controller (Eg. Windows mixed reality)
  14739. */
  14740. controllerType: PoseEnabledControllerType;
  14741. protected _calculatedPosition: Vector3;
  14742. private _calculatedRotation;
  14743. /**
  14744. * The raw pose from the device
  14745. */
  14746. rawPose: DevicePose;
  14747. private _trackPosition;
  14748. private _maxRotationDistFromHeadset;
  14749. private _draggedRoomRotation;
  14750. /**
  14751. * @hidden
  14752. */
  14753. _disableTrackPosition(fixedPosition: Vector3): void;
  14754. /**
  14755. * Internal, the mesh attached to the controller
  14756. * @hidden
  14757. */
  14758. _mesh: Nullable<AbstractMesh>;
  14759. private _poseControlledCamera;
  14760. private _leftHandSystemQuaternion;
  14761. /**
  14762. * Internal, matrix used to convert room space to babylon space
  14763. * @hidden
  14764. */
  14765. _deviceToWorld: Matrix;
  14766. /**
  14767. * Node to be used when casting a ray from the controller
  14768. * @hidden
  14769. */
  14770. _pointingPoseNode: Nullable<TransformNode>;
  14771. /**
  14772. * Name of the child mesh that can be used to cast a ray from the controller
  14773. */
  14774. static readonly POINTING_POSE: string;
  14775. /**
  14776. * Creates a new PoseEnabledController from a gamepad
  14777. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14778. */
  14779. constructor(browserGamepad: any);
  14780. private _workingMatrix;
  14781. /**
  14782. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14783. */
  14784. update(): void;
  14785. /**
  14786. * Updates only the pose device and mesh without doing any button event checking
  14787. */
  14788. protected _updatePoseAndMesh(): void;
  14789. /**
  14790. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14791. * @param poseData raw pose fromthe device
  14792. */
  14793. updateFromDevice(poseData: DevicePose): void;
  14794. /**
  14795. * @hidden
  14796. */
  14797. _meshAttachedObservable: Observable<AbstractMesh>;
  14798. /**
  14799. * Attaches a mesh to the controller
  14800. * @param mesh the mesh to be attached
  14801. */
  14802. attachToMesh(mesh: AbstractMesh): void;
  14803. /**
  14804. * Attaches the controllers mesh to a camera
  14805. * @param camera the camera the mesh should be attached to
  14806. */
  14807. attachToPoseControlledCamera(camera: TargetCamera): void;
  14808. /**
  14809. * Disposes of the controller
  14810. */
  14811. dispose(): void;
  14812. /**
  14813. * The mesh that is attached to the controller
  14814. */
  14815. get mesh(): Nullable<AbstractMesh>;
  14816. /**
  14817. * Gets the ray of the controller in the direction the controller is pointing
  14818. * @param length the length the resulting ray should be
  14819. * @returns a ray in the direction the controller is pointing
  14820. */
  14821. getForwardRay(length?: number): Ray;
  14822. }
  14823. }
  14824. declare module BABYLON {
  14825. /**
  14826. * Defines the WebVRController object that represents controllers tracked in 3D space
  14827. */
  14828. export abstract class WebVRController extends PoseEnabledController {
  14829. /**
  14830. * Internal, the default controller model for the controller
  14831. */
  14832. protected _defaultModel: Nullable<AbstractMesh>;
  14833. /**
  14834. * Fired when the trigger state has changed
  14835. */
  14836. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14837. /**
  14838. * Fired when the main button state has changed
  14839. */
  14840. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14841. /**
  14842. * Fired when the secondary button state has changed
  14843. */
  14844. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14845. /**
  14846. * Fired when the pad state has changed
  14847. */
  14848. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14849. /**
  14850. * Fired when controllers stick values have changed
  14851. */
  14852. onPadValuesChangedObservable: Observable<StickValues>;
  14853. /**
  14854. * Array of button availible on the controller
  14855. */
  14856. protected _buttons: Array<MutableGamepadButton>;
  14857. private _onButtonStateChange;
  14858. /**
  14859. * Fired when a controller button's state has changed
  14860. * @param callback the callback containing the button that was modified
  14861. */
  14862. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14863. /**
  14864. * X and Y axis corresponding to the controllers joystick
  14865. */
  14866. pad: StickValues;
  14867. /**
  14868. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14869. */
  14870. hand: string;
  14871. /**
  14872. * The default controller model for the controller
  14873. */
  14874. get defaultModel(): Nullable<AbstractMesh>;
  14875. /**
  14876. * Creates a new WebVRController from a gamepad
  14877. * @param vrGamepad the gamepad that the WebVRController should be created from
  14878. */
  14879. constructor(vrGamepad: any);
  14880. /**
  14881. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14882. */
  14883. update(): void;
  14884. /**
  14885. * Function to be called when a button is modified
  14886. */
  14887. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14888. /**
  14889. * Loads a mesh and attaches it to the controller
  14890. * @param scene the scene the mesh should be added to
  14891. * @param meshLoaded callback for when the mesh has been loaded
  14892. */
  14893. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14894. private _setButtonValue;
  14895. private _changes;
  14896. private _checkChanges;
  14897. /**
  14898. * Disposes of th webVRCOntroller
  14899. */
  14900. dispose(): void;
  14901. }
  14902. }
  14903. declare module BABYLON {
  14904. /**
  14905. * The HemisphericLight simulates the ambient environment light,
  14906. * so the passed direction is the light reflection direction, not the incoming direction.
  14907. */
  14908. export class HemisphericLight extends Light {
  14909. /**
  14910. * The groundColor is the light in the opposite direction to the one specified during creation.
  14911. * 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.
  14912. */
  14913. groundColor: Color3;
  14914. /**
  14915. * The light reflection direction, not the incoming direction.
  14916. */
  14917. direction: Vector3;
  14918. /**
  14919. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14920. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14921. * The HemisphericLight can't cast shadows.
  14922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14923. * @param name The friendly name of the light
  14924. * @param direction The direction of the light reflection
  14925. * @param scene The scene the light belongs to
  14926. */
  14927. constructor(name: string, direction: Vector3, scene: Scene);
  14928. protected _buildUniformLayout(): void;
  14929. /**
  14930. * Returns the string "HemisphericLight".
  14931. * @return The class name
  14932. */
  14933. getClassName(): string;
  14934. /**
  14935. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14936. * Returns the updated direction.
  14937. * @param target The target the direction should point to
  14938. * @return The computed direction
  14939. */
  14940. setDirectionToTarget(target: Vector3): Vector3;
  14941. /**
  14942. * Returns the shadow generator associated to the light.
  14943. * @returns Always null for hemispheric lights because it does not support shadows.
  14944. */
  14945. getShadowGenerator(): Nullable<IShadowGenerator>;
  14946. /**
  14947. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14948. * @param effect The effect to update
  14949. * @param lightIndex The index of the light in the effect to update
  14950. * @returns The hemispheric light
  14951. */
  14952. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14953. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14954. /**
  14955. * Computes the world matrix of the node
  14956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14957. * @param useWasUpdatedFlag defines a reserved property
  14958. * @returns the world matrix
  14959. */
  14960. computeWorldMatrix(): Matrix;
  14961. /**
  14962. * Returns the integer 3.
  14963. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14964. */
  14965. getTypeID(): number;
  14966. /**
  14967. * Prepares the list of defines specific to the light type.
  14968. * @param defines the list of defines
  14969. * @param lightIndex defines the index of the light for the effect
  14970. */
  14971. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14972. }
  14973. }
  14974. declare module BABYLON {
  14975. /** @hidden */
  14976. export var vrMultiviewToSingleviewPixelShader: {
  14977. name: string;
  14978. shader: string;
  14979. };
  14980. }
  14981. declare module BABYLON {
  14982. /**
  14983. * Renders to multiple views with a single draw call
  14984. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14985. */
  14986. export class MultiviewRenderTarget extends RenderTargetTexture {
  14987. /**
  14988. * Creates a multiview render target
  14989. * @param scene scene used with the render target
  14990. * @param size the size of the render target (used for each view)
  14991. */
  14992. constructor(scene: Scene, size?: number | {
  14993. width: number;
  14994. height: number;
  14995. } | {
  14996. ratio: number;
  14997. });
  14998. /**
  14999. * @hidden
  15000. * @param faceIndex the face index, if its a cube texture
  15001. */
  15002. _bindFrameBuffer(faceIndex?: number): void;
  15003. /**
  15004. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15005. * @returns the view count
  15006. */
  15007. getViewCount(): number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Represents a camera frustum
  15013. */
  15014. export class Frustum {
  15015. /**
  15016. * Gets the planes representing the frustum
  15017. * @param transform matrix to be applied to the returned planes
  15018. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15019. */
  15020. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15021. /**
  15022. * Gets the near frustum plane transformed by the transform matrix
  15023. * @param transform transformation matrix to be applied to the resulting frustum plane
  15024. * @param frustumPlane the resuling frustum plane
  15025. */
  15026. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15027. /**
  15028. * Gets the far frustum plane transformed by the transform matrix
  15029. * @param transform transformation matrix to be applied to the resulting frustum plane
  15030. * @param frustumPlane the resuling frustum plane
  15031. */
  15032. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15033. /**
  15034. * Gets the left frustum plane transformed by the transform matrix
  15035. * @param transform transformation matrix to be applied to the resulting frustum plane
  15036. * @param frustumPlane the resuling frustum plane
  15037. */
  15038. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15039. /**
  15040. * Gets the right frustum plane transformed by the transform matrix
  15041. * @param transform transformation matrix to be applied to the resulting frustum plane
  15042. * @param frustumPlane the resuling frustum plane
  15043. */
  15044. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15045. /**
  15046. * Gets the top frustum plane transformed by the transform matrix
  15047. * @param transform transformation matrix to be applied to the resulting frustum plane
  15048. * @param frustumPlane the resuling frustum plane
  15049. */
  15050. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15051. /**
  15052. * Gets the bottom frustum plane transformed by the transform matrix
  15053. * @param transform transformation matrix to be applied to the resulting frustum plane
  15054. * @param frustumPlane the resuling frustum plane
  15055. */
  15056. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15057. /**
  15058. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15059. * @param transform transformation matrix to be applied to the resulting frustum planes
  15060. * @param frustumPlanes the resuling frustum planes
  15061. */
  15062. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15063. }
  15064. }
  15065. declare module BABYLON {
  15066. interface Engine {
  15067. /**
  15068. * Creates a new multiview render target
  15069. * @param width defines the width of the texture
  15070. * @param height defines the height of the texture
  15071. * @returns the created multiview texture
  15072. */
  15073. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15074. /**
  15075. * Binds a multiview framebuffer to be drawn to
  15076. * @param multiviewTexture texture to bind
  15077. */
  15078. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15079. }
  15080. interface Camera {
  15081. /**
  15082. * @hidden
  15083. * 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)
  15084. */
  15085. _useMultiviewToSingleView: boolean;
  15086. /**
  15087. * @hidden
  15088. * 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)
  15089. */
  15090. _multiviewTexture: Nullable<RenderTargetTexture>;
  15091. /**
  15092. * @hidden
  15093. * ensures the multiview texture of the camera exists and has the specified width/height
  15094. * @param width height to set on the multiview texture
  15095. * @param height width to set on the multiview texture
  15096. */
  15097. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15098. }
  15099. interface Scene {
  15100. /** @hidden */
  15101. _transformMatrixR: Matrix;
  15102. /** @hidden */
  15103. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15104. /** @hidden */
  15105. _createMultiviewUbo(): void;
  15106. /** @hidden */
  15107. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15108. /** @hidden */
  15109. _renderMultiviewToSingleView(camera: Camera): void;
  15110. }
  15111. }
  15112. declare module BABYLON {
  15113. /**
  15114. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15115. * This will not be used for webXR as it supports displaying texture arrays directly
  15116. */
  15117. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15118. /**
  15119. * Initializes a VRMultiviewToSingleview
  15120. * @param name name of the post process
  15121. * @param camera camera to be applied to
  15122. * @param scaleFactor scaling factor to the size of the output texture
  15123. */
  15124. constructor(name: string, camera: Camera, scaleFactor: number);
  15125. }
  15126. }
  15127. declare module BABYLON {
  15128. /**
  15129. * Interface used to define additional presentation attributes
  15130. */
  15131. export interface IVRPresentationAttributes {
  15132. /**
  15133. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15134. */
  15135. highRefreshRate: boolean;
  15136. /**
  15137. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15138. */
  15139. foveationLevel: number;
  15140. }
  15141. interface Engine {
  15142. /** @hidden */
  15143. _vrDisplay: any;
  15144. /** @hidden */
  15145. _vrSupported: boolean;
  15146. /** @hidden */
  15147. _oldSize: Size;
  15148. /** @hidden */
  15149. _oldHardwareScaleFactor: number;
  15150. /** @hidden */
  15151. _vrExclusivePointerMode: boolean;
  15152. /** @hidden */
  15153. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15154. /** @hidden */
  15155. _onVRDisplayPointerRestricted: () => void;
  15156. /** @hidden */
  15157. _onVRDisplayPointerUnrestricted: () => void;
  15158. /** @hidden */
  15159. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15160. /** @hidden */
  15161. _onVrDisplayDisconnect: Nullable<() => void>;
  15162. /** @hidden */
  15163. _onVrDisplayPresentChange: Nullable<() => void>;
  15164. /**
  15165. * Observable signaled when VR display mode changes
  15166. */
  15167. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15168. /**
  15169. * Observable signaled when VR request present is complete
  15170. */
  15171. onVRRequestPresentComplete: Observable<boolean>;
  15172. /**
  15173. * Observable signaled when VR request present starts
  15174. */
  15175. onVRRequestPresentStart: Observable<Engine>;
  15176. /**
  15177. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15178. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15179. */
  15180. isInVRExclusivePointerMode: boolean;
  15181. /**
  15182. * Gets a boolean indicating if a webVR device was detected
  15183. * @returns true if a webVR device was detected
  15184. */
  15185. isVRDevicePresent(): boolean;
  15186. /**
  15187. * Gets the current webVR device
  15188. * @returns the current webVR device (or null)
  15189. */
  15190. getVRDevice(): any;
  15191. /**
  15192. * Initializes a webVR display and starts listening to display change events
  15193. * The onVRDisplayChangedObservable will be notified upon these changes
  15194. * @returns A promise containing a VRDisplay and if vr is supported
  15195. */
  15196. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15197. /** @hidden */
  15198. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15199. /**
  15200. * Gets or sets the presentation attributes used to configure VR rendering
  15201. */
  15202. vrPresentationAttributes?: IVRPresentationAttributes;
  15203. /**
  15204. * Call this function to switch to webVR mode
  15205. * Will do nothing if webVR is not supported or if there is no webVR device
  15206. * @param options the webvr options provided to the camera. mainly used for multiview
  15207. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15208. */
  15209. enableVR(options: WebVROptions): void;
  15210. /** @hidden */
  15211. _onVRFullScreenTriggered(): void;
  15212. }
  15213. }
  15214. declare module BABYLON {
  15215. /**
  15216. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15217. * IMPORTANT!! The data is right-hand data.
  15218. * @export
  15219. * @interface DevicePose
  15220. */
  15221. export interface DevicePose {
  15222. /**
  15223. * The position of the device, values in array are [x,y,z].
  15224. */
  15225. readonly position: Nullable<Float32Array>;
  15226. /**
  15227. * The linearVelocity of the device, values in array are [x,y,z].
  15228. */
  15229. readonly linearVelocity: Nullable<Float32Array>;
  15230. /**
  15231. * The linearAcceleration of the device, values in array are [x,y,z].
  15232. */
  15233. readonly linearAcceleration: Nullable<Float32Array>;
  15234. /**
  15235. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15236. */
  15237. readonly orientation: Nullable<Float32Array>;
  15238. /**
  15239. * The angularVelocity of the device, values in array are [x,y,z].
  15240. */
  15241. readonly angularVelocity: Nullable<Float32Array>;
  15242. /**
  15243. * The angularAcceleration of the device, values in array are [x,y,z].
  15244. */
  15245. readonly angularAcceleration: Nullable<Float32Array>;
  15246. }
  15247. /**
  15248. * Interface representing a pose controlled object in Babylon.
  15249. * A pose controlled object has both regular pose values as well as pose values
  15250. * from an external device such as a VR head mounted display
  15251. */
  15252. export interface PoseControlled {
  15253. /**
  15254. * The position of the object in babylon space.
  15255. */
  15256. position: Vector3;
  15257. /**
  15258. * The rotation quaternion of the object in babylon space.
  15259. */
  15260. rotationQuaternion: Quaternion;
  15261. /**
  15262. * The position of the device in babylon space.
  15263. */
  15264. devicePosition?: Vector3;
  15265. /**
  15266. * The rotation quaternion of the device in babylon space.
  15267. */
  15268. deviceRotationQuaternion: Quaternion;
  15269. /**
  15270. * The raw pose coming from the device.
  15271. */
  15272. rawPose: Nullable<DevicePose>;
  15273. /**
  15274. * The scale of the device to be used when translating from device space to babylon space.
  15275. */
  15276. deviceScaleFactor: number;
  15277. /**
  15278. * Updates the poseControlled values based on the input device pose.
  15279. * @param poseData the pose data to update the object with
  15280. */
  15281. updateFromDevice(poseData: DevicePose): void;
  15282. }
  15283. /**
  15284. * Set of options to customize the webVRCamera
  15285. */
  15286. export interface WebVROptions {
  15287. /**
  15288. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15289. */
  15290. trackPosition?: boolean;
  15291. /**
  15292. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15293. */
  15294. positionScale?: number;
  15295. /**
  15296. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15297. */
  15298. displayName?: string;
  15299. /**
  15300. * Should the native controller meshes be initialized. (default: true)
  15301. */
  15302. controllerMeshes?: boolean;
  15303. /**
  15304. * Creating a default HemiLight only on controllers. (default: true)
  15305. */
  15306. defaultLightingOnControllers?: boolean;
  15307. /**
  15308. * If you don't want to use the default VR button of the helper. (default: false)
  15309. */
  15310. useCustomVRButton?: boolean;
  15311. /**
  15312. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15313. */
  15314. customVRButton?: HTMLButtonElement;
  15315. /**
  15316. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15317. */
  15318. rayLength?: number;
  15319. /**
  15320. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15321. */
  15322. defaultHeight?: number;
  15323. /**
  15324. * If multiview should be used if availible (default: false)
  15325. */
  15326. useMultiview?: boolean;
  15327. }
  15328. /**
  15329. * This represents a WebVR camera.
  15330. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15331. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15332. */
  15333. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15334. private webVROptions;
  15335. /**
  15336. * @hidden
  15337. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15338. */
  15339. _vrDevice: any;
  15340. /**
  15341. * The rawPose of the vrDevice.
  15342. */
  15343. rawPose: Nullable<DevicePose>;
  15344. private _onVREnabled;
  15345. private _specsVersion;
  15346. private _attached;
  15347. private _frameData;
  15348. protected _descendants: Array<Node>;
  15349. private _deviceRoomPosition;
  15350. /** @hidden */
  15351. _deviceRoomRotationQuaternion: Quaternion;
  15352. private _standingMatrix;
  15353. /**
  15354. * Represents device position in babylon space.
  15355. */
  15356. devicePosition: Vector3;
  15357. /**
  15358. * Represents device rotation in babylon space.
  15359. */
  15360. deviceRotationQuaternion: Quaternion;
  15361. /**
  15362. * The scale of the device to be used when translating from device space to babylon space.
  15363. */
  15364. deviceScaleFactor: number;
  15365. private _deviceToWorld;
  15366. private _worldToDevice;
  15367. /**
  15368. * References to the webVR controllers for the vrDevice.
  15369. */
  15370. controllers: Array<WebVRController>;
  15371. /**
  15372. * Emits an event when a controller is attached.
  15373. */
  15374. onControllersAttachedObservable: Observable<WebVRController[]>;
  15375. /**
  15376. * Emits an event when a controller's mesh has been loaded;
  15377. */
  15378. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15379. /**
  15380. * Emits an event when the HMD's pose has been updated.
  15381. */
  15382. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15383. private _poseSet;
  15384. /**
  15385. * If the rig cameras be used as parent instead of this camera.
  15386. */
  15387. rigParenting: boolean;
  15388. private _lightOnControllers;
  15389. private _defaultHeight?;
  15390. /**
  15391. * Instantiates a WebVRFreeCamera.
  15392. * @param name The name of the WebVRFreeCamera
  15393. * @param position The starting anchor position for the camera
  15394. * @param scene The scene the camera belongs to
  15395. * @param webVROptions a set of customizable options for the webVRCamera
  15396. */
  15397. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15398. /**
  15399. * Gets the device distance from the ground in meters.
  15400. * @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.
  15401. */
  15402. deviceDistanceToRoomGround(): number;
  15403. /**
  15404. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15405. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15406. */
  15407. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15408. /**
  15409. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15410. * @returns A promise with a boolean set to if the standing matrix is supported.
  15411. */
  15412. useStandingMatrixAsync(): Promise<boolean>;
  15413. /**
  15414. * Disposes the camera
  15415. */
  15416. dispose(): void;
  15417. /**
  15418. * Gets a vrController by name.
  15419. * @param name The name of the controller to retreive
  15420. * @returns the controller matching the name specified or null if not found
  15421. */
  15422. getControllerByName(name: string): Nullable<WebVRController>;
  15423. private _leftController;
  15424. /**
  15425. * The controller corresponding to the users left hand.
  15426. */
  15427. get leftController(): Nullable<WebVRController>;
  15428. private _rightController;
  15429. /**
  15430. * The controller corresponding to the users right hand.
  15431. */
  15432. get rightController(): Nullable<WebVRController>;
  15433. /**
  15434. * Casts a ray forward from the vrCamera's gaze.
  15435. * @param length Length of the ray (default: 100)
  15436. * @returns the ray corresponding to the gaze
  15437. */
  15438. getForwardRay(length?: number): Ray;
  15439. /**
  15440. * @hidden
  15441. * Updates the camera based on device's frame data
  15442. */
  15443. _checkInputs(): void;
  15444. /**
  15445. * Updates the poseControlled values based on the input device pose.
  15446. * @param poseData Pose coming from the device
  15447. */
  15448. updateFromDevice(poseData: DevicePose): void;
  15449. private _htmlElementAttached;
  15450. private _detachIfAttached;
  15451. /**
  15452. * WebVR's attach control will start broadcasting frames to the device.
  15453. * Note that in certain browsers (chrome for example) this function must be called
  15454. * within a user-interaction callback. Example:
  15455. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15456. *
  15457. * @param element html element to attach the vrDevice to
  15458. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15459. */
  15460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15461. /**
  15462. * Detaches the camera from the html element and disables VR
  15463. *
  15464. * @param element html element to detach from
  15465. */
  15466. detachControl(element: HTMLElement): void;
  15467. /**
  15468. * @returns the name of this class
  15469. */
  15470. getClassName(): string;
  15471. /**
  15472. * Calls resetPose on the vrDisplay
  15473. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15474. */
  15475. resetToCurrentRotation(): void;
  15476. /**
  15477. * @hidden
  15478. * Updates the rig cameras (left and right eye)
  15479. */
  15480. _updateRigCameras(): void;
  15481. private _workingVector;
  15482. private _oneVector;
  15483. private _workingMatrix;
  15484. private updateCacheCalled;
  15485. private _correctPositionIfNotTrackPosition;
  15486. /**
  15487. * @hidden
  15488. * Updates the cached values of the camera
  15489. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15490. */
  15491. _updateCache(ignoreParentClass?: boolean): void;
  15492. /**
  15493. * @hidden
  15494. * Get current device position in babylon world
  15495. */
  15496. _computeDevicePosition(): void;
  15497. /**
  15498. * Updates the current device position and rotation in the babylon world
  15499. */
  15500. update(): void;
  15501. /**
  15502. * @hidden
  15503. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15504. * @returns an identity matrix
  15505. */
  15506. _getViewMatrix(): Matrix;
  15507. private _tmpMatrix;
  15508. /**
  15509. * This function is called by the two RIG cameras.
  15510. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15511. * @hidden
  15512. */
  15513. _getWebVRViewMatrix(): Matrix;
  15514. /** @hidden */
  15515. _getWebVRProjectionMatrix(): Matrix;
  15516. private _onGamepadConnectedObserver;
  15517. private _onGamepadDisconnectedObserver;
  15518. private _updateCacheWhenTrackingDisabledObserver;
  15519. /**
  15520. * Initializes the controllers and their meshes
  15521. */
  15522. initControllers(): void;
  15523. }
  15524. }
  15525. declare module BABYLON {
  15526. /**
  15527. * Size options for a post process
  15528. */
  15529. export type PostProcessOptions = {
  15530. width: number;
  15531. height: number;
  15532. };
  15533. /**
  15534. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15535. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15536. */
  15537. export class PostProcess {
  15538. /** Name of the PostProcess. */
  15539. name: string;
  15540. /**
  15541. * Gets or sets the unique id of the post process
  15542. */
  15543. uniqueId: number;
  15544. /**
  15545. * Width of the texture to apply the post process on
  15546. */
  15547. width: number;
  15548. /**
  15549. * Height of the texture to apply the post process on
  15550. */
  15551. height: number;
  15552. /**
  15553. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15554. * @hidden
  15555. */
  15556. _outputTexture: Nullable<InternalTexture>;
  15557. /**
  15558. * Sampling mode used by the shader
  15559. * See https://doc.babylonjs.com/classes/3.1/texture
  15560. */
  15561. renderTargetSamplingMode: number;
  15562. /**
  15563. * Clear color to use when screen clearing
  15564. */
  15565. clearColor: Color4;
  15566. /**
  15567. * If the buffer needs to be cleared before applying the post process. (default: true)
  15568. * Should be set to false if shader will overwrite all previous pixels.
  15569. */
  15570. autoClear: boolean;
  15571. /**
  15572. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15573. */
  15574. alphaMode: number;
  15575. /**
  15576. * Sets the setAlphaBlendConstants of the babylon engine
  15577. */
  15578. alphaConstants: Color4;
  15579. /**
  15580. * Animations to be used for the post processing
  15581. */
  15582. animations: Animation[];
  15583. /**
  15584. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15585. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15586. */
  15587. enablePixelPerfectMode: boolean;
  15588. /**
  15589. * Force the postprocess to be applied without taking in account viewport
  15590. */
  15591. forceFullscreenViewport: boolean;
  15592. /**
  15593. * List of inspectable custom properties (used by the Inspector)
  15594. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15595. */
  15596. inspectableCustomProperties: IInspectable[];
  15597. /**
  15598. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15599. *
  15600. * | Value | Type | Description |
  15601. * | ----- | ----------------------------------- | ----------- |
  15602. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15603. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15604. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15605. *
  15606. */
  15607. scaleMode: number;
  15608. /**
  15609. * Force textures to be a power of two (default: false)
  15610. */
  15611. alwaysForcePOT: boolean;
  15612. private _samples;
  15613. /**
  15614. * Number of sample textures (default: 1)
  15615. */
  15616. get samples(): number;
  15617. set samples(n: number);
  15618. /**
  15619. * Modify the scale of the post process to be the same as the viewport (default: false)
  15620. */
  15621. adaptScaleToCurrentViewport: boolean;
  15622. private _camera;
  15623. private _scene;
  15624. private _engine;
  15625. private _options;
  15626. private _reusable;
  15627. private _textureType;
  15628. private _textureFormat;
  15629. /**
  15630. * Smart array of input and output textures for the post process.
  15631. * @hidden
  15632. */
  15633. _textures: SmartArray<InternalTexture>;
  15634. /**
  15635. * The index in _textures that corresponds to the output texture.
  15636. * @hidden
  15637. */
  15638. _currentRenderTextureInd: number;
  15639. private _effect;
  15640. private _samplers;
  15641. private _fragmentUrl;
  15642. private _vertexUrl;
  15643. private _parameters;
  15644. private _scaleRatio;
  15645. protected _indexParameters: any;
  15646. private _shareOutputWithPostProcess;
  15647. private _texelSize;
  15648. private _forcedOutputTexture;
  15649. /**
  15650. * Returns the fragment url or shader name used in the post process.
  15651. * @returns the fragment url or name in the shader store.
  15652. */
  15653. getEffectName(): string;
  15654. /**
  15655. * An event triggered when the postprocess is activated.
  15656. */
  15657. onActivateObservable: Observable<Camera>;
  15658. private _onActivateObserver;
  15659. /**
  15660. * A function that is added to the onActivateObservable
  15661. */
  15662. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15663. /**
  15664. * An event triggered when the postprocess changes its size.
  15665. */
  15666. onSizeChangedObservable: Observable<PostProcess>;
  15667. private _onSizeChangedObserver;
  15668. /**
  15669. * A function that is added to the onSizeChangedObservable
  15670. */
  15671. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15672. /**
  15673. * An event triggered when the postprocess applies its effect.
  15674. */
  15675. onApplyObservable: Observable<Effect>;
  15676. private _onApplyObserver;
  15677. /**
  15678. * A function that is added to the onApplyObservable
  15679. */
  15680. set onApply(callback: (effect: Effect) => void);
  15681. /**
  15682. * An event triggered before rendering the postprocess
  15683. */
  15684. onBeforeRenderObservable: Observable<Effect>;
  15685. private _onBeforeRenderObserver;
  15686. /**
  15687. * A function that is added to the onBeforeRenderObservable
  15688. */
  15689. set onBeforeRender(callback: (effect: Effect) => void);
  15690. /**
  15691. * An event triggered after rendering the postprocess
  15692. */
  15693. onAfterRenderObservable: Observable<Effect>;
  15694. private _onAfterRenderObserver;
  15695. /**
  15696. * A function that is added to the onAfterRenderObservable
  15697. */
  15698. set onAfterRender(callback: (efect: Effect) => void);
  15699. /**
  15700. * 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
  15701. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15702. */
  15703. get inputTexture(): InternalTexture;
  15704. set inputTexture(value: InternalTexture);
  15705. /**
  15706. * Gets the camera which post process is applied to.
  15707. * @returns The camera the post process is applied to.
  15708. */
  15709. getCamera(): Camera;
  15710. /**
  15711. * Gets the texel size of the postprocess.
  15712. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15713. */
  15714. get texelSize(): Vector2;
  15715. /**
  15716. * Creates a new instance PostProcess
  15717. * @param name The name of the PostProcess.
  15718. * @param fragmentUrl The url of the fragment shader to be used.
  15719. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15720. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15721. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15722. * @param camera The camera to apply the render pass to.
  15723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15724. * @param engine The engine which the post process will be applied. (default: current engine)
  15725. * @param reusable If the post process can be reused on the same frame. (default: false)
  15726. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15727. * @param textureType Type of textures used when performing the post process. (default: 0)
  15728. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15729. * @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
  15730. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15731. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  15732. */
  15733. constructor(
  15734. /** Name of the PostProcess. */
  15735. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  15736. /**
  15737. * Gets a string idenfifying the name of the class
  15738. * @returns "PostProcess" string
  15739. */
  15740. getClassName(): string;
  15741. /**
  15742. * Gets the engine which this post process belongs to.
  15743. * @returns The engine the post process was enabled with.
  15744. */
  15745. getEngine(): Engine;
  15746. /**
  15747. * The effect that is created when initializing the post process.
  15748. * @returns The created effect corresponding the the postprocess.
  15749. */
  15750. getEffect(): Effect;
  15751. /**
  15752. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15753. * @param postProcess The post process to share the output with.
  15754. * @returns This post process.
  15755. */
  15756. shareOutputWith(postProcess: PostProcess): PostProcess;
  15757. /**
  15758. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15759. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15760. */
  15761. useOwnOutput(): void;
  15762. /**
  15763. * Updates the effect with the current post process compile time values and recompiles the shader.
  15764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15767. * @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
  15768. * @param onCompiled Called when the shader has been compiled.
  15769. * @param onError Called if there is an error when compiling a shader.
  15770. */
  15771. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15772. /**
  15773. * The post process is reusable if it can be used multiple times within one frame.
  15774. * @returns If the post process is reusable
  15775. */
  15776. isReusable(): boolean;
  15777. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15778. markTextureDirty(): void;
  15779. /**
  15780. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15781. * 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.
  15782. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15783. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15784. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15785. * @returns The target texture that was bound to be written to.
  15786. */
  15787. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15788. /**
  15789. * If the post process is supported.
  15790. */
  15791. get isSupported(): boolean;
  15792. /**
  15793. * The aspect ratio of the output texture.
  15794. */
  15795. get aspectRatio(): number;
  15796. /**
  15797. * Get a value indicating if the post-process is ready to be used
  15798. * @returns true if the post-process is ready (shader is compiled)
  15799. */
  15800. isReady(): boolean;
  15801. /**
  15802. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15803. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15804. */
  15805. apply(): Nullable<Effect>;
  15806. private _disposeTextures;
  15807. /**
  15808. * Disposes the post process.
  15809. * @param camera The camera to dispose the post process on.
  15810. */
  15811. dispose(camera?: Camera): void;
  15812. }
  15813. }
  15814. declare module BABYLON {
  15815. /** @hidden */
  15816. export var kernelBlurVaryingDeclaration: {
  15817. name: string;
  15818. shader: string;
  15819. };
  15820. }
  15821. declare module BABYLON {
  15822. /** @hidden */
  15823. export var kernelBlurFragment: {
  15824. name: string;
  15825. shader: string;
  15826. };
  15827. }
  15828. declare module BABYLON {
  15829. /** @hidden */
  15830. export var kernelBlurFragment2: {
  15831. name: string;
  15832. shader: string;
  15833. };
  15834. }
  15835. declare module BABYLON {
  15836. /** @hidden */
  15837. export var kernelBlurPixelShader: {
  15838. name: string;
  15839. shader: string;
  15840. };
  15841. }
  15842. declare module BABYLON {
  15843. /** @hidden */
  15844. export var kernelBlurVertex: {
  15845. name: string;
  15846. shader: string;
  15847. };
  15848. }
  15849. declare module BABYLON {
  15850. /** @hidden */
  15851. export var kernelBlurVertexShader: {
  15852. name: string;
  15853. shader: string;
  15854. };
  15855. }
  15856. declare module BABYLON {
  15857. /**
  15858. * The Blur Post Process which blurs an image based on a kernel and direction.
  15859. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15860. */
  15861. export class BlurPostProcess extends PostProcess {
  15862. /** The direction in which to blur the image. */
  15863. direction: Vector2;
  15864. private blockCompilation;
  15865. protected _kernel: number;
  15866. protected _idealKernel: number;
  15867. protected _packedFloat: boolean;
  15868. private _staticDefines;
  15869. /**
  15870. * Sets the length in pixels of the blur sample region
  15871. */
  15872. set kernel(v: number);
  15873. /**
  15874. * Gets the length in pixels of the blur sample region
  15875. */
  15876. get kernel(): number;
  15877. /**
  15878. * Sets wether or not the blur needs to unpack/repack floats
  15879. */
  15880. set packedFloat(v: boolean);
  15881. /**
  15882. * Gets wether or not the blur is unpacking/repacking floats
  15883. */
  15884. get packedFloat(): boolean;
  15885. /**
  15886. * Creates a new instance BlurPostProcess
  15887. * @param name The name of the effect.
  15888. * @param direction The direction in which to blur the image.
  15889. * @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.
  15890. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15891. * @param camera The camera to apply the render pass to.
  15892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15893. * @param engine The engine which the post process will be applied. (default: current engine)
  15894. * @param reusable If the post process can be reused on the same frame. (default: false)
  15895. * @param textureType Type of textures used when performing the post process. (default: 0)
  15896. * @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)
  15897. */
  15898. constructor(name: string,
  15899. /** The direction in which to blur the image. */
  15900. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15901. /**
  15902. * Updates the effect with the current post process compile time values and recompiles the shader.
  15903. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15904. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15905. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15906. * @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
  15907. * @param onCompiled Called when the shader has been compiled.
  15908. * @param onError Called if there is an error when compiling a shader.
  15909. */
  15910. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15911. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15912. /**
  15913. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15914. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15915. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15916. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15917. * The gaps between physical kernels are compensated for in the weighting of the samples
  15918. * @param idealKernel Ideal blur kernel.
  15919. * @return Nearest best kernel.
  15920. */
  15921. protected _nearestBestKernel(idealKernel: number): number;
  15922. /**
  15923. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15924. * @param x The point on the Gaussian distribution to sample.
  15925. * @return the value of the Gaussian function at x.
  15926. */
  15927. protected _gaussianWeight(x: number): number;
  15928. /**
  15929. * Generates a string that can be used as a floating point number in GLSL.
  15930. * @param x Value to print.
  15931. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15932. * @return GLSL float string.
  15933. */
  15934. protected _glslFloat(x: number, decimalFigures?: number): string;
  15935. }
  15936. }
  15937. declare module BABYLON {
  15938. /**
  15939. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15940. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15941. * You can then easily use it as a reflectionTexture on a flat surface.
  15942. * In case the surface is not a plane, please consider relying on reflection probes.
  15943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15944. */
  15945. export class MirrorTexture extends RenderTargetTexture {
  15946. private scene;
  15947. /**
  15948. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15949. * 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.
  15950. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15951. */
  15952. mirrorPlane: Plane;
  15953. /**
  15954. * Define the blur ratio used to blur the reflection if needed.
  15955. */
  15956. set blurRatio(value: number);
  15957. get blurRatio(): number;
  15958. /**
  15959. * Define the adaptive blur kernel used to blur the reflection if needed.
  15960. * This will autocompute the closest best match for the `blurKernel`
  15961. */
  15962. set adaptiveBlurKernel(value: number);
  15963. /**
  15964. * Define the blur kernel used to blur the reflection if needed.
  15965. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15966. */
  15967. set blurKernel(value: number);
  15968. /**
  15969. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15970. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15971. */
  15972. set blurKernelX(value: number);
  15973. get blurKernelX(): number;
  15974. /**
  15975. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15976. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15977. */
  15978. set blurKernelY(value: number);
  15979. get blurKernelY(): number;
  15980. private _autoComputeBlurKernel;
  15981. protected _onRatioRescale(): void;
  15982. private _updateGammaSpace;
  15983. private _imageProcessingConfigChangeObserver;
  15984. private _transformMatrix;
  15985. private _mirrorMatrix;
  15986. private _savedViewMatrix;
  15987. private _blurX;
  15988. private _blurY;
  15989. private _adaptiveBlurKernel;
  15990. private _blurKernelX;
  15991. private _blurKernelY;
  15992. private _blurRatio;
  15993. /**
  15994. * Instantiates a Mirror Texture.
  15995. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15996. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15997. * You can then easily use it as a reflectionTexture on a flat surface.
  15998. * In case the surface is not a plane, please consider relying on reflection probes.
  15999. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16000. * @param name
  16001. * @param size
  16002. * @param scene
  16003. * @param generateMipMaps
  16004. * @param type
  16005. * @param samplingMode
  16006. * @param generateDepthBuffer
  16007. */
  16008. constructor(name: string, size: number | {
  16009. width: number;
  16010. height: number;
  16011. } | {
  16012. ratio: number;
  16013. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16014. private _preparePostProcesses;
  16015. /**
  16016. * Clone the mirror texture.
  16017. * @returns the cloned texture
  16018. */
  16019. clone(): MirrorTexture;
  16020. /**
  16021. * Serialize the texture to a JSON representation you could use in Parse later on
  16022. * @returns the serialized JSON representation
  16023. */
  16024. serialize(): any;
  16025. /**
  16026. * Dispose the texture and release its associated resources.
  16027. */
  16028. dispose(): void;
  16029. }
  16030. }
  16031. declare module BABYLON {
  16032. /**
  16033. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16034. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16035. */
  16036. export class Texture extends BaseTexture {
  16037. /**
  16038. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16039. */
  16040. static SerializeBuffers: boolean;
  16041. /** @hidden */
  16042. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  16043. /** @hidden */
  16044. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  16045. /** @hidden */
  16046. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  16047. /** nearest is mag = nearest and min = nearest and mip = linear */
  16048. static readonly NEAREST_SAMPLINGMODE: number;
  16049. /** nearest is mag = nearest and min = nearest and mip = linear */
  16050. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16051. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16052. static readonly BILINEAR_SAMPLINGMODE: number;
  16053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16054. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16055. /** Trilinear is mag = linear and min = linear and mip = linear */
  16056. static readonly TRILINEAR_SAMPLINGMODE: number;
  16057. /** Trilinear is mag = linear and min = linear and mip = linear */
  16058. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16059. /** mag = nearest and min = nearest and mip = nearest */
  16060. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16061. /** mag = nearest and min = linear and mip = nearest */
  16062. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16063. /** mag = nearest and min = linear and mip = linear */
  16064. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16065. /** mag = nearest and min = linear and mip = none */
  16066. static readonly NEAREST_LINEAR: number;
  16067. /** mag = nearest and min = nearest and mip = none */
  16068. static readonly NEAREST_NEAREST: number;
  16069. /** mag = linear and min = nearest and mip = nearest */
  16070. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16071. /** mag = linear and min = nearest and mip = linear */
  16072. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16073. /** mag = linear and min = linear and mip = none */
  16074. static readonly LINEAR_LINEAR: number;
  16075. /** mag = linear and min = nearest and mip = none */
  16076. static readonly LINEAR_NEAREST: number;
  16077. /** Explicit coordinates mode */
  16078. static readonly EXPLICIT_MODE: number;
  16079. /** Spherical coordinates mode */
  16080. static readonly SPHERICAL_MODE: number;
  16081. /** Planar coordinates mode */
  16082. static readonly PLANAR_MODE: number;
  16083. /** Cubic coordinates mode */
  16084. static readonly CUBIC_MODE: number;
  16085. /** Projection coordinates mode */
  16086. static readonly PROJECTION_MODE: number;
  16087. /** Inverse Cubic coordinates mode */
  16088. static readonly SKYBOX_MODE: number;
  16089. /** Inverse Cubic coordinates mode */
  16090. static readonly INVCUBIC_MODE: number;
  16091. /** Equirectangular coordinates mode */
  16092. static readonly EQUIRECTANGULAR_MODE: number;
  16093. /** Equirectangular Fixed coordinates mode */
  16094. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16095. /** Equirectangular Fixed Mirrored coordinates mode */
  16096. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16097. /** Texture is not repeating outside of 0..1 UVs */
  16098. static readonly CLAMP_ADDRESSMODE: number;
  16099. /** Texture is repeating outside of 0..1 UVs */
  16100. static readonly WRAP_ADDRESSMODE: number;
  16101. /** Texture is repeating and mirrored */
  16102. static readonly MIRROR_ADDRESSMODE: number;
  16103. /**
  16104. * 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
  16105. */
  16106. static UseSerializedUrlIfAny: boolean;
  16107. /**
  16108. * Define the url of the texture.
  16109. */
  16110. url: Nullable<string>;
  16111. /**
  16112. * Define an offset on the texture to offset the u coordinates of the UVs
  16113. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16114. */
  16115. uOffset: number;
  16116. /**
  16117. * Define an offset on the texture to offset the v coordinates of the UVs
  16118. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16119. */
  16120. vOffset: number;
  16121. /**
  16122. * Define an offset on the texture to scale the u coordinates of the UVs
  16123. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16124. */
  16125. uScale: number;
  16126. /**
  16127. * Define an offset on the texture to scale the v coordinates of the UVs
  16128. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16129. */
  16130. vScale: number;
  16131. /**
  16132. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16133. * @see http://doc.babylonjs.com/how_to/more_materials
  16134. */
  16135. uAng: number;
  16136. /**
  16137. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16138. * @see http://doc.babylonjs.com/how_to/more_materials
  16139. */
  16140. vAng: number;
  16141. /**
  16142. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16143. * @see http://doc.babylonjs.com/how_to/more_materials
  16144. */
  16145. wAng: number;
  16146. /**
  16147. * Defines the center of rotation (U)
  16148. */
  16149. uRotationCenter: number;
  16150. /**
  16151. * Defines the center of rotation (V)
  16152. */
  16153. vRotationCenter: number;
  16154. /**
  16155. * Defines the center of rotation (W)
  16156. */
  16157. wRotationCenter: number;
  16158. /**
  16159. * Are mip maps generated for this texture or not.
  16160. */
  16161. get noMipmap(): boolean;
  16162. /**
  16163. * List of inspectable custom properties (used by the Inspector)
  16164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16165. */
  16166. inspectableCustomProperties: Nullable<IInspectable[]>;
  16167. private _noMipmap;
  16168. /** @hidden */
  16169. _invertY: boolean;
  16170. private _rowGenerationMatrix;
  16171. private _cachedTextureMatrix;
  16172. private _projectionModeMatrix;
  16173. private _t0;
  16174. private _t1;
  16175. private _t2;
  16176. private _cachedUOffset;
  16177. private _cachedVOffset;
  16178. private _cachedUScale;
  16179. private _cachedVScale;
  16180. private _cachedUAng;
  16181. private _cachedVAng;
  16182. private _cachedWAng;
  16183. private _cachedProjectionMatrixId;
  16184. private _cachedCoordinatesMode;
  16185. /** @hidden */
  16186. protected _initialSamplingMode: number;
  16187. /** @hidden */
  16188. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16189. private _deleteBuffer;
  16190. protected _format: Nullable<number>;
  16191. private _delayedOnLoad;
  16192. private _delayedOnError;
  16193. private _mimeType?;
  16194. /**
  16195. * Observable triggered once the texture has been loaded.
  16196. */
  16197. onLoadObservable: Observable<Texture>;
  16198. protected _isBlocking: boolean;
  16199. /**
  16200. * Is the texture preventing material to render while loading.
  16201. * If false, a default texture will be used instead of the loading one during the preparation step.
  16202. */
  16203. set isBlocking(value: boolean);
  16204. get isBlocking(): boolean;
  16205. /**
  16206. * Get the current sampling mode associated with the texture.
  16207. */
  16208. get samplingMode(): number;
  16209. /**
  16210. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16211. */
  16212. get invertY(): boolean;
  16213. /**
  16214. * Instantiates a new texture.
  16215. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16216. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16217. * @param url defines the url of the picture to load as a texture
  16218. * @param scene defines the scene or engine the texture will belong to
  16219. * @param noMipmap defines if the texture will require mip maps or not
  16220. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad defines a callback triggered when the texture has been loaded
  16223. * @param onError defines a callback triggered when an error occurred during the loading session
  16224. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16225. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16226. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16227. * @param mimeType defines an optional mime type information
  16228. */
  16229. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16230. /**
  16231. * Update the url (and optional buffer) of this texture if url was null during construction.
  16232. * @param url the url of the texture
  16233. * @param buffer the buffer of the texture (defaults to null)
  16234. * @param onLoad callback called when the texture is loaded (defaults to null)
  16235. */
  16236. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16237. /**
  16238. * Finish the loading sequence of a texture flagged as delayed load.
  16239. * @hidden
  16240. */
  16241. delayLoad(): void;
  16242. private _prepareRowForTextureGeneration;
  16243. /**
  16244. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16245. * @returns the transform matrix of the texture.
  16246. */
  16247. getTextureMatrix(uBase?: number): Matrix;
  16248. /**
  16249. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16250. * @returns The reflection texture transform
  16251. */
  16252. getReflectionTextureMatrix(): Matrix;
  16253. /**
  16254. * Clones the texture.
  16255. * @returns the cloned texture
  16256. */
  16257. clone(): Texture;
  16258. /**
  16259. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16260. * @returns The JSON representation of the texture
  16261. */
  16262. serialize(): any;
  16263. /**
  16264. * Get the current class name of the texture useful for serialization or dynamic coding.
  16265. * @returns "Texture"
  16266. */
  16267. getClassName(): string;
  16268. /**
  16269. * Dispose the texture and release its associated resources.
  16270. */
  16271. dispose(): void;
  16272. /**
  16273. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16274. * @param parsedTexture Define the JSON representation of the texture
  16275. * @param scene Define the scene the parsed texture should be instantiated in
  16276. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16277. * @returns The parsed texture if successful
  16278. */
  16279. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16280. /**
  16281. * Creates a texture from its base 64 representation.
  16282. * @param data Define the base64 payload without the data: prefix
  16283. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16284. * @param scene Define the scene the texture should belong to
  16285. * @param noMipmap Forces the texture to not create mip map information if true
  16286. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16287. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16288. * @param onLoad define a callback triggered when the texture has been loaded
  16289. * @param onError define a callback triggered when an error occurred during the loading session
  16290. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16291. * @returns the created texture
  16292. */
  16293. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16294. /**
  16295. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16296. * @param data Define the base64 payload without the data: prefix
  16297. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16298. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16299. * @param scene Define the scene the texture should belong to
  16300. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16301. * @param noMipmap Forces the texture to not create mip map information if true
  16302. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16303. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16304. * @param onLoad define a callback triggered when the texture has been loaded
  16305. * @param onError define a callback triggered when an error occurred during the loading session
  16306. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16307. * @returns the created texture
  16308. */
  16309. 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;
  16310. }
  16311. }
  16312. declare module BABYLON {
  16313. /**
  16314. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16315. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16316. */
  16317. export class PostProcessManager {
  16318. private _scene;
  16319. private _indexBuffer;
  16320. private _vertexBuffers;
  16321. /**
  16322. * Creates a new instance PostProcess
  16323. * @param scene The scene that the post process is associated with.
  16324. */
  16325. constructor(scene: Scene);
  16326. private _prepareBuffers;
  16327. private _buildIndexBuffer;
  16328. /**
  16329. * Rebuilds the vertex buffers of the manager.
  16330. * @hidden
  16331. */
  16332. _rebuild(): void;
  16333. /**
  16334. * Prepares a frame to be run through a post process.
  16335. * @param sourceTexture The input texture to the post procesess. (default: null)
  16336. * @param postProcesses An array of post processes to be run. (default: null)
  16337. * @returns True if the post processes were able to be run.
  16338. * @hidden
  16339. */
  16340. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16341. /**
  16342. * Manually render a set of post processes to a texture.
  16343. * @param postProcesses An array of post processes to be run.
  16344. * @param targetTexture The target texture to render to.
  16345. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16346. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16347. * @param lodLevel defines which lod of the texture to render to
  16348. */
  16349. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16350. /**
  16351. * Finalize the result of the output of the postprocesses.
  16352. * @param doNotPresent If true the result will not be displayed to the screen.
  16353. * @param targetTexture The target texture to render to.
  16354. * @param faceIndex The index of the face to bind the target texture to.
  16355. * @param postProcesses The array of post processes to render.
  16356. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16357. * @hidden
  16358. */
  16359. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16360. /**
  16361. * Disposes of the post process manager.
  16362. */
  16363. dispose(): void;
  16364. }
  16365. }
  16366. declare module BABYLON {
  16367. /** Interface used by value gradients (color, factor, ...) */
  16368. export interface IValueGradient {
  16369. /**
  16370. * Gets or sets the gradient value (between 0 and 1)
  16371. */
  16372. gradient: number;
  16373. }
  16374. /** Class used to store color4 gradient */
  16375. export class ColorGradient implements IValueGradient {
  16376. /**
  16377. * Gets or sets the gradient value (between 0 and 1)
  16378. */
  16379. gradient: number;
  16380. /**
  16381. * Gets or sets first associated color
  16382. */
  16383. color1: Color4;
  16384. /**
  16385. * Gets or sets second associated color
  16386. */
  16387. color2?: Color4;
  16388. /**
  16389. * Will get a color picked randomly between color1 and color2.
  16390. * If color2 is undefined then color1 will be used
  16391. * @param result defines the target Color4 to store the result in
  16392. */
  16393. getColorToRef(result: Color4): void;
  16394. }
  16395. /** Class used to store color 3 gradient */
  16396. export class Color3Gradient implements IValueGradient {
  16397. /**
  16398. * Gets or sets the gradient value (between 0 and 1)
  16399. */
  16400. gradient: number;
  16401. /**
  16402. * Gets or sets the associated color
  16403. */
  16404. color: Color3;
  16405. }
  16406. /** Class used to store factor gradient */
  16407. export class FactorGradient implements IValueGradient {
  16408. /**
  16409. * Gets or sets the gradient value (between 0 and 1)
  16410. */
  16411. gradient: number;
  16412. /**
  16413. * Gets or sets first associated factor
  16414. */
  16415. factor1: number;
  16416. /**
  16417. * Gets or sets second associated factor
  16418. */
  16419. factor2?: number;
  16420. /**
  16421. * Will get a number picked randomly between factor1 and factor2.
  16422. * If factor2 is undefined then factor1 will be used
  16423. * @returns the picked number
  16424. */
  16425. getFactor(): number;
  16426. }
  16427. /**
  16428. * Helper used to simplify some generic gradient tasks
  16429. */
  16430. export class GradientHelper {
  16431. /**
  16432. * Gets the current gradient from an array of IValueGradient
  16433. * @param ratio defines the current ratio to get
  16434. * @param gradients defines the array of IValueGradient
  16435. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16436. */
  16437. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16438. }
  16439. }
  16440. declare module BABYLON {
  16441. interface ThinEngine {
  16442. /**
  16443. * Creates a dynamic texture
  16444. * @param width defines the width of the texture
  16445. * @param height defines the height of the texture
  16446. * @param generateMipMaps defines if the engine should generate the mip levels
  16447. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16448. * @returns the dynamic texture inside an InternalTexture
  16449. */
  16450. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16451. /**
  16452. * Update the content of a dynamic texture
  16453. * @param texture defines the texture to update
  16454. * @param canvas defines the canvas containing the source
  16455. * @param invertY defines if data must be stored with Y axis inverted
  16456. * @param premulAlpha defines if alpha is stored as premultiplied
  16457. * @param format defines the format of the data
  16458. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16459. */
  16460. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16461. }
  16462. }
  16463. declare module BABYLON {
  16464. /**
  16465. * Helper class used to generate a canvas to manipulate images
  16466. */
  16467. export class CanvasGenerator {
  16468. /**
  16469. * Create a new canvas (or offscreen canvas depending on the context)
  16470. * @param width defines the expected width
  16471. * @param height defines the expected height
  16472. * @return a new canvas or offscreen canvas
  16473. */
  16474. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16475. }
  16476. }
  16477. declare module BABYLON {
  16478. /**
  16479. * A class extending Texture allowing drawing on a texture
  16480. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16481. */
  16482. export class DynamicTexture extends Texture {
  16483. private _generateMipMaps;
  16484. private _canvas;
  16485. private _context;
  16486. private _engine;
  16487. /**
  16488. * Creates a DynamicTexture
  16489. * @param name defines the name of the texture
  16490. * @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
  16491. * @param scene defines the scene where you want the texture
  16492. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16493. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16494. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16495. */
  16496. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16497. /**
  16498. * Get the current class name of the texture useful for serialization or dynamic coding.
  16499. * @returns "DynamicTexture"
  16500. */
  16501. getClassName(): string;
  16502. /**
  16503. * Gets the current state of canRescale
  16504. */
  16505. get canRescale(): boolean;
  16506. private _recreate;
  16507. /**
  16508. * Scales the texture
  16509. * @param ratio the scale factor to apply to both width and height
  16510. */
  16511. scale(ratio: number): void;
  16512. /**
  16513. * Resizes the texture
  16514. * @param width the new width
  16515. * @param height the new height
  16516. */
  16517. scaleTo(width: number, height: number): void;
  16518. /**
  16519. * Gets the context of the canvas used by the texture
  16520. * @returns the canvas context of the dynamic texture
  16521. */
  16522. getContext(): CanvasRenderingContext2D;
  16523. /**
  16524. * Clears the texture
  16525. */
  16526. clear(): void;
  16527. /**
  16528. * Updates the texture
  16529. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16530. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16531. */
  16532. update(invertY?: boolean, premulAlpha?: boolean): void;
  16533. /**
  16534. * Draws text onto the texture
  16535. * @param text defines the text to be drawn
  16536. * @param x defines the placement of the text from the left
  16537. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16538. * @param font defines the font to be used with font-style, font-size, font-name
  16539. * @param color defines the color used for the text
  16540. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16541. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16542. * @param update defines whether texture is immediately update (default is true)
  16543. */
  16544. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16545. /**
  16546. * Clones the texture
  16547. * @returns the clone of the texture.
  16548. */
  16549. clone(): DynamicTexture;
  16550. /**
  16551. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16552. * @returns a serialized dynamic texture object
  16553. */
  16554. serialize(): any;
  16555. /** @hidden */
  16556. _rebuild(): void;
  16557. }
  16558. }
  16559. declare module BABYLON {
  16560. interface AbstractScene {
  16561. /**
  16562. * The list of procedural textures added to the scene
  16563. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16564. */
  16565. proceduralTextures: Array<ProceduralTexture>;
  16566. }
  16567. /**
  16568. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16569. * in a given scene.
  16570. */
  16571. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16572. /**
  16573. * The component name helpfull to identify the component in the list of scene components.
  16574. */
  16575. readonly name: string;
  16576. /**
  16577. * The scene the component belongs to.
  16578. */
  16579. scene: Scene;
  16580. /**
  16581. * Creates a new instance of the component for the given scene
  16582. * @param scene Defines the scene to register the component in
  16583. */
  16584. constructor(scene: Scene);
  16585. /**
  16586. * Registers the component in a given scene
  16587. */
  16588. register(): void;
  16589. /**
  16590. * Rebuilds the elements related to this component in case of
  16591. * context lost for instance.
  16592. */
  16593. rebuild(): void;
  16594. /**
  16595. * Disposes the component and the associated ressources.
  16596. */
  16597. dispose(): void;
  16598. private _beforeClear;
  16599. }
  16600. }
  16601. declare module BABYLON {
  16602. interface ThinEngine {
  16603. /**
  16604. * Creates a new render target cube texture
  16605. * @param size defines the size of the texture
  16606. * @param options defines the options used to create the texture
  16607. * @returns a new render target cube texture stored in an InternalTexture
  16608. */
  16609. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16610. }
  16611. }
  16612. declare module BABYLON {
  16613. /** @hidden */
  16614. export var proceduralVertexShader: {
  16615. name: string;
  16616. shader: string;
  16617. };
  16618. }
  16619. declare module BABYLON {
  16620. /**
  16621. * 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.
  16622. * This is the base class of any Procedural texture and contains most of the shareable code.
  16623. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16624. */
  16625. export class ProceduralTexture extends Texture {
  16626. isCube: boolean;
  16627. /**
  16628. * Define if the texture is enabled or not (disabled texture will not render)
  16629. */
  16630. isEnabled: boolean;
  16631. /**
  16632. * Define if the texture must be cleared before rendering (default is true)
  16633. */
  16634. autoClear: boolean;
  16635. /**
  16636. * Callback called when the texture is generated
  16637. */
  16638. onGenerated: () => void;
  16639. /**
  16640. * Event raised when the texture is generated
  16641. */
  16642. onGeneratedObservable: Observable<ProceduralTexture>;
  16643. /** @hidden */
  16644. _generateMipMaps: boolean;
  16645. /** @hidden **/
  16646. _effect: Effect;
  16647. /** @hidden */
  16648. _textures: {
  16649. [key: string]: Texture;
  16650. };
  16651. private _size;
  16652. private _currentRefreshId;
  16653. private _frameId;
  16654. private _refreshRate;
  16655. private _vertexBuffers;
  16656. private _indexBuffer;
  16657. private _uniforms;
  16658. private _samplers;
  16659. private _fragment;
  16660. private _floats;
  16661. private _ints;
  16662. private _floatsArrays;
  16663. private _colors3;
  16664. private _colors4;
  16665. private _vectors2;
  16666. private _vectors3;
  16667. private _matrices;
  16668. private _fallbackTexture;
  16669. private _fallbackTextureUsed;
  16670. private _engine;
  16671. private _cachedDefines;
  16672. private _contentUpdateId;
  16673. private _contentData;
  16674. /**
  16675. * Instantiates a new procedural texture.
  16676. * 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.
  16677. * This is the base class of any Procedural texture and contains most of the shareable code.
  16678. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16679. * @param name Define the name of the texture
  16680. * @param size Define the size of the texture to create
  16681. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16682. * @param scene Define the scene the texture belongs to
  16683. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16684. * @param generateMipMaps Define if the texture should creates mip maps or not
  16685. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16686. */
  16687. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16688. /**
  16689. * The effect that is created when initializing the post process.
  16690. * @returns The created effect corresponding the the postprocess.
  16691. */
  16692. getEffect(): Effect;
  16693. /**
  16694. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16695. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16696. */
  16697. getContent(): Nullable<ArrayBufferView>;
  16698. private _createIndexBuffer;
  16699. /** @hidden */
  16700. _rebuild(): void;
  16701. /**
  16702. * Resets the texture in order to recreate its associated resources.
  16703. * This can be called in case of context loss
  16704. */
  16705. reset(): void;
  16706. protected _getDefines(): string;
  16707. /**
  16708. * Is the texture ready to be used ? (rendered at least once)
  16709. * @returns true if ready, otherwise, false.
  16710. */
  16711. isReady(): boolean;
  16712. /**
  16713. * Resets the refresh counter of the texture and start bak from scratch.
  16714. * Could be useful to regenerate the texture if it is setup to render only once.
  16715. */
  16716. resetRefreshCounter(): void;
  16717. /**
  16718. * Set the fragment shader to use in order to render the texture.
  16719. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16720. */
  16721. setFragment(fragment: any): void;
  16722. /**
  16723. * Define the refresh rate of the texture or the rendering frequency.
  16724. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16725. */
  16726. get refreshRate(): number;
  16727. set refreshRate(value: number);
  16728. /** @hidden */
  16729. _shouldRender(): boolean;
  16730. /**
  16731. * Get the size the texture is rendering at.
  16732. * @returns the size (texture is always squared)
  16733. */
  16734. getRenderSize(): number;
  16735. /**
  16736. * Resize the texture to new value.
  16737. * @param size Define the new size the texture should have
  16738. * @param generateMipMaps Define whether the new texture should create mip maps
  16739. */
  16740. resize(size: number, generateMipMaps: boolean): void;
  16741. private _checkUniform;
  16742. /**
  16743. * Set a texture in the shader program used to render.
  16744. * @param name Define the name of the uniform samplers as defined in the shader
  16745. * @param texture Define the texture to bind to this sampler
  16746. * @return the texture itself allowing "fluent" like uniform updates
  16747. */
  16748. setTexture(name: string, texture: Texture): ProceduralTexture;
  16749. /**
  16750. * Set a float in the shader.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the texture itself allowing "fluent" like uniform updates
  16754. */
  16755. setFloat(name: string, value: number): ProceduralTexture;
  16756. /**
  16757. * Set a int in the shader.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the texture itself allowing "fluent" like uniform updates
  16761. */
  16762. setInt(name: string, value: number): ProceduralTexture;
  16763. /**
  16764. * Set an array of floats in the shader.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the texture itself allowing "fluent" like uniform updates
  16768. */
  16769. setFloats(name: string, value: number[]): ProceduralTexture;
  16770. /**
  16771. * Set a vec3 in the shader from a Color3.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the texture itself allowing "fluent" like uniform updates
  16775. */
  16776. setColor3(name: string, value: Color3): ProceduralTexture;
  16777. /**
  16778. * Set a vec4 in the shader from a Color4.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the texture itself allowing "fluent" like uniform updates
  16782. */
  16783. setColor4(name: string, value: Color4): ProceduralTexture;
  16784. /**
  16785. * Set a vec2 in the shader from a Vector2.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the texture itself allowing "fluent" like uniform updates
  16789. */
  16790. setVector2(name: string, value: Vector2): ProceduralTexture;
  16791. /**
  16792. * Set a vec3 in the shader from a Vector3.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the texture itself allowing "fluent" like uniform updates
  16796. */
  16797. setVector3(name: string, value: Vector3): ProceduralTexture;
  16798. /**
  16799. * Set a mat4 in the shader from a MAtrix.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the texture itself allowing "fluent" like uniform updates
  16803. */
  16804. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16805. /**
  16806. * Render the texture to its associated render target.
  16807. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16808. */
  16809. render(useCameraPostProcess?: boolean): void;
  16810. /**
  16811. * Clone the texture.
  16812. * @returns the cloned texture
  16813. */
  16814. clone(): ProceduralTexture;
  16815. /**
  16816. * Dispose the texture and release its asoociated resources.
  16817. */
  16818. dispose(): void;
  16819. }
  16820. }
  16821. declare module BABYLON {
  16822. /**
  16823. * This represents the base class for particle system in Babylon.
  16824. * 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.
  16825. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16826. * @example https://doc.babylonjs.com/babylon101/particles
  16827. */
  16828. export class BaseParticleSystem {
  16829. /**
  16830. * Source color is added to the destination color without alpha affecting the result
  16831. */
  16832. static BLENDMODE_ONEONE: number;
  16833. /**
  16834. * Blend current color and particle color using particle’s alpha
  16835. */
  16836. static BLENDMODE_STANDARD: number;
  16837. /**
  16838. * Add current color and particle color multiplied by particle’s alpha
  16839. */
  16840. static BLENDMODE_ADD: number;
  16841. /**
  16842. * Multiply current color with particle color
  16843. */
  16844. static BLENDMODE_MULTIPLY: number;
  16845. /**
  16846. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16847. */
  16848. static BLENDMODE_MULTIPLYADD: number;
  16849. /**
  16850. * List of animations used by the particle system.
  16851. */
  16852. animations: Animation[];
  16853. /**
  16854. * The id of the Particle system.
  16855. */
  16856. id: string;
  16857. /**
  16858. * The friendly name of the Particle system.
  16859. */
  16860. name: string;
  16861. /**
  16862. * The rendering group used by the Particle system to chose when to render.
  16863. */
  16864. renderingGroupId: number;
  16865. /**
  16866. * The emitter represents the Mesh or position we are attaching the particle system to.
  16867. */
  16868. emitter: Nullable<AbstractMesh | Vector3>;
  16869. /**
  16870. * The maximum number of particles to emit per frame
  16871. */
  16872. emitRate: number;
  16873. /**
  16874. * If you want to launch only a few particles at once, that can be done, as well.
  16875. */
  16876. manualEmitCount: number;
  16877. /**
  16878. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16879. */
  16880. updateSpeed: number;
  16881. /**
  16882. * The amount of time the particle system is running (depends of the overall update speed).
  16883. */
  16884. targetStopDuration: number;
  16885. /**
  16886. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16887. */
  16888. disposeOnStop: boolean;
  16889. /**
  16890. * Minimum power of emitting particles.
  16891. */
  16892. minEmitPower: number;
  16893. /**
  16894. * Maximum power of emitting particles.
  16895. */
  16896. maxEmitPower: number;
  16897. /**
  16898. * Minimum life time of emitting particles.
  16899. */
  16900. minLifeTime: number;
  16901. /**
  16902. * Maximum life time of emitting particles.
  16903. */
  16904. maxLifeTime: number;
  16905. /**
  16906. * Minimum Size of emitting particles.
  16907. */
  16908. minSize: number;
  16909. /**
  16910. * Maximum Size of emitting particles.
  16911. */
  16912. maxSize: number;
  16913. /**
  16914. * Minimum scale of emitting particles on X axis.
  16915. */
  16916. minScaleX: number;
  16917. /**
  16918. * Maximum scale of emitting particles on X axis.
  16919. */
  16920. maxScaleX: number;
  16921. /**
  16922. * Minimum scale of emitting particles on Y axis.
  16923. */
  16924. minScaleY: number;
  16925. /**
  16926. * Maximum scale of emitting particles on Y axis.
  16927. */
  16928. maxScaleY: number;
  16929. /**
  16930. * Gets or sets the minimal initial rotation in radians.
  16931. */
  16932. minInitialRotation: number;
  16933. /**
  16934. * Gets or sets the maximal initial rotation in radians.
  16935. */
  16936. maxInitialRotation: number;
  16937. /**
  16938. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16939. */
  16940. minAngularSpeed: number;
  16941. /**
  16942. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16943. */
  16944. maxAngularSpeed: number;
  16945. /**
  16946. * The texture used to render each particle. (this can be a spritesheet)
  16947. */
  16948. particleTexture: Nullable<Texture>;
  16949. /**
  16950. * The layer mask we are rendering the particles through.
  16951. */
  16952. layerMask: number;
  16953. /**
  16954. * This can help using your own shader to render the particle system.
  16955. * The according effect will be created
  16956. */
  16957. customShader: any;
  16958. /**
  16959. * By default particle system starts as soon as they are created. This prevents the
  16960. * automatic start to happen and let you decide when to start emitting particles.
  16961. */
  16962. preventAutoStart: boolean;
  16963. private _noiseTexture;
  16964. /**
  16965. * Gets or sets a texture used to add random noise to particle positions
  16966. */
  16967. get noiseTexture(): Nullable<ProceduralTexture>;
  16968. set noiseTexture(value: Nullable<ProceduralTexture>);
  16969. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16970. noiseStrength: Vector3;
  16971. /**
  16972. * Callback triggered when the particle animation is ending.
  16973. */
  16974. onAnimationEnd: Nullable<() => void>;
  16975. /**
  16976. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16977. */
  16978. blendMode: number;
  16979. /**
  16980. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16981. * to override the particles.
  16982. */
  16983. forceDepthWrite: boolean;
  16984. /** 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 */
  16985. preWarmCycles: number;
  16986. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16987. preWarmStepOffset: number;
  16988. /**
  16989. * 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)
  16990. */
  16991. spriteCellChangeSpeed: number;
  16992. /**
  16993. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16994. */
  16995. startSpriteCellID: number;
  16996. /**
  16997. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16998. */
  16999. endSpriteCellID: number;
  17000. /**
  17001. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17002. */
  17003. spriteCellWidth: number;
  17004. /**
  17005. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17006. */
  17007. spriteCellHeight: number;
  17008. /**
  17009. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17010. */
  17011. spriteRandomStartCell: boolean;
  17012. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17013. translationPivot: Vector2;
  17014. /** @hidden */
  17015. protected _isAnimationSheetEnabled: boolean;
  17016. /**
  17017. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17018. */
  17019. beginAnimationOnStart: boolean;
  17020. /**
  17021. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17022. */
  17023. beginAnimationFrom: number;
  17024. /**
  17025. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17026. */
  17027. beginAnimationTo: number;
  17028. /**
  17029. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17030. */
  17031. beginAnimationLoop: boolean;
  17032. /**
  17033. * Gets or sets a world offset applied to all particles
  17034. */
  17035. worldOffset: Vector3;
  17036. /**
  17037. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17038. */
  17039. get isAnimationSheetEnabled(): boolean;
  17040. set isAnimationSheetEnabled(value: boolean);
  17041. /**
  17042. * Get hosting scene
  17043. * @returns the scene
  17044. */
  17045. getScene(): Scene;
  17046. /**
  17047. * You can use gravity if you want to give an orientation to your particles.
  17048. */
  17049. gravity: Vector3;
  17050. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17051. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17052. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17053. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17054. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17055. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17056. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17057. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17058. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17059. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17060. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17061. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17062. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17063. /**
  17064. * Defines the delay in milliseconds before starting the system (0 by default)
  17065. */
  17066. startDelay: number;
  17067. /**
  17068. * Gets the current list of drag gradients.
  17069. * You must use addDragGradient and removeDragGradient to udpate this list
  17070. * @returns the list of drag gradients
  17071. */
  17072. getDragGradients(): Nullable<Array<FactorGradient>>;
  17073. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17074. limitVelocityDamping: number;
  17075. /**
  17076. * Gets the current list of limit velocity gradients.
  17077. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17078. * @returns the list of limit velocity gradients
  17079. */
  17080. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17081. /**
  17082. * Gets the current list of color gradients.
  17083. * You must use addColorGradient and removeColorGradient to udpate this list
  17084. * @returns the list of color gradients
  17085. */
  17086. getColorGradients(): Nullable<Array<ColorGradient>>;
  17087. /**
  17088. * Gets the current list of size gradients.
  17089. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17090. * @returns the list of size gradients
  17091. */
  17092. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17093. /**
  17094. * Gets the current list of color remap gradients.
  17095. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17096. * @returns the list of color remap gradients
  17097. */
  17098. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17099. /**
  17100. * Gets the current list of alpha remap gradients.
  17101. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17102. * @returns the list of alpha remap gradients
  17103. */
  17104. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17105. /**
  17106. * Gets the current list of life time gradients.
  17107. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17108. * @returns the list of life time gradients
  17109. */
  17110. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17111. /**
  17112. * Gets the current list of angular speed gradients.
  17113. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17114. * @returns the list of angular speed gradients
  17115. */
  17116. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17117. /**
  17118. * Gets the current list of velocity gradients.
  17119. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17120. * @returns the list of velocity gradients
  17121. */
  17122. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17123. /**
  17124. * Gets the current list of start size gradients.
  17125. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17126. * @returns the list of start size gradients
  17127. */
  17128. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17129. /**
  17130. * Gets the current list of emit rate gradients.
  17131. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17132. * @returns the list of emit rate gradients
  17133. */
  17134. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17135. /**
  17136. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17137. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17138. */
  17139. get direction1(): Vector3;
  17140. set direction1(value: Vector3);
  17141. /**
  17142. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17143. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17144. */
  17145. get direction2(): Vector3;
  17146. set direction2(value: Vector3);
  17147. /**
  17148. * 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.
  17149. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17150. */
  17151. get minEmitBox(): Vector3;
  17152. set minEmitBox(value: Vector3);
  17153. /**
  17154. * 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.
  17155. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17156. */
  17157. get maxEmitBox(): Vector3;
  17158. set maxEmitBox(value: Vector3);
  17159. /**
  17160. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17161. */
  17162. color1: Color4;
  17163. /**
  17164. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17165. */
  17166. color2: Color4;
  17167. /**
  17168. * Color the particle will have at the end of its lifetime
  17169. */
  17170. colorDead: Color4;
  17171. /**
  17172. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17173. */
  17174. textureMask: Color4;
  17175. /**
  17176. * The particle emitter type defines the emitter used by the particle system.
  17177. * It can be for example box, sphere, or cone...
  17178. */
  17179. particleEmitterType: IParticleEmitterType;
  17180. /** @hidden */
  17181. _isSubEmitter: boolean;
  17182. /**
  17183. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17184. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17185. */
  17186. billboardMode: number;
  17187. protected _isBillboardBased: boolean;
  17188. /**
  17189. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17190. */
  17191. get isBillboardBased(): boolean;
  17192. set isBillboardBased(value: boolean);
  17193. /**
  17194. * The scene the particle system belongs to.
  17195. */
  17196. protected _scene: Scene;
  17197. /**
  17198. * Local cache of defines for image processing.
  17199. */
  17200. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17201. /**
  17202. * Default configuration related to image processing available in the standard Material.
  17203. */
  17204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17205. /**
  17206. * Gets the image processing configuration used either in this material.
  17207. */
  17208. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17209. /**
  17210. * Sets the Default image processing configuration used either in the this material.
  17211. *
  17212. * If sets to null, the scene one is in use.
  17213. */
  17214. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17215. /**
  17216. * Attaches a new image processing configuration to the Standard Material.
  17217. * @param configuration
  17218. */
  17219. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17220. /** @hidden */
  17221. protected _reset(): void;
  17222. /** @hidden */
  17223. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17224. /**
  17225. * Instantiates a particle system.
  17226. * 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.
  17227. * @param name The name of the particle system
  17228. */
  17229. constructor(name: string);
  17230. /**
  17231. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17232. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17233. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17234. * @returns the emitter
  17235. */
  17236. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17237. /**
  17238. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17239. * @param radius The radius of the hemisphere to emit from
  17240. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17241. * @returns the emitter
  17242. */
  17243. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17244. /**
  17245. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17246. * @param radius The radius of the sphere to emit from
  17247. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17248. * @returns the emitter
  17249. */
  17250. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17251. /**
  17252. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17253. * @param radius The radius of the sphere to emit from
  17254. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17255. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17256. * @returns the emitter
  17257. */
  17258. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17259. /**
  17260. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17261. * @param radius The radius of the emission cylinder
  17262. * @param height The height of the emission cylinder
  17263. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17264. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17265. * @returns the emitter
  17266. */
  17267. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17268. /**
  17269. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17270. * @param radius The radius of the cylinder to emit from
  17271. * @param height The height of the emission cylinder
  17272. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17273. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17274. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17275. * @returns the emitter
  17276. */
  17277. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17278. /**
  17279. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17280. * @param radius The radius of the cone to emit from
  17281. * @param angle The base angle of the cone
  17282. * @returns the emitter
  17283. */
  17284. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17285. /**
  17286. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17287. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17288. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17289. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17290. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17291. * @returns the emitter
  17292. */
  17293. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17294. }
  17295. }
  17296. declare module BABYLON {
  17297. /**
  17298. * Type of sub emitter
  17299. */
  17300. export enum SubEmitterType {
  17301. /**
  17302. * Attached to the particle over it's lifetime
  17303. */
  17304. ATTACHED = 0,
  17305. /**
  17306. * Created when the particle dies
  17307. */
  17308. END = 1
  17309. }
  17310. /**
  17311. * Sub emitter class used to emit particles from an existing particle
  17312. */
  17313. export class SubEmitter {
  17314. /**
  17315. * the particle system to be used by the sub emitter
  17316. */
  17317. particleSystem: ParticleSystem;
  17318. /**
  17319. * Type of the submitter (Default: END)
  17320. */
  17321. type: SubEmitterType;
  17322. /**
  17323. * 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)
  17324. * Note: This only is supported when using an emitter of type Mesh
  17325. */
  17326. inheritDirection: boolean;
  17327. /**
  17328. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17329. */
  17330. inheritedVelocityAmount: number;
  17331. /**
  17332. * Creates a sub emitter
  17333. * @param particleSystem the particle system to be used by the sub emitter
  17334. */
  17335. constructor(
  17336. /**
  17337. * the particle system to be used by the sub emitter
  17338. */
  17339. particleSystem: ParticleSystem);
  17340. /**
  17341. * Clones the sub emitter
  17342. * @returns the cloned sub emitter
  17343. */
  17344. clone(): SubEmitter;
  17345. /**
  17346. * Serialize current object to a JSON object
  17347. * @returns the serialized object
  17348. */
  17349. serialize(): any;
  17350. /** @hidden */
  17351. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17352. /**
  17353. * Creates a new SubEmitter from a serialized JSON version
  17354. * @param serializationObject defines the JSON object to read from
  17355. * @param scene defines the hosting scene
  17356. * @param rootUrl defines the rootUrl for data loading
  17357. * @returns a new SubEmitter
  17358. */
  17359. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17360. /** Release associated resources */
  17361. dispose(): void;
  17362. }
  17363. }
  17364. declare module BABYLON {
  17365. /** @hidden */
  17366. export var imageProcessingDeclaration: {
  17367. name: string;
  17368. shader: string;
  17369. };
  17370. }
  17371. declare module BABYLON {
  17372. /** @hidden */
  17373. export var imageProcessingFunctions: {
  17374. name: string;
  17375. shader: string;
  17376. };
  17377. }
  17378. declare module BABYLON {
  17379. /** @hidden */
  17380. export var particlesPixelShader: {
  17381. name: string;
  17382. shader: string;
  17383. };
  17384. }
  17385. declare module BABYLON {
  17386. /** @hidden */
  17387. export var particlesVertexShader: {
  17388. name: string;
  17389. shader: string;
  17390. };
  17391. }
  17392. declare module BABYLON {
  17393. /**
  17394. * This represents a particle system in Babylon.
  17395. * 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.
  17396. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17397. * @example https://doc.babylonjs.com/babylon101/particles
  17398. */
  17399. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17400. /**
  17401. * Billboard mode will only apply to Y axis
  17402. */
  17403. static readonly BILLBOARDMODE_Y: number;
  17404. /**
  17405. * Billboard mode will apply to all axes
  17406. */
  17407. static readonly BILLBOARDMODE_ALL: number;
  17408. /**
  17409. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17410. */
  17411. static readonly BILLBOARDMODE_STRETCHED: number;
  17412. /**
  17413. * This function can be defined to provide custom update for active particles.
  17414. * This function will be called instead of regular update (age, position, color, etc.).
  17415. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17416. */
  17417. updateFunction: (particles: Particle[]) => void;
  17418. private _emitterWorldMatrix;
  17419. /**
  17420. * This function can be defined to specify initial direction for every new particle.
  17421. * It by default use the emitterType defined function
  17422. */
  17423. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17424. /**
  17425. * This function can be defined to specify initial position for every new particle.
  17426. * It by default use the emitterType defined function
  17427. */
  17428. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17429. /**
  17430. * @hidden
  17431. */
  17432. _inheritedVelocityOffset: Vector3;
  17433. /**
  17434. * An event triggered when the system is disposed
  17435. */
  17436. onDisposeObservable: Observable<ParticleSystem>;
  17437. private _onDisposeObserver;
  17438. /**
  17439. * Sets a callback that will be triggered when the system is disposed
  17440. */
  17441. set onDispose(callback: () => void);
  17442. private _particles;
  17443. private _epsilon;
  17444. private _capacity;
  17445. private _stockParticles;
  17446. private _newPartsExcess;
  17447. private _vertexData;
  17448. private _vertexBuffer;
  17449. private _vertexBuffers;
  17450. private _spriteBuffer;
  17451. private _indexBuffer;
  17452. private _effect;
  17453. private _customEffect;
  17454. private _cachedDefines;
  17455. private _scaledColorStep;
  17456. private _colorDiff;
  17457. private _scaledDirection;
  17458. private _scaledGravity;
  17459. private _currentRenderId;
  17460. private _alive;
  17461. private _useInstancing;
  17462. private _started;
  17463. private _stopped;
  17464. private _actualFrame;
  17465. private _scaledUpdateSpeed;
  17466. private _vertexBufferSize;
  17467. /** @hidden */
  17468. _currentEmitRateGradient: Nullable<FactorGradient>;
  17469. /** @hidden */
  17470. _currentEmitRate1: number;
  17471. /** @hidden */
  17472. _currentEmitRate2: number;
  17473. /** @hidden */
  17474. _currentStartSizeGradient: Nullable<FactorGradient>;
  17475. /** @hidden */
  17476. _currentStartSize1: number;
  17477. /** @hidden */
  17478. _currentStartSize2: number;
  17479. private readonly _rawTextureWidth;
  17480. private _rampGradientsTexture;
  17481. private _useRampGradients;
  17482. /** Gets or sets a boolean indicating that ramp gradients must be used
  17483. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17484. */
  17485. get useRampGradients(): boolean;
  17486. set useRampGradients(value: boolean);
  17487. /**
  17488. * 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.
  17489. * 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: [])
  17490. */
  17491. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17492. private _subEmitters;
  17493. /**
  17494. * @hidden
  17495. * If the particle systems emitter should be disposed when the particle system is disposed
  17496. */
  17497. _disposeEmitterOnDispose: boolean;
  17498. /**
  17499. * The current active Sub-systems, this property is used by the root particle system only.
  17500. */
  17501. activeSubSystems: Array<ParticleSystem>;
  17502. private _rootParticleSystem;
  17503. /**
  17504. * Gets the current list of active particles
  17505. */
  17506. get particles(): Particle[];
  17507. /**
  17508. * Returns the string "ParticleSystem"
  17509. * @returns a string containing the class name
  17510. */
  17511. getClassName(): string;
  17512. /**
  17513. * Instantiates a particle system.
  17514. * 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.
  17515. * @param name The name of the particle system
  17516. * @param capacity The max number of particles alive at the same time
  17517. * @param scene The scene the particle system belongs to
  17518. * @param customEffect a custom effect used to change the way particles are rendered by default
  17519. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17520. * @param epsilon Offset used to render the particles
  17521. */
  17522. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17523. private _addFactorGradient;
  17524. private _removeFactorGradient;
  17525. /**
  17526. * Adds a new life time gradient
  17527. * @param gradient defines the gradient to use (between 0 and 1)
  17528. * @param factor defines the life time factor to affect to the specified gradient
  17529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17530. * @returns the current particle system
  17531. */
  17532. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17533. /**
  17534. * Remove a specific life time gradient
  17535. * @param gradient defines the gradient to remove
  17536. * @returns the current particle system
  17537. */
  17538. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17539. /**
  17540. * Adds a new size gradient
  17541. * @param gradient defines the gradient to use (between 0 and 1)
  17542. * @param factor defines the size factor to affect to the specified gradient
  17543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17544. * @returns the current particle system
  17545. */
  17546. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17547. /**
  17548. * Remove a specific size gradient
  17549. * @param gradient defines the gradient to remove
  17550. * @returns the current particle system
  17551. */
  17552. removeSizeGradient(gradient: number): IParticleSystem;
  17553. /**
  17554. * Adds a new color remap gradient
  17555. * @param gradient defines the gradient to use (between 0 and 1)
  17556. * @param min defines the color remap minimal range
  17557. * @param max defines the color remap maximal range
  17558. * @returns the current particle system
  17559. */
  17560. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17561. /**
  17562. * Remove a specific color remap gradient
  17563. * @param gradient defines the gradient to remove
  17564. * @returns the current particle system
  17565. */
  17566. removeColorRemapGradient(gradient: number): IParticleSystem;
  17567. /**
  17568. * Adds a new alpha remap gradient
  17569. * @param gradient defines the gradient to use (between 0 and 1)
  17570. * @param min defines the alpha remap minimal range
  17571. * @param max defines the alpha remap maximal range
  17572. * @returns the current particle system
  17573. */
  17574. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17575. /**
  17576. * Remove a specific alpha remap gradient
  17577. * @param gradient defines the gradient to remove
  17578. * @returns the current particle system
  17579. */
  17580. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17581. /**
  17582. * Adds a new angular speed gradient
  17583. * @param gradient defines the gradient to use (between 0 and 1)
  17584. * @param factor defines the angular speed to affect to the specified gradient
  17585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17586. * @returns the current particle system
  17587. */
  17588. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17589. /**
  17590. * Remove a specific angular speed gradient
  17591. * @param gradient defines the gradient to remove
  17592. * @returns the current particle system
  17593. */
  17594. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17595. /**
  17596. * Adds a new velocity gradient
  17597. * @param gradient defines the gradient to use (between 0 and 1)
  17598. * @param factor defines the velocity to affect to the specified gradient
  17599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17600. * @returns the current particle system
  17601. */
  17602. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17603. /**
  17604. * Remove a specific velocity gradient
  17605. * @param gradient defines the gradient to remove
  17606. * @returns the current particle system
  17607. */
  17608. removeVelocityGradient(gradient: number): IParticleSystem;
  17609. /**
  17610. * Adds a new limit velocity gradient
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param factor defines the limit velocity value to affect to the specified gradient
  17613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17614. * @returns the current particle system
  17615. */
  17616. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17617. /**
  17618. * Remove a specific limit velocity gradient
  17619. * @param gradient defines the gradient to remove
  17620. * @returns the current particle system
  17621. */
  17622. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17623. /**
  17624. * Adds a new drag gradient
  17625. * @param gradient defines the gradient to use (between 0 and 1)
  17626. * @param factor defines the drag value to affect to the specified gradient
  17627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17628. * @returns the current particle system
  17629. */
  17630. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17631. /**
  17632. * Remove a specific drag gradient
  17633. * @param gradient defines the gradient to remove
  17634. * @returns the current particle system
  17635. */
  17636. removeDragGradient(gradient: number): IParticleSystem;
  17637. /**
  17638. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17639. * @param gradient defines the gradient to use (between 0 and 1)
  17640. * @param factor defines the emit rate value to affect to the specified gradient
  17641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17642. * @returns the current particle system
  17643. */
  17644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17645. /**
  17646. * Remove a specific emit rate gradient
  17647. * @param gradient defines the gradient to remove
  17648. * @returns the current particle system
  17649. */
  17650. removeEmitRateGradient(gradient: number): IParticleSystem;
  17651. /**
  17652. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17653. * @param gradient defines the gradient to use (between 0 and 1)
  17654. * @param factor defines the start size value to affect to the specified gradient
  17655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17656. * @returns the current particle system
  17657. */
  17658. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17659. /**
  17660. * Remove a specific start size gradient
  17661. * @param gradient defines the gradient to remove
  17662. * @returns the current particle system
  17663. */
  17664. removeStartSizeGradient(gradient: number): IParticleSystem;
  17665. private _createRampGradientTexture;
  17666. /**
  17667. * Gets the current list of ramp gradients.
  17668. * You must use addRampGradient and removeRampGradient to udpate this list
  17669. * @returns the list of ramp gradients
  17670. */
  17671. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17672. /**
  17673. * Adds a new ramp gradient used to remap particle colors
  17674. * @param gradient defines the gradient to use (between 0 and 1)
  17675. * @param color defines the color to affect to the specified gradient
  17676. * @returns the current particle system
  17677. */
  17678. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17679. /**
  17680. * Remove a specific ramp gradient
  17681. * @param gradient defines the gradient to remove
  17682. * @returns the current particle system
  17683. */
  17684. removeRampGradient(gradient: number): ParticleSystem;
  17685. /**
  17686. * Adds a new color gradient
  17687. * @param gradient defines the gradient to use (between 0 and 1)
  17688. * @param color1 defines the color to affect to the specified gradient
  17689. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17690. * @returns this particle system
  17691. */
  17692. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17693. /**
  17694. * Remove a specific color gradient
  17695. * @param gradient defines the gradient to remove
  17696. * @returns this particle system
  17697. */
  17698. removeColorGradient(gradient: number): IParticleSystem;
  17699. private _fetchR;
  17700. protected _reset(): void;
  17701. private _resetEffect;
  17702. private _createVertexBuffers;
  17703. private _createIndexBuffer;
  17704. /**
  17705. * Gets the maximum number of particles active at the same time.
  17706. * @returns The max number of active particles.
  17707. */
  17708. getCapacity(): number;
  17709. /**
  17710. * Gets whether there are still active particles in the system.
  17711. * @returns True if it is alive, otherwise false.
  17712. */
  17713. isAlive(): boolean;
  17714. /**
  17715. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17716. * @returns True if it has been started, otherwise false.
  17717. */
  17718. isStarted(): boolean;
  17719. private _prepareSubEmitterInternalArray;
  17720. /**
  17721. * Starts the particle system and begins to emit
  17722. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17723. */
  17724. start(delay?: number): void;
  17725. /**
  17726. * Stops the particle system.
  17727. * @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.
  17728. */
  17729. stop(stopSubEmitters?: boolean): void;
  17730. /**
  17731. * Remove all active particles
  17732. */
  17733. reset(): void;
  17734. /**
  17735. * @hidden (for internal use only)
  17736. */
  17737. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17738. /**
  17739. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17740. * Its lifetime will start back at 0.
  17741. */
  17742. recycleParticle: (particle: Particle) => void;
  17743. private _stopSubEmitters;
  17744. private _createParticle;
  17745. private _removeFromRoot;
  17746. private _emitFromParticle;
  17747. private _update;
  17748. /** @hidden */
  17749. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17750. /** @hidden */
  17751. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17752. /** @hidden */
  17753. private _getEffect;
  17754. /**
  17755. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17756. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17757. */
  17758. animate(preWarmOnly?: boolean): void;
  17759. private _appendParticleVertices;
  17760. /**
  17761. * Rebuilds the particle system.
  17762. */
  17763. rebuild(): void;
  17764. /**
  17765. * Is this system ready to be used/rendered
  17766. * @return true if the system is ready
  17767. */
  17768. isReady(): boolean;
  17769. private _render;
  17770. /**
  17771. * Renders the particle system in its current state.
  17772. * @returns the current number of particles
  17773. */
  17774. render(): number;
  17775. /**
  17776. * Disposes the particle system and free the associated resources
  17777. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17778. */
  17779. dispose(disposeTexture?: boolean): void;
  17780. /**
  17781. * Clones the particle system.
  17782. * @param name The name of the cloned object
  17783. * @param newEmitter The new emitter to use
  17784. * @returns the cloned particle system
  17785. */
  17786. clone(name: string, newEmitter: any): ParticleSystem;
  17787. /**
  17788. * Serializes the particle system to a JSON object.
  17789. * @returns the JSON object
  17790. */
  17791. serialize(): any;
  17792. /** @hidden */
  17793. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17794. /** @hidden */
  17795. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17796. /**
  17797. * Parses a JSON object to create a particle system.
  17798. * @param parsedParticleSystem The JSON object to parse
  17799. * @param scene The scene to create the particle system in
  17800. * @param rootUrl The root url to use to load external dependencies like texture
  17801. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17802. * @returns the Parsed particle system
  17803. */
  17804. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17805. }
  17806. }
  17807. declare module BABYLON {
  17808. /**
  17809. * A particle represents one of the element emitted by a particle system.
  17810. * This is mainly define by its coordinates, direction, velocity and age.
  17811. */
  17812. export class Particle {
  17813. /**
  17814. * The particle system the particle belongs to.
  17815. */
  17816. particleSystem: ParticleSystem;
  17817. private static _Count;
  17818. /**
  17819. * Unique ID of the particle
  17820. */
  17821. id: number;
  17822. /**
  17823. * The world position of the particle in the scene.
  17824. */
  17825. position: Vector3;
  17826. /**
  17827. * The world direction of the particle in the scene.
  17828. */
  17829. direction: Vector3;
  17830. /**
  17831. * The color of the particle.
  17832. */
  17833. color: Color4;
  17834. /**
  17835. * The color change of the particle per step.
  17836. */
  17837. colorStep: Color4;
  17838. /**
  17839. * Defines how long will the life of the particle be.
  17840. */
  17841. lifeTime: number;
  17842. /**
  17843. * The current age of the particle.
  17844. */
  17845. age: number;
  17846. /**
  17847. * The current size of the particle.
  17848. */
  17849. size: number;
  17850. /**
  17851. * The current scale of the particle.
  17852. */
  17853. scale: Vector2;
  17854. /**
  17855. * The current angle of the particle.
  17856. */
  17857. angle: number;
  17858. /**
  17859. * Defines how fast is the angle changing.
  17860. */
  17861. angularSpeed: number;
  17862. /**
  17863. * Defines the cell index used by the particle to be rendered from a sprite.
  17864. */
  17865. cellIndex: number;
  17866. /**
  17867. * The information required to support color remapping
  17868. */
  17869. remapData: Vector4;
  17870. /** @hidden */
  17871. _randomCellOffset?: number;
  17872. /** @hidden */
  17873. _initialDirection: Nullable<Vector3>;
  17874. /** @hidden */
  17875. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17876. /** @hidden */
  17877. _initialStartSpriteCellID: number;
  17878. /** @hidden */
  17879. _initialEndSpriteCellID: number;
  17880. /** @hidden */
  17881. _currentColorGradient: Nullable<ColorGradient>;
  17882. /** @hidden */
  17883. _currentColor1: Color4;
  17884. /** @hidden */
  17885. _currentColor2: Color4;
  17886. /** @hidden */
  17887. _currentSizeGradient: Nullable<FactorGradient>;
  17888. /** @hidden */
  17889. _currentSize1: number;
  17890. /** @hidden */
  17891. _currentSize2: number;
  17892. /** @hidden */
  17893. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17894. /** @hidden */
  17895. _currentAngularSpeed1: number;
  17896. /** @hidden */
  17897. _currentAngularSpeed2: number;
  17898. /** @hidden */
  17899. _currentVelocityGradient: Nullable<FactorGradient>;
  17900. /** @hidden */
  17901. _currentVelocity1: number;
  17902. /** @hidden */
  17903. _currentVelocity2: number;
  17904. /** @hidden */
  17905. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17906. /** @hidden */
  17907. _currentLimitVelocity1: number;
  17908. /** @hidden */
  17909. _currentLimitVelocity2: number;
  17910. /** @hidden */
  17911. _currentDragGradient: Nullable<FactorGradient>;
  17912. /** @hidden */
  17913. _currentDrag1: number;
  17914. /** @hidden */
  17915. _currentDrag2: number;
  17916. /** @hidden */
  17917. _randomNoiseCoordinates1: Vector3;
  17918. /** @hidden */
  17919. _randomNoiseCoordinates2: Vector3;
  17920. /**
  17921. * Creates a new instance Particle
  17922. * @param particleSystem the particle system the particle belongs to
  17923. */
  17924. constructor(
  17925. /**
  17926. * The particle system the particle belongs to.
  17927. */
  17928. particleSystem: ParticleSystem);
  17929. private updateCellInfoFromSystem;
  17930. /**
  17931. * Defines how the sprite cell index is updated for the particle
  17932. */
  17933. updateCellIndex(): void;
  17934. /** @hidden */
  17935. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17936. /** @hidden */
  17937. _inheritParticleInfoToSubEmitters(): void;
  17938. /** @hidden */
  17939. _reset(): void;
  17940. /**
  17941. * Copy the properties of particle to another one.
  17942. * @param other the particle to copy the information to.
  17943. */
  17944. copyTo(other: Particle): void;
  17945. }
  17946. }
  17947. declare module BABYLON {
  17948. /**
  17949. * Particle emitter represents a volume emitting particles.
  17950. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17951. */
  17952. export interface IParticleEmitterType {
  17953. /**
  17954. * Called by the particle System when the direction is computed for the created particle.
  17955. * @param worldMatrix is the world matrix of the particle system
  17956. * @param directionToUpdate is the direction vector to update with the result
  17957. * @param particle is the particle we are computed the direction for
  17958. */
  17959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17960. /**
  17961. * Called by the particle System when the position is computed for the created particle.
  17962. * @param worldMatrix is the world matrix of the particle system
  17963. * @param positionToUpdate is the position vector to update with the result
  17964. * @param particle is the particle we are computed the position for
  17965. */
  17966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17967. /**
  17968. * Clones the current emitter and returns a copy of it
  17969. * @returns the new emitter
  17970. */
  17971. clone(): IParticleEmitterType;
  17972. /**
  17973. * Called by the GPUParticleSystem to setup the update shader
  17974. * @param effect defines the update shader
  17975. */
  17976. applyToShader(effect: Effect): void;
  17977. /**
  17978. * Returns a string to use to update the GPU particles update shader
  17979. * @returns the effect defines string
  17980. */
  17981. getEffectDefines(): string;
  17982. /**
  17983. * Returns a string representing the class name
  17984. * @returns a string containing the class name
  17985. */
  17986. getClassName(): string;
  17987. /**
  17988. * Serializes the particle system to a JSON object.
  17989. * @returns the JSON object
  17990. */
  17991. serialize(): any;
  17992. /**
  17993. * Parse properties from a JSON object
  17994. * @param serializationObject defines the JSON object
  17995. * @param scene defines the hosting scene
  17996. */
  17997. parse(serializationObject: any, scene: Scene): void;
  17998. }
  17999. }
  18000. declare module BABYLON {
  18001. /**
  18002. * Particle emitter emitting particles from the inside of a box.
  18003. * It emits the particles randomly between 2 given directions.
  18004. */
  18005. export class BoxParticleEmitter implements IParticleEmitterType {
  18006. /**
  18007. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18008. */
  18009. direction1: Vector3;
  18010. /**
  18011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18012. */
  18013. direction2: Vector3;
  18014. /**
  18015. * 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.
  18016. */
  18017. minEmitBox: Vector3;
  18018. /**
  18019. * 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.
  18020. */
  18021. maxEmitBox: Vector3;
  18022. /**
  18023. * Creates a new instance BoxParticleEmitter
  18024. */
  18025. constructor();
  18026. /**
  18027. * Called by the particle System when the direction is computed for the created particle.
  18028. * @param worldMatrix is the world matrix of the particle system
  18029. * @param directionToUpdate is the direction vector to update with the result
  18030. * @param particle is the particle we are computed the direction for
  18031. */
  18032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18033. /**
  18034. * Called by the particle System when the position is computed for the created particle.
  18035. * @param worldMatrix is the world matrix of the particle system
  18036. * @param positionToUpdate is the position vector to update with the result
  18037. * @param particle is the particle we are computed the position for
  18038. */
  18039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18040. /**
  18041. * Clones the current emitter and returns a copy of it
  18042. * @returns the new emitter
  18043. */
  18044. clone(): BoxParticleEmitter;
  18045. /**
  18046. * Called by the GPUParticleSystem to setup the update shader
  18047. * @param effect defines the update shader
  18048. */
  18049. applyToShader(effect: Effect): void;
  18050. /**
  18051. * Returns a string to use to update the GPU particles update shader
  18052. * @returns a string containng the defines string
  18053. */
  18054. getEffectDefines(): string;
  18055. /**
  18056. * Returns the string "BoxParticleEmitter"
  18057. * @returns a string containing the class name
  18058. */
  18059. getClassName(): string;
  18060. /**
  18061. * Serializes the particle system to a JSON object.
  18062. * @returns the JSON object
  18063. */
  18064. serialize(): any;
  18065. /**
  18066. * Parse properties from a JSON object
  18067. * @param serializationObject defines the JSON object
  18068. */
  18069. parse(serializationObject: any): void;
  18070. }
  18071. }
  18072. declare module BABYLON {
  18073. /**
  18074. * Particle emitter emitting particles from the inside of a cone.
  18075. * It emits the particles alongside the cone volume from the base to the particle.
  18076. * The emission direction might be randomized.
  18077. */
  18078. export class ConeParticleEmitter implements IParticleEmitterType {
  18079. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18080. directionRandomizer: number;
  18081. private _radius;
  18082. private _angle;
  18083. private _height;
  18084. /**
  18085. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18086. */
  18087. radiusRange: number;
  18088. /**
  18089. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18090. */
  18091. heightRange: number;
  18092. /**
  18093. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18094. */
  18095. emitFromSpawnPointOnly: boolean;
  18096. /**
  18097. * Gets or sets the radius of the emission cone
  18098. */
  18099. get radius(): number;
  18100. set radius(value: number);
  18101. /**
  18102. * Gets or sets the angle of the emission cone
  18103. */
  18104. get angle(): number;
  18105. set angle(value: number);
  18106. private _buildHeight;
  18107. /**
  18108. * Creates a new instance ConeParticleEmitter
  18109. * @param radius the radius of the emission cone (1 by default)
  18110. * @param angle the cone base angle (PI by default)
  18111. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18112. */
  18113. constructor(radius?: number, angle?: number,
  18114. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18115. directionRandomizer?: number);
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Called by the particle System when the position is computed for the created particle.
  18125. * @param worldMatrix is the world matrix of the particle system
  18126. * @param positionToUpdate is the position vector to update with the result
  18127. * @param particle is the particle we are computed the position for
  18128. */
  18129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18130. /**
  18131. * Clones the current emitter and returns a copy of it
  18132. * @returns the new emitter
  18133. */
  18134. clone(): ConeParticleEmitter;
  18135. /**
  18136. * Called by the GPUParticleSystem to setup the update shader
  18137. * @param effect defines the update shader
  18138. */
  18139. applyToShader(effect: Effect): void;
  18140. /**
  18141. * Returns a string to use to update the GPU particles update shader
  18142. * @returns a string containng the defines string
  18143. */
  18144. getEffectDefines(): string;
  18145. /**
  18146. * Returns the string "ConeParticleEmitter"
  18147. * @returns a string containing the class name
  18148. */
  18149. getClassName(): string;
  18150. /**
  18151. * Serializes the particle system to a JSON object.
  18152. * @returns the JSON object
  18153. */
  18154. serialize(): any;
  18155. /**
  18156. * Parse properties from a JSON object
  18157. * @param serializationObject defines the JSON object
  18158. */
  18159. parse(serializationObject: any): void;
  18160. }
  18161. }
  18162. declare module BABYLON {
  18163. /**
  18164. * Particle emitter emitting particles from the inside of a cylinder.
  18165. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18166. */
  18167. export class CylinderParticleEmitter implements IParticleEmitterType {
  18168. /**
  18169. * The radius of the emission cylinder.
  18170. */
  18171. radius: number;
  18172. /**
  18173. * The height of the emission cylinder.
  18174. */
  18175. height: number;
  18176. /**
  18177. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18178. */
  18179. radiusRange: number;
  18180. /**
  18181. * How much to randomize the particle direction [0-1].
  18182. */
  18183. directionRandomizer: number;
  18184. /**
  18185. * Creates a new instance CylinderParticleEmitter
  18186. * @param radius the radius of the emission cylinder (1 by default)
  18187. * @param height the height of the emission cylinder (1 by default)
  18188. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18189. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18190. */
  18191. constructor(
  18192. /**
  18193. * The radius of the emission cylinder.
  18194. */
  18195. radius?: number,
  18196. /**
  18197. * The height of the emission cylinder.
  18198. */
  18199. height?: number,
  18200. /**
  18201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18202. */
  18203. radiusRange?: number,
  18204. /**
  18205. * How much to randomize the particle direction [0-1].
  18206. */
  18207. directionRandomizer?: number);
  18208. /**
  18209. * Called by the particle System when the direction is computed for the created particle.
  18210. * @param worldMatrix is the world matrix of the particle system
  18211. * @param directionToUpdate is the direction vector to update with the result
  18212. * @param particle is the particle we are computed the direction for
  18213. */
  18214. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18215. /**
  18216. * Called by the particle System when the position is computed for the created particle.
  18217. * @param worldMatrix is the world matrix of the particle system
  18218. * @param positionToUpdate is the position vector to update with the result
  18219. * @param particle is the particle we are computed the position for
  18220. */
  18221. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18222. /**
  18223. * Clones the current emitter and returns a copy of it
  18224. * @returns the new emitter
  18225. */
  18226. clone(): CylinderParticleEmitter;
  18227. /**
  18228. * Called by the GPUParticleSystem to setup the update shader
  18229. * @param effect defines the update shader
  18230. */
  18231. applyToShader(effect: Effect): void;
  18232. /**
  18233. * Returns a string to use to update the GPU particles update shader
  18234. * @returns a string containng the defines string
  18235. */
  18236. getEffectDefines(): string;
  18237. /**
  18238. * Returns the string "CylinderParticleEmitter"
  18239. * @returns a string containing the class name
  18240. */
  18241. getClassName(): string;
  18242. /**
  18243. * Serializes the particle system to a JSON object.
  18244. * @returns the JSON object
  18245. */
  18246. serialize(): any;
  18247. /**
  18248. * Parse properties from a JSON object
  18249. * @param serializationObject defines the JSON object
  18250. */
  18251. parse(serializationObject: any): void;
  18252. }
  18253. /**
  18254. * Particle emitter emitting particles from the inside of a cylinder.
  18255. * It emits the particles randomly between two vectors.
  18256. */
  18257. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18258. /**
  18259. * The min limit of the emission direction.
  18260. */
  18261. direction1: Vector3;
  18262. /**
  18263. * The max limit of the emission direction.
  18264. */
  18265. direction2: Vector3;
  18266. /**
  18267. * Creates a new instance CylinderDirectedParticleEmitter
  18268. * @param radius the radius of the emission cylinder (1 by default)
  18269. * @param height the height of the emission cylinder (1 by default)
  18270. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18271. * @param direction1 the min limit of the emission direction (up vector by default)
  18272. * @param direction2 the max limit of the emission direction (up vector by default)
  18273. */
  18274. constructor(radius?: number, height?: number, radiusRange?: number,
  18275. /**
  18276. * The min limit of the emission direction.
  18277. */
  18278. direction1?: Vector3,
  18279. /**
  18280. * The max limit of the emission direction.
  18281. */
  18282. direction2?: Vector3);
  18283. /**
  18284. * Called by the particle System when the direction is computed for the created particle.
  18285. * @param worldMatrix is the world matrix of the particle system
  18286. * @param directionToUpdate is the direction vector to update with the result
  18287. * @param particle is the particle we are computed the direction for
  18288. */
  18289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18290. /**
  18291. * Clones the current emitter and returns a copy of it
  18292. * @returns the new emitter
  18293. */
  18294. clone(): CylinderDirectedParticleEmitter;
  18295. /**
  18296. * Called by the GPUParticleSystem to setup the update shader
  18297. * @param effect defines the update shader
  18298. */
  18299. applyToShader(effect: Effect): void;
  18300. /**
  18301. * Returns a string to use to update the GPU particles update shader
  18302. * @returns a string containng the defines string
  18303. */
  18304. getEffectDefines(): string;
  18305. /**
  18306. * Returns the string "CylinderDirectedParticleEmitter"
  18307. * @returns a string containing the class name
  18308. */
  18309. getClassName(): string;
  18310. /**
  18311. * Serializes the particle system to a JSON object.
  18312. * @returns the JSON object
  18313. */
  18314. serialize(): any;
  18315. /**
  18316. * Parse properties from a JSON object
  18317. * @param serializationObject defines the JSON object
  18318. */
  18319. parse(serializationObject: any): void;
  18320. }
  18321. }
  18322. declare module BABYLON {
  18323. /**
  18324. * Particle emitter emitting particles from the inside of a hemisphere.
  18325. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18326. */
  18327. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18328. /**
  18329. * The radius of the emission hemisphere.
  18330. */
  18331. radius: number;
  18332. /**
  18333. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18334. */
  18335. radiusRange: number;
  18336. /**
  18337. * How much to randomize the particle direction [0-1].
  18338. */
  18339. directionRandomizer: number;
  18340. /**
  18341. * Creates a new instance HemisphericParticleEmitter
  18342. * @param radius the radius of the emission hemisphere (1 by default)
  18343. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18344. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18345. */
  18346. constructor(
  18347. /**
  18348. * The radius of the emission hemisphere.
  18349. */
  18350. radius?: number,
  18351. /**
  18352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18353. */
  18354. radiusRange?: number,
  18355. /**
  18356. * How much to randomize the particle direction [0-1].
  18357. */
  18358. directionRandomizer?: number);
  18359. /**
  18360. * Called by the particle System when the direction is computed for the created particle.
  18361. * @param worldMatrix is the world matrix of the particle system
  18362. * @param directionToUpdate is the direction vector to update with the result
  18363. * @param particle is the particle we are computed the direction for
  18364. */
  18365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18366. /**
  18367. * Called by the particle System when the position is computed for the created particle.
  18368. * @param worldMatrix is the world matrix of the particle system
  18369. * @param positionToUpdate is the position vector to update with the result
  18370. * @param particle is the particle we are computed the position for
  18371. */
  18372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18373. /**
  18374. * Clones the current emitter and returns a copy of it
  18375. * @returns the new emitter
  18376. */
  18377. clone(): HemisphericParticleEmitter;
  18378. /**
  18379. * Called by the GPUParticleSystem to setup the update shader
  18380. * @param effect defines the update shader
  18381. */
  18382. applyToShader(effect: Effect): void;
  18383. /**
  18384. * Returns a string to use to update the GPU particles update shader
  18385. * @returns a string containng the defines string
  18386. */
  18387. getEffectDefines(): string;
  18388. /**
  18389. * Returns the string "HemisphericParticleEmitter"
  18390. * @returns a string containing the class name
  18391. */
  18392. getClassName(): string;
  18393. /**
  18394. * Serializes the particle system to a JSON object.
  18395. * @returns the JSON object
  18396. */
  18397. serialize(): any;
  18398. /**
  18399. * Parse properties from a JSON object
  18400. * @param serializationObject defines the JSON object
  18401. */
  18402. parse(serializationObject: any): void;
  18403. }
  18404. }
  18405. declare module BABYLON {
  18406. /**
  18407. * Particle emitter emitting particles from a point.
  18408. * It emits the particles randomly between 2 given directions.
  18409. */
  18410. export class PointParticleEmitter implements IParticleEmitterType {
  18411. /**
  18412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18413. */
  18414. direction1: Vector3;
  18415. /**
  18416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18417. */
  18418. direction2: Vector3;
  18419. /**
  18420. * Creates a new instance PointParticleEmitter
  18421. */
  18422. constructor();
  18423. /**
  18424. * Called by the particle System when the direction is computed for the created particle.
  18425. * @param worldMatrix is the world matrix of the particle system
  18426. * @param directionToUpdate is the direction vector to update with the result
  18427. * @param particle is the particle we are computed the direction for
  18428. */
  18429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18430. /**
  18431. * Called by the particle System when the position is computed for the created particle.
  18432. * @param worldMatrix is the world matrix of the particle system
  18433. * @param positionToUpdate is the position vector to update with the result
  18434. * @param particle is the particle we are computed the position for
  18435. */
  18436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18437. /**
  18438. * Clones the current emitter and returns a copy of it
  18439. * @returns the new emitter
  18440. */
  18441. clone(): PointParticleEmitter;
  18442. /**
  18443. * Called by the GPUParticleSystem to setup the update shader
  18444. * @param effect defines the update shader
  18445. */
  18446. applyToShader(effect: Effect): void;
  18447. /**
  18448. * Returns a string to use to update the GPU particles update shader
  18449. * @returns a string containng the defines string
  18450. */
  18451. getEffectDefines(): string;
  18452. /**
  18453. * Returns the string "PointParticleEmitter"
  18454. * @returns a string containing the class name
  18455. */
  18456. getClassName(): string;
  18457. /**
  18458. * Serializes the particle system to a JSON object.
  18459. * @returns the JSON object
  18460. */
  18461. serialize(): any;
  18462. /**
  18463. * Parse properties from a JSON object
  18464. * @param serializationObject defines the JSON object
  18465. */
  18466. parse(serializationObject: any): void;
  18467. }
  18468. }
  18469. declare module BABYLON {
  18470. /**
  18471. * Particle emitter emitting particles from the inside of a sphere.
  18472. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18473. */
  18474. export class SphereParticleEmitter implements IParticleEmitterType {
  18475. /**
  18476. * The radius of the emission sphere.
  18477. */
  18478. radius: number;
  18479. /**
  18480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18481. */
  18482. radiusRange: number;
  18483. /**
  18484. * How much to randomize the particle direction [0-1].
  18485. */
  18486. directionRandomizer: number;
  18487. /**
  18488. * Creates a new instance SphereParticleEmitter
  18489. * @param radius the radius of the emission sphere (1 by default)
  18490. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18491. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18492. */
  18493. constructor(
  18494. /**
  18495. * The radius of the emission sphere.
  18496. */
  18497. radius?: number,
  18498. /**
  18499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18500. */
  18501. radiusRange?: number,
  18502. /**
  18503. * How much to randomize the particle direction [0-1].
  18504. */
  18505. directionRandomizer?: number);
  18506. /**
  18507. * Called by the particle System when the direction is computed for the created particle.
  18508. * @param worldMatrix is the world matrix of the particle system
  18509. * @param directionToUpdate is the direction vector to update with the result
  18510. * @param particle is the particle we are computed the direction for
  18511. */
  18512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18513. /**
  18514. * Called by the particle System when the position is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param positionToUpdate is the position vector to update with the result
  18517. * @param particle is the particle we are computed the position for
  18518. */
  18519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Clones the current emitter and returns a copy of it
  18522. * @returns the new emitter
  18523. */
  18524. clone(): SphereParticleEmitter;
  18525. /**
  18526. * Called by the GPUParticleSystem to setup the update shader
  18527. * @param effect defines the update shader
  18528. */
  18529. applyToShader(effect: Effect): void;
  18530. /**
  18531. * Returns a string to use to update the GPU particles update shader
  18532. * @returns a string containng the defines string
  18533. */
  18534. getEffectDefines(): string;
  18535. /**
  18536. * Returns the string "SphereParticleEmitter"
  18537. * @returns a string containing the class name
  18538. */
  18539. getClassName(): string;
  18540. /**
  18541. * Serializes the particle system to a JSON object.
  18542. * @returns the JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parse properties from a JSON object
  18547. * @param serializationObject defines the JSON object
  18548. */
  18549. parse(serializationObject: any): void;
  18550. }
  18551. /**
  18552. * Particle emitter emitting particles from the inside of a sphere.
  18553. * It emits the particles randomly between two vectors.
  18554. */
  18555. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18556. /**
  18557. * The min limit of the emission direction.
  18558. */
  18559. direction1: Vector3;
  18560. /**
  18561. * The max limit of the emission direction.
  18562. */
  18563. direction2: Vector3;
  18564. /**
  18565. * Creates a new instance SphereDirectedParticleEmitter
  18566. * @param radius the radius of the emission sphere (1 by default)
  18567. * @param direction1 the min limit of the emission direction (up vector by default)
  18568. * @param direction2 the max limit of the emission direction (up vector by default)
  18569. */
  18570. constructor(radius?: number,
  18571. /**
  18572. * The min limit of the emission direction.
  18573. */
  18574. direction1?: Vector3,
  18575. /**
  18576. * The max limit of the emission direction.
  18577. */
  18578. direction2?: Vector3);
  18579. /**
  18580. * Called by the particle System when the direction is computed for the created particle.
  18581. * @param worldMatrix is the world matrix of the particle system
  18582. * @param directionToUpdate is the direction vector to update with the result
  18583. * @param particle is the particle we are computed the direction for
  18584. */
  18585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18586. /**
  18587. * Clones the current emitter and returns a copy of it
  18588. * @returns the new emitter
  18589. */
  18590. clone(): SphereDirectedParticleEmitter;
  18591. /**
  18592. * Called by the GPUParticleSystem to setup the update shader
  18593. * @param effect defines the update shader
  18594. */
  18595. applyToShader(effect: Effect): void;
  18596. /**
  18597. * Returns a string to use to update the GPU particles update shader
  18598. * @returns a string containng the defines string
  18599. */
  18600. getEffectDefines(): string;
  18601. /**
  18602. * Returns the string "SphereDirectedParticleEmitter"
  18603. * @returns a string containing the class name
  18604. */
  18605. getClassName(): string;
  18606. /**
  18607. * Serializes the particle system to a JSON object.
  18608. * @returns the JSON object
  18609. */
  18610. serialize(): any;
  18611. /**
  18612. * Parse properties from a JSON object
  18613. * @param serializationObject defines the JSON object
  18614. */
  18615. parse(serializationObject: any): void;
  18616. }
  18617. }
  18618. declare module BABYLON {
  18619. /**
  18620. * Particle emitter emitting particles from a custom list of positions.
  18621. */
  18622. export class CustomParticleEmitter implements IParticleEmitterType {
  18623. /**
  18624. * Gets or sets the position generator that will create the inital position of each particle.
  18625. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18626. */
  18627. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  18628. /**
  18629. * Gets or sets the destination generator that will create the final destination of each particle.
  18630. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18631. */
  18632. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  18633. /**
  18634. * Creates a new instance CustomParticleEmitter
  18635. */
  18636. constructor();
  18637. /**
  18638. * Called by the particle System when the direction is computed for the created particle.
  18639. * @param worldMatrix is the world matrix of the particle system
  18640. * @param directionToUpdate is the direction vector to update with the result
  18641. * @param particle is the particle we are computed the direction for
  18642. */
  18643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18644. /**
  18645. * Called by the particle System when the position is computed for the created particle.
  18646. * @param worldMatrix is the world matrix of the particle system
  18647. * @param positionToUpdate is the position vector to update with the result
  18648. * @param particle is the particle we are computed the position for
  18649. */
  18650. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18651. /**
  18652. * Clones the current emitter and returns a copy of it
  18653. * @returns the new emitter
  18654. */
  18655. clone(): CustomParticleEmitter;
  18656. /**
  18657. * Called by the GPUParticleSystem to setup the update shader
  18658. * @param effect defines the update shader
  18659. */
  18660. applyToShader(effect: Effect): void;
  18661. /**
  18662. * Returns a string to use to update the GPU particles update shader
  18663. * @returns a string containng the defines string
  18664. */
  18665. getEffectDefines(): string;
  18666. /**
  18667. * Returns the string "PointParticleEmitter"
  18668. * @returns a string containing the class name
  18669. */
  18670. getClassName(): string;
  18671. /**
  18672. * Serializes the particle system to a JSON object.
  18673. * @returns the JSON object
  18674. */
  18675. serialize(): any;
  18676. /**
  18677. * Parse properties from a JSON object
  18678. * @param serializationObject defines the JSON object
  18679. */
  18680. parse(serializationObject: any): void;
  18681. }
  18682. }
  18683. declare module BABYLON {
  18684. /**
  18685. * Particle emitter emitting particles from the inside of a box.
  18686. * It emits the particles randomly between 2 given directions.
  18687. */
  18688. export class MeshParticleEmitter implements IParticleEmitterType {
  18689. /** Defines the mesh to use as source */
  18690. mesh?: AbstractMesh | undefined;
  18691. private _indices;
  18692. private _positions;
  18693. private _normals;
  18694. private _storedNormal;
  18695. /**
  18696. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18697. */
  18698. direction1: Vector3;
  18699. /**
  18700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18701. */
  18702. direction2: Vector3;
  18703. /**
  18704. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  18705. */
  18706. useMeshNormalsForDirection: boolean;
  18707. /**
  18708. * Creates a new instance MeshParticleEmitter
  18709. * @param mesh defines the mesh to use as source
  18710. */
  18711. constructor(
  18712. /** Defines the mesh to use as source */
  18713. mesh?: AbstractMesh | undefined);
  18714. /**
  18715. * Called by the particle System when the direction is computed for the created particle.
  18716. * @param worldMatrix is the world matrix of the particle system
  18717. * @param directionToUpdate is the direction vector to update with the result
  18718. * @param particle is the particle we are computed the direction for
  18719. */
  18720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18721. /**
  18722. * Called by the particle System when the position is computed for the created particle.
  18723. * @param worldMatrix is the world matrix of the particle system
  18724. * @param positionToUpdate is the position vector to update with the result
  18725. * @param particle is the particle we are computed the position for
  18726. */
  18727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18728. /**
  18729. * Clones the current emitter and returns a copy of it
  18730. * @returns the new emitter
  18731. */
  18732. clone(): MeshParticleEmitter;
  18733. /**
  18734. * Called by the GPUParticleSystem to setup the update shader
  18735. * @param effect defines the update shader
  18736. */
  18737. applyToShader(effect: Effect): void;
  18738. /**
  18739. * Returns a string to use to update the GPU particles update shader
  18740. * @returns a string containng the defines string
  18741. */
  18742. getEffectDefines(): string;
  18743. /**
  18744. * Returns the string "BoxParticleEmitter"
  18745. * @returns a string containing the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Serializes the particle system to a JSON object.
  18750. * @returns the JSON object
  18751. */
  18752. serialize(): any;
  18753. /**
  18754. * Parse properties from a JSON object
  18755. * @param serializationObject defines the JSON object
  18756. */
  18757. parse(serializationObject: any, scene: Scene): void;
  18758. }
  18759. }
  18760. declare module BABYLON {
  18761. /**
  18762. * Interface representing a particle system in Babylon.js.
  18763. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18764. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18765. */
  18766. export interface IParticleSystem {
  18767. /**
  18768. * List of animations used by the particle system.
  18769. */
  18770. animations: Animation[];
  18771. /**
  18772. * The id of the Particle system.
  18773. */
  18774. id: string;
  18775. /**
  18776. * The name of the Particle system.
  18777. */
  18778. name: string;
  18779. /**
  18780. * The emitter represents the Mesh or position we are attaching the particle system to.
  18781. */
  18782. emitter: Nullable<AbstractMesh | Vector3>;
  18783. /**
  18784. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18785. */
  18786. isBillboardBased: boolean;
  18787. /**
  18788. * The rendering group used by the Particle system to chose when to render.
  18789. */
  18790. renderingGroupId: number;
  18791. /**
  18792. * The layer mask we are rendering the particles through.
  18793. */
  18794. layerMask: number;
  18795. /**
  18796. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18797. */
  18798. updateSpeed: number;
  18799. /**
  18800. * The amount of time the particle system is running (depends of the overall update speed).
  18801. */
  18802. targetStopDuration: number;
  18803. /**
  18804. * The texture used to render each particle. (this can be a spritesheet)
  18805. */
  18806. particleTexture: Nullable<Texture>;
  18807. /**
  18808. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18809. */
  18810. blendMode: number;
  18811. /**
  18812. * Minimum life time of emitting particles.
  18813. */
  18814. minLifeTime: number;
  18815. /**
  18816. * Maximum life time of emitting particles.
  18817. */
  18818. maxLifeTime: number;
  18819. /**
  18820. * Minimum Size of emitting particles.
  18821. */
  18822. minSize: number;
  18823. /**
  18824. * Maximum Size of emitting particles.
  18825. */
  18826. maxSize: number;
  18827. /**
  18828. * Minimum scale of emitting particles on X axis.
  18829. */
  18830. minScaleX: number;
  18831. /**
  18832. * Maximum scale of emitting particles on X axis.
  18833. */
  18834. maxScaleX: number;
  18835. /**
  18836. * Minimum scale of emitting particles on Y axis.
  18837. */
  18838. minScaleY: number;
  18839. /**
  18840. * Maximum scale of emitting particles on Y axis.
  18841. */
  18842. maxScaleY: number;
  18843. /**
  18844. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18845. */
  18846. color1: Color4;
  18847. /**
  18848. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18849. */
  18850. color2: Color4;
  18851. /**
  18852. * Color the particle will have at the end of its lifetime.
  18853. */
  18854. colorDead: Color4;
  18855. /**
  18856. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18857. */
  18858. emitRate: number;
  18859. /**
  18860. * You can use gravity if you want to give an orientation to your particles.
  18861. */
  18862. gravity: Vector3;
  18863. /**
  18864. * Minimum power of emitting particles.
  18865. */
  18866. minEmitPower: number;
  18867. /**
  18868. * Maximum power of emitting particles.
  18869. */
  18870. maxEmitPower: number;
  18871. /**
  18872. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18873. */
  18874. minAngularSpeed: number;
  18875. /**
  18876. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18877. */
  18878. maxAngularSpeed: number;
  18879. /**
  18880. * Gets or sets the minimal initial rotation in radians.
  18881. */
  18882. minInitialRotation: number;
  18883. /**
  18884. * Gets or sets the maximal initial rotation in radians.
  18885. */
  18886. maxInitialRotation: number;
  18887. /**
  18888. * The particle emitter type defines the emitter used by the particle system.
  18889. * It can be for example box, sphere, or cone...
  18890. */
  18891. particleEmitterType: Nullable<IParticleEmitterType>;
  18892. /**
  18893. * Defines the delay in milliseconds before starting the system (0 by default)
  18894. */
  18895. startDelay: number;
  18896. /**
  18897. * 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
  18898. */
  18899. preWarmCycles: number;
  18900. /**
  18901. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18902. */
  18903. preWarmStepOffset: number;
  18904. /**
  18905. * 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)
  18906. */
  18907. spriteCellChangeSpeed: number;
  18908. /**
  18909. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18910. */
  18911. startSpriteCellID: number;
  18912. /**
  18913. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18914. */
  18915. endSpriteCellID: number;
  18916. /**
  18917. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18918. */
  18919. spriteCellWidth: number;
  18920. /**
  18921. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18922. */
  18923. spriteCellHeight: number;
  18924. /**
  18925. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18926. */
  18927. spriteRandomStartCell: boolean;
  18928. /**
  18929. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18930. */
  18931. isAnimationSheetEnabled: boolean;
  18932. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18933. translationPivot: Vector2;
  18934. /**
  18935. * Gets or sets a texture used to add random noise to particle positions
  18936. */
  18937. noiseTexture: Nullable<BaseTexture>;
  18938. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18939. noiseStrength: Vector3;
  18940. /**
  18941. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18942. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18943. */
  18944. billboardMode: number;
  18945. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18946. limitVelocityDamping: number;
  18947. /**
  18948. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18949. */
  18950. beginAnimationOnStart: boolean;
  18951. /**
  18952. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18953. */
  18954. beginAnimationFrom: number;
  18955. /**
  18956. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18957. */
  18958. beginAnimationTo: number;
  18959. /**
  18960. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18961. */
  18962. beginAnimationLoop: boolean;
  18963. /**
  18964. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18965. */
  18966. disposeOnStop: boolean;
  18967. /**
  18968. * Gets the maximum number of particles active at the same time.
  18969. * @returns The max number of active particles.
  18970. */
  18971. getCapacity(): number;
  18972. /**
  18973. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18974. * @returns True if it has been started, otherwise false.
  18975. */
  18976. isStarted(): boolean;
  18977. /**
  18978. * Animates the particle system for this frame.
  18979. */
  18980. animate(): void;
  18981. /**
  18982. * Renders the particle system in its current state.
  18983. * @returns the current number of particles
  18984. */
  18985. render(): number;
  18986. /**
  18987. * Dispose the particle system and frees its associated resources.
  18988. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18989. */
  18990. dispose(disposeTexture?: boolean): void;
  18991. /**
  18992. * Clones the particle system.
  18993. * @param name The name of the cloned object
  18994. * @param newEmitter The new emitter to use
  18995. * @returns the cloned particle system
  18996. */
  18997. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18998. /**
  18999. * Serializes the particle system to a JSON object.
  19000. * @returns the JSON object
  19001. */
  19002. serialize(): any;
  19003. /**
  19004. * Rebuild the particle system
  19005. */
  19006. rebuild(): void;
  19007. /**
  19008. * Starts the particle system and begins to emit
  19009. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19010. */
  19011. start(delay?: number): void;
  19012. /**
  19013. * Stops the particle system.
  19014. */
  19015. stop(): void;
  19016. /**
  19017. * Remove all active particles
  19018. */
  19019. reset(): void;
  19020. /**
  19021. * Is this system ready to be used/rendered
  19022. * @return true if the system is ready
  19023. */
  19024. isReady(): boolean;
  19025. /**
  19026. * Adds a new color gradient
  19027. * @param gradient defines the gradient to use (between 0 and 1)
  19028. * @param color1 defines the color to affect to the specified gradient
  19029. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19030. * @returns the current particle system
  19031. */
  19032. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19033. /**
  19034. * Remove a specific color gradient
  19035. * @param gradient defines the gradient to remove
  19036. * @returns the current particle system
  19037. */
  19038. removeColorGradient(gradient: number): IParticleSystem;
  19039. /**
  19040. * Adds a new size gradient
  19041. * @param gradient defines the gradient to use (between 0 and 1)
  19042. * @param factor defines the size factor to affect to the specified gradient
  19043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19044. * @returns the current particle system
  19045. */
  19046. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19047. /**
  19048. * Remove a specific size gradient
  19049. * @param gradient defines the gradient to remove
  19050. * @returns the current particle system
  19051. */
  19052. removeSizeGradient(gradient: number): IParticleSystem;
  19053. /**
  19054. * Gets the current list of color gradients.
  19055. * You must use addColorGradient and removeColorGradient to udpate this list
  19056. * @returns the list of color gradients
  19057. */
  19058. getColorGradients(): Nullable<Array<ColorGradient>>;
  19059. /**
  19060. * Gets the current list of size gradients.
  19061. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19062. * @returns the list of size gradients
  19063. */
  19064. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19065. /**
  19066. * Gets the current list of angular speed gradients.
  19067. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19068. * @returns the list of angular speed gradients
  19069. */
  19070. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19071. /**
  19072. * Adds a new angular speed gradient
  19073. * @param gradient defines the gradient to use (between 0 and 1)
  19074. * @param factor defines the angular speed to affect to the specified gradient
  19075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19076. * @returns the current particle system
  19077. */
  19078. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19079. /**
  19080. * Remove a specific angular speed gradient
  19081. * @param gradient defines the gradient to remove
  19082. * @returns the current particle system
  19083. */
  19084. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19085. /**
  19086. * Gets the current list of velocity gradients.
  19087. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19088. * @returns the list of velocity gradients
  19089. */
  19090. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19091. /**
  19092. * Adds a new velocity gradient
  19093. * @param gradient defines the gradient to use (between 0 and 1)
  19094. * @param factor defines the velocity to affect to the specified gradient
  19095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19096. * @returns the current particle system
  19097. */
  19098. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19099. /**
  19100. * Remove a specific velocity gradient
  19101. * @param gradient defines the gradient to remove
  19102. * @returns the current particle system
  19103. */
  19104. removeVelocityGradient(gradient: number): IParticleSystem;
  19105. /**
  19106. * Gets the current list of limit velocity gradients.
  19107. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19108. * @returns the list of limit velocity gradients
  19109. */
  19110. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19111. /**
  19112. * Adds a new limit velocity gradient
  19113. * @param gradient defines the gradient to use (between 0 and 1)
  19114. * @param factor defines the limit velocity to affect to the specified gradient
  19115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19116. * @returns the current particle system
  19117. */
  19118. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19119. /**
  19120. * Remove a specific limit velocity gradient
  19121. * @param gradient defines the gradient to remove
  19122. * @returns the current particle system
  19123. */
  19124. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19125. /**
  19126. * Adds a new drag gradient
  19127. * @param gradient defines the gradient to use (between 0 and 1)
  19128. * @param factor defines the drag to affect to the specified gradient
  19129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19130. * @returns the current particle system
  19131. */
  19132. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19133. /**
  19134. * Remove a specific drag gradient
  19135. * @param gradient defines the gradient to remove
  19136. * @returns the current particle system
  19137. */
  19138. removeDragGradient(gradient: number): IParticleSystem;
  19139. /**
  19140. * Gets the current list of drag gradients.
  19141. * You must use addDragGradient and removeDragGradient to udpate this list
  19142. * @returns the list of drag gradients
  19143. */
  19144. getDragGradients(): Nullable<Array<FactorGradient>>;
  19145. /**
  19146. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19147. * @param gradient defines the gradient to use (between 0 and 1)
  19148. * @param factor defines the emit rate to affect to the specified gradient
  19149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19150. * @returns the current particle system
  19151. */
  19152. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19153. /**
  19154. * Remove a specific emit rate gradient
  19155. * @param gradient defines the gradient to remove
  19156. * @returns the current particle system
  19157. */
  19158. removeEmitRateGradient(gradient: number): IParticleSystem;
  19159. /**
  19160. * Gets the current list of emit rate gradients.
  19161. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19162. * @returns the list of emit rate gradients
  19163. */
  19164. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19165. /**
  19166. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19167. * @param gradient defines the gradient to use (between 0 and 1)
  19168. * @param factor defines the start size to affect to the specified gradient
  19169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19170. * @returns the current particle system
  19171. */
  19172. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19173. /**
  19174. * Remove a specific start size gradient
  19175. * @param gradient defines the gradient to remove
  19176. * @returns the current particle system
  19177. */
  19178. removeStartSizeGradient(gradient: number): IParticleSystem;
  19179. /**
  19180. * Gets the current list of start size gradients.
  19181. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19182. * @returns the list of start size gradients
  19183. */
  19184. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19185. /**
  19186. * Adds a new life time gradient
  19187. * @param gradient defines the gradient to use (between 0 and 1)
  19188. * @param factor defines the life time factor to affect to the specified gradient
  19189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19190. * @returns the current particle system
  19191. */
  19192. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19193. /**
  19194. * Remove a specific life time gradient
  19195. * @param gradient defines the gradient to remove
  19196. * @returns the current particle system
  19197. */
  19198. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19199. /**
  19200. * Gets the current list of life time gradients.
  19201. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19202. * @returns the list of life time gradients
  19203. */
  19204. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19205. /**
  19206. * Gets the current list of color gradients.
  19207. * You must use addColorGradient and removeColorGradient to udpate this list
  19208. * @returns the list of color gradients
  19209. */
  19210. getColorGradients(): Nullable<Array<ColorGradient>>;
  19211. /**
  19212. * Adds a new ramp gradient used to remap particle colors
  19213. * @param gradient defines the gradient to use (between 0 and 1)
  19214. * @param color defines the color to affect to the specified gradient
  19215. * @returns the current particle system
  19216. */
  19217. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19218. /**
  19219. * Gets the current list of ramp gradients.
  19220. * You must use addRampGradient and removeRampGradient to udpate this list
  19221. * @returns the list of ramp gradients
  19222. */
  19223. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19224. /** Gets or sets a boolean indicating that ramp gradients must be used
  19225. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19226. */
  19227. useRampGradients: boolean;
  19228. /**
  19229. * Adds a new color remap gradient
  19230. * @param gradient defines the gradient to use (between 0 and 1)
  19231. * @param min defines the color remap minimal range
  19232. * @param max defines the color remap maximal range
  19233. * @returns the current particle system
  19234. */
  19235. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19236. /**
  19237. * Gets the current list of color remap gradients.
  19238. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19239. * @returns the list of color remap gradients
  19240. */
  19241. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19242. /**
  19243. * Adds a new alpha remap gradient
  19244. * @param gradient defines the gradient to use (between 0 and 1)
  19245. * @param min defines the alpha remap minimal range
  19246. * @param max defines the alpha remap maximal range
  19247. * @returns the current particle system
  19248. */
  19249. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19250. /**
  19251. * Gets the current list of alpha remap gradients.
  19252. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19253. * @returns the list of alpha remap gradients
  19254. */
  19255. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19256. /**
  19257. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19258. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19259. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19260. * @returns the emitter
  19261. */
  19262. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19263. /**
  19264. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19265. * @param radius The radius of the hemisphere to emit from
  19266. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19267. * @returns the emitter
  19268. */
  19269. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19270. /**
  19271. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19272. * @param radius The radius of the sphere to emit from
  19273. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19274. * @returns the emitter
  19275. */
  19276. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19277. /**
  19278. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19279. * @param radius The radius of the sphere to emit from
  19280. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19281. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19282. * @returns the emitter
  19283. */
  19284. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19285. /**
  19286. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19287. * @param radius The radius of the emission cylinder
  19288. * @param height The height of the emission cylinder
  19289. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19290. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19291. * @returns the emitter
  19292. */
  19293. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19294. /**
  19295. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19296. * @param radius The radius of the cylinder to emit from
  19297. * @param height The height of the emission cylinder
  19298. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19299. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19300. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19301. * @returns the emitter
  19302. */
  19303. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19304. /**
  19305. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19306. * @param radius The radius of the cone to emit from
  19307. * @param angle The base angle of the cone
  19308. * @returns the emitter
  19309. */
  19310. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19311. /**
  19312. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19313. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19314. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19315. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19316. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19317. * @returns the emitter
  19318. */
  19319. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19320. /**
  19321. * Get hosting scene
  19322. * @returns the scene
  19323. */
  19324. getScene(): Scene;
  19325. }
  19326. }
  19327. declare module BABYLON {
  19328. /**
  19329. * Creates an instance based on a source mesh.
  19330. */
  19331. export class InstancedMesh extends AbstractMesh {
  19332. private _sourceMesh;
  19333. private _currentLOD;
  19334. /** @hidden */
  19335. _indexInSourceMeshInstanceArray: number;
  19336. constructor(name: string, source: Mesh);
  19337. /**
  19338. * Returns the string "InstancedMesh".
  19339. */
  19340. getClassName(): string;
  19341. /** Gets the list of lights affecting that mesh */
  19342. get lightSources(): Light[];
  19343. _resyncLightSources(): void;
  19344. _resyncLightSource(light: Light): void;
  19345. _removeLightSource(light: Light, dispose: boolean): void;
  19346. /**
  19347. * If the source mesh receives shadows
  19348. */
  19349. get receiveShadows(): boolean;
  19350. /**
  19351. * The material of the source mesh
  19352. */
  19353. get material(): Nullable<Material>;
  19354. /**
  19355. * Visibility of the source mesh
  19356. */
  19357. get visibility(): number;
  19358. /**
  19359. * Skeleton of the source mesh
  19360. */
  19361. get skeleton(): Nullable<Skeleton>;
  19362. /**
  19363. * Rendering ground id of the source mesh
  19364. */
  19365. get renderingGroupId(): number;
  19366. set renderingGroupId(value: number);
  19367. /**
  19368. * Returns the total number of vertices (integer).
  19369. */
  19370. getTotalVertices(): number;
  19371. /**
  19372. * Returns a positive integer : the total number of indices in this mesh geometry.
  19373. * @returns the numner of indices or zero if the mesh has no geometry.
  19374. */
  19375. getTotalIndices(): number;
  19376. /**
  19377. * The source mesh of the instance
  19378. */
  19379. get sourceMesh(): Mesh;
  19380. /**
  19381. * Is this node ready to be used/rendered
  19382. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19383. * @return {boolean} is it ready
  19384. */
  19385. isReady(completeCheck?: boolean): boolean;
  19386. /**
  19387. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19388. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19389. * @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.
  19390. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19391. */
  19392. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19393. /**
  19394. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19395. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19396. * The `data` are either a numeric array either a Float32Array.
  19397. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19398. * 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).
  19399. * Note that a new underlying VertexBuffer object is created each call.
  19400. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19401. *
  19402. * Possible `kind` values :
  19403. * - VertexBuffer.PositionKind
  19404. * - VertexBuffer.UVKind
  19405. * - VertexBuffer.UV2Kind
  19406. * - VertexBuffer.UV3Kind
  19407. * - VertexBuffer.UV4Kind
  19408. * - VertexBuffer.UV5Kind
  19409. * - VertexBuffer.UV6Kind
  19410. * - VertexBuffer.ColorKind
  19411. * - VertexBuffer.MatricesIndicesKind
  19412. * - VertexBuffer.MatricesIndicesExtraKind
  19413. * - VertexBuffer.MatricesWeightsKind
  19414. * - VertexBuffer.MatricesWeightsExtraKind
  19415. *
  19416. * Returns the Mesh.
  19417. */
  19418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19419. /**
  19420. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19421. * If the mesh has no geometry, it is simply returned as it is.
  19422. * The `data` are either a numeric array either a Float32Array.
  19423. * No new underlying VertexBuffer object is created.
  19424. * 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.
  19425. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19426. *
  19427. * Possible `kind` values :
  19428. * - VertexBuffer.PositionKind
  19429. * - VertexBuffer.UVKind
  19430. * - VertexBuffer.UV2Kind
  19431. * - VertexBuffer.UV3Kind
  19432. * - VertexBuffer.UV4Kind
  19433. * - VertexBuffer.UV5Kind
  19434. * - VertexBuffer.UV6Kind
  19435. * - VertexBuffer.ColorKind
  19436. * - VertexBuffer.MatricesIndicesKind
  19437. * - VertexBuffer.MatricesIndicesExtraKind
  19438. * - VertexBuffer.MatricesWeightsKind
  19439. * - VertexBuffer.MatricesWeightsExtraKind
  19440. *
  19441. * Returns the Mesh.
  19442. */
  19443. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19444. /**
  19445. * Sets the mesh indices.
  19446. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19447. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19448. * This method creates a new index buffer each call.
  19449. * Returns the Mesh.
  19450. */
  19451. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19452. /**
  19453. * Boolean : True if the mesh owns the requested kind of data.
  19454. */
  19455. isVerticesDataPresent(kind: string): boolean;
  19456. /**
  19457. * Returns an array of indices (IndicesArray).
  19458. */
  19459. getIndices(): Nullable<IndicesArray>;
  19460. get _positions(): Nullable<Vector3[]>;
  19461. /**
  19462. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19463. * This means the mesh underlying bounding box and sphere are recomputed.
  19464. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19465. * @returns the current mesh
  19466. */
  19467. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19468. /** @hidden */
  19469. _preActivate(): InstancedMesh;
  19470. /** @hidden */
  19471. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19472. /** @hidden */
  19473. _postActivate(): void;
  19474. getWorldMatrix(): Matrix;
  19475. get isAnInstance(): boolean;
  19476. /**
  19477. * Returns the current associated LOD AbstractMesh.
  19478. */
  19479. getLOD(camera: Camera): AbstractMesh;
  19480. /** @hidden */
  19481. _syncSubMeshes(): InstancedMesh;
  19482. /** @hidden */
  19483. _generatePointsArray(): boolean;
  19484. /**
  19485. * Creates a new InstancedMesh from the current mesh.
  19486. * - name (string) : the cloned mesh name
  19487. * - newParent (optional Node) : the optional Node to parent the clone to.
  19488. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19489. *
  19490. * Returns the clone.
  19491. */
  19492. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19493. /**
  19494. * Disposes the InstancedMesh.
  19495. * Returns nothing.
  19496. */
  19497. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19498. }
  19499. interface Mesh {
  19500. /**
  19501. * Register a custom buffer that will be instanced
  19502. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19503. * @param kind defines the buffer kind
  19504. * @param stride defines the stride in floats
  19505. */
  19506. registerInstancedBuffer(kind: string, stride: number): void;
  19507. /** @hidden */
  19508. _userInstancedBuffersStorage: {
  19509. data: {
  19510. [key: string]: Float32Array;
  19511. };
  19512. sizes: {
  19513. [key: string]: number;
  19514. };
  19515. vertexBuffers: {
  19516. [key: string]: Nullable<VertexBuffer>;
  19517. };
  19518. strides: {
  19519. [key: string]: number;
  19520. };
  19521. };
  19522. }
  19523. interface AbstractMesh {
  19524. /**
  19525. * Object used to store instanced buffers defined by user
  19526. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19527. */
  19528. instancedBuffers: {
  19529. [key: string]: any;
  19530. };
  19531. }
  19532. }
  19533. declare module BABYLON {
  19534. /**
  19535. * Defines the options associated with the creation of a shader material.
  19536. */
  19537. export interface IShaderMaterialOptions {
  19538. /**
  19539. * Does the material work in alpha blend mode
  19540. */
  19541. needAlphaBlending: boolean;
  19542. /**
  19543. * Does the material work in alpha test mode
  19544. */
  19545. needAlphaTesting: boolean;
  19546. /**
  19547. * The list of attribute names used in the shader
  19548. */
  19549. attributes: string[];
  19550. /**
  19551. * The list of unifrom names used in the shader
  19552. */
  19553. uniforms: string[];
  19554. /**
  19555. * The list of UBO names used in the shader
  19556. */
  19557. uniformBuffers: string[];
  19558. /**
  19559. * The list of sampler names used in the shader
  19560. */
  19561. samplers: string[];
  19562. /**
  19563. * The list of defines used in the shader
  19564. */
  19565. defines: string[];
  19566. }
  19567. /**
  19568. * 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.
  19569. *
  19570. * This returned material effects how the mesh will look based on the code in the shaders.
  19571. *
  19572. * @see http://doc.babylonjs.com/how_to/shader_material
  19573. */
  19574. export class ShaderMaterial extends Material {
  19575. private _shaderPath;
  19576. private _options;
  19577. private _textures;
  19578. private _textureArrays;
  19579. private _floats;
  19580. private _ints;
  19581. private _floatsArrays;
  19582. private _colors3;
  19583. private _colors3Arrays;
  19584. private _colors4;
  19585. private _colors4Arrays;
  19586. private _vectors2;
  19587. private _vectors3;
  19588. private _vectors4;
  19589. private _matrices;
  19590. private _matrixArrays;
  19591. private _matrices3x3;
  19592. private _matrices2x2;
  19593. private _vectors2Arrays;
  19594. private _vectors3Arrays;
  19595. private _vectors4Arrays;
  19596. private _cachedWorldViewMatrix;
  19597. private _cachedWorldViewProjectionMatrix;
  19598. private _renderId;
  19599. private _multiview;
  19600. /**
  19601. * Instantiate a new shader material.
  19602. * 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.
  19603. * This returned material effects how the mesh will look based on the code in the shaders.
  19604. * @see http://doc.babylonjs.com/how_to/shader_material
  19605. * @param name Define the name of the material in the scene
  19606. * @param scene Define the scene the material belongs to
  19607. * @param shaderPath Defines the route to the shader code in one of three ways:
  19608. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19609. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19610. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19611. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19612. * @param options Define the options used to create the shader
  19613. */
  19614. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19615. /**
  19616. * Gets the shader path used to define the shader code
  19617. * It can be modified to trigger a new compilation
  19618. */
  19619. get shaderPath(): any;
  19620. /**
  19621. * Sets the shader path used to define the shader code
  19622. * It can be modified to trigger a new compilation
  19623. */
  19624. set shaderPath(shaderPath: any);
  19625. /**
  19626. * Gets the options used to compile the shader.
  19627. * They can be modified to trigger a new compilation
  19628. */
  19629. get options(): IShaderMaterialOptions;
  19630. /**
  19631. * Gets the current class name of the material e.g. "ShaderMaterial"
  19632. * Mainly use in serialization.
  19633. * @returns the class name
  19634. */
  19635. getClassName(): string;
  19636. /**
  19637. * Specifies if the material will require alpha blending
  19638. * @returns a boolean specifying if alpha blending is needed
  19639. */
  19640. needAlphaBlending(): boolean;
  19641. /**
  19642. * Specifies if this material should be rendered in alpha test mode
  19643. * @returns a boolean specifying if an alpha test is needed.
  19644. */
  19645. needAlphaTesting(): boolean;
  19646. private _checkUniform;
  19647. /**
  19648. * Set a texture in the shader.
  19649. * @param name Define the name of the uniform samplers as defined in the shader
  19650. * @param texture Define the texture to bind to this sampler
  19651. * @return the material itself allowing "fluent" like uniform updates
  19652. */
  19653. setTexture(name: string, texture: Texture): ShaderMaterial;
  19654. /**
  19655. * Set a texture array in the shader.
  19656. * @param name Define the name of the uniform sampler array as defined in the shader
  19657. * @param textures Define the list of textures to bind to this sampler
  19658. * @return the material itself allowing "fluent" like uniform updates
  19659. */
  19660. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19661. /**
  19662. * Set a float in the shader.
  19663. * @param name Define the name of the uniform as defined in the shader
  19664. * @param value Define the value to give to the uniform
  19665. * @return the material itself allowing "fluent" like uniform updates
  19666. */
  19667. setFloat(name: string, value: number): ShaderMaterial;
  19668. /**
  19669. * Set a int in the shader.
  19670. * @param name Define the name of the uniform as defined in the shader
  19671. * @param value Define the value to give to the uniform
  19672. * @return the material itself allowing "fluent" like uniform updates
  19673. */
  19674. setInt(name: string, value: number): ShaderMaterial;
  19675. /**
  19676. * Set an array of floats in the shader.
  19677. * @param name Define the name of the uniform as defined in the shader
  19678. * @param value Define the value to give to the uniform
  19679. * @return the material itself allowing "fluent" like uniform updates
  19680. */
  19681. setFloats(name: string, value: number[]): ShaderMaterial;
  19682. /**
  19683. * Set a vec3 in the shader from a Color3.
  19684. * @param name Define the name of the uniform as defined in the shader
  19685. * @param value Define the value to give to the uniform
  19686. * @return the material itself allowing "fluent" like uniform updates
  19687. */
  19688. setColor3(name: string, value: Color3): ShaderMaterial;
  19689. /**
  19690. * Set a vec3 array in the shader from a Color3 array.
  19691. * @param name Define the name of the uniform as defined in the shader
  19692. * @param value Define the value to give to the uniform
  19693. * @return the material itself allowing "fluent" like uniform updates
  19694. */
  19695. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19696. /**
  19697. * Set a vec4 in the shader from a Color4.
  19698. * @param name Define the name of the uniform as defined in the shader
  19699. * @param value Define the value to give to the uniform
  19700. * @return the material itself allowing "fluent" like uniform updates
  19701. */
  19702. setColor4(name: string, value: Color4): ShaderMaterial;
  19703. /**
  19704. * Set a vec4 array in the shader from a Color4 array.
  19705. * @param name Define the name of the uniform as defined in the shader
  19706. * @param value Define the value to give to the uniform
  19707. * @return the material itself allowing "fluent" like uniform updates
  19708. */
  19709. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19710. /**
  19711. * Set a vec2 in the shader from a Vector2.
  19712. * @param name Define the name of the uniform as defined in the shader
  19713. * @param value Define the value to give to the uniform
  19714. * @return the material itself allowing "fluent" like uniform updates
  19715. */
  19716. setVector2(name: string, value: Vector2): ShaderMaterial;
  19717. /**
  19718. * Set a vec3 in the shader from a Vector3.
  19719. * @param name Define the name of the uniform as defined in the shader
  19720. * @param value Define the value to give to the uniform
  19721. * @return the material itself allowing "fluent" like uniform updates
  19722. */
  19723. setVector3(name: string, value: Vector3): ShaderMaterial;
  19724. /**
  19725. * Set a vec4 in the shader from a Vector4.
  19726. * @param name Define the name of the uniform as defined in the shader
  19727. * @param value Define the value to give to the uniform
  19728. * @return the material itself allowing "fluent" like uniform updates
  19729. */
  19730. setVector4(name: string, value: Vector4): ShaderMaterial;
  19731. /**
  19732. * Set a mat4 in the shader from a Matrix.
  19733. * @param name Define the name of the uniform as defined in the shader
  19734. * @param value Define the value to give to the uniform
  19735. * @return the material itself allowing "fluent" like uniform updates
  19736. */
  19737. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19738. /**
  19739. * Set a float32Array in the shader from a matrix array.
  19740. * @param name Define the name of the uniform as defined in the shader
  19741. * @param value Define the value to give to the uniform
  19742. * @return the material itself allowing "fluent" like uniform updates
  19743. */
  19744. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19745. /**
  19746. * Set a mat3 in the shader from a Float32Array.
  19747. * @param name Define the name of the uniform as defined in the shader
  19748. * @param value Define the value to give to the uniform
  19749. * @return the material itself allowing "fluent" like uniform updates
  19750. */
  19751. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19752. /**
  19753. * Set a mat2 in the shader from a Float32Array.
  19754. * @param name Define the name of the uniform as defined in the shader
  19755. * @param value Define the value to give to the uniform
  19756. * @return the material itself allowing "fluent" like uniform updates
  19757. */
  19758. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19759. /**
  19760. * Set a vec2 array in the shader from a number array.
  19761. * @param name Define the name of the uniform as defined in the shader
  19762. * @param value Define the value to give to the uniform
  19763. * @return the material itself allowing "fluent" like uniform updates
  19764. */
  19765. setArray2(name: string, value: number[]): ShaderMaterial;
  19766. /**
  19767. * Set a vec3 array in the shader from a number array.
  19768. * @param name Define the name of the uniform as defined in the shader
  19769. * @param value Define the value to give to the uniform
  19770. * @return the material itself allowing "fluent" like uniform updates
  19771. */
  19772. setArray3(name: string, value: number[]): ShaderMaterial;
  19773. /**
  19774. * Set a vec4 array in the shader from a number array.
  19775. * @param name Define the name of the uniform as defined in the shader
  19776. * @param value Define the value to give to the uniform
  19777. * @return the material itself allowing "fluent" like uniform updates
  19778. */
  19779. setArray4(name: string, value: number[]): ShaderMaterial;
  19780. private _checkCache;
  19781. /**
  19782. * Specifies that the submesh is ready to be used
  19783. * @param mesh defines the mesh to check
  19784. * @param subMesh defines which submesh to check
  19785. * @param useInstances specifies that instances should be used
  19786. * @returns a boolean indicating that the submesh is ready or not
  19787. */
  19788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19789. /**
  19790. * Checks if the material is ready to render the requested mesh
  19791. * @param mesh Define the mesh to render
  19792. * @param useInstances Define whether or not the material is used with instances
  19793. * @returns true if ready, otherwise false
  19794. */
  19795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19796. /**
  19797. * Binds the world matrix to the material
  19798. * @param world defines the world transformation matrix
  19799. */
  19800. bindOnlyWorldMatrix(world: Matrix): void;
  19801. /**
  19802. * Binds the material to the mesh
  19803. * @param world defines the world transformation matrix
  19804. * @param mesh defines the mesh to bind the material to
  19805. */
  19806. bind(world: Matrix, mesh?: Mesh): void;
  19807. /**
  19808. * Gets the active textures from the material
  19809. * @returns an array of textures
  19810. */
  19811. getActiveTextures(): BaseTexture[];
  19812. /**
  19813. * Specifies if the material uses a texture
  19814. * @param texture defines the texture to check against the material
  19815. * @returns a boolean specifying if the material uses the texture
  19816. */
  19817. hasTexture(texture: BaseTexture): boolean;
  19818. /**
  19819. * Makes a duplicate of the material, and gives it a new name
  19820. * @param name defines the new name for the duplicated material
  19821. * @returns the cloned material
  19822. */
  19823. clone(name: string): ShaderMaterial;
  19824. /**
  19825. * Disposes the material
  19826. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19827. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19828. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19829. */
  19830. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19831. /**
  19832. * Serializes this material in a JSON representation
  19833. * @returns the serialized material object
  19834. */
  19835. serialize(): any;
  19836. /**
  19837. * Creates a shader material from parsed shader material data
  19838. * @param source defines the JSON represnetation of the material
  19839. * @param scene defines the hosting scene
  19840. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19841. * @returns a new material
  19842. */
  19843. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19844. }
  19845. }
  19846. declare module BABYLON {
  19847. /** @hidden */
  19848. export var colorPixelShader: {
  19849. name: string;
  19850. shader: string;
  19851. };
  19852. }
  19853. declare module BABYLON {
  19854. /** @hidden */
  19855. export var colorVertexShader: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module BABYLON {
  19861. /**
  19862. * Line mesh
  19863. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19864. */
  19865. export class LinesMesh extends Mesh {
  19866. /**
  19867. * If vertex color should be applied to the mesh
  19868. */
  19869. readonly useVertexColor?: boolean | undefined;
  19870. /**
  19871. * If vertex alpha should be applied to the mesh
  19872. */
  19873. readonly useVertexAlpha?: boolean | undefined;
  19874. /**
  19875. * Color of the line (Default: White)
  19876. */
  19877. color: Color3;
  19878. /**
  19879. * Alpha of the line (Default: 1)
  19880. */
  19881. alpha: number;
  19882. /**
  19883. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19884. * This margin is expressed in world space coordinates, so its value may vary.
  19885. * Default value is 0.1
  19886. */
  19887. intersectionThreshold: number;
  19888. private _colorShader;
  19889. private color4;
  19890. /**
  19891. * Creates a new LinesMesh
  19892. * @param name defines the name
  19893. * @param scene defines the hosting scene
  19894. * @param parent defines the parent mesh if any
  19895. * @param source defines the optional source LinesMesh used to clone data from
  19896. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19897. * When false, achieved by calling a clone(), also passing False.
  19898. * This will make creation of children, recursive.
  19899. * @param useVertexColor defines if this LinesMesh supports vertex color
  19900. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19901. */
  19902. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19903. /**
  19904. * If vertex color should be applied to the mesh
  19905. */
  19906. useVertexColor?: boolean | undefined,
  19907. /**
  19908. * If vertex alpha should be applied to the mesh
  19909. */
  19910. useVertexAlpha?: boolean | undefined);
  19911. private _addClipPlaneDefine;
  19912. private _removeClipPlaneDefine;
  19913. isReady(): boolean;
  19914. /**
  19915. * Returns the string "LineMesh"
  19916. */
  19917. getClassName(): string;
  19918. /**
  19919. * @hidden
  19920. */
  19921. get material(): Material;
  19922. /**
  19923. * @hidden
  19924. */
  19925. set material(value: Material);
  19926. /**
  19927. * @hidden
  19928. */
  19929. get checkCollisions(): boolean;
  19930. /** @hidden */
  19931. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19932. /** @hidden */
  19933. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19934. /**
  19935. * Disposes of the line mesh
  19936. * @param doNotRecurse If children should be disposed
  19937. */
  19938. dispose(doNotRecurse?: boolean): void;
  19939. /**
  19940. * Returns a new LineMesh object cloned from the current one.
  19941. */
  19942. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  19943. /**
  19944. * Creates a new InstancedLinesMesh object from the mesh model.
  19945. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19946. * @param name defines the name of the new instance
  19947. * @returns a new InstancedLinesMesh
  19948. */
  19949. createInstance(name: string): InstancedLinesMesh;
  19950. }
  19951. /**
  19952. * Creates an instance based on a source LinesMesh
  19953. */
  19954. export class InstancedLinesMesh extends InstancedMesh {
  19955. /**
  19956. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19957. * This margin is expressed in world space coordinates, so its value may vary.
  19958. * Initilized with the intersectionThreshold value of the source LinesMesh
  19959. */
  19960. intersectionThreshold: number;
  19961. constructor(name: string, source: LinesMesh);
  19962. /**
  19963. * Returns the string "InstancedLinesMesh".
  19964. */
  19965. getClassName(): string;
  19966. }
  19967. }
  19968. declare module BABYLON {
  19969. /** @hidden */
  19970. export var linePixelShader: {
  19971. name: string;
  19972. shader: string;
  19973. };
  19974. }
  19975. declare module BABYLON {
  19976. /** @hidden */
  19977. export var lineVertexShader: {
  19978. name: string;
  19979. shader: string;
  19980. };
  19981. }
  19982. declare module BABYLON {
  19983. interface AbstractMesh {
  19984. /**
  19985. * Gets the edgesRenderer associated with the mesh
  19986. */
  19987. edgesRenderer: Nullable<EdgesRenderer>;
  19988. }
  19989. interface LinesMesh {
  19990. /**
  19991. * Enables the edge rendering mode on the mesh.
  19992. * This mode makes the mesh edges visible
  19993. * @param epsilon defines the maximal distance between two angles to detect a face
  19994. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19995. * @returns the currentAbstractMesh
  19996. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19997. */
  19998. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19999. }
  20000. interface InstancedLinesMesh {
  20001. /**
  20002. * Enables the edge rendering mode on the mesh.
  20003. * This mode makes the mesh edges visible
  20004. * @param epsilon defines the maximal distance between two angles to detect a face
  20005. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20006. * @returns the current InstancedLinesMesh
  20007. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20008. */
  20009. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20010. }
  20011. /**
  20012. * Defines the minimum contract an Edges renderer should follow.
  20013. */
  20014. export interface IEdgesRenderer extends IDisposable {
  20015. /**
  20016. * Gets or sets a boolean indicating if the edgesRenderer is active
  20017. */
  20018. isEnabled: boolean;
  20019. /**
  20020. * Renders the edges of the attached mesh,
  20021. */
  20022. render(): void;
  20023. /**
  20024. * Checks wether or not the edges renderer is ready to render.
  20025. * @return true if ready, otherwise false.
  20026. */
  20027. isReady(): boolean;
  20028. }
  20029. /**
  20030. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20031. */
  20032. export class EdgesRenderer implements IEdgesRenderer {
  20033. /**
  20034. * Define the size of the edges with an orthographic camera
  20035. */
  20036. edgesWidthScalerForOrthographic: number;
  20037. /**
  20038. * Define the size of the edges with a perspective camera
  20039. */
  20040. edgesWidthScalerForPerspective: number;
  20041. protected _source: AbstractMesh;
  20042. protected _linesPositions: number[];
  20043. protected _linesNormals: number[];
  20044. protected _linesIndices: number[];
  20045. protected _epsilon: number;
  20046. protected _indicesCount: number;
  20047. protected _lineShader: ShaderMaterial;
  20048. protected _ib: DataBuffer;
  20049. protected _buffers: {
  20050. [key: string]: Nullable<VertexBuffer>;
  20051. };
  20052. protected _checkVerticesInsteadOfIndices: boolean;
  20053. private _meshRebuildObserver;
  20054. private _meshDisposeObserver;
  20055. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20056. isEnabled: boolean;
  20057. /**
  20058. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20059. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20060. * @param source Mesh used to create edges
  20061. * @param epsilon sum of angles in adjacency to check for edge
  20062. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20063. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20064. */
  20065. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20066. protected _prepareRessources(): void;
  20067. /** @hidden */
  20068. _rebuild(): void;
  20069. /**
  20070. * Releases the required resources for the edges renderer
  20071. */
  20072. dispose(): void;
  20073. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20074. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20075. /**
  20076. * Checks if the pair of p0 and p1 is en edge
  20077. * @param faceIndex
  20078. * @param edge
  20079. * @param faceNormals
  20080. * @param p0
  20081. * @param p1
  20082. * @private
  20083. */
  20084. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20085. /**
  20086. * push line into the position, normal and index buffer
  20087. * @protected
  20088. */
  20089. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20090. /**
  20091. * Generates lines edges from adjacencjes
  20092. * @private
  20093. */
  20094. _generateEdgesLines(): void;
  20095. /**
  20096. * Checks wether or not the edges renderer is ready to render.
  20097. * @return true if ready, otherwise false.
  20098. */
  20099. isReady(): boolean;
  20100. /**
  20101. * Renders the edges of the attached mesh,
  20102. */
  20103. render(): void;
  20104. }
  20105. /**
  20106. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20107. */
  20108. export class LineEdgesRenderer extends EdgesRenderer {
  20109. /**
  20110. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20111. * @param source LineMesh used to generate edges
  20112. * @param epsilon not important (specified angle for edge detection)
  20113. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20114. */
  20115. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20116. /**
  20117. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20118. */
  20119. _generateEdgesLines(): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * This represents the object necessary to create a rendering group.
  20125. * This is exclusively used and created by the rendering manager.
  20126. * To modify the behavior, you use the available helpers in your scene or meshes.
  20127. * @hidden
  20128. */
  20129. export class RenderingGroup {
  20130. index: number;
  20131. private static _zeroVector;
  20132. private _scene;
  20133. private _opaqueSubMeshes;
  20134. private _transparentSubMeshes;
  20135. private _alphaTestSubMeshes;
  20136. private _depthOnlySubMeshes;
  20137. private _particleSystems;
  20138. private _spriteManagers;
  20139. private _opaqueSortCompareFn;
  20140. private _alphaTestSortCompareFn;
  20141. private _transparentSortCompareFn;
  20142. private _renderOpaque;
  20143. private _renderAlphaTest;
  20144. private _renderTransparent;
  20145. /** @hidden */
  20146. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20147. onBeforeTransparentRendering: () => void;
  20148. /**
  20149. * Set the opaque sort comparison function.
  20150. * If null the sub meshes will be render in the order they were created
  20151. */
  20152. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20153. /**
  20154. * Set the alpha test sort comparison function.
  20155. * If null the sub meshes will be render in the order they were created
  20156. */
  20157. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20158. /**
  20159. * Set the transparent sort comparison function.
  20160. * If null the sub meshes will be render in the order they were created
  20161. */
  20162. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20163. /**
  20164. * Creates a new rendering group.
  20165. * @param index The rendering group index
  20166. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20167. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20168. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20169. */
  20170. 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>);
  20171. /**
  20172. * Render all the sub meshes contained in the group.
  20173. * @param customRenderFunction Used to override the default render behaviour of the group.
  20174. * @returns true if rendered some submeshes.
  20175. */
  20176. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20177. /**
  20178. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20179. * @param subMeshes The submeshes to render
  20180. */
  20181. private renderOpaqueSorted;
  20182. /**
  20183. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20184. * @param subMeshes The submeshes to render
  20185. */
  20186. private renderAlphaTestSorted;
  20187. /**
  20188. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20189. * @param subMeshes The submeshes to render
  20190. */
  20191. private renderTransparentSorted;
  20192. /**
  20193. * Renders the submeshes in a specified order.
  20194. * @param subMeshes The submeshes to sort before render
  20195. * @param sortCompareFn The comparison function use to sort
  20196. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20197. * @param transparent Specifies to activate blending if true
  20198. */
  20199. private static renderSorted;
  20200. /**
  20201. * Renders the submeshes in the order they were dispatched (no sort applied).
  20202. * @param subMeshes The submeshes to render
  20203. */
  20204. private static renderUnsorted;
  20205. /**
  20206. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20207. * are rendered back to front if in the same alpha index.
  20208. *
  20209. * @param a The first submesh
  20210. * @param b The second submesh
  20211. * @returns The result of the comparison
  20212. */
  20213. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20214. /**
  20215. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20216. * are rendered back to front.
  20217. *
  20218. * @param a The first submesh
  20219. * @param b The second submesh
  20220. * @returns The result of the comparison
  20221. */
  20222. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20223. /**
  20224. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20225. * are rendered front to back (prevent overdraw).
  20226. *
  20227. * @param a The first submesh
  20228. * @param b The second submesh
  20229. * @returns The result of the comparison
  20230. */
  20231. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20232. /**
  20233. * Resets the different lists of submeshes to prepare a new frame.
  20234. */
  20235. prepare(): void;
  20236. dispose(): void;
  20237. /**
  20238. * Inserts the submesh in its correct queue depending on its material.
  20239. * @param subMesh The submesh to dispatch
  20240. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20241. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20242. */
  20243. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20244. dispatchSprites(spriteManager: ISpriteManager): void;
  20245. dispatchParticles(particleSystem: IParticleSystem): void;
  20246. private _renderParticles;
  20247. private _renderSprites;
  20248. }
  20249. }
  20250. declare module BABYLON {
  20251. /**
  20252. * Interface describing the different options available in the rendering manager
  20253. * regarding Auto Clear between groups.
  20254. */
  20255. export interface IRenderingManagerAutoClearSetup {
  20256. /**
  20257. * Defines whether or not autoclear is enable.
  20258. */
  20259. autoClear: boolean;
  20260. /**
  20261. * Defines whether or not to autoclear the depth buffer.
  20262. */
  20263. depth: boolean;
  20264. /**
  20265. * Defines whether or not to autoclear the stencil buffer.
  20266. */
  20267. stencil: boolean;
  20268. }
  20269. /**
  20270. * This class is used by the onRenderingGroupObservable
  20271. */
  20272. export class RenderingGroupInfo {
  20273. /**
  20274. * The Scene that being rendered
  20275. */
  20276. scene: Scene;
  20277. /**
  20278. * The camera currently used for the rendering pass
  20279. */
  20280. camera: Nullable<Camera>;
  20281. /**
  20282. * The ID of the renderingGroup being processed
  20283. */
  20284. renderingGroupId: number;
  20285. }
  20286. /**
  20287. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20288. * It is enable to manage the different groups as well as the different necessary sort functions.
  20289. * This should not be used directly aside of the few static configurations
  20290. */
  20291. export class RenderingManager {
  20292. /**
  20293. * The max id used for rendering groups (not included)
  20294. */
  20295. static MAX_RENDERINGGROUPS: number;
  20296. /**
  20297. * The min id used for rendering groups (included)
  20298. */
  20299. static MIN_RENDERINGGROUPS: number;
  20300. /**
  20301. * Used to globally prevent autoclearing scenes.
  20302. */
  20303. static AUTOCLEAR: boolean;
  20304. /**
  20305. * @hidden
  20306. */
  20307. _useSceneAutoClearSetup: boolean;
  20308. private _scene;
  20309. private _renderingGroups;
  20310. private _depthStencilBufferAlreadyCleaned;
  20311. private _autoClearDepthStencil;
  20312. private _customOpaqueSortCompareFn;
  20313. private _customAlphaTestSortCompareFn;
  20314. private _customTransparentSortCompareFn;
  20315. private _renderingGroupInfo;
  20316. /**
  20317. * Instantiates a new rendering group for a particular scene
  20318. * @param scene Defines the scene the groups belongs to
  20319. */
  20320. constructor(scene: Scene);
  20321. private _clearDepthStencilBuffer;
  20322. /**
  20323. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20324. * @hidden
  20325. */
  20326. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20327. /**
  20328. * Resets the different information of the group to prepare a new frame
  20329. * @hidden
  20330. */
  20331. reset(): void;
  20332. /**
  20333. * Dispose and release the group and its associated resources.
  20334. * @hidden
  20335. */
  20336. dispose(): void;
  20337. /**
  20338. * Clear the info related to rendering groups preventing retention points during dispose.
  20339. */
  20340. freeRenderingGroups(): void;
  20341. private _prepareRenderingGroup;
  20342. /**
  20343. * Add a sprite manager to the rendering manager in order to render it this frame.
  20344. * @param spriteManager Define the sprite manager to render
  20345. */
  20346. dispatchSprites(spriteManager: ISpriteManager): void;
  20347. /**
  20348. * Add a particle system to the rendering manager in order to render it this frame.
  20349. * @param particleSystem Define the particle system to render
  20350. */
  20351. dispatchParticles(particleSystem: IParticleSystem): void;
  20352. /**
  20353. * Add a submesh to the manager in order to render it this frame
  20354. * @param subMesh The submesh to dispatch
  20355. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20356. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20357. */
  20358. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20359. /**
  20360. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20361. * This allowed control for front to back rendering or reversly depending of the special needs.
  20362. *
  20363. * @param renderingGroupId The rendering group id corresponding to its index
  20364. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20365. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20366. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20367. */
  20368. 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;
  20369. /**
  20370. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20371. *
  20372. * @param renderingGroupId The rendering group id corresponding to its index
  20373. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20374. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20375. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20376. */
  20377. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20378. /**
  20379. * Gets the current auto clear configuration for one rendering group of the rendering
  20380. * manager.
  20381. * @param index the rendering group index to get the information for
  20382. * @returns The auto clear setup for the requested rendering group
  20383. */
  20384. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20385. }
  20386. }
  20387. declare module BABYLON {
  20388. /**
  20389. * This Helps creating a texture that will be created from a camera in your scene.
  20390. * It is basically a dynamic texture that could be used to create special effects for instance.
  20391. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20392. */
  20393. export class RenderTargetTexture extends Texture {
  20394. isCube: boolean;
  20395. /**
  20396. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20397. */
  20398. static readonly REFRESHRATE_RENDER_ONCE: number;
  20399. /**
  20400. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20401. */
  20402. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20403. /**
  20404. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20405. * the central point of your effect and can save a lot of performances.
  20406. */
  20407. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20408. /**
  20409. * Use this predicate to dynamically define the list of mesh you want to render.
  20410. * If set, the renderList property will be overwritten.
  20411. */
  20412. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20413. private _renderList;
  20414. /**
  20415. * Use this list to define the list of mesh you want to render.
  20416. */
  20417. get renderList(): Nullable<Array<AbstractMesh>>;
  20418. set renderList(value: Nullable<Array<AbstractMesh>>);
  20419. /**
  20420. * Use this function to overload the renderList array at rendering time.
  20421. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20422. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20423. * the cube (if the RTT is a cube, else layerOrFace=0).
  20424. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20425. */
  20426. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20427. private _hookArray;
  20428. /**
  20429. * Define if particles should be rendered in your texture.
  20430. */
  20431. renderParticles: boolean;
  20432. /**
  20433. * Define if sprites should be rendered in your texture.
  20434. */
  20435. renderSprites: boolean;
  20436. /**
  20437. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20438. */
  20439. coordinatesMode: number;
  20440. /**
  20441. * Define the camera used to render the texture.
  20442. */
  20443. activeCamera: Nullable<Camera>;
  20444. /**
  20445. * Override the render function of the texture with your own one.
  20446. */
  20447. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20448. /**
  20449. * Define if camera post processes should be use while rendering the texture.
  20450. */
  20451. useCameraPostProcesses: boolean;
  20452. /**
  20453. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20454. */
  20455. ignoreCameraViewport: boolean;
  20456. private _postProcessManager;
  20457. private _postProcesses;
  20458. private _resizeObserver;
  20459. /**
  20460. * An event triggered when the texture is unbind.
  20461. */
  20462. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20463. /**
  20464. * An event triggered when the texture is unbind.
  20465. */
  20466. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20467. private _onAfterUnbindObserver;
  20468. /**
  20469. * Set a after unbind callback in the texture.
  20470. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20471. */
  20472. set onAfterUnbind(callback: () => void);
  20473. /**
  20474. * An event triggered before rendering the texture
  20475. */
  20476. onBeforeRenderObservable: Observable<number>;
  20477. private _onBeforeRenderObserver;
  20478. /**
  20479. * Set a before render callback in the texture.
  20480. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20481. */
  20482. set onBeforeRender(callback: (faceIndex: number) => void);
  20483. /**
  20484. * An event triggered after rendering the texture
  20485. */
  20486. onAfterRenderObservable: Observable<number>;
  20487. private _onAfterRenderObserver;
  20488. /**
  20489. * Set a after render callback in the texture.
  20490. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20491. */
  20492. set onAfterRender(callback: (faceIndex: number) => void);
  20493. /**
  20494. * An event triggered after the texture clear
  20495. */
  20496. onClearObservable: Observable<Engine>;
  20497. private _onClearObserver;
  20498. /**
  20499. * Set a clear callback in the texture.
  20500. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20501. */
  20502. set onClear(callback: (Engine: Engine) => void);
  20503. /**
  20504. * An event triggered when the texture is resized.
  20505. */
  20506. onResizeObservable: Observable<RenderTargetTexture>;
  20507. /**
  20508. * Define the clear color of the Render Target if it should be different from the scene.
  20509. */
  20510. clearColor: Color4;
  20511. protected _size: number | {
  20512. width: number;
  20513. height: number;
  20514. layers?: number;
  20515. };
  20516. protected _initialSizeParameter: number | {
  20517. width: number;
  20518. height: number;
  20519. } | {
  20520. ratio: number;
  20521. };
  20522. protected _sizeRatio: Nullable<number>;
  20523. /** @hidden */
  20524. _generateMipMaps: boolean;
  20525. protected _renderingManager: RenderingManager;
  20526. /** @hidden */
  20527. _waitingRenderList: string[];
  20528. protected _doNotChangeAspectRatio: boolean;
  20529. protected _currentRefreshId: number;
  20530. protected _refreshRate: number;
  20531. protected _textureMatrix: Matrix;
  20532. protected _samples: number;
  20533. protected _renderTargetOptions: RenderTargetCreationOptions;
  20534. /**
  20535. * Gets render target creation options that were used.
  20536. */
  20537. get renderTargetOptions(): RenderTargetCreationOptions;
  20538. protected _engine: Engine;
  20539. protected _onRatioRescale(): void;
  20540. /**
  20541. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20542. * It must define where the camera used to render the texture is set
  20543. */
  20544. boundingBoxPosition: Vector3;
  20545. private _boundingBoxSize;
  20546. /**
  20547. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20548. * When defined, the cubemap will switch to local mode
  20549. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20550. * @example https://www.babylonjs-playground.com/#RNASML
  20551. */
  20552. set boundingBoxSize(value: Vector3);
  20553. get boundingBoxSize(): Vector3;
  20554. /**
  20555. * In case the RTT has been created with a depth texture, get the associated
  20556. * depth texture.
  20557. * Otherwise, return null.
  20558. */
  20559. get depthStencilTexture(): Nullable<InternalTexture>;
  20560. /**
  20561. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20562. * or used a shadow, depth texture...
  20563. * @param name The friendly name of the texture
  20564. * @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)
  20565. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20566. * @param generateMipMaps True if mip maps need to be generated after render.
  20567. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20568. * @param type The type of the buffer in the RTT (int, half float, float...)
  20569. * @param isCube True if a cube texture needs to be created
  20570. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20571. * @param generateDepthBuffer True to generate a depth buffer
  20572. * @param generateStencilBuffer True to generate a stencil buffer
  20573. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20574. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20575. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20576. */
  20577. constructor(name: string, size: number | {
  20578. width: number;
  20579. height: number;
  20580. layers?: number;
  20581. } | {
  20582. ratio: number;
  20583. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20584. /**
  20585. * Creates a depth stencil texture.
  20586. * This is only available in WebGL 2 or with the depth texture extension available.
  20587. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20588. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20589. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20590. */
  20591. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20592. private _processSizeParameter;
  20593. /**
  20594. * Define the number of samples to use in case of MSAA.
  20595. * It defaults to one meaning no MSAA has been enabled.
  20596. */
  20597. get samples(): number;
  20598. set samples(value: number);
  20599. /**
  20600. * Resets the refresh counter of the texture and start bak from scratch.
  20601. * Could be useful to regenerate the texture if it is setup to render only once.
  20602. */
  20603. resetRefreshCounter(): void;
  20604. /**
  20605. * Define the refresh rate of the texture or the rendering frequency.
  20606. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20607. */
  20608. get refreshRate(): number;
  20609. set refreshRate(value: number);
  20610. /**
  20611. * Adds a post process to the render target rendering passes.
  20612. * @param postProcess define the post process to add
  20613. */
  20614. addPostProcess(postProcess: PostProcess): void;
  20615. /**
  20616. * Clear all the post processes attached to the render target
  20617. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20618. */
  20619. clearPostProcesses(dispose?: boolean): void;
  20620. /**
  20621. * Remove one of the post process from the list of attached post processes to the texture
  20622. * @param postProcess define the post process to remove from the list
  20623. */
  20624. removePostProcess(postProcess: PostProcess): void;
  20625. /** @hidden */
  20626. _shouldRender(): boolean;
  20627. /**
  20628. * Gets the actual render size of the texture.
  20629. * @returns the width of the render size
  20630. */
  20631. getRenderSize(): number;
  20632. /**
  20633. * Gets the actual render width of the texture.
  20634. * @returns the width of the render size
  20635. */
  20636. getRenderWidth(): number;
  20637. /**
  20638. * Gets the actual render height of the texture.
  20639. * @returns the height of the render size
  20640. */
  20641. getRenderHeight(): number;
  20642. /**
  20643. * Gets the actual number of layers of the texture.
  20644. * @returns the number of layers
  20645. */
  20646. getRenderLayers(): number;
  20647. /**
  20648. * Get if the texture can be rescaled or not.
  20649. */
  20650. get canRescale(): boolean;
  20651. /**
  20652. * Resize the texture using a ratio.
  20653. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20654. */
  20655. scale(ratio: number): void;
  20656. /**
  20657. * Get the texture reflection matrix used to rotate/transform the reflection.
  20658. * @returns the reflection matrix
  20659. */
  20660. getReflectionTextureMatrix(): Matrix;
  20661. /**
  20662. * Resize the texture to a new desired size.
  20663. * Be carrefull as it will recreate all the data in the new texture.
  20664. * @param size Define the new size. It can be:
  20665. * - a number for squared texture,
  20666. * - an object containing { width: number, height: number }
  20667. * - or an object containing a ratio { ratio: number }
  20668. */
  20669. resize(size: number | {
  20670. width: number;
  20671. height: number;
  20672. } | {
  20673. ratio: number;
  20674. }): void;
  20675. private _defaultRenderListPrepared;
  20676. /**
  20677. * Renders all the objects from the render list into the texture.
  20678. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20679. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20680. */
  20681. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20682. private _bestReflectionRenderTargetDimension;
  20683. private _prepareRenderingManager;
  20684. /**
  20685. * @hidden
  20686. * @param faceIndex face index to bind to if this is a cubetexture
  20687. * @param layer defines the index of the texture to bind in the array
  20688. */
  20689. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20690. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20691. private renderToTarget;
  20692. /**
  20693. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20694. * This allowed control for front to back rendering or reversly depending of the special needs.
  20695. *
  20696. * @param renderingGroupId The rendering group id corresponding to its index
  20697. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20698. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20699. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20700. */
  20701. 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;
  20702. /**
  20703. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20704. *
  20705. * @param renderingGroupId The rendering group id corresponding to its index
  20706. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20707. */
  20708. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20709. /**
  20710. * Clones the texture.
  20711. * @returns the cloned texture
  20712. */
  20713. clone(): RenderTargetTexture;
  20714. /**
  20715. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20716. * @returns The JSON representation of the texture
  20717. */
  20718. serialize(): any;
  20719. /**
  20720. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20721. */
  20722. disposeFramebufferObjects(): void;
  20723. /**
  20724. * Dispose the texture and release its associated resources.
  20725. */
  20726. dispose(): void;
  20727. /** @hidden */
  20728. _rebuild(): void;
  20729. /**
  20730. * Clear the info related to rendering groups preventing retention point in material dispose.
  20731. */
  20732. freeRenderingGroups(): void;
  20733. /**
  20734. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20735. * @returns the view count
  20736. */
  20737. getViewCount(): number;
  20738. }
  20739. }
  20740. declare module BABYLON {
  20741. /**
  20742. * Options for compiling materials.
  20743. */
  20744. export interface IMaterialCompilationOptions {
  20745. /**
  20746. * Defines whether clip planes are enabled.
  20747. */
  20748. clipPlane: boolean;
  20749. /**
  20750. * Defines whether instances are enabled.
  20751. */
  20752. useInstances: boolean;
  20753. }
  20754. /**
  20755. * Base class for the main features of a material in Babylon.js
  20756. */
  20757. export class Material implements IAnimatable {
  20758. /**
  20759. * Returns the triangle fill mode
  20760. */
  20761. static readonly TriangleFillMode: number;
  20762. /**
  20763. * Returns the wireframe mode
  20764. */
  20765. static readonly WireFrameFillMode: number;
  20766. /**
  20767. * Returns the point fill mode
  20768. */
  20769. static readonly PointFillMode: number;
  20770. /**
  20771. * Returns the point list draw mode
  20772. */
  20773. static readonly PointListDrawMode: number;
  20774. /**
  20775. * Returns the line list draw mode
  20776. */
  20777. static readonly LineListDrawMode: number;
  20778. /**
  20779. * Returns the line loop draw mode
  20780. */
  20781. static readonly LineLoopDrawMode: number;
  20782. /**
  20783. * Returns the line strip draw mode
  20784. */
  20785. static readonly LineStripDrawMode: number;
  20786. /**
  20787. * Returns the triangle strip draw mode
  20788. */
  20789. static readonly TriangleStripDrawMode: number;
  20790. /**
  20791. * Returns the triangle fan draw mode
  20792. */
  20793. static readonly TriangleFanDrawMode: number;
  20794. /**
  20795. * Stores the clock-wise side orientation
  20796. */
  20797. static readonly ClockWiseSideOrientation: number;
  20798. /**
  20799. * Stores the counter clock-wise side orientation
  20800. */
  20801. static readonly CounterClockWiseSideOrientation: number;
  20802. /**
  20803. * The dirty texture flag value
  20804. */
  20805. static readonly TextureDirtyFlag: number;
  20806. /**
  20807. * The dirty light flag value
  20808. */
  20809. static readonly LightDirtyFlag: number;
  20810. /**
  20811. * The dirty fresnel flag value
  20812. */
  20813. static readonly FresnelDirtyFlag: number;
  20814. /**
  20815. * The dirty attribute flag value
  20816. */
  20817. static readonly AttributesDirtyFlag: number;
  20818. /**
  20819. * The dirty misc flag value
  20820. */
  20821. static readonly MiscDirtyFlag: number;
  20822. /**
  20823. * The all dirty flag value
  20824. */
  20825. static readonly AllDirtyFlag: number;
  20826. /**
  20827. * The ID of the material
  20828. */
  20829. id: string;
  20830. /**
  20831. * Gets or sets the unique id of the material
  20832. */
  20833. uniqueId: number;
  20834. /**
  20835. * The name of the material
  20836. */
  20837. name: string;
  20838. /**
  20839. * Gets or sets user defined metadata
  20840. */
  20841. metadata: any;
  20842. /**
  20843. * For internal use only. Please do not use.
  20844. */
  20845. reservedDataStore: any;
  20846. /**
  20847. * Specifies if the ready state should be checked on each call
  20848. */
  20849. checkReadyOnEveryCall: boolean;
  20850. /**
  20851. * Specifies if the ready state should be checked once
  20852. */
  20853. checkReadyOnlyOnce: boolean;
  20854. /**
  20855. * The state of the material
  20856. */
  20857. state: string;
  20858. /**
  20859. * The alpha value of the material
  20860. */
  20861. protected _alpha: number;
  20862. /**
  20863. * List of inspectable custom properties (used by the Inspector)
  20864. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20865. */
  20866. inspectableCustomProperties: IInspectable[];
  20867. /**
  20868. * Sets the alpha value of the material
  20869. */
  20870. set alpha(value: number);
  20871. /**
  20872. * Gets the alpha value of the material
  20873. */
  20874. get alpha(): number;
  20875. /**
  20876. * Specifies if back face culling is enabled
  20877. */
  20878. protected _backFaceCulling: boolean;
  20879. /**
  20880. * Sets the back-face culling state
  20881. */
  20882. set backFaceCulling(value: boolean);
  20883. /**
  20884. * Gets the back-face culling state
  20885. */
  20886. get backFaceCulling(): boolean;
  20887. /**
  20888. * Stores the value for side orientation
  20889. */
  20890. sideOrientation: number;
  20891. /**
  20892. * Callback triggered when the material is compiled
  20893. */
  20894. onCompiled: Nullable<(effect: Effect) => void>;
  20895. /**
  20896. * Callback triggered when an error occurs
  20897. */
  20898. onError: Nullable<(effect: Effect, errors: string) => void>;
  20899. /**
  20900. * Callback triggered to get the render target textures
  20901. */
  20902. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20903. /**
  20904. * Gets a boolean indicating that current material needs to register RTT
  20905. */
  20906. get hasRenderTargetTextures(): boolean;
  20907. /**
  20908. * Specifies if the material should be serialized
  20909. */
  20910. doNotSerialize: boolean;
  20911. /**
  20912. * @hidden
  20913. */
  20914. _storeEffectOnSubMeshes: boolean;
  20915. /**
  20916. * Stores the animations for the material
  20917. */
  20918. animations: Nullable<Array<Animation>>;
  20919. /**
  20920. * An event triggered when the material is disposed
  20921. */
  20922. onDisposeObservable: Observable<Material>;
  20923. /**
  20924. * An observer which watches for dispose events
  20925. */
  20926. private _onDisposeObserver;
  20927. private _onUnBindObservable;
  20928. /**
  20929. * Called during a dispose event
  20930. */
  20931. set onDispose(callback: () => void);
  20932. private _onBindObservable;
  20933. /**
  20934. * An event triggered when the material is bound
  20935. */
  20936. get onBindObservable(): Observable<AbstractMesh>;
  20937. /**
  20938. * An observer which watches for bind events
  20939. */
  20940. private _onBindObserver;
  20941. /**
  20942. * Called during a bind event
  20943. */
  20944. set onBind(callback: (Mesh: AbstractMesh) => void);
  20945. /**
  20946. * An event triggered when the material is unbound
  20947. */
  20948. get onUnBindObservable(): Observable<Material>;
  20949. /**
  20950. * Stores the value of the alpha mode
  20951. */
  20952. private _alphaMode;
  20953. /**
  20954. * Sets the value of the alpha mode.
  20955. *
  20956. * | Value | Type | Description |
  20957. * | --- | --- | --- |
  20958. * | 0 | ALPHA_DISABLE | |
  20959. * | 1 | ALPHA_ADD | |
  20960. * | 2 | ALPHA_COMBINE | |
  20961. * | 3 | ALPHA_SUBTRACT | |
  20962. * | 4 | ALPHA_MULTIPLY | |
  20963. * | 5 | ALPHA_MAXIMIZED | |
  20964. * | 6 | ALPHA_ONEONE | |
  20965. * | 7 | ALPHA_PREMULTIPLIED | |
  20966. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20967. * | 9 | ALPHA_INTERPOLATE | |
  20968. * | 10 | ALPHA_SCREENMODE | |
  20969. *
  20970. */
  20971. set alphaMode(value: number);
  20972. /**
  20973. * Gets the value of the alpha mode
  20974. */
  20975. get alphaMode(): number;
  20976. /**
  20977. * Stores the state of the need depth pre-pass value
  20978. */
  20979. private _needDepthPrePass;
  20980. /**
  20981. * Sets the need depth pre-pass value
  20982. */
  20983. set needDepthPrePass(value: boolean);
  20984. /**
  20985. * Gets the depth pre-pass value
  20986. */
  20987. get needDepthPrePass(): boolean;
  20988. /**
  20989. * Specifies if depth writing should be disabled
  20990. */
  20991. disableDepthWrite: boolean;
  20992. /**
  20993. * Specifies if depth writing should be forced
  20994. */
  20995. forceDepthWrite: boolean;
  20996. /**
  20997. * Specifies the depth function that should be used. 0 means the default engine function
  20998. */
  20999. depthFunction: number;
  21000. /**
  21001. * Specifies if there should be a separate pass for culling
  21002. */
  21003. separateCullingPass: boolean;
  21004. /**
  21005. * Stores the state specifing if fog should be enabled
  21006. */
  21007. private _fogEnabled;
  21008. /**
  21009. * Sets the state for enabling fog
  21010. */
  21011. set fogEnabled(value: boolean);
  21012. /**
  21013. * Gets the value of the fog enabled state
  21014. */
  21015. get fogEnabled(): boolean;
  21016. /**
  21017. * Stores the size of points
  21018. */
  21019. pointSize: number;
  21020. /**
  21021. * Stores the z offset value
  21022. */
  21023. zOffset: number;
  21024. /**
  21025. * Gets a value specifying if wireframe mode is enabled
  21026. */
  21027. get wireframe(): boolean;
  21028. /**
  21029. * Sets the state of wireframe mode
  21030. */
  21031. set wireframe(value: boolean);
  21032. /**
  21033. * Gets the value specifying if point clouds are enabled
  21034. */
  21035. get pointsCloud(): boolean;
  21036. /**
  21037. * Sets the state of point cloud mode
  21038. */
  21039. set pointsCloud(value: boolean);
  21040. /**
  21041. * Gets the material fill mode
  21042. */
  21043. get fillMode(): number;
  21044. /**
  21045. * Sets the material fill mode
  21046. */
  21047. set fillMode(value: number);
  21048. /**
  21049. * @hidden
  21050. * Stores the effects for the material
  21051. */
  21052. _effect: Nullable<Effect>;
  21053. /**
  21054. * Specifies if uniform buffers should be used
  21055. */
  21056. private _useUBO;
  21057. /**
  21058. * Stores a reference to the scene
  21059. */
  21060. private _scene;
  21061. /**
  21062. * Stores the fill mode state
  21063. */
  21064. private _fillMode;
  21065. /**
  21066. * Specifies if the depth write state should be cached
  21067. */
  21068. private _cachedDepthWriteState;
  21069. /**
  21070. * Specifies if the depth function state should be cached
  21071. */
  21072. private _cachedDepthFunctionState;
  21073. /**
  21074. * Stores the uniform buffer
  21075. */
  21076. protected _uniformBuffer: UniformBuffer;
  21077. /** @hidden */
  21078. _indexInSceneMaterialArray: number;
  21079. /** @hidden */
  21080. meshMap: Nullable<{
  21081. [id: string]: AbstractMesh | undefined;
  21082. }>;
  21083. /**
  21084. * Creates a material instance
  21085. * @param name defines the name of the material
  21086. * @param scene defines the scene to reference
  21087. * @param doNotAdd specifies if the material should be added to the scene
  21088. */
  21089. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21090. /**
  21091. * Returns a string representation of the current material
  21092. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21093. * @returns a string with material information
  21094. */
  21095. toString(fullDetails?: boolean): string;
  21096. /**
  21097. * Gets the class name of the material
  21098. * @returns a string with the class name of the material
  21099. */
  21100. getClassName(): string;
  21101. /**
  21102. * Specifies if updates for the material been locked
  21103. */
  21104. get isFrozen(): boolean;
  21105. /**
  21106. * Locks updates for the material
  21107. */
  21108. freeze(): void;
  21109. /**
  21110. * Unlocks updates for the material
  21111. */
  21112. unfreeze(): void;
  21113. /**
  21114. * Specifies if the material is ready to be used
  21115. * @param mesh defines the mesh to check
  21116. * @param useInstances specifies if instances should be used
  21117. * @returns a boolean indicating if the material is ready to be used
  21118. */
  21119. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21120. /**
  21121. * Specifies that the submesh is ready to be used
  21122. * @param mesh defines the mesh to check
  21123. * @param subMesh defines which submesh to check
  21124. * @param useInstances specifies that instances should be used
  21125. * @returns a boolean indicating that the submesh is ready or not
  21126. */
  21127. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21128. /**
  21129. * Returns the material effect
  21130. * @returns the effect associated with the material
  21131. */
  21132. getEffect(): Nullable<Effect>;
  21133. /**
  21134. * Returns the current scene
  21135. * @returns a Scene
  21136. */
  21137. getScene(): Scene;
  21138. /**
  21139. * Specifies if the material will require alpha blending
  21140. * @returns a boolean specifying if alpha blending is needed
  21141. */
  21142. needAlphaBlending(): boolean;
  21143. /**
  21144. * Specifies if the mesh will require alpha blending
  21145. * @param mesh defines the mesh to check
  21146. * @returns a boolean specifying if alpha blending is needed for the mesh
  21147. */
  21148. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21149. /**
  21150. * Specifies if this material should be rendered in alpha test mode
  21151. * @returns a boolean specifying if an alpha test is needed.
  21152. */
  21153. needAlphaTesting(): boolean;
  21154. /**
  21155. * Gets the texture used for the alpha test
  21156. * @returns the texture to use for alpha testing
  21157. */
  21158. getAlphaTestTexture(): Nullable<BaseTexture>;
  21159. /**
  21160. * Marks the material to indicate that it needs to be re-calculated
  21161. */
  21162. markDirty(): void;
  21163. /** @hidden */
  21164. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21165. /**
  21166. * Binds the material to the mesh
  21167. * @param world defines the world transformation matrix
  21168. * @param mesh defines the mesh to bind the material to
  21169. */
  21170. bind(world: Matrix, mesh?: Mesh): void;
  21171. /**
  21172. * Binds the submesh to the material
  21173. * @param world defines the world transformation matrix
  21174. * @param mesh defines the mesh containing the submesh
  21175. * @param subMesh defines the submesh to bind the material to
  21176. */
  21177. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21178. /**
  21179. * Binds the world matrix to the material
  21180. * @param world defines the world transformation matrix
  21181. */
  21182. bindOnlyWorldMatrix(world: Matrix): void;
  21183. /**
  21184. * Binds the scene's uniform buffer to the effect.
  21185. * @param effect defines the effect to bind to the scene uniform buffer
  21186. * @param sceneUbo defines the uniform buffer storing scene data
  21187. */
  21188. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21189. /**
  21190. * Binds the view matrix to the effect
  21191. * @param effect defines the effect to bind the view matrix to
  21192. */
  21193. bindView(effect: Effect): void;
  21194. /**
  21195. * Binds the view projection matrix to the effect
  21196. * @param effect defines the effect to bind the view projection matrix to
  21197. */
  21198. bindViewProjection(effect: Effect): void;
  21199. /**
  21200. * Specifies if material alpha testing should be turned on for the mesh
  21201. * @param mesh defines the mesh to check
  21202. */
  21203. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21204. /**
  21205. * Processes to execute after binding the material to a mesh
  21206. * @param mesh defines the rendered mesh
  21207. */
  21208. protected _afterBind(mesh?: Mesh): void;
  21209. /**
  21210. * Unbinds the material from the mesh
  21211. */
  21212. unbind(): void;
  21213. /**
  21214. * Gets the active textures from the material
  21215. * @returns an array of textures
  21216. */
  21217. getActiveTextures(): BaseTexture[];
  21218. /**
  21219. * Specifies if the material uses a texture
  21220. * @param texture defines the texture to check against the material
  21221. * @returns a boolean specifying if the material uses the texture
  21222. */
  21223. hasTexture(texture: BaseTexture): boolean;
  21224. /**
  21225. * Makes a duplicate of the material, and gives it a new name
  21226. * @param name defines the new name for the duplicated material
  21227. * @returns the cloned material
  21228. */
  21229. clone(name: string): Nullable<Material>;
  21230. /**
  21231. * Gets the meshes bound to the material
  21232. * @returns an array of meshes bound to the material
  21233. */
  21234. getBindedMeshes(): AbstractMesh[];
  21235. /**
  21236. * Force shader compilation
  21237. * @param mesh defines the mesh associated with this material
  21238. * @param onCompiled defines a function to execute once the material is compiled
  21239. * @param options defines the options to configure the compilation
  21240. * @param onError defines a function to execute if the material fails compiling
  21241. */
  21242. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21243. /**
  21244. * Force shader compilation
  21245. * @param mesh defines the mesh that will use this material
  21246. * @param options defines additional options for compiling the shaders
  21247. * @returns a promise that resolves when the compilation completes
  21248. */
  21249. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21250. private static readonly _AllDirtyCallBack;
  21251. private static readonly _ImageProcessingDirtyCallBack;
  21252. private static readonly _TextureDirtyCallBack;
  21253. private static readonly _FresnelDirtyCallBack;
  21254. private static readonly _MiscDirtyCallBack;
  21255. private static readonly _LightsDirtyCallBack;
  21256. private static readonly _AttributeDirtyCallBack;
  21257. private static _FresnelAndMiscDirtyCallBack;
  21258. private static _TextureAndMiscDirtyCallBack;
  21259. private static readonly _DirtyCallbackArray;
  21260. private static readonly _RunDirtyCallBacks;
  21261. /**
  21262. * Marks a define in the material to indicate that it needs to be re-computed
  21263. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21264. */
  21265. markAsDirty(flag: number): void;
  21266. /**
  21267. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21268. * @param func defines a function which checks material defines against the submeshes
  21269. */
  21270. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21271. /**
  21272. * Indicates that we need to re-calculated for all submeshes
  21273. */
  21274. protected _markAllSubMeshesAsAllDirty(): void;
  21275. /**
  21276. * Indicates that image processing needs to be re-calculated for all submeshes
  21277. */
  21278. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21279. /**
  21280. * Indicates that textures need to be re-calculated for all submeshes
  21281. */
  21282. protected _markAllSubMeshesAsTexturesDirty(): void;
  21283. /**
  21284. * Indicates that fresnel needs to be re-calculated for all submeshes
  21285. */
  21286. protected _markAllSubMeshesAsFresnelDirty(): void;
  21287. /**
  21288. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21289. */
  21290. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21291. /**
  21292. * Indicates that lights need to be re-calculated for all submeshes
  21293. */
  21294. protected _markAllSubMeshesAsLightsDirty(): void;
  21295. /**
  21296. * Indicates that attributes need to be re-calculated for all submeshes
  21297. */
  21298. protected _markAllSubMeshesAsAttributesDirty(): void;
  21299. /**
  21300. * Indicates that misc needs to be re-calculated for all submeshes
  21301. */
  21302. protected _markAllSubMeshesAsMiscDirty(): void;
  21303. /**
  21304. * Indicates that textures and misc need to be re-calculated for all submeshes
  21305. */
  21306. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21307. /**
  21308. * Disposes the material
  21309. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21310. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21311. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21312. */
  21313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21314. /** @hidden */
  21315. private releaseVertexArrayObject;
  21316. /**
  21317. * Serializes this material
  21318. * @returns the serialized material object
  21319. */
  21320. serialize(): any;
  21321. /**
  21322. * Creates a material from parsed material data
  21323. * @param parsedMaterial defines parsed material data
  21324. * @param scene defines the hosting scene
  21325. * @param rootUrl defines the root URL to use to load textures
  21326. * @returns a new material
  21327. */
  21328. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21329. }
  21330. }
  21331. declare module BABYLON {
  21332. /**
  21333. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21334. * separate meshes. This can be use to improve performances.
  21335. * @see http://doc.babylonjs.com/how_to/multi_materials
  21336. */
  21337. export class MultiMaterial extends Material {
  21338. private _subMaterials;
  21339. /**
  21340. * Gets or Sets the list of Materials used within the multi material.
  21341. * They need to be ordered according to the submeshes order in the associated mesh
  21342. */
  21343. get subMaterials(): Nullable<Material>[];
  21344. set subMaterials(value: Nullable<Material>[]);
  21345. /**
  21346. * Function used to align with Node.getChildren()
  21347. * @returns the list of Materials used within the multi material
  21348. */
  21349. getChildren(): Nullable<Material>[];
  21350. /**
  21351. * Instantiates a new Multi Material
  21352. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21353. * separate meshes. This can be use to improve performances.
  21354. * @see http://doc.babylonjs.com/how_to/multi_materials
  21355. * @param name Define the name in the scene
  21356. * @param scene Define the scene the material belongs to
  21357. */
  21358. constructor(name: string, scene: Scene);
  21359. private _hookArray;
  21360. /**
  21361. * Get one of the submaterial by its index in the submaterials array
  21362. * @param index The index to look the sub material at
  21363. * @returns The Material if the index has been defined
  21364. */
  21365. getSubMaterial(index: number): Nullable<Material>;
  21366. /**
  21367. * Get the list of active textures for the whole sub materials list.
  21368. * @returns All the textures that will be used during the rendering
  21369. */
  21370. getActiveTextures(): BaseTexture[];
  21371. /**
  21372. * Gets the current class name of the material e.g. "MultiMaterial"
  21373. * Mainly use in serialization.
  21374. * @returns the class name
  21375. */
  21376. getClassName(): string;
  21377. /**
  21378. * Checks if the material is ready to render the requested sub mesh
  21379. * @param mesh Define the mesh the submesh belongs to
  21380. * @param subMesh Define the sub mesh to look readyness for
  21381. * @param useInstances Define whether or not the material is used with instances
  21382. * @returns true if ready, otherwise false
  21383. */
  21384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21385. /**
  21386. * Clones the current material and its related sub materials
  21387. * @param name Define the name of the newly cloned material
  21388. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21389. * @returns the cloned material
  21390. */
  21391. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21392. /**
  21393. * Serializes the materials into a JSON representation.
  21394. * @returns the JSON representation
  21395. */
  21396. serialize(): any;
  21397. /**
  21398. * Dispose the material and release its associated resources
  21399. * @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)
  21400. * @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)
  21401. * @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)
  21402. */
  21403. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21404. /**
  21405. * Creates a MultiMaterial from parsed MultiMaterial data.
  21406. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21407. * @param scene defines the hosting scene
  21408. * @returns a new MultiMaterial
  21409. */
  21410. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21411. }
  21412. }
  21413. declare module BABYLON {
  21414. /**
  21415. * Base class for submeshes
  21416. */
  21417. export class BaseSubMesh {
  21418. /** @hidden */
  21419. _materialDefines: Nullable<MaterialDefines>;
  21420. /** @hidden */
  21421. _materialEffect: Nullable<Effect>;
  21422. /**
  21423. * Gets material defines used by the effect associated to the sub mesh
  21424. */
  21425. get materialDefines(): Nullable<MaterialDefines>;
  21426. /**
  21427. * Sets material defines used by the effect associated to the sub mesh
  21428. */
  21429. set materialDefines(defines: Nullable<MaterialDefines>);
  21430. /**
  21431. * Gets associated effect
  21432. */
  21433. get effect(): Nullable<Effect>;
  21434. /**
  21435. * Sets associated effect (effect used to render this submesh)
  21436. * @param effect defines the effect to associate with
  21437. * @param defines defines the set of defines used to compile this effect
  21438. */
  21439. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21440. }
  21441. /**
  21442. * Defines a subdivision inside a mesh
  21443. */
  21444. export class SubMesh extends BaseSubMesh implements ICullable {
  21445. /** the material index to use */
  21446. materialIndex: number;
  21447. /** vertex index start */
  21448. verticesStart: number;
  21449. /** vertices count */
  21450. verticesCount: number;
  21451. /** index start */
  21452. indexStart: number;
  21453. /** indices count */
  21454. indexCount: number;
  21455. /** @hidden */
  21456. _linesIndexCount: number;
  21457. private _mesh;
  21458. private _renderingMesh;
  21459. private _boundingInfo;
  21460. private _linesIndexBuffer;
  21461. /** @hidden */
  21462. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21463. /** @hidden */
  21464. _trianglePlanes: Plane[];
  21465. /** @hidden */
  21466. _lastColliderTransformMatrix: Nullable<Matrix>;
  21467. /** @hidden */
  21468. _renderId: number;
  21469. /** @hidden */
  21470. _alphaIndex: number;
  21471. /** @hidden */
  21472. _distanceToCamera: number;
  21473. /** @hidden */
  21474. _id: number;
  21475. private _currentMaterial;
  21476. /**
  21477. * Add a new submesh to a mesh
  21478. * @param materialIndex defines the material index to use
  21479. * @param verticesStart defines vertex index start
  21480. * @param verticesCount defines vertices count
  21481. * @param indexStart defines index start
  21482. * @param indexCount defines indices count
  21483. * @param mesh defines the parent mesh
  21484. * @param renderingMesh defines an optional rendering mesh
  21485. * @param createBoundingBox defines if bounding box should be created for this submesh
  21486. * @returns the new submesh
  21487. */
  21488. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21489. /**
  21490. * Creates a new submesh
  21491. * @param materialIndex defines the material index to use
  21492. * @param verticesStart defines vertex index start
  21493. * @param verticesCount defines vertices count
  21494. * @param indexStart defines index start
  21495. * @param indexCount defines indices count
  21496. * @param mesh defines the parent mesh
  21497. * @param renderingMesh defines an optional rendering mesh
  21498. * @param createBoundingBox defines if bounding box should be created for this submesh
  21499. */
  21500. constructor(
  21501. /** the material index to use */
  21502. materialIndex: number,
  21503. /** vertex index start */
  21504. verticesStart: number,
  21505. /** vertices count */
  21506. verticesCount: number,
  21507. /** index start */
  21508. indexStart: number,
  21509. /** indices count */
  21510. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21511. /**
  21512. * Returns true if this submesh covers the entire parent mesh
  21513. * @ignorenaming
  21514. */
  21515. get IsGlobal(): boolean;
  21516. /**
  21517. * Returns the submesh BoudingInfo object
  21518. * @returns current bounding info (or mesh's one if the submesh is global)
  21519. */
  21520. getBoundingInfo(): BoundingInfo;
  21521. /**
  21522. * Sets the submesh BoundingInfo
  21523. * @param boundingInfo defines the new bounding info to use
  21524. * @returns the SubMesh
  21525. */
  21526. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21527. /**
  21528. * Returns the mesh of the current submesh
  21529. * @return the parent mesh
  21530. */
  21531. getMesh(): AbstractMesh;
  21532. /**
  21533. * Returns the rendering mesh of the submesh
  21534. * @returns the rendering mesh (could be different from parent mesh)
  21535. */
  21536. getRenderingMesh(): Mesh;
  21537. /**
  21538. * Returns the submesh material
  21539. * @returns null or the current material
  21540. */
  21541. getMaterial(): Nullable<Material>;
  21542. /**
  21543. * Sets a new updated BoundingInfo object to the submesh
  21544. * @param data defines an optional position array to use to determine the bounding info
  21545. * @returns the SubMesh
  21546. */
  21547. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21548. /** @hidden */
  21549. _checkCollision(collider: Collider): boolean;
  21550. /**
  21551. * Updates the submesh BoundingInfo
  21552. * @param world defines the world matrix to use to update the bounding info
  21553. * @returns the submesh
  21554. */
  21555. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21556. /**
  21557. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21558. * @param frustumPlanes defines the frustum planes
  21559. * @returns true if the submesh is intersecting with the frustum
  21560. */
  21561. isInFrustum(frustumPlanes: Plane[]): boolean;
  21562. /**
  21563. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21564. * @param frustumPlanes defines the frustum planes
  21565. * @returns true if the submesh is inside the frustum
  21566. */
  21567. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21568. /**
  21569. * Renders the submesh
  21570. * @param enableAlphaMode defines if alpha needs to be used
  21571. * @returns the submesh
  21572. */
  21573. render(enableAlphaMode: boolean): SubMesh;
  21574. /**
  21575. * @hidden
  21576. */
  21577. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21578. /**
  21579. * Checks if the submesh intersects with a ray
  21580. * @param ray defines the ray to test
  21581. * @returns true is the passed ray intersects the submesh bounding box
  21582. */
  21583. canIntersects(ray: Ray): boolean;
  21584. /**
  21585. * Intersects current submesh with a ray
  21586. * @param ray defines the ray to test
  21587. * @param positions defines mesh's positions array
  21588. * @param indices defines mesh's indices array
  21589. * @param fastCheck defines if only bounding info should be used
  21590. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21591. * @returns intersection info or null if no intersection
  21592. */
  21593. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21594. /** @hidden */
  21595. private _intersectLines;
  21596. /** @hidden */
  21597. private _intersectUnIndexedLines;
  21598. /** @hidden */
  21599. private _intersectTriangles;
  21600. /** @hidden */
  21601. private _intersectUnIndexedTriangles;
  21602. /** @hidden */
  21603. _rebuild(): void;
  21604. /**
  21605. * Creates a new submesh from the passed mesh
  21606. * @param newMesh defines the new hosting mesh
  21607. * @param newRenderingMesh defines an optional rendering mesh
  21608. * @returns the new submesh
  21609. */
  21610. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21611. /**
  21612. * Release associated resources
  21613. */
  21614. dispose(): void;
  21615. /**
  21616. * Gets the class name
  21617. * @returns the string "SubMesh".
  21618. */
  21619. getClassName(): string;
  21620. /**
  21621. * Creates a new submesh from indices data
  21622. * @param materialIndex the index of the main mesh material
  21623. * @param startIndex the index where to start the copy in the mesh indices array
  21624. * @param indexCount the number of indices to copy then from the startIndex
  21625. * @param mesh the main mesh to create the submesh from
  21626. * @param renderingMesh the optional rendering mesh
  21627. * @returns a new submesh
  21628. */
  21629. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21630. }
  21631. }
  21632. declare module BABYLON {
  21633. /**
  21634. * Class used to represent data loading progression
  21635. */
  21636. export class SceneLoaderFlags {
  21637. private static _ForceFullSceneLoadingForIncremental;
  21638. private static _ShowLoadingScreen;
  21639. private static _CleanBoneMatrixWeights;
  21640. private static _loggingLevel;
  21641. /**
  21642. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21643. */
  21644. static get ForceFullSceneLoadingForIncremental(): boolean;
  21645. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21646. /**
  21647. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21648. */
  21649. static get ShowLoadingScreen(): boolean;
  21650. static set ShowLoadingScreen(value: boolean);
  21651. /**
  21652. * Defines the current logging level (while loading the scene)
  21653. * @ignorenaming
  21654. */
  21655. static get loggingLevel(): number;
  21656. static set loggingLevel(value: number);
  21657. /**
  21658. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21659. */
  21660. static get CleanBoneMatrixWeights(): boolean;
  21661. static set CleanBoneMatrixWeights(value: boolean);
  21662. }
  21663. }
  21664. declare module BABYLON {
  21665. /**
  21666. * Class used to store geometry data (vertex buffers + index buffer)
  21667. */
  21668. export class Geometry implements IGetSetVerticesData {
  21669. /**
  21670. * Gets or sets the ID of the geometry
  21671. */
  21672. id: string;
  21673. /**
  21674. * Gets or sets the unique ID of the geometry
  21675. */
  21676. uniqueId: number;
  21677. /**
  21678. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21679. */
  21680. delayLoadState: number;
  21681. /**
  21682. * Gets the file containing the data to load when running in delay load state
  21683. */
  21684. delayLoadingFile: Nullable<string>;
  21685. /**
  21686. * Callback called when the geometry is updated
  21687. */
  21688. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21689. private _scene;
  21690. private _engine;
  21691. private _meshes;
  21692. private _totalVertices;
  21693. /** @hidden */
  21694. _indices: IndicesArray;
  21695. /** @hidden */
  21696. _vertexBuffers: {
  21697. [key: string]: VertexBuffer;
  21698. };
  21699. private _isDisposed;
  21700. private _extend;
  21701. private _boundingBias;
  21702. /** @hidden */
  21703. _delayInfo: Array<string>;
  21704. private _indexBuffer;
  21705. private _indexBufferIsUpdatable;
  21706. /** @hidden */
  21707. _boundingInfo: Nullable<BoundingInfo>;
  21708. /** @hidden */
  21709. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21710. /** @hidden */
  21711. _softwareSkinningFrameId: number;
  21712. private _vertexArrayObjects;
  21713. private _updatable;
  21714. /** @hidden */
  21715. _positions: Nullable<Vector3[]>;
  21716. /**
  21717. * 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
  21718. */
  21719. get boundingBias(): Vector2;
  21720. /**
  21721. * 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
  21722. */
  21723. set boundingBias(value: Vector2);
  21724. /**
  21725. * Static function used to attach a new empty geometry to a mesh
  21726. * @param mesh defines the mesh to attach the geometry to
  21727. * @returns the new Geometry
  21728. */
  21729. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21730. /**
  21731. * Creates a new geometry
  21732. * @param id defines the unique ID
  21733. * @param scene defines the hosting scene
  21734. * @param vertexData defines the VertexData used to get geometry data
  21735. * @param updatable defines if geometry must be updatable (false by default)
  21736. * @param mesh defines the mesh that will be associated with the geometry
  21737. */
  21738. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21739. /**
  21740. * Gets the current extend of the geometry
  21741. */
  21742. get extend(): {
  21743. minimum: Vector3;
  21744. maximum: Vector3;
  21745. };
  21746. /**
  21747. * Gets the hosting scene
  21748. * @returns the hosting Scene
  21749. */
  21750. getScene(): Scene;
  21751. /**
  21752. * Gets the hosting engine
  21753. * @returns the hosting Engine
  21754. */
  21755. getEngine(): Engine;
  21756. /**
  21757. * Defines if the geometry is ready to use
  21758. * @returns true if the geometry is ready to be used
  21759. */
  21760. isReady(): boolean;
  21761. /**
  21762. * Gets a value indicating that the geometry should not be serialized
  21763. */
  21764. get doNotSerialize(): boolean;
  21765. /** @hidden */
  21766. _rebuild(): void;
  21767. /**
  21768. * Affects all geometry data in one call
  21769. * @param vertexData defines the geometry data
  21770. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21771. */
  21772. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21773. /**
  21774. * Set specific vertex data
  21775. * @param kind defines the data kind (Position, normal, etc...)
  21776. * @param data defines the vertex data to use
  21777. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21778. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21779. */
  21780. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21781. /**
  21782. * Removes a specific vertex data
  21783. * @param kind defines the data kind (Position, normal, etc...)
  21784. */
  21785. removeVerticesData(kind: string): void;
  21786. /**
  21787. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21788. * @param buffer defines the vertex buffer to use
  21789. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21790. */
  21791. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21792. /**
  21793. * Update a specific vertex buffer
  21794. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21795. * It will do nothing if the buffer is not updatable
  21796. * @param kind defines the data kind (Position, normal, etc...)
  21797. * @param data defines the data to use
  21798. * @param offset defines the offset in the target buffer where to store the data
  21799. * @param useBytes set to true if the offset is in bytes
  21800. */
  21801. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21802. /**
  21803. * Update a specific vertex buffer
  21804. * This function will create a new buffer if the current one is not updatable
  21805. * @param kind defines the data kind (Position, normal, etc...)
  21806. * @param data defines the data to use
  21807. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21808. */
  21809. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21810. private _updateBoundingInfo;
  21811. /** @hidden */
  21812. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21813. /**
  21814. * Gets total number of vertices
  21815. * @returns the total number of vertices
  21816. */
  21817. getTotalVertices(): number;
  21818. /**
  21819. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21820. * @param kind defines the data kind (Position, normal, etc...)
  21821. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21822. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21823. * @returns a float array containing vertex data
  21824. */
  21825. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21826. /**
  21827. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21828. * @param kind defines the data kind (Position, normal, etc...)
  21829. * @returns true if the vertex buffer with the specified kind is updatable
  21830. */
  21831. isVertexBufferUpdatable(kind: string): boolean;
  21832. /**
  21833. * Gets a specific vertex buffer
  21834. * @param kind defines the data kind (Position, normal, etc...)
  21835. * @returns a VertexBuffer
  21836. */
  21837. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21838. /**
  21839. * Returns all vertex buffers
  21840. * @return an object holding all vertex buffers indexed by kind
  21841. */
  21842. getVertexBuffers(): Nullable<{
  21843. [key: string]: VertexBuffer;
  21844. }>;
  21845. /**
  21846. * Gets a boolean indicating if specific vertex buffer is present
  21847. * @param kind defines the data kind (Position, normal, etc...)
  21848. * @returns true if data is present
  21849. */
  21850. isVerticesDataPresent(kind: string): boolean;
  21851. /**
  21852. * Gets a list of all attached data kinds (Position, normal, etc...)
  21853. * @returns a list of string containing all kinds
  21854. */
  21855. getVerticesDataKinds(): string[];
  21856. /**
  21857. * Update index buffer
  21858. * @param indices defines the indices to store in the index buffer
  21859. * @param offset defines the offset in the target buffer where to store the data
  21860. * @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)
  21861. */
  21862. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21863. /**
  21864. * Creates a new index buffer
  21865. * @param indices defines the indices to store in the index buffer
  21866. * @param totalVertices defines the total number of vertices (could be null)
  21867. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21868. */
  21869. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21870. /**
  21871. * Return the total number of indices
  21872. * @returns the total number of indices
  21873. */
  21874. getTotalIndices(): number;
  21875. /**
  21876. * Gets the index buffer array
  21877. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21878. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21879. * @returns the index buffer array
  21880. */
  21881. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21882. /**
  21883. * Gets the index buffer
  21884. * @return the index buffer
  21885. */
  21886. getIndexBuffer(): Nullable<DataBuffer>;
  21887. /** @hidden */
  21888. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21889. /**
  21890. * Release the associated resources for a specific mesh
  21891. * @param mesh defines the source mesh
  21892. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21893. */
  21894. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21895. /**
  21896. * Apply current geometry to a given mesh
  21897. * @param mesh defines the mesh to apply geometry to
  21898. */
  21899. applyToMesh(mesh: Mesh): void;
  21900. private _updateExtend;
  21901. private _applyToMesh;
  21902. private notifyUpdate;
  21903. /**
  21904. * Load the geometry if it was flagged as delay loaded
  21905. * @param scene defines the hosting scene
  21906. * @param onLoaded defines a callback called when the geometry is loaded
  21907. */
  21908. load(scene: Scene, onLoaded?: () => void): void;
  21909. private _queueLoad;
  21910. /**
  21911. * Invert the geometry to move from a right handed system to a left handed one.
  21912. */
  21913. toLeftHanded(): void;
  21914. /** @hidden */
  21915. _resetPointsArrayCache(): void;
  21916. /** @hidden */
  21917. _generatePointsArray(): boolean;
  21918. /**
  21919. * Gets a value indicating if the geometry is disposed
  21920. * @returns true if the geometry was disposed
  21921. */
  21922. isDisposed(): boolean;
  21923. private _disposeVertexArrayObjects;
  21924. /**
  21925. * Free all associated resources
  21926. */
  21927. dispose(): void;
  21928. /**
  21929. * Clone the current geometry into a new geometry
  21930. * @param id defines the unique ID of the new geometry
  21931. * @returns a new geometry object
  21932. */
  21933. copy(id: string): Geometry;
  21934. /**
  21935. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21936. * @return a JSON representation of the current geometry data (without the vertices data)
  21937. */
  21938. serialize(): any;
  21939. private toNumberArray;
  21940. /**
  21941. * Serialize all vertices data into a JSON oject
  21942. * @returns a JSON representation of the current geometry data
  21943. */
  21944. serializeVerticeData(): any;
  21945. /**
  21946. * Extracts a clone of a mesh geometry
  21947. * @param mesh defines the source mesh
  21948. * @param id defines the unique ID of the new geometry object
  21949. * @returns the new geometry object
  21950. */
  21951. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21952. /**
  21953. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21954. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21955. * Be aware Math.random() could cause collisions, but:
  21956. * "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"
  21957. * @returns a string containing a new GUID
  21958. */
  21959. static RandomId(): string;
  21960. /** @hidden */
  21961. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21962. private static _CleanMatricesWeights;
  21963. /**
  21964. * Create a new geometry from persisted data (Using .babylon file format)
  21965. * @param parsedVertexData defines the persisted data
  21966. * @param scene defines the hosting scene
  21967. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21968. * @returns the new geometry object
  21969. */
  21970. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21971. }
  21972. }
  21973. declare module BABYLON {
  21974. /**
  21975. * Define an interface for all classes that will get and set the data on vertices
  21976. */
  21977. export interface IGetSetVerticesData {
  21978. /**
  21979. * Gets a boolean indicating if specific vertex data is present
  21980. * @param kind defines the vertex data kind to use
  21981. * @returns true is data kind is present
  21982. */
  21983. isVerticesDataPresent(kind: string): boolean;
  21984. /**
  21985. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21986. * @param kind defines the data kind (Position, normal, etc...)
  21987. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21988. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21989. * @returns a float array containing vertex data
  21990. */
  21991. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21992. /**
  21993. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21994. * @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.
  21995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21996. * @returns the indices array or an empty array if the mesh has no geometry
  21997. */
  21998. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21999. /**
  22000. * Set specific vertex data
  22001. * @param kind defines the data kind (Position, normal, etc...)
  22002. * @param data defines the vertex data to use
  22003. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22004. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22005. */
  22006. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22007. /**
  22008. * Update a specific associated vertex buffer
  22009. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22010. * - VertexBuffer.PositionKind
  22011. * - VertexBuffer.UVKind
  22012. * - VertexBuffer.UV2Kind
  22013. * - VertexBuffer.UV3Kind
  22014. * - VertexBuffer.UV4Kind
  22015. * - VertexBuffer.UV5Kind
  22016. * - VertexBuffer.UV6Kind
  22017. * - VertexBuffer.ColorKind
  22018. * - VertexBuffer.MatricesIndicesKind
  22019. * - VertexBuffer.MatricesIndicesExtraKind
  22020. * - VertexBuffer.MatricesWeightsKind
  22021. * - VertexBuffer.MatricesWeightsExtraKind
  22022. * @param data defines the data source
  22023. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22024. * @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)
  22025. */
  22026. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22027. /**
  22028. * Creates a new index buffer
  22029. * @param indices defines the indices to store in the index buffer
  22030. * @param totalVertices defines the total number of vertices (could be null)
  22031. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22032. */
  22033. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22034. }
  22035. /**
  22036. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22037. */
  22038. export class VertexData {
  22039. /**
  22040. * Mesh side orientation : usually the external or front surface
  22041. */
  22042. static readonly FRONTSIDE: number;
  22043. /**
  22044. * Mesh side orientation : usually the internal or back surface
  22045. */
  22046. static readonly BACKSIDE: number;
  22047. /**
  22048. * Mesh side orientation : both internal and external or front and back surfaces
  22049. */
  22050. static readonly DOUBLESIDE: number;
  22051. /**
  22052. * Mesh side orientation : by default, `FRONTSIDE`
  22053. */
  22054. static readonly DEFAULTSIDE: number;
  22055. /**
  22056. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22057. */
  22058. positions: Nullable<FloatArray>;
  22059. /**
  22060. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22061. */
  22062. normals: Nullable<FloatArray>;
  22063. /**
  22064. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22065. */
  22066. tangents: Nullable<FloatArray>;
  22067. /**
  22068. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22069. */
  22070. uvs: Nullable<FloatArray>;
  22071. /**
  22072. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22073. */
  22074. uvs2: Nullable<FloatArray>;
  22075. /**
  22076. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22077. */
  22078. uvs3: Nullable<FloatArray>;
  22079. /**
  22080. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22081. */
  22082. uvs4: Nullable<FloatArray>;
  22083. /**
  22084. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22085. */
  22086. uvs5: Nullable<FloatArray>;
  22087. /**
  22088. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22089. */
  22090. uvs6: Nullable<FloatArray>;
  22091. /**
  22092. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22093. */
  22094. colors: Nullable<FloatArray>;
  22095. /**
  22096. * 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).
  22097. */
  22098. matricesIndices: Nullable<FloatArray>;
  22099. /**
  22100. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22101. */
  22102. matricesWeights: Nullable<FloatArray>;
  22103. /**
  22104. * An array extending the number of possible indices
  22105. */
  22106. matricesIndicesExtra: Nullable<FloatArray>;
  22107. /**
  22108. * An array extending the number of possible weights when the number of indices is extended
  22109. */
  22110. matricesWeightsExtra: Nullable<FloatArray>;
  22111. /**
  22112. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22113. */
  22114. indices: Nullable<IndicesArray>;
  22115. /**
  22116. * Uses the passed data array to set the set the values for the specified kind of data
  22117. * @param data a linear array of floating numbers
  22118. * @param kind the type of data that is being set, eg positions, colors etc
  22119. */
  22120. set(data: FloatArray, kind: string): void;
  22121. /**
  22122. * Associates the vertexData to the passed Mesh.
  22123. * Sets it as updatable or not (default `false`)
  22124. * @param mesh the mesh the vertexData is applied to
  22125. * @param updatable when used and having the value true allows new data to update the vertexData
  22126. * @returns the VertexData
  22127. */
  22128. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22129. /**
  22130. * Associates the vertexData to the passed Geometry.
  22131. * Sets it as updatable or not (default `false`)
  22132. * @param geometry the geometry the vertexData is applied to
  22133. * @param updatable when used and having the value true allows new data to update the vertexData
  22134. * @returns VertexData
  22135. */
  22136. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22137. /**
  22138. * Updates the associated mesh
  22139. * @param mesh the mesh to be updated
  22140. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22141. * @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
  22142. * @returns VertexData
  22143. */
  22144. updateMesh(mesh: Mesh): VertexData;
  22145. /**
  22146. * Updates the associated geometry
  22147. * @param geometry the geometry to be updated
  22148. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22149. * @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
  22150. * @returns VertexData.
  22151. */
  22152. updateGeometry(geometry: Geometry): VertexData;
  22153. private _applyTo;
  22154. private _update;
  22155. /**
  22156. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22157. * @param matrix the transforming matrix
  22158. * @returns the VertexData
  22159. */
  22160. transform(matrix: Matrix): VertexData;
  22161. /**
  22162. * Merges the passed VertexData into the current one
  22163. * @param other the VertexData to be merged into the current one
  22164. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22165. * @returns the modified VertexData
  22166. */
  22167. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22168. private _mergeElement;
  22169. private _validate;
  22170. /**
  22171. * Serializes the VertexData
  22172. * @returns a serialized object
  22173. */
  22174. serialize(): any;
  22175. /**
  22176. * Extracts the vertexData from a mesh
  22177. * @param mesh the mesh from which to extract the VertexData
  22178. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22179. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22180. * @returns the object VertexData associated to the passed mesh
  22181. */
  22182. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22183. /**
  22184. * Extracts the vertexData from the geometry
  22185. * @param geometry the geometry from which to extract the VertexData
  22186. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22187. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22188. * @returns the object VertexData associated to the passed mesh
  22189. */
  22190. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22191. private static _ExtractFrom;
  22192. /**
  22193. * Creates the VertexData for a Ribbon
  22194. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22195. * * pathArray array of paths, each of which an array of successive Vector3
  22196. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22197. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22198. * * 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
  22199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22200. * * 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)
  22201. * * 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)
  22202. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22203. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22204. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22205. * @returns the VertexData of the ribbon
  22206. */
  22207. static CreateRibbon(options: {
  22208. pathArray: Vector3[][];
  22209. closeArray?: boolean;
  22210. closePath?: boolean;
  22211. offset?: number;
  22212. sideOrientation?: number;
  22213. frontUVs?: Vector4;
  22214. backUVs?: Vector4;
  22215. invertUV?: boolean;
  22216. uvs?: Vector2[];
  22217. colors?: Color4[];
  22218. }): VertexData;
  22219. /**
  22220. * Creates the VertexData for a box
  22221. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22222. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22223. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22224. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22225. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22226. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22227. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22229. * * 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)
  22230. * * 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)
  22231. * @returns the VertexData of the box
  22232. */
  22233. static CreateBox(options: {
  22234. size?: number;
  22235. width?: number;
  22236. height?: number;
  22237. depth?: number;
  22238. faceUV?: Vector4[];
  22239. faceColors?: Color4[];
  22240. sideOrientation?: number;
  22241. frontUVs?: Vector4;
  22242. backUVs?: Vector4;
  22243. }): VertexData;
  22244. /**
  22245. * Creates the VertexData for a tiled box
  22246. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22247. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22248. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22249. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22251. * @returns the VertexData of the box
  22252. */
  22253. static CreateTiledBox(options: {
  22254. pattern?: number;
  22255. width?: number;
  22256. height?: number;
  22257. depth?: number;
  22258. tileSize?: number;
  22259. tileWidth?: number;
  22260. tileHeight?: number;
  22261. alignHorizontal?: number;
  22262. alignVertical?: number;
  22263. faceUV?: Vector4[];
  22264. faceColors?: Color4[];
  22265. sideOrientation?: number;
  22266. }): VertexData;
  22267. /**
  22268. * Creates the VertexData for a tiled plane
  22269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22270. * * pattern a limited pattern arrangement depending on the number
  22271. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22272. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22273. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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)
  22276. * * 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)
  22277. * @returns the VertexData of the tiled plane
  22278. */
  22279. static CreateTiledPlane(options: {
  22280. pattern?: number;
  22281. tileSize?: number;
  22282. tileWidth?: number;
  22283. tileHeight?: number;
  22284. size?: number;
  22285. width?: number;
  22286. height?: number;
  22287. alignHorizontal?: number;
  22288. alignVertical?: number;
  22289. sideOrientation?: number;
  22290. frontUVs?: Vector4;
  22291. backUVs?: Vector4;
  22292. }): VertexData;
  22293. /**
  22294. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22295. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22296. * * segments sets the number of horizontal strips optional, default 32
  22297. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22298. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22299. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22300. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22301. * * 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
  22302. * * 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
  22303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22304. * * 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)
  22305. * * 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)
  22306. * @returns the VertexData of the ellipsoid
  22307. */
  22308. static CreateSphere(options: {
  22309. segments?: number;
  22310. diameter?: number;
  22311. diameterX?: number;
  22312. diameterY?: number;
  22313. diameterZ?: number;
  22314. arc?: number;
  22315. slice?: number;
  22316. sideOrientation?: number;
  22317. frontUVs?: Vector4;
  22318. backUVs?: Vector4;
  22319. }): VertexData;
  22320. /**
  22321. * Creates the VertexData for a cylinder, cone or prism
  22322. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22323. * * height sets the height (y direction) of the cylinder, optional, default 2
  22324. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22325. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22326. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22327. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22328. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22329. * * 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
  22330. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22331. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22332. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22333. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22335. * * 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)
  22336. * * 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)
  22337. * @returns the VertexData of the cylinder, cone or prism
  22338. */
  22339. static CreateCylinder(options: {
  22340. height?: number;
  22341. diameterTop?: number;
  22342. diameterBottom?: number;
  22343. diameter?: number;
  22344. tessellation?: number;
  22345. subdivisions?: number;
  22346. arc?: number;
  22347. faceColors?: Color4[];
  22348. faceUV?: Vector4[];
  22349. hasRings?: boolean;
  22350. enclose?: boolean;
  22351. sideOrientation?: number;
  22352. frontUVs?: Vector4;
  22353. backUVs?: Vector4;
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a torus
  22357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22358. * * diameter the diameter of the torus, optional default 1
  22359. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22360. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22362. * * 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)
  22363. * * 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)
  22364. * @returns the VertexData of the torus
  22365. */
  22366. static CreateTorus(options: {
  22367. diameter?: number;
  22368. thickness?: number;
  22369. tessellation?: number;
  22370. sideOrientation?: number;
  22371. frontUVs?: Vector4;
  22372. backUVs?: Vector4;
  22373. }): VertexData;
  22374. /**
  22375. * Creates the VertexData of the LineSystem
  22376. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22377. * - lines an array of lines, each line being an array of successive Vector3
  22378. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22379. * @returns the VertexData of the LineSystem
  22380. */
  22381. static CreateLineSystem(options: {
  22382. lines: Vector3[][];
  22383. colors?: Nullable<Color4[][]>;
  22384. }): VertexData;
  22385. /**
  22386. * Create the VertexData for a DashedLines
  22387. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22388. * - points an array successive Vector3
  22389. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22390. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22391. * - dashNb the intended total number of dashes, optional, default 200
  22392. * @returns the VertexData for the DashedLines
  22393. */
  22394. static CreateDashedLines(options: {
  22395. points: Vector3[];
  22396. dashSize?: number;
  22397. gapSize?: number;
  22398. dashNb?: number;
  22399. }): VertexData;
  22400. /**
  22401. * Creates the VertexData for a Ground
  22402. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22403. * - width the width (x direction) of the ground, optional, default 1
  22404. * - height the height (z direction) of the ground, optional, default 1
  22405. * - subdivisions the number of subdivisions per side, optional, default 1
  22406. * @returns the VertexData of the Ground
  22407. */
  22408. static CreateGround(options: {
  22409. width?: number;
  22410. height?: number;
  22411. subdivisions?: number;
  22412. subdivisionsX?: number;
  22413. subdivisionsY?: number;
  22414. }): VertexData;
  22415. /**
  22416. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22417. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22418. * * xmin the ground minimum X coordinate, optional, default -1
  22419. * * zmin the ground minimum Z coordinate, optional, default -1
  22420. * * xmax the ground maximum X coordinate, optional, default 1
  22421. * * zmax the ground maximum Z coordinate, optional, default 1
  22422. * * 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}
  22423. * * 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}
  22424. * @returns the VertexData of the TiledGround
  22425. */
  22426. static CreateTiledGround(options: {
  22427. xmin: number;
  22428. zmin: number;
  22429. xmax: number;
  22430. zmax: number;
  22431. subdivisions?: {
  22432. w: number;
  22433. h: number;
  22434. };
  22435. precision?: {
  22436. w: number;
  22437. h: number;
  22438. };
  22439. }): VertexData;
  22440. /**
  22441. * Creates the VertexData of the Ground designed from a heightmap
  22442. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22443. * * width the width (x direction) of the ground
  22444. * * height the height (z direction) of the ground
  22445. * * subdivisions the number of subdivisions per side
  22446. * * minHeight the minimum altitude on the ground, optional, default 0
  22447. * * maxHeight the maximum altitude on the ground, optional default 1
  22448. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22449. * * buffer the array holding the image color data
  22450. * * bufferWidth the width of image
  22451. * * bufferHeight the height of image
  22452. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22453. * @returns the VertexData of the Ground designed from a heightmap
  22454. */
  22455. static CreateGroundFromHeightMap(options: {
  22456. width: number;
  22457. height: number;
  22458. subdivisions: number;
  22459. minHeight: number;
  22460. maxHeight: number;
  22461. colorFilter: Color3;
  22462. buffer: Uint8Array;
  22463. bufferWidth: number;
  22464. bufferHeight: number;
  22465. alphaFilter: number;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for a Plane
  22469. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22470. * * size sets the width and height of the plane to the value of size, optional default 1
  22471. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22472. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22474. * * 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)
  22475. * * 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)
  22476. * @returns the VertexData of the box
  22477. */
  22478. static CreatePlane(options: {
  22479. size?: number;
  22480. width?: number;
  22481. height?: number;
  22482. sideOrientation?: number;
  22483. frontUVs?: Vector4;
  22484. backUVs?: Vector4;
  22485. }): VertexData;
  22486. /**
  22487. * Creates the VertexData of the Disc or regular Polygon
  22488. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22489. * * radius the radius of the disc, optional default 0.5
  22490. * * tessellation the number of polygon sides, optional, default 64
  22491. * * 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
  22492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22493. * * 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)
  22494. * * 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)
  22495. * @returns the VertexData of the box
  22496. */
  22497. static CreateDisc(options: {
  22498. radius?: number;
  22499. tessellation?: number;
  22500. arc?: number;
  22501. sideOrientation?: number;
  22502. frontUVs?: Vector4;
  22503. backUVs?: Vector4;
  22504. }): VertexData;
  22505. /**
  22506. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22507. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22508. * @param polygon a mesh built from polygonTriangulation.build()
  22509. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22510. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22511. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22512. * @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)
  22513. * @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)
  22514. * @returns the VertexData of the Polygon
  22515. */
  22516. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22517. /**
  22518. * Creates the VertexData of the IcoSphere
  22519. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22520. * * radius the radius of the IcoSphere, optional default 1
  22521. * * radiusX allows stretching in the x direction, optional, default radius
  22522. * * radiusY allows stretching in the y direction, optional, default radius
  22523. * * radiusZ allows stretching in the z direction, optional, default radius
  22524. * * flat when true creates a flat shaded mesh, optional, default true
  22525. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22526. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22527. * * 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)
  22528. * * 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)
  22529. * @returns the VertexData of the IcoSphere
  22530. */
  22531. static CreateIcoSphere(options: {
  22532. radius?: number;
  22533. radiusX?: number;
  22534. radiusY?: number;
  22535. radiusZ?: number;
  22536. flat?: boolean;
  22537. subdivisions?: number;
  22538. sideOrientation?: number;
  22539. frontUVs?: Vector4;
  22540. backUVs?: Vector4;
  22541. }): VertexData;
  22542. /**
  22543. * Creates the VertexData for a Polyhedron
  22544. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22545. * * type provided types are:
  22546. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22547. * * 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)
  22548. * * size the size of the IcoSphere, optional default 1
  22549. * * sizeX allows stretching in the x direction, optional, default size
  22550. * * sizeY allows stretching in the y direction, optional, default size
  22551. * * sizeZ allows stretching in the z direction, optional, default size
  22552. * * 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
  22553. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22554. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22555. * * flat when true creates a flat shaded mesh, optional, default true
  22556. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22558. * * 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)
  22559. * * 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)
  22560. * @returns the VertexData of the Polyhedron
  22561. */
  22562. static CreatePolyhedron(options: {
  22563. type?: number;
  22564. size?: number;
  22565. sizeX?: number;
  22566. sizeY?: number;
  22567. sizeZ?: number;
  22568. custom?: any;
  22569. faceUV?: Vector4[];
  22570. faceColors?: Color4[];
  22571. flat?: boolean;
  22572. sideOrientation?: number;
  22573. frontUVs?: Vector4;
  22574. backUVs?: Vector4;
  22575. }): VertexData;
  22576. /**
  22577. * Creates the VertexData for a TorusKnot
  22578. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22579. * * radius the radius of the torus knot, optional, default 2
  22580. * * tube the thickness of the tube, optional, default 0.5
  22581. * * radialSegments the number of sides on each tube segments, optional, default 32
  22582. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22583. * * p the number of windings around the z axis, optional, default 2
  22584. * * q the number of windings around the x axis, optional, default 3
  22585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22586. * * 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)
  22587. * * 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)
  22588. * @returns the VertexData of the Torus Knot
  22589. */
  22590. static CreateTorusKnot(options: {
  22591. radius?: number;
  22592. tube?: number;
  22593. radialSegments?: number;
  22594. tubularSegments?: number;
  22595. p?: number;
  22596. q?: number;
  22597. sideOrientation?: number;
  22598. frontUVs?: Vector4;
  22599. backUVs?: Vector4;
  22600. }): VertexData;
  22601. /**
  22602. * Compute normals for given positions and indices
  22603. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22604. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22605. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22606. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22607. * * facetNormals : optional array of facet normals (vector3)
  22608. * * facetPositions : optional array of facet positions (vector3)
  22609. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22610. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22611. * * bInfo : optional bounding info, required for facetPartitioning computation
  22612. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22613. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22614. * * useRightHandedSystem: optional boolean to for right handed system computation
  22615. * * depthSort : optional boolean to enable the facet depth sort computation
  22616. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22617. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22618. */
  22619. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22620. facetNormals?: any;
  22621. facetPositions?: any;
  22622. facetPartitioning?: any;
  22623. ratio?: number;
  22624. bInfo?: any;
  22625. bbSize?: Vector3;
  22626. subDiv?: any;
  22627. useRightHandedSystem?: boolean;
  22628. depthSort?: boolean;
  22629. distanceTo?: Vector3;
  22630. depthSortedFacets?: any;
  22631. }): void;
  22632. /** @hidden */
  22633. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22634. /**
  22635. * Applies VertexData created from the imported parameters to the geometry
  22636. * @param parsedVertexData the parsed data from an imported file
  22637. * @param geometry the geometry to apply the VertexData to
  22638. */
  22639. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22640. }
  22641. }
  22642. declare module BABYLON {
  22643. /**
  22644. * Defines a target to use with MorphTargetManager
  22645. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22646. */
  22647. export class MorphTarget implements IAnimatable {
  22648. /** defines the name of the target */
  22649. name: string;
  22650. /**
  22651. * Gets or sets the list of animations
  22652. */
  22653. animations: Animation[];
  22654. private _scene;
  22655. private _positions;
  22656. private _normals;
  22657. private _tangents;
  22658. private _uvs;
  22659. private _influence;
  22660. private _uniqueId;
  22661. /**
  22662. * Observable raised when the influence changes
  22663. */
  22664. onInfluenceChanged: Observable<boolean>;
  22665. /** @hidden */
  22666. _onDataLayoutChanged: Observable<void>;
  22667. /**
  22668. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22669. */
  22670. get influence(): number;
  22671. set influence(influence: number);
  22672. /**
  22673. * Gets or sets the id of the morph Target
  22674. */
  22675. id: string;
  22676. private _animationPropertiesOverride;
  22677. /**
  22678. * Gets or sets the animation properties override
  22679. */
  22680. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22681. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22682. /**
  22683. * Creates a new MorphTarget
  22684. * @param name defines the name of the target
  22685. * @param influence defines the influence to use
  22686. * @param scene defines the scene the morphtarget belongs to
  22687. */
  22688. constructor(
  22689. /** defines the name of the target */
  22690. name: string, influence?: number, scene?: Nullable<Scene>);
  22691. /**
  22692. * Gets the unique ID of this manager
  22693. */
  22694. get uniqueId(): number;
  22695. /**
  22696. * Gets a boolean defining if the target contains position data
  22697. */
  22698. get hasPositions(): boolean;
  22699. /**
  22700. * Gets a boolean defining if the target contains normal data
  22701. */
  22702. get hasNormals(): boolean;
  22703. /**
  22704. * Gets a boolean defining if the target contains tangent data
  22705. */
  22706. get hasTangents(): boolean;
  22707. /**
  22708. * Gets a boolean defining if the target contains texture coordinates data
  22709. */
  22710. get hasUVs(): boolean;
  22711. /**
  22712. * Affects position data to this target
  22713. * @param data defines the position data to use
  22714. */
  22715. setPositions(data: Nullable<FloatArray>): void;
  22716. /**
  22717. * Gets the position data stored in this target
  22718. * @returns a FloatArray containing the position data (or null if not present)
  22719. */
  22720. getPositions(): Nullable<FloatArray>;
  22721. /**
  22722. * Affects normal data to this target
  22723. * @param data defines the normal data to use
  22724. */
  22725. setNormals(data: Nullable<FloatArray>): void;
  22726. /**
  22727. * Gets the normal data stored in this target
  22728. * @returns a FloatArray containing the normal data (or null if not present)
  22729. */
  22730. getNormals(): Nullable<FloatArray>;
  22731. /**
  22732. * Affects tangent data to this target
  22733. * @param data defines the tangent data to use
  22734. */
  22735. setTangents(data: Nullable<FloatArray>): void;
  22736. /**
  22737. * Gets the tangent data stored in this target
  22738. * @returns a FloatArray containing the tangent data (or null if not present)
  22739. */
  22740. getTangents(): Nullable<FloatArray>;
  22741. /**
  22742. * Affects texture coordinates data to this target
  22743. * @param data defines the texture coordinates data to use
  22744. */
  22745. setUVs(data: Nullable<FloatArray>): void;
  22746. /**
  22747. * Gets the texture coordinates data stored in this target
  22748. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22749. */
  22750. getUVs(): Nullable<FloatArray>;
  22751. /**
  22752. * Clone the current target
  22753. * @returns a new MorphTarget
  22754. */
  22755. clone(): MorphTarget;
  22756. /**
  22757. * Serializes the current target into a Serialization object
  22758. * @returns the serialized object
  22759. */
  22760. serialize(): any;
  22761. /**
  22762. * Returns the string "MorphTarget"
  22763. * @returns "MorphTarget"
  22764. */
  22765. getClassName(): string;
  22766. /**
  22767. * Creates a new target from serialized data
  22768. * @param serializationObject defines the serialized data to use
  22769. * @returns a new MorphTarget
  22770. */
  22771. static Parse(serializationObject: any): MorphTarget;
  22772. /**
  22773. * Creates a MorphTarget from mesh data
  22774. * @param mesh defines the source mesh
  22775. * @param name defines the name to use for the new target
  22776. * @param influence defines the influence to attach to the target
  22777. * @returns a new MorphTarget
  22778. */
  22779. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22780. }
  22781. }
  22782. declare module BABYLON {
  22783. /**
  22784. * This class is used to deform meshes using morphing between different targets
  22785. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22786. */
  22787. export class MorphTargetManager {
  22788. private _targets;
  22789. private _targetInfluenceChangedObservers;
  22790. private _targetDataLayoutChangedObservers;
  22791. private _activeTargets;
  22792. private _scene;
  22793. private _influences;
  22794. private _supportsNormals;
  22795. private _supportsTangents;
  22796. private _supportsUVs;
  22797. private _vertexCount;
  22798. private _uniqueId;
  22799. private _tempInfluences;
  22800. /**
  22801. * Gets or sets a boolean indicating if normals must be morphed
  22802. */
  22803. enableNormalMorphing: boolean;
  22804. /**
  22805. * Gets or sets a boolean indicating if tangents must be morphed
  22806. */
  22807. enableTangentMorphing: boolean;
  22808. /**
  22809. * Gets or sets a boolean indicating if UV must be morphed
  22810. */
  22811. enableUVMorphing: boolean;
  22812. /**
  22813. * Creates a new MorphTargetManager
  22814. * @param scene defines the current scene
  22815. */
  22816. constructor(scene?: Nullable<Scene>);
  22817. /**
  22818. * Gets the unique ID of this manager
  22819. */
  22820. get uniqueId(): number;
  22821. /**
  22822. * Gets the number of vertices handled by this manager
  22823. */
  22824. get vertexCount(): number;
  22825. /**
  22826. * Gets a boolean indicating if this manager supports morphing of normals
  22827. */
  22828. get supportsNormals(): boolean;
  22829. /**
  22830. * Gets a boolean indicating if this manager supports morphing of tangents
  22831. */
  22832. get supportsTangents(): boolean;
  22833. /**
  22834. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22835. */
  22836. get supportsUVs(): boolean;
  22837. /**
  22838. * Gets the number of targets stored in this manager
  22839. */
  22840. get numTargets(): number;
  22841. /**
  22842. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22843. */
  22844. get numInfluencers(): number;
  22845. /**
  22846. * Gets the list of influences (one per target)
  22847. */
  22848. get influences(): Float32Array;
  22849. /**
  22850. * Gets the active target at specified index. An active target is a target with an influence > 0
  22851. * @param index defines the index to check
  22852. * @returns the requested target
  22853. */
  22854. getActiveTarget(index: number): MorphTarget;
  22855. /**
  22856. * Gets the target at specified index
  22857. * @param index defines the index to check
  22858. * @returns the requested target
  22859. */
  22860. getTarget(index: number): MorphTarget;
  22861. /**
  22862. * Add a new target to this manager
  22863. * @param target defines the target to add
  22864. */
  22865. addTarget(target: MorphTarget): void;
  22866. /**
  22867. * Removes a target from the manager
  22868. * @param target defines the target to remove
  22869. */
  22870. removeTarget(target: MorphTarget): void;
  22871. /**
  22872. * Clone the current manager
  22873. * @returns a new MorphTargetManager
  22874. */
  22875. clone(): MorphTargetManager;
  22876. /**
  22877. * Serializes the current manager into a Serialization object
  22878. * @returns the serialized object
  22879. */
  22880. serialize(): any;
  22881. private _syncActiveTargets;
  22882. /**
  22883. * Syncrhonize the targets with all the meshes using this morph target manager
  22884. */
  22885. synchronize(): void;
  22886. /**
  22887. * Creates a new MorphTargetManager from serialized data
  22888. * @param serializationObject defines the serialized data
  22889. * @param scene defines the hosting scene
  22890. * @returns the new MorphTargetManager
  22891. */
  22892. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22893. }
  22894. }
  22895. declare module BABYLON {
  22896. /**
  22897. * Class used to represent a specific level of detail of a mesh
  22898. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22899. */
  22900. export class MeshLODLevel {
  22901. /** Defines the distance where this level should start being displayed */
  22902. distance: number;
  22903. /** Defines the mesh to use to render this level */
  22904. mesh: Nullable<Mesh>;
  22905. /**
  22906. * Creates a new LOD level
  22907. * @param distance defines the distance where this level should star being displayed
  22908. * @param mesh defines the mesh to use to render this level
  22909. */
  22910. constructor(
  22911. /** Defines the distance where this level should start being displayed */
  22912. distance: number,
  22913. /** Defines the mesh to use to render this level */
  22914. mesh: Nullable<Mesh>);
  22915. }
  22916. }
  22917. declare module BABYLON {
  22918. /**
  22919. * Mesh representing the gorund
  22920. */
  22921. export class GroundMesh extends Mesh {
  22922. /** If octree should be generated */
  22923. generateOctree: boolean;
  22924. private _heightQuads;
  22925. /** @hidden */
  22926. _subdivisionsX: number;
  22927. /** @hidden */
  22928. _subdivisionsY: number;
  22929. /** @hidden */
  22930. _width: number;
  22931. /** @hidden */
  22932. _height: number;
  22933. /** @hidden */
  22934. _minX: number;
  22935. /** @hidden */
  22936. _maxX: number;
  22937. /** @hidden */
  22938. _minZ: number;
  22939. /** @hidden */
  22940. _maxZ: number;
  22941. constructor(name: string, scene: Scene);
  22942. /**
  22943. * "GroundMesh"
  22944. * @returns "GroundMesh"
  22945. */
  22946. getClassName(): string;
  22947. /**
  22948. * The minimum of x and y subdivisions
  22949. */
  22950. get subdivisions(): number;
  22951. /**
  22952. * X subdivisions
  22953. */
  22954. get subdivisionsX(): number;
  22955. /**
  22956. * Y subdivisions
  22957. */
  22958. get subdivisionsY(): number;
  22959. /**
  22960. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22961. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22962. * @param chunksCount the number of subdivisions for x and y
  22963. * @param octreeBlocksSize (Default: 32)
  22964. */
  22965. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22966. /**
  22967. * Returns a height (y) value in the Worl system :
  22968. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22969. * @param x x coordinate
  22970. * @param z z coordinate
  22971. * @returns the ground y position if (x, z) are outside the ground surface.
  22972. */
  22973. getHeightAtCoordinates(x: number, z: number): number;
  22974. /**
  22975. * Returns a normalized vector (Vector3) orthogonal to the ground
  22976. * at the ground coordinates (x, z) expressed in the World system.
  22977. * @param x x coordinate
  22978. * @param z z coordinate
  22979. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22980. */
  22981. getNormalAtCoordinates(x: number, z: number): Vector3;
  22982. /**
  22983. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22984. * at the ground coordinates (x, z) expressed in the World system.
  22985. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22986. * @param x x coordinate
  22987. * @param z z coordinate
  22988. * @param ref vector to store the result
  22989. * @returns the GroundMesh.
  22990. */
  22991. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22992. /**
  22993. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22994. * if the ground has been updated.
  22995. * This can be used in the render loop.
  22996. * @returns the GroundMesh.
  22997. */
  22998. updateCoordinateHeights(): GroundMesh;
  22999. private _getFacetAt;
  23000. private _initHeightQuads;
  23001. private _computeHeightQuads;
  23002. /**
  23003. * Serializes this ground mesh
  23004. * @param serializationObject object to write serialization to
  23005. */
  23006. serialize(serializationObject: any): void;
  23007. /**
  23008. * Parses a serialized ground mesh
  23009. * @param parsedMesh the serialized mesh
  23010. * @param scene the scene to create the ground mesh in
  23011. * @returns the created ground mesh
  23012. */
  23013. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23014. }
  23015. }
  23016. declare module BABYLON {
  23017. /**
  23018. * Interface for Physics-Joint data
  23019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23020. */
  23021. export interface PhysicsJointData {
  23022. /**
  23023. * The main pivot of the joint
  23024. */
  23025. mainPivot?: Vector3;
  23026. /**
  23027. * The connected pivot of the joint
  23028. */
  23029. connectedPivot?: Vector3;
  23030. /**
  23031. * The main axis of the joint
  23032. */
  23033. mainAxis?: Vector3;
  23034. /**
  23035. * The connected axis of the joint
  23036. */
  23037. connectedAxis?: Vector3;
  23038. /**
  23039. * The collision of the joint
  23040. */
  23041. collision?: boolean;
  23042. /**
  23043. * Native Oimo/Cannon/Energy data
  23044. */
  23045. nativeParams?: any;
  23046. }
  23047. /**
  23048. * This is a holder class for the physics joint created by the physics plugin
  23049. * It holds a set of functions to control the underlying joint
  23050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23051. */
  23052. export class PhysicsJoint {
  23053. /**
  23054. * The type of the physics joint
  23055. */
  23056. type: number;
  23057. /**
  23058. * The data for the physics joint
  23059. */
  23060. jointData: PhysicsJointData;
  23061. private _physicsJoint;
  23062. protected _physicsPlugin: IPhysicsEnginePlugin;
  23063. /**
  23064. * Initializes the physics joint
  23065. * @param type The type of the physics joint
  23066. * @param jointData The data for the physics joint
  23067. */
  23068. constructor(
  23069. /**
  23070. * The type of the physics joint
  23071. */
  23072. type: number,
  23073. /**
  23074. * The data for the physics joint
  23075. */
  23076. jointData: PhysicsJointData);
  23077. /**
  23078. * Gets the physics joint
  23079. */
  23080. get physicsJoint(): any;
  23081. /**
  23082. * Sets the physics joint
  23083. */
  23084. set physicsJoint(newJoint: any);
  23085. /**
  23086. * Sets the physics plugin
  23087. */
  23088. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23089. /**
  23090. * Execute a function that is physics-plugin specific.
  23091. * @param {Function} func the function that will be executed.
  23092. * It accepts two parameters: the physics world and the physics joint
  23093. */
  23094. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23095. /**
  23096. * Distance-Joint type
  23097. */
  23098. static DistanceJoint: number;
  23099. /**
  23100. * Hinge-Joint type
  23101. */
  23102. static HingeJoint: number;
  23103. /**
  23104. * Ball-and-Socket joint type
  23105. */
  23106. static BallAndSocketJoint: number;
  23107. /**
  23108. * Wheel-Joint type
  23109. */
  23110. static WheelJoint: number;
  23111. /**
  23112. * Slider-Joint type
  23113. */
  23114. static SliderJoint: number;
  23115. /**
  23116. * Prismatic-Joint type
  23117. */
  23118. static PrismaticJoint: number;
  23119. /**
  23120. * Universal-Joint type
  23121. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23122. */
  23123. static UniversalJoint: number;
  23124. /**
  23125. * Hinge-Joint 2 type
  23126. */
  23127. static Hinge2Joint: number;
  23128. /**
  23129. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23130. */
  23131. static PointToPointJoint: number;
  23132. /**
  23133. * Spring-Joint type
  23134. */
  23135. static SpringJoint: number;
  23136. /**
  23137. * Lock-Joint type
  23138. */
  23139. static LockJoint: number;
  23140. }
  23141. /**
  23142. * A class representing a physics distance joint
  23143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23144. */
  23145. export class DistanceJoint extends PhysicsJoint {
  23146. /**
  23147. *
  23148. * @param jointData The data for the Distance-Joint
  23149. */
  23150. constructor(jointData: DistanceJointData);
  23151. /**
  23152. * Update the predefined distance.
  23153. * @param maxDistance The maximum preferred distance
  23154. * @param minDistance The minimum preferred distance
  23155. */
  23156. updateDistance(maxDistance: number, minDistance?: number): void;
  23157. }
  23158. /**
  23159. * Represents a Motor-Enabled Joint
  23160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23161. */
  23162. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23163. /**
  23164. * Initializes the Motor-Enabled Joint
  23165. * @param type The type of the joint
  23166. * @param jointData The physica joint data for the joint
  23167. */
  23168. constructor(type: number, jointData: PhysicsJointData);
  23169. /**
  23170. * Set the motor values.
  23171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23172. * @param force the force to apply
  23173. * @param maxForce max force for this motor.
  23174. */
  23175. setMotor(force?: number, maxForce?: number): void;
  23176. /**
  23177. * Set the motor's limits.
  23178. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23179. * @param upperLimit The upper limit of the motor
  23180. * @param lowerLimit The lower limit of the motor
  23181. */
  23182. setLimit(upperLimit: number, lowerLimit?: number): void;
  23183. }
  23184. /**
  23185. * This class represents a single physics Hinge-Joint
  23186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23187. */
  23188. export class HingeJoint extends MotorEnabledJoint {
  23189. /**
  23190. * Initializes the Hinge-Joint
  23191. * @param jointData The joint data for the Hinge-Joint
  23192. */
  23193. constructor(jointData: PhysicsJointData);
  23194. /**
  23195. * Set the motor values.
  23196. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23197. * @param {number} force the force to apply
  23198. * @param {number} maxForce max force for this motor.
  23199. */
  23200. setMotor(force?: number, maxForce?: number): void;
  23201. /**
  23202. * Set the motor's limits.
  23203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23204. * @param upperLimit The upper limit of the motor
  23205. * @param lowerLimit The lower limit of the motor
  23206. */
  23207. setLimit(upperLimit: number, lowerLimit?: number): void;
  23208. }
  23209. /**
  23210. * This class represents a dual hinge physics joint (same as wheel joint)
  23211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23212. */
  23213. export class Hinge2Joint extends MotorEnabledJoint {
  23214. /**
  23215. * Initializes the Hinge2-Joint
  23216. * @param jointData The joint data for the Hinge2-Joint
  23217. */
  23218. constructor(jointData: PhysicsJointData);
  23219. /**
  23220. * Set the motor values.
  23221. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23222. * @param {number} targetSpeed the speed the motor is to reach
  23223. * @param {number} maxForce max force for this motor.
  23224. * @param {motorIndex} the motor's index, 0 or 1.
  23225. */
  23226. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23227. /**
  23228. * Set the motor limits.
  23229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23230. * @param {number} upperLimit the upper limit
  23231. * @param {number} lowerLimit lower limit
  23232. * @param {motorIndex} the motor's index, 0 or 1.
  23233. */
  23234. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23235. }
  23236. /**
  23237. * Interface for a motor enabled joint
  23238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23239. */
  23240. export interface IMotorEnabledJoint {
  23241. /**
  23242. * Physics joint
  23243. */
  23244. physicsJoint: any;
  23245. /**
  23246. * Sets the motor of the motor-enabled joint
  23247. * @param force The force of the motor
  23248. * @param maxForce The maximum force of the motor
  23249. * @param motorIndex The index of the motor
  23250. */
  23251. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23252. /**
  23253. * Sets the limit of the motor
  23254. * @param upperLimit The upper limit of the motor
  23255. * @param lowerLimit The lower limit of the motor
  23256. * @param motorIndex The index of the motor
  23257. */
  23258. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23259. }
  23260. /**
  23261. * Joint data for a Distance-Joint
  23262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23263. */
  23264. export interface DistanceJointData extends PhysicsJointData {
  23265. /**
  23266. * Max distance the 2 joint objects can be apart
  23267. */
  23268. maxDistance: number;
  23269. }
  23270. /**
  23271. * Joint data from a spring joint
  23272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23273. */
  23274. export interface SpringJointData extends PhysicsJointData {
  23275. /**
  23276. * Length of the spring
  23277. */
  23278. length: number;
  23279. /**
  23280. * Stiffness of the spring
  23281. */
  23282. stiffness: number;
  23283. /**
  23284. * Damping of the spring
  23285. */
  23286. damping: number;
  23287. /** this callback will be called when applying the force to the impostors. */
  23288. forceApplicationCallback: () => void;
  23289. }
  23290. }
  23291. declare module BABYLON {
  23292. /**
  23293. * Holds the data for the raycast result
  23294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23295. */
  23296. export class PhysicsRaycastResult {
  23297. private _hasHit;
  23298. private _hitDistance;
  23299. private _hitNormalWorld;
  23300. private _hitPointWorld;
  23301. private _rayFromWorld;
  23302. private _rayToWorld;
  23303. /**
  23304. * Gets if there was a hit
  23305. */
  23306. get hasHit(): boolean;
  23307. /**
  23308. * Gets the distance from the hit
  23309. */
  23310. get hitDistance(): number;
  23311. /**
  23312. * Gets the hit normal/direction in the world
  23313. */
  23314. get hitNormalWorld(): Vector3;
  23315. /**
  23316. * Gets the hit point in the world
  23317. */
  23318. get hitPointWorld(): Vector3;
  23319. /**
  23320. * Gets the ray "start point" of the ray in the world
  23321. */
  23322. get rayFromWorld(): Vector3;
  23323. /**
  23324. * Gets the ray "end point" of the ray in the world
  23325. */
  23326. get rayToWorld(): Vector3;
  23327. /**
  23328. * Sets the hit data (normal & point in world space)
  23329. * @param hitNormalWorld defines the normal in world space
  23330. * @param hitPointWorld defines the point in world space
  23331. */
  23332. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23333. /**
  23334. * Sets the distance from the start point to the hit point
  23335. * @param distance
  23336. */
  23337. setHitDistance(distance: number): void;
  23338. /**
  23339. * Calculates the distance manually
  23340. */
  23341. calculateHitDistance(): void;
  23342. /**
  23343. * Resets all the values to default
  23344. * @param from The from point on world space
  23345. * @param to The to point on world space
  23346. */
  23347. reset(from?: Vector3, to?: Vector3): void;
  23348. }
  23349. /**
  23350. * Interface for the size containing width and height
  23351. */
  23352. interface IXYZ {
  23353. /**
  23354. * X
  23355. */
  23356. x: number;
  23357. /**
  23358. * Y
  23359. */
  23360. y: number;
  23361. /**
  23362. * Z
  23363. */
  23364. z: number;
  23365. }
  23366. }
  23367. declare module BABYLON {
  23368. /**
  23369. * Interface used to describe a physics joint
  23370. */
  23371. export interface PhysicsImpostorJoint {
  23372. /** Defines the main impostor to which the joint is linked */
  23373. mainImpostor: PhysicsImpostor;
  23374. /** Defines the impostor that is connected to the main impostor using this joint */
  23375. connectedImpostor: PhysicsImpostor;
  23376. /** Defines the joint itself */
  23377. joint: PhysicsJoint;
  23378. }
  23379. /** @hidden */
  23380. export interface IPhysicsEnginePlugin {
  23381. world: any;
  23382. name: string;
  23383. setGravity(gravity: Vector3): void;
  23384. setTimeStep(timeStep: number): void;
  23385. getTimeStep(): number;
  23386. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23387. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23388. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23389. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23390. removePhysicsBody(impostor: PhysicsImpostor): void;
  23391. generateJoint(joint: PhysicsImpostorJoint): void;
  23392. removeJoint(joint: PhysicsImpostorJoint): void;
  23393. isSupported(): boolean;
  23394. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23395. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23396. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23397. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23398. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23399. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23400. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23401. getBodyMass(impostor: PhysicsImpostor): number;
  23402. getBodyFriction(impostor: PhysicsImpostor): number;
  23403. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23404. getBodyRestitution(impostor: PhysicsImpostor): number;
  23405. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23406. getBodyPressure?(impostor: PhysicsImpostor): number;
  23407. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23408. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23409. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23410. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23411. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23412. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23413. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23414. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23415. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23416. sleepBody(impostor: PhysicsImpostor): void;
  23417. wakeUpBody(impostor: PhysicsImpostor): void;
  23418. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23419. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23420. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23421. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23422. getRadius(impostor: PhysicsImpostor): number;
  23423. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23425. dispose(): void;
  23426. }
  23427. /**
  23428. * Interface used to define a physics engine
  23429. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23430. */
  23431. export interface IPhysicsEngine {
  23432. /**
  23433. * Gets the gravity vector used by the simulation
  23434. */
  23435. gravity: Vector3;
  23436. /**
  23437. * Sets the gravity vector used by the simulation
  23438. * @param gravity defines the gravity vector to use
  23439. */
  23440. setGravity(gravity: Vector3): void;
  23441. /**
  23442. * Set the time step of the physics engine.
  23443. * Default is 1/60.
  23444. * To slow it down, enter 1/600 for example.
  23445. * To speed it up, 1/30
  23446. * @param newTimeStep the new timestep to apply to this world.
  23447. */
  23448. setTimeStep(newTimeStep: number): void;
  23449. /**
  23450. * Get the time step of the physics engine.
  23451. * @returns the current time step
  23452. */
  23453. getTimeStep(): number;
  23454. /**
  23455. * Set the sub time step of the physics engine.
  23456. * Default is 0 meaning there is no sub steps
  23457. * To increase physics resolution precision, set a small value (like 1 ms)
  23458. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23459. */
  23460. setSubTimeStep(subTimeStep: number): void;
  23461. /**
  23462. * Get the sub time step of the physics engine.
  23463. * @returns the current sub time step
  23464. */
  23465. getSubTimeStep(): number;
  23466. /**
  23467. * Release all resources
  23468. */
  23469. dispose(): void;
  23470. /**
  23471. * Gets the name of the current physics plugin
  23472. * @returns the name of the plugin
  23473. */
  23474. getPhysicsPluginName(): string;
  23475. /**
  23476. * Adding a new impostor for the impostor tracking.
  23477. * This will be done by the impostor itself.
  23478. * @param impostor the impostor to add
  23479. */
  23480. addImpostor(impostor: PhysicsImpostor): void;
  23481. /**
  23482. * Remove an impostor from the engine.
  23483. * This impostor and its mesh will not longer be updated by the physics engine.
  23484. * @param impostor the impostor to remove
  23485. */
  23486. removeImpostor(impostor: PhysicsImpostor): void;
  23487. /**
  23488. * Add a joint to the physics engine
  23489. * @param mainImpostor defines the main impostor to which the joint is added.
  23490. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23491. * @param joint defines the joint that will connect both impostors.
  23492. */
  23493. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23494. /**
  23495. * Removes a joint from the simulation
  23496. * @param mainImpostor defines the impostor used with the joint
  23497. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23498. * @param joint defines the joint to remove
  23499. */
  23500. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23501. /**
  23502. * Gets the current plugin used to run the simulation
  23503. * @returns current plugin
  23504. */
  23505. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23506. /**
  23507. * Gets the list of physic impostors
  23508. * @returns an array of PhysicsImpostor
  23509. */
  23510. getImpostors(): Array<PhysicsImpostor>;
  23511. /**
  23512. * Gets the impostor for a physics enabled object
  23513. * @param object defines the object impersonated by the impostor
  23514. * @returns the PhysicsImpostor or null if not found
  23515. */
  23516. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23517. /**
  23518. * Gets the impostor for a physics body object
  23519. * @param body defines physics body used by the impostor
  23520. * @returns the PhysicsImpostor or null if not found
  23521. */
  23522. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23523. /**
  23524. * Does a raycast in the physics world
  23525. * @param from when should the ray start?
  23526. * @param to when should the ray end?
  23527. * @returns PhysicsRaycastResult
  23528. */
  23529. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23530. /**
  23531. * Called by the scene. No need to call it.
  23532. * @param delta defines the timespam between frames
  23533. */
  23534. _step(delta: number): void;
  23535. }
  23536. }
  23537. declare module BABYLON {
  23538. /**
  23539. * The interface for the physics imposter parameters
  23540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23541. */
  23542. export interface PhysicsImpostorParameters {
  23543. /**
  23544. * The mass of the physics imposter
  23545. */
  23546. mass: number;
  23547. /**
  23548. * The friction of the physics imposter
  23549. */
  23550. friction?: number;
  23551. /**
  23552. * The coefficient of restitution of the physics imposter
  23553. */
  23554. restitution?: number;
  23555. /**
  23556. * The native options of the physics imposter
  23557. */
  23558. nativeOptions?: any;
  23559. /**
  23560. * Specifies if the parent should be ignored
  23561. */
  23562. ignoreParent?: boolean;
  23563. /**
  23564. * Specifies if bi-directional transformations should be disabled
  23565. */
  23566. disableBidirectionalTransformation?: boolean;
  23567. /**
  23568. * The pressure inside the physics imposter, soft object only
  23569. */
  23570. pressure?: number;
  23571. /**
  23572. * The stiffness the physics imposter, soft object only
  23573. */
  23574. stiffness?: number;
  23575. /**
  23576. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23577. */
  23578. velocityIterations?: number;
  23579. /**
  23580. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23581. */
  23582. positionIterations?: number;
  23583. /**
  23584. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23585. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23586. * Add to fix multiple points
  23587. */
  23588. fixedPoints?: number;
  23589. /**
  23590. * The collision margin around a soft object
  23591. */
  23592. margin?: number;
  23593. /**
  23594. * The collision margin around a soft object
  23595. */
  23596. damping?: number;
  23597. /**
  23598. * The path for a rope based on an extrusion
  23599. */
  23600. path?: any;
  23601. /**
  23602. * The shape of an extrusion used for a rope based on an extrusion
  23603. */
  23604. shape?: any;
  23605. }
  23606. /**
  23607. * Interface for a physics-enabled object
  23608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23609. */
  23610. export interface IPhysicsEnabledObject {
  23611. /**
  23612. * The position of the physics-enabled object
  23613. */
  23614. position: Vector3;
  23615. /**
  23616. * The rotation of the physics-enabled object
  23617. */
  23618. rotationQuaternion: Nullable<Quaternion>;
  23619. /**
  23620. * The scale of the physics-enabled object
  23621. */
  23622. scaling: Vector3;
  23623. /**
  23624. * The rotation of the physics-enabled object
  23625. */
  23626. rotation?: Vector3;
  23627. /**
  23628. * The parent of the physics-enabled object
  23629. */
  23630. parent?: any;
  23631. /**
  23632. * The bounding info of the physics-enabled object
  23633. * @returns The bounding info of the physics-enabled object
  23634. */
  23635. getBoundingInfo(): BoundingInfo;
  23636. /**
  23637. * Computes the world matrix
  23638. * @param force Specifies if the world matrix should be computed by force
  23639. * @returns A world matrix
  23640. */
  23641. computeWorldMatrix(force: boolean): Matrix;
  23642. /**
  23643. * Gets the world matrix
  23644. * @returns A world matrix
  23645. */
  23646. getWorldMatrix?(): Matrix;
  23647. /**
  23648. * Gets the child meshes
  23649. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23650. * @returns An array of abstract meshes
  23651. */
  23652. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23653. /**
  23654. * Gets the vertex data
  23655. * @param kind The type of vertex data
  23656. * @returns A nullable array of numbers, or a float32 array
  23657. */
  23658. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23659. /**
  23660. * Gets the indices from the mesh
  23661. * @returns A nullable array of index arrays
  23662. */
  23663. getIndices?(): Nullable<IndicesArray>;
  23664. /**
  23665. * Gets the scene from the mesh
  23666. * @returns the indices array or null
  23667. */
  23668. getScene?(): Scene;
  23669. /**
  23670. * Gets the absolute position from the mesh
  23671. * @returns the absolute position
  23672. */
  23673. getAbsolutePosition(): Vector3;
  23674. /**
  23675. * Gets the absolute pivot point from the mesh
  23676. * @returns the absolute pivot point
  23677. */
  23678. getAbsolutePivotPoint(): Vector3;
  23679. /**
  23680. * Rotates the mesh
  23681. * @param axis The axis of rotation
  23682. * @param amount The amount of rotation
  23683. * @param space The space of the rotation
  23684. * @returns The rotation transform node
  23685. */
  23686. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23687. /**
  23688. * Translates the mesh
  23689. * @param axis The axis of translation
  23690. * @param distance The distance of translation
  23691. * @param space The space of the translation
  23692. * @returns The transform node
  23693. */
  23694. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23695. /**
  23696. * Sets the absolute position of the mesh
  23697. * @param absolutePosition The absolute position of the mesh
  23698. * @returns The transform node
  23699. */
  23700. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23701. /**
  23702. * Gets the class name of the mesh
  23703. * @returns The class name
  23704. */
  23705. getClassName(): string;
  23706. }
  23707. /**
  23708. * Represents a physics imposter
  23709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23710. */
  23711. export class PhysicsImpostor {
  23712. /**
  23713. * The physics-enabled object used as the physics imposter
  23714. */
  23715. object: IPhysicsEnabledObject;
  23716. /**
  23717. * The type of the physics imposter
  23718. */
  23719. type: number;
  23720. private _options;
  23721. private _scene?;
  23722. /**
  23723. * The default object size of the imposter
  23724. */
  23725. static DEFAULT_OBJECT_SIZE: Vector3;
  23726. /**
  23727. * The identity quaternion of the imposter
  23728. */
  23729. static IDENTITY_QUATERNION: Quaternion;
  23730. /** @hidden */
  23731. _pluginData: any;
  23732. private _physicsEngine;
  23733. private _physicsBody;
  23734. private _bodyUpdateRequired;
  23735. private _onBeforePhysicsStepCallbacks;
  23736. private _onAfterPhysicsStepCallbacks;
  23737. /** @hidden */
  23738. _onPhysicsCollideCallbacks: Array<{
  23739. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23740. otherImpostors: Array<PhysicsImpostor>;
  23741. }>;
  23742. private _deltaPosition;
  23743. private _deltaRotation;
  23744. private _deltaRotationConjugated;
  23745. /** @hidden */
  23746. _isFromLine: boolean;
  23747. private _parent;
  23748. private _isDisposed;
  23749. private static _tmpVecs;
  23750. private static _tmpQuat;
  23751. /**
  23752. * Specifies if the physics imposter is disposed
  23753. */
  23754. get isDisposed(): boolean;
  23755. /**
  23756. * Gets the mass of the physics imposter
  23757. */
  23758. get mass(): number;
  23759. set mass(value: number);
  23760. /**
  23761. * Gets the coefficient of friction
  23762. */
  23763. get friction(): number;
  23764. /**
  23765. * Sets the coefficient of friction
  23766. */
  23767. set friction(value: number);
  23768. /**
  23769. * Gets the coefficient of restitution
  23770. */
  23771. get restitution(): number;
  23772. /**
  23773. * Sets the coefficient of restitution
  23774. */
  23775. set restitution(value: number);
  23776. /**
  23777. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23778. */
  23779. get pressure(): number;
  23780. /**
  23781. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23782. */
  23783. set pressure(value: number);
  23784. /**
  23785. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23786. */
  23787. get stiffness(): number;
  23788. /**
  23789. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23790. */
  23791. set stiffness(value: number);
  23792. /**
  23793. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23794. */
  23795. get velocityIterations(): number;
  23796. /**
  23797. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23798. */
  23799. set velocityIterations(value: number);
  23800. /**
  23801. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23802. */
  23803. get positionIterations(): number;
  23804. /**
  23805. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23806. */
  23807. set positionIterations(value: number);
  23808. /**
  23809. * The unique id of the physics imposter
  23810. * set by the physics engine when adding this impostor to the array
  23811. */
  23812. uniqueId: number;
  23813. /**
  23814. * @hidden
  23815. */
  23816. soft: boolean;
  23817. /**
  23818. * @hidden
  23819. */
  23820. segments: number;
  23821. private _joints;
  23822. /**
  23823. * Initializes the physics imposter
  23824. * @param object The physics-enabled object used as the physics imposter
  23825. * @param type The type of the physics imposter
  23826. * @param _options The options for the physics imposter
  23827. * @param _scene The Babylon scene
  23828. */
  23829. constructor(
  23830. /**
  23831. * The physics-enabled object used as the physics imposter
  23832. */
  23833. object: IPhysicsEnabledObject,
  23834. /**
  23835. * The type of the physics imposter
  23836. */
  23837. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23838. /**
  23839. * This function will completly initialize this impostor.
  23840. * It will create a new body - but only if this mesh has no parent.
  23841. * If it has, this impostor will not be used other than to define the impostor
  23842. * of the child mesh.
  23843. * @hidden
  23844. */
  23845. _init(): void;
  23846. private _getPhysicsParent;
  23847. /**
  23848. * Should a new body be generated.
  23849. * @returns boolean specifying if body initialization is required
  23850. */
  23851. isBodyInitRequired(): boolean;
  23852. /**
  23853. * Sets the updated scaling
  23854. * @param updated Specifies if the scaling is updated
  23855. */
  23856. setScalingUpdated(): void;
  23857. /**
  23858. * Force a regeneration of this or the parent's impostor's body.
  23859. * Use under cautious - This will remove all joints already implemented.
  23860. */
  23861. forceUpdate(): void;
  23862. /**
  23863. * Gets the body that holds this impostor. Either its own, or its parent.
  23864. */
  23865. get physicsBody(): any;
  23866. /**
  23867. * Get the parent of the physics imposter
  23868. * @returns Physics imposter or null
  23869. */
  23870. get parent(): Nullable<PhysicsImpostor>;
  23871. /**
  23872. * Sets the parent of the physics imposter
  23873. */
  23874. set parent(value: Nullable<PhysicsImpostor>);
  23875. /**
  23876. * Set the physics body. Used mainly by the physics engine/plugin
  23877. */
  23878. set physicsBody(physicsBody: any);
  23879. /**
  23880. * Resets the update flags
  23881. */
  23882. resetUpdateFlags(): void;
  23883. /**
  23884. * Gets the object extend size
  23885. * @returns the object extend size
  23886. */
  23887. getObjectExtendSize(): Vector3;
  23888. /**
  23889. * Gets the object center
  23890. * @returns The object center
  23891. */
  23892. getObjectCenter(): Vector3;
  23893. /**
  23894. * Get a specific parameter from the options parameters
  23895. * @param paramName The object parameter name
  23896. * @returns The object parameter
  23897. */
  23898. getParam(paramName: string): any;
  23899. /**
  23900. * Sets a specific parameter in the options given to the physics plugin
  23901. * @param paramName The parameter name
  23902. * @param value The value of the parameter
  23903. */
  23904. setParam(paramName: string, value: number): void;
  23905. /**
  23906. * Specifically change the body's mass option. Won't recreate the physics body object
  23907. * @param mass The mass of the physics imposter
  23908. */
  23909. setMass(mass: number): void;
  23910. /**
  23911. * Gets the linear velocity
  23912. * @returns linear velocity or null
  23913. */
  23914. getLinearVelocity(): Nullable<Vector3>;
  23915. /**
  23916. * Sets the linear velocity
  23917. * @param velocity linear velocity or null
  23918. */
  23919. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23920. /**
  23921. * Gets the angular velocity
  23922. * @returns angular velocity or null
  23923. */
  23924. getAngularVelocity(): Nullable<Vector3>;
  23925. /**
  23926. * Sets the angular velocity
  23927. * @param velocity The velocity or null
  23928. */
  23929. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23930. /**
  23931. * Execute a function with the physics plugin native code
  23932. * Provide a function the will have two variables - the world object and the physics body object
  23933. * @param func The function to execute with the physics plugin native code
  23934. */
  23935. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23936. /**
  23937. * Register a function that will be executed before the physics world is stepping forward
  23938. * @param func The function to execute before the physics world is stepped forward
  23939. */
  23940. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23941. /**
  23942. * Unregister a function that will be executed before the physics world is stepping forward
  23943. * @param func The function to execute before the physics world is stepped forward
  23944. */
  23945. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23946. /**
  23947. * Register a function that will be executed after the physics step
  23948. * @param func The function to execute after physics step
  23949. */
  23950. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23951. /**
  23952. * Unregisters a function that will be executed after the physics step
  23953. * @param func The function to execute after physics step
  23954. */
  23955. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23956. /**
  23957. * register a function that will be executed when this impostor collides against a different body
  23958. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23959. * @param func Callback that is executed on collision
  23960. */
  23961. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23962. /**
  23963. * Unregisters the physics imposter on contact
  23964. * @param collideAgainst The physics object to collide against
  23965. * @param func Callback to execute on collision
  23966. */
  23967. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23968. private _tmpQuat;
  23969. private _tmpQuat2;
  23970. /**
  23971. * Get the parent rotation
  23972. * @returns The parent rotation
  23973. */
  23974. getParentsRotation(): Quaternion;
  23975. /**
  23976. * this function is executed by the physics engine.
  23977. */
  23978. beforeStep: () => void;
  23979. /**
  23980. * this function is executed by the physics engine
  23981. */
  23982. afterStep: () => void;
  23983. /**
  23984. * Legacy collision detection event support
  23985. */
  23986. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23987. /**
  23988. * event and body object due to cannon's event-based architecture.
  23989. */
  23990. onCollide: (e: {
  23991. body: any;
  23992. }) => void;
  23993. /**
  23994. * Apply a force
  23995. * @param force The force to apply
  23996. * @param contactPoint The contact point for the force
  23997. * @returns The physics imposter
  23998. */
  23999. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24000. /**
  24001. * Apply an impulse
  24002. * @param force The impulse force
  24003. * @param contactPoint The contact point for the impulse force
  24004. * @returns The physics imposter
  24005. */
  24006. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24007. /**
  24008. * A help function to create a joint
  24009. * @param otherImpostor A physics imposter used to create a joint
  24010. * @param jointType The type of joint
  24011. * @param jointData The data for the joint
  24012. * @returns The physics imposter
  24013. */
  24014. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24015. /**
  24016. * Add a joint to this impostor with a different impostor
  24017. * @param otherImpostor A physics imposter used to add a joint
  24018. * @param joint The joint to add
  24019. * @returns The physics imposter
  24020. */
  24021. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24022. /**
  24023. * Add an anchor to a cloth impostor
  24024. * @param otherImpostor rigid impostor to anchor to
  24025. * @param width ratio across width from 0 to 1
  24026. * @param height ratio up height from 0 to 1
  24027. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24028. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24029. * @returns impostor the soft imposter
  24030. */
  24031. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24032. /**
  24033. * Add a hook to a rope impostor
  24034. * @param otherImpostor rigid impostor to anchor to
  24035. * @param length ratio across rope from 0 to 1
  24036. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24037. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24038. * @returns impostor the rope imposter
  24039. */
  24040. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24041. /**
  24042. * Will keep this body still, in a sleep mode.
  24043. * @returns the physics imposter
  24044. */
  24045. sleep(): PhysicsImpostor;
  24046. /**
  24047. * Wake the body up.
  24048. * @returns The physics imposter
  24049. */
  24050. wakeUp(): PhysicsImpostor;
  24051. /**
  24052. * Clones the physics imposter
  24053. * @param newObject The physics imposter clones to this physics-enabled object
  24054. * @returns A nullable physics imposter
  24055. */
  24056. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24057. /**
  24058. * Disposes the physics imposter
  24059. */
  24060. dispose(): void;
  24061. /**
  24062. * Sets the delta position
  24063. * @param position The delta position amount
  24064. */
  24065. setDeltaPosition(position: Vector3): void;
  24066. /**
  24067. * Sets the delta rotation
  24068. * @param rotation The delta rotation amount
  24069. */
  24070. setDeltaRotation(rotation: Quaternion): void;
  24071. /**
  24072. * Gets the box size of the physics imposter and stores the result in the input parameter
  24073. * @param result Stores the box size
  24074. * @returns The physics imposter
  24075. */
  24076. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24077. /**
  24078. * Gets the radius of the physics imposter
  24079. * @returns Radius of the physics imposter
  24080. */
  24081. getRadius(): number;
  24082. /**
  24083. * Sync a bone with this impostor
  24084. * @param bone The bone to sync to the impostor.
  24085. * @param boneMesh The mesh that the bone is influencing.
  24086. * @param jointPivot The pivot of the joint / bone in local space.
  24087. * @param distToJoint Optional distance from the impostor to the joint.
  24088. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24089. */
  24090. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24091. /**
  24092. * Sync impostor to a bone
  24093. * @param bone The bone that the impostor will be synced to.
  24094. * @param boneMesh The mesh that the bone is influencing.
  24095. * @param jointPivot The pivot of the joint / bone in local space.
  24096. * @param distToJoint Optional distance from the impostor to the joint.
  24097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24098. * @param boneAxis Optional vector3 axis the bone is aligned with
  24099. */
  24100. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24101. /**
  24102. * No-Imposter type
  24103. */
  24104. static NoImpostor: number;
  24105. /**
  24106. * Sphere-Imposter type
  24107. */
  24108. static SphereImpostor: number;
  24109. /**
  24110. * Box-Imposter type
  24111. */
  24112. static BoxImpostor: number;
  24113. /**
  24114. * Plane-Imposter type
  24115. */
  24116. static PlaneImpostor: number;
  24117. /**
  24118. * Mesh-imposter type
  24119. */
  24120. static MeshImpostor: number;
  24121. /**
  24122. * Capsule-Impostor type (Ammo.js plugin only)
  24123. */
  24124. static CapsuleImpostor: number;
  24125. /**
  24126. * Cylinder-Imposter type
  24127. */
  24128. static CylinderImpostor: number;
  24129. /**
  24130. * Particle-Imposter type
  24131. */
  24132. static ParticleImpostor: number;
  24133. /**
  24134. * Heightmap-Imposter type
  24135. */
  24136. static HeightmapImpostor: number;
  24137. /**
  24138. * ConvexHull-Impostor type (Ammo.js plugin only)
  24139. */
  24140. static ConvexHullImpostor: number;
  24141. /**
  24142. * Custom-Imposter type (Ammo.js plugin only)
  24143. */
  24144. static CustomImpostor: number;
  24145. /**
  24146. * Rope-Imposter type
  24147. */
  24148. static RopeImpostor: number;
  24149. /**
  24150. * Cloth-Imposter type
  24151. */
  24152. static ClothImpostor: number;
  24153. /**
  24154. * Softbody-Imposter type
  24155. */
  24156. static SoftbodyImpostor: number;
  24157. }
  24158. }
  24159. declare module BABYLON {
  24160. /**
  24161. * @hidden
  24162. **/
  24163. export class _CreationDataStorage {
  24164. closePath?: boolean;
  24165. closeArray?: boolean;
  24166. idx: number[];
  24167. dashSize: number;
  24168. gapSize: number;
  24169. path3D: Path3D;
  24170. pathArray: Vector3[][];
  24171. arc: number;
  24172. radius: number;
  24173. cap: number;
  24174. tessellation: number;
  24175. }
  24176. /**
  24177. * @hidden
  24178. **/
  24179. class _InstanceDataStorage {
  24180. visibleInstances: any;
  24181. batchCache: _InstancesBatch;
  24182. instancesBufferSize: number;
  24183. instancesBuffer: Nullable<Buffer>;
  24184. instancesData: Float32Array;
  24185. overridenInstanceCount: number;
  24186. isFrozen: boolean;
  24187. previousBatch: Nullable<_InstancesBatch>;
  24188. hardwareInstancedRendering: boolean;
  24189. sideOrientation: number;
  24190. manualUpdate: boolean;
  24191. }
  24192. /**
  24193. * @hidden
  24194. **/
  24195. export class _InstancesBatch {
  24196. mustReturn: boolean;
  24197. visibleInstances: Nullable<InstancedMesh[]>[];
  24198. renderSelf: boolean[];
  24199. hardwareInstancedRendering: boolean[];
  24200. }
  24201. /**
  24202. * Class used to represent renderable models
  24203. */
  24204. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24205. /**
  24206. * Mesh side orientation : usually the external or front surface
  24207. */
  24208. static readonly FRONTSIDE: number;
  24209. /**
  24210. * Mesh side orientation : usually the internal or back surface
  24211. */
  24212. static readonly BACKSIDE: number;
  24213. /**
  24214. * Mesh side orientation : both internal and external or front and back surfaces
  24215. */
  24216. static readonly DOUBLESIDE: number;
  24217. /**
  24218. * Mesh side orientation : by default, `FRONTSIDE`
  24219. */
  24220. static readonly DEFAULTSIDE: number;
  24221. /**
  24222. * Mesh cap setting : no cap
  24223. */
  24224. static readonly NO_CAP: number;
  24225. /**
  24226. * Mesh cap setting : one cap at the beginning of the mesh
  24227. */
  24228. static readonly CAP_START: number;
  24229. /**
  24230. * Mesh cap setting : one cap at the end of the mesh
  24231. */
  24232. static readonly CAP_END: number;
  24233. /**
  24234. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24235. */
  24236. static readonly CAP_ALL: number;
  24237. /**
  24238. * Mesh pattern setting : no flip or rotate
  24239. */
  24240. static readonly NO_FLIP: number;
  24241. /**
  24242. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24243. */
  24244. static readonly FLIP_TILE: number;
  24245. /**
  24246. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24247. */
  24248. static readonly ROTATE_TILE: number;
  24249. /**
  24250. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24251. */
  24252. static readonly FLIP_ROW: number;
  24253. /**
  24254. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24255. */
  24256. static readonly ROTATE_ROW: number;
  24257. /**
  24258. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24259. */
  24260. static readonly FLIP_N_ROTATE_TILE: number;
  24261. /**
  24262. * Mesh pattern setting : rotate pattern and rotate
  24263. */
  24264. static readonly FLIP_N_ROTATE_ROW: number;
  24265. /**
  24266. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24267. */
  24268. static readonly CENTER: number;
  24269. /**
  24270. * Mesh tile positioning : part tiles on left
  24271. */
  24272. static readonly LEFT: number;
  24273. /**
  24274. * Mesh tile positioning : part tiles on right
  24275. */
  24276. static readonly RIGHT: number;
  24277. /**
  24278. * Mesh tile positioning : part tiles on top
  24279. */
  24280. static readonly TOP: number;
  24281. /**
  24282. * Mesh tile positioning : part tiles on bottom
  24283. */
  24284. static readonly BOTTOM: number;
  24285. /**
  24286. * Gets the default side orientation.
  24287. * @param orientation the orientation to value to attempt to get
  24288. * @returns the default orientation
  24289. * @hidden
  24290. */
  24291. static _GetDefaultSideOrientation(orientation?: number): number;
  24292. private _internalMeshDataInfo;
  24293. /**
  24294. * An event triggered before rendering the mesh
  24295. */
  24296. get onBeforeRenderObservable(): Observable<Mesh>;
  24297. /**
  24298. * An event triggered before binding the mesh
  24299. */
  24300. get onBeforeBindObservable(): Observable<Mesh>;
  24301. /**
  24302. * An event triggered after rendering the mesh
  24303. */
  24304. get onAfterRenderObservable(): Observable<Mesh>;
  24305. /**
  24306. * An event triggered before drawing the mesh
  24307. */
  24308. get onBeforeDrawObservable(): Observable<Mesh>;
  24309. private _onBeforeDrawObserver;
  24310. /**
  24311. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24312. */
  24313. set onBeforeDraw(callback: () => void);
  24314. get hasInstances(): boolean;
  24315. /**
  24316. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24317. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24318. */
  24319. delayLoadState: number;
  24320. /**
  24321. * Gets the list of instances created from this mesh
  24322. * it is not supposed to be modified manually.
  24323. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24324. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24325. */
  24326. instances: InstancedMesh[];
  24327. /**
  24328. * Gets the file containing delay loading data for this mesh
  24329. */
  24330. delayLoadingFile: string;
  24331. /** @hidden */
  24332. _binaryInfo: any;
  24333. /**
  24334. * User defined function used to change how LOD level selection is done
  24335. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24336. */
  24337. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24338. /**
  24339. * Gets or sets the morph target manager
  24340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24341. */
  24342. get morphTargetManager(): Nullable<MorphTargetManager>;
  24343. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24344. /** @hidden */
  24345. _creationDataStorage: Nullable<_CreationDataStorage>;
  24346. /** @hidden */
  24347. _geometry: Nullable<Geometry>;
  24348. /** @hidden */
  24349. _delayInfo: Array<string>;
  24350. /** @hidden */
  24351. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24352. /** @hidden */
  24353. _instanceDataStorage: _InstanceDataStorage;
  24354. private _effectiveMaterial;
  24355. /** @hidden */
  24356. _shouldGenerateFlatShading: boolean;
  24357. /** @hidden */
  24358. _originalBuilderSideOrientation: number;
  24359. /**
  24360. * Use this property to change the original side orientation defined at construction time
  24361. */
  24362. overrideMaterialSideOrientation: Nullable<number>;
  24363. /**
  24364. * Gets the source mesh (the one used to clone this one from)
  24365. */
  24366. get source(): Nullable<Mesh>;
  24367. /**
  24368. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24369. */
  24370. get isUnIndexed(): boolean;
  24371. set isUnIndexed(value: boolean);
  24372. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24373. get worldMatrixInstancedBuffer(): Float32Array;
  24374. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24375. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24376. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24377. /**
  24378. * @constructor
  24379. * @param name The value used by scene.getMeshByName() to do a lookup.
  24380. * @param scene The scene to add this mesh to.
  24381. * @param parent The parent of this mesh, if it has one
  24382. * @param source An optional Mesh from which geometry is shared, cloned.
  24383. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24384. * When false, achieved by calling a clone(), also passing False.
  24385. * This will make creation of children, recursive.
  24386. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24387. */
  24388. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24389. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24390. doNotInstantiate: boolean;
  24391. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24392. /**
  24393. * Gets the class name
  24394. * @returns the string "Mesh".
  24395. */
  24396. getClassName(): string;
  24397. /** @hidden */
  24398. get _isMesh(): boolean;
  24399. /**
  24400. * Returns a description of this mesh
  24401. * @param fullDetails define if full details about this mesh must be used
  24402. * @returns a descriptive string representing this mesh
  24403. */
  24404. toString(fullDetails?: boolean): string;
  24405. /** @hidden */
  24406. _unBindEffect(): void;
  24407. /**
  24408. * Gets a boolean indicating if this mesh has LOD
  24409. */
  24410. get hasLODLevels(): boolean;
  24411. /**
  24412. * Gets the list of MeshLODLevel associated with the current mesh
  24413. * @returns an array of MeshLODLevel
  24414. */
  24415. getLODLevels(): MeshLODLevel[];
  24416. private _sortLODLevels;
  24417. /**
  24418. * Add a mesh as LOD level triggered at the given distance.
  24419. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24420. * @param distance The distance from the center of the object to show this level
  24421. * @param mesh The mesh to be added as LOD level (can be null)
  24422. * @return This mesh (for chaining)
  24423. */
  24424. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24425. /**
  24426. * Returns the LOD level mesh at the passed distance or null if not found.
  24427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24428. * @param distance The distance from the center of the object to show this level
  24429. * @returns a Mesh or `null`
  24430. */
  24431. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24432. /**
  24433. * Remove a mesh from the LOD array
  24434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24435. * @param mesh defines the mesh to be removed
  24436. * @return This mesh (for chaining)
  24437. */
  24438. removeLODLevel(mesh: Mesh): Mesh;
  24439. /**
  24440. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24441. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24442. * @param camera defines the camera to use to compute distance
  24443. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24444. * @return This mesh (for chaining)
  24445. */
  24446. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24447. /**
  24448. * Gets the mesh internal Geometry object
  24449. */
  24450. get geometry(): Nullable<Geometry>;
  24451. /**
  24452. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24453. * @returns the total number of vertices
  24454. */
  24455. getTotalVertices(): number;
  24456. /**
  24457. * Returns the content of an associated vertex buffer
  24458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24459. * - VertexBuffer.PositionKind
  24460. * - VertexBuffer.UVKind
  24461. * - VertexBuffer.UV2Kind
  24462. * - VertexBuffer.UV3Kind
  24463. * - VertexBuffer.UV4Kind
  24464. * - VertexBuffer.UV5Kind
  24465. * - VertexBuffer.UV6Kind
  24466. * - VertexBuffer.ColorKind
  24467. * - VertexBuffer.MatricesIndicesKind
  24468. * - VertexBuffer.MatricesIndicesExtraKind
  24469. * - VertexBuffer.MatricesWeightsKind
  24470. * - VertexBuffer.MatricesWeightsExtraKind
  24471. * @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
  24472. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24473. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24474. */
  24475. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24476. /**
  24477. * Returns the mesh VertexBuffer object from the requested `kind`
  24478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24479. * - VertexBuffer.PositionKind
  24480. * - VertexBuffer.NormalKind
  24481. * - VertexBuffer.UVKind
  24482. * - VertexBuffer.UV2Kind
  24483. * - VertexBuffer.UV3Kind
  24484. * - VertexBuffer.UV4Kind
  24485. * - VertexBuffer.UV5Kind
  24486. * - VertexBuffer.UV6Kind
  24487. * - VertexBuffer.ColorKind
  24488. * - VertexBuffer.MatricesIndicesKind
  24489. * - VertexBuffer.MatricesIndicesExtraKind
  24490. * - VertexBuffer.MatricesWeightsKind
  24491. * - VertexBuffer.MatricesWeightsExtraKind
  24492. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24493. */
  24494. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24495. /**
  24496. * Tests if a specific vertex buffer is associated with this mesh
  24497. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24498. * - VertexBuffer.PositionKind
  24499. * - VertexBuffer.NormalKind
  24500. * - VertexBuffer.UVKind
  24501. * - VertexBuffer.UV2Kind
  24502. * - VertexBuffer.UV3Kind
  24503. * - VertexBuffer.UV4Kind
  24504. * - VertexBuffer.UV5Kind
  24505. * - VertexBuffer.UV6Kind
  24506. * - VertexBuffer.ColorKind
  24507. * - VertexBuffer.MatricesIndicesKind
  24508. * - VertexBuffer.MatricesIndicesExtraKind
  24509. * - VertexBuffer.MatricesWeightsKind
  24510. * - VertexBuffer.MatricesWeightsExtraKind
  24511. * @returns a boolean
  24512. */
  24513. isVerticesDataPresent(kind: string): boolean;
  24514. /**
  24515. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24516. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24517. * - VertexBuffer.PositionKind
  24518. * - VertexBuffer.UVKind
  24519. * - VertexBuffer.UV2Kind
  24520. * - VertexBuffer.UV3Kind
  24521. * - VertexBuffer.UV4Kind
  24522. * - VertexBuffer.UV5Kind
  24523. * - VertexBuffer.UV6Kind
  24524. * - VertexBuffer.ColorKind
  24525. * - VertexBuffer.MatricesIndicesKind
  24526. * - VertexBuffer.MatricesIndicesExtraKind
  24527. * - VertexBuffer.MatricesWeightsKind
  24528. * - VertexBuffer.MatricesWeightsExtraKind
  24529. * @returns a boolean
  24530. */
  24531. isVertexBufferUpdatable(kind: string): boolean;
  24532. /**
  24533. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24534. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24535. * - VertexBuffer.PositionKind
  24536. * - VertexBuffer.NormalKind
  24537. * - VertexBuffer.UVKind
  24538. * - VertexBuffer.UV2Kind
  24539. * - VertexBuffer.UV3Kind
  24540. * - VertexBuffer.UV4Kind
  24541. * - VertexBuffer.UV5Kind
  24542. * - VertexBuffer.UV6Kind
  24543. * - VertexBuffer.ColorKind
  24544. * - VertexBuffer.MatricesIndicesKind
  24545. * - VertexBuffer.MatricesIndicesExtraKind
  24546. * - VertexBuffer.MatricesWeightsKind
  24547. * - VertexBuffer.MatricesWeightsExtraKind
  24548. * @returns an array of strings
  24549. */
  24550. getVerticesDataKinds(): string[];
  24551. /**
  24552. * Returns a positive integer : the total number of indices in this mesh geometry.
  24553. * @returns the numner of indices or zero if the mesh has no geometry.
  24554. */
  24555. getTotalIndices(): number;
  24556. /**
  24557. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24558. * @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.
  24559. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24560. * @returns the indices array or an empty array if the mesh has no geometry
  24561. */
  24562. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24563. get isBlocked(): boolean;
  24564. /**
  24565. * Determine if the current mesh is ready to be rendered
  24566. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24567. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24568. * @returns true if all associated assets are ready (material, textures, shaders)
  24569. */
  24570. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24571. /**
  24572. * 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.
  24573. */
  24574. get areNormalsFrozen(): boolean;
  24575. /**
  24576. * 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.
  24577. * @returns the current mesh
  24578. */
  24579. freezeNormals(): Mesh;
  24580. /**
  24581. * 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
  24582. * @returns the current mesh
  24583. */
  24584. unfreezeNormals(): Mesh;
  24585. /**
  24586. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24587. */
  24588. set overridenInstanceCount(count: number);
  24589. /** @hidden */
  24590. _preActivate(): Mesh;
  24591. /** @hidden */
  24592. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24593. /** @hidden */
  24594. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24595. /**
  24596. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24597. * This means the mesh underlying bounding box and sphere are recomputed.
  24598. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24599. * @returns the current mesh
  24600. */
  24601. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24602. /** @hidden */
  24603. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24604. /**
  24605. * This function will subdivide the mesh into multiple submeshes
  24606. * @param count defines the expected number of submeshes
  24607. */
  24608. subdivide(count: number): void;
  24609. /**
  24610. * Copy a FloatArray into a specific associated vertex buffer
  24611. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24612. * - VertexBuffer.PositionKind
  24613. * - VertexBuffer.UVKind
  24614. * - VertexBuffer.UV2Kind
  24615. * - VertexBuffer.UV3Kind
  24616. * - VertexBuffer.UV4Kind
  24617. * - VertexBuffer.UV5Kind
  24618. * - VertexBuffer.UV6Kind
  24619. * - VertexBuffer.ColorKind
  24620. * - VertexBuffer.MatricesIndicesKind
  24621. * - VertexBuffer.MatricesIndicesExtraKind
  24622. * - VertexBuffer.MatricesWeightsKind
  24623. * - VertexBuffer.MatricesWeightsExtraKind
  24624. * @param data defines the data source
  24625. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24626. * @param stride defines the data stride size (can be null)
  24627. * @returns the current mesh
  24628. */
  24629. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24630. /**
  24631. * Delete a vertex buffer associated with this mesh
  24632. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24633. * - VertexBuffer.PositionKind
  24634. * - VertexBuffer.UVKind
  24635. * - VertexBuffer.UV2Kind
  24636. * - VertexBuffer.UV3Kind
  24637. * - VertexBuffer.UV4Kind
  24638. * - VertexBuffer.UV5Kind
  24639. * - VertexBuffer.UV6Kind
  24640. * - VertexBuffer.ColorKind
  24641. * - VertexBuffer.MatricesIndicesKind
  24642. * - VertexBuffer.MatricesIndicesExtraKind
  24643. * - VertexBuffer.MatricesWeightsKind
  24644. * - VertexBuffer.MatricesWeightsExtraKind
  24645. */
  24646. removeVerticesData(kind: string): void;
  24647. /**
  24648. * Flags an associated vertex buffer as updatable
  24649. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24650. * - VertexBuffer.PositionKind
  24651. * - VertexBuffer.UVKind
  24652. * - VertexBuffer.UV2Kind
  24653. * - VertexBuffer.UV3Kind
  24654. * - VertexBuffer.UV4Kind
  24655. * - VertexBuffer.UV5Kind
  24656. * - VertexBuffer.UV6Kind
  24657. * - VertexBuffer.ColorKind
  24658. * - VertexBuffer.MatricesIndicesKind
  24659. * - VertexBuffer.MatricesIndicesExtraKind
  24660. * - VertexBuffer.MatricesWeightsKind
  24661. * - VertexBuffer.MatricesWeightsExtraKind
  24662. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24663. */
  24664. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24665. /**
  24666. * Sets the mesh global Vertex Buffer
  24667. * @param buffer defines the buffer to use
  24668. * @returns the current mesh
  24669. */
  24670. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24671. /**
  24672. * Update a specific associated vertex buffer
  24673. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24674. * - VertexBuffer.PositionKind
  24675. * - VertexBuffer.UVKind
  24676. * - VertexBuffer.UV2Kind
  24677. * - VertexBuffer.UV3Kind
  24678. * - VertexBuffer.UV4Kind
  24679. * - VertexBuffer.UV5Kind
  24680. * - VertexBuffer.UV6Kind
  24681. * - VertexBuffer.ColorKind
  24682. * - VertexBuffer.MatricesIndicesKind
  24683. * - VertexBuffer.MatricesIndicesExtraKind
  24684. * - VertexBuffer.MatricesWeightsKind
  24685. * - VertexBuffer.MatricesWeightsExtraKind
  24686. * @param data defines the data source
  24687. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24688. * @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)
  24689. * @returns the current mesh
  24690. */
  24691. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24692. /**
  24693. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24694. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24695. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24696. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24697. * @returns the current mesh
  24698. */
  24699. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24700. /**
  24701. * Creates a un-shared specific occurence of the geometry for the mesh.
  24702. * @returns the current mesh
  24703. */
  24704. makeGeometryUnique(): Mesh;
  24705. /**
  24706. * Set the index buffer of this mesh
  24707. * @param indices defines the source data
  24708. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24709. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24710. * @returns the current mesh
  24711. */
  24712. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24713. /**
  24714. * Update the current index buffer
  24715. * @param indices defines the source data
  24716. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24717. * @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)
  24718. * @returns the current mesh
  24719. */
  24720. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24721. /**
  24722. * Invert the geometry to move from a right handed system to a left handed one.
  24723. * @returns the current mesh
  24724. */
  24725. toLeftHanded(): Mesh;
  24726. /** @hidden */
  24727. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24728. /** @hidden */
  24729. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24730. /**
  24731. * Registers for this mesh a javascript function called just before the rendering process
  24732. * @param func defines the function to call before rendering this mesh
  24733. * @returns the current mesh
  24734. */
  24735. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24736. /**
  24737. * Disposes a previously registered javascript function called before the rendering
  24738. * @param func defines the function to remove
  24739. * @returns the current mesh
  24740. */
  24741. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24742. /**
  24743. * Registers for this mesh a javascript function called just after the rendering is complete
  24744. * @param func defines the function to call after rendering this mesh
  24745. * @returns the current mesh
  24746. */
  24747. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24748. /**
  24749. * Disposes a previously registered javascript function called after the rendering.
  24750. * @param func defines the function to remove
  24751. * @returns the current mesh
  24752. */
  24753. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24754. /** @hidden */
  24755. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24756. /** @hidden */
  24757. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24758. /** @hidden */
  24759. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24760. /** @hidden */
  24761. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24762. /** @hidden */
  24763. _rebuild(): void;
  24764. /** @hidden */
  24765. _freeze(): void;
  24766. /** @hidden */
  24767. _unFreeze(): void;
  24768. /**
  24769. * 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
  24770. * @param subMesh defines the subMesh to render
  24771. * @param enableAlphaMode defines if alpha mode can be changed
  24772. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24773. * @returns the current mesh
  24774. */
  24775. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24776. private _onBeforeDraw;
  24777. /**
  24778. * Renormalize the mesh and patch it up if there are no weights
  24779. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24780. * However in the case of zero weights then we set just a single influence to 1.
  24781. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24782. */
  24783. cleanMatrixWeights(): void;
  24784. private normalizeSkinFourWeights;
  24785. private normalizeSkinWeightsAndExtra;
  24786. /**
  24787. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24788. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24789. * the user know there was an issue with importing the mesh
  24790. * @returns a validation object with skinned, valid and report string
  24791. */
  24792. validateSkinning(): {
  24793. skinned: boolean;
  24794. valid: boolean;
  24795. report: string;
  24796. };
  24797. /** @hidden */
  24798. _checkDelayState(): Mesh;
  24799. private _queueLoad;
  24800. /**
  24801. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24802. * A mesh is in the frustum if its bounding box intersects the frustum
  24803. * @param frustumPlanes defines the frustum to test
  24804. * @returns true if the mesh is in the frustum planes
  24805. */
  24806. isInFrustum(frustumPlanes: Plane[]): boolean;
  24807. /**
  24808. * Sets the mesh material by the material or multiMaterial `id` property
  24809. * @param id is a string identifying the material or the multiMaterial
  24810. * @returns the current mesh
  24811. */
  24812. setMaterialByID(id: string): Mesh;
  24813. /**
  24814. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24815. * @returns an array of IAnimatable
  24816. */
  24817. getAnimatables(): IAnimatable[];
  24818. /**
  24819. * Modifies the mesh geometry according to the passed transformation matrix.
  24820. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24821. * The mesh normals are modified using the same transformation.
  24822. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24823. * @param transform defines the transform matrix to use
  24824. * @see http://doc.babylonjs.com/resources/baking_transformations
  24825. * @returns the current mesh
  24826. */
  24827. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24828. /**
  24829. * Modifies the mesh geometry according to its own current World Matrix.
  24830. * The mesh World Matrix is then reset.
  24831. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24832. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24833. * @see http://doc.babylonjs.com/resources/baking_transformations
  24834. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24835. * @returns the current mesh
  24836. */
  24837. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24838. /** @hidden */
  24839. get _positions(): Nullable<Vector3[]>;
  24840. /** @hidden */
  24841. _resetPointsArrayCache(): Mesh;
  24842. /** @hidden */
  24843. _generatePointsArray(): boolean;
  24844. /**
  24845. * Returns a new Mesh object generated from the current mesh properties.
  24846. * This method must not get confused with createInstance()
  24847. * @param name is a string, the name given to the new mesh
  24848. * @param newParent can be any Node object (default `null`)
  24849. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24850. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24851. * @returns a new mesh
  24852. */
  24853. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24854. /**
  24855. * Releases resources associated with this mesh.
  24856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24858. */
  24859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24860. /** @hidden */
  24861. _disposeInstanceSpecificData(): void;
  24862. /**
  24863. * Modifies the mesh geometry according to a displacement map.
  24864. * 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.
  24865. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24866. * @param url is a string, the URL from the image file is to be downloaded.
  24867. * @param minHeight is the lower limit of the displacement.
  24868. * @param maxHeight is the upper limit of the displacement.
  24869. * @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.
  24870. * @param uvOffset is an optional vector2 used to offset UV.
  24871. * @param uvScale is an optional vector2 used to scale UV.
  24872. * @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.
  24873. * @returns the Mesh.
  24874. */
  24875. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24876. /**
  24877. * Modifies the mesh geometry according to a displacementMap buffer.
  24878. * 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.
  24879. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24880. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24881. * @param heightMapWidth is the width of the buffer image.
  24882. * @param heightMapHeight is the height of the buffer image.
  24883. * @param minHeight is the lower limit of the displacement.
  24884. * @param maxHeight is the upper limit of the displacement.
  24885. * @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.
  24886. * @param uvOffset is an optional vector2 used to offset UV.
  24887. * @param uvScale is an optional vector2 used to scale UV.
  24888. * @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.
  24889. * @returns the Mesh.
  24890. */
  24891. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24892. /**
  24893. * Modify the mesh to get a flat shading rendering.
  24894. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24895. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24896. * @returns current mesh
  24897. */
  24898. convertToFlatShadedMesh(): Mesh;
  24899. /**
  24900. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24901. * In other words, more vertices, no more indices and a single bigger VBO.
  24902. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24903. * @returns current mesh
  24904. */
  24905. convertToUnIndexedMesh(): Mesh;
  24906. /**
  24907. * Inverses facet orientations.
  24908. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24909. * @param flipNormals will also inverts the normals
  24910. * @returns current mesh
  24911. */
  24912. flipFaces(flipNormals?: boolean): Mesh;
  24913. /**
  24914. * Increase the number of facets and hence vertices in a mesh
  24915. * Vertex normals are interpolated from existing vertex normals
  24916. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24917. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24918. */
  24919. increaseVertices(numberPerEdge: number): void;
  24920. /**
  24921. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24922. * This will undo any application of covertToFlatShadedMesh
  24923. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24924. */
  24925. forceSharedVertices(): void;
  24926. /** @hidden */
  24927. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24928. /** @hidden */
  24929. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24930. /**
  24931. * Creates a new InstancedMesh object from the mesh model.
  24932. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24933. * @param name defines the name of the new instance
  24934. * @returns a new InstancedMesh
  24935. */
  24936. createInstance(name: string): InstancedMesh;
  24937. /**
  24938. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24939. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24940. * @returns the current mesh
  24941. */
  24942. synchronizeInstances(): Mesh;
  24943. /**
  24944. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24945. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24946. * This should be used together with the simplification to avoid disappearing triangles.
  24947. * @param successCallback an optional success callback to be called after the optimization finished.
  24948. * @returns the current mesh
  24949. */
  24950. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24951. /**
  24952. * Serialize current mesh
  24953. * @param serializationObject defines the object which will receive the serialization data
  24954. */
  24955. serialize(serializationObject: any): void;
  24956. /** @hidden */
  24957. _syncGeometryWithMorphTargetManager(): void;
  24958. /** @hidden */
  24959. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24960. /**
  24961. * Returns a new Mesh object parsed from the source provided.
  24962. * @param parsedMesh is the source
  24963. * @param scene defines the hosting scene
  24964. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24965. * @returns a new Mesh
  24966. */
  24967. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24968. /**
  24969. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24970. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24971. * @param name defines the name of the mesh to create
  24972. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24973. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24974. * @param closePath creates a seam between the first and the last points of each path of the path array
  24975. * @param offset is taken in account only if the `pathArray` is containing a single path
  24976. * @param scene defines the hosting scene
  24977. * @param updatable defines if the mesh must be flagged as updatable
  24978. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24979. * @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)
  24980. * @returns a new Mesh
  24981. */
  24982. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24983. /**
  24984. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24985. * @param name defines the name of the mesh to create
  24986. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24987. * @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
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @returns a new Mesh
  24992. */
  24993. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24994. /**
  24995. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24996. * @param name defines the name of the mesh to create
  24997. * @param size sets the size (float) of each box side (default 1)
  24998. * @param scene defines the hosting scene
  24999. * @param updatable defines if the mesh must be flagged as updatable
  25000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25001. * @returns a new Mesh
  25002. */
  25003. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25004. /**
  25005. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25006. * @param name defines the name of the mesh to create
  25007. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25008. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25009. * @param scene defines the hosting scene
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @returns a new Mesh
  25013. */
  25014. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25015. /**
  25016. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25017. * @param name defines the name of the mesh to create
  25018. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25019. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25020. * @param scene defines the hosting scene
  25021. * @returns a new Mesh
  25022. */
  25023. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25024. /**
  25025. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25026. * @param name defines the name of the mesh to create
  25027. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25028. * @param diameterTop set the top cap diameter (floats, default 1)
  25029. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25030. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25031. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25032. * @param scene defines the hosting scene
  25033. * @param updatable defines if the mesh must be flagged as updatable
  25034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25035. * @returns a new Mesh
  25036. */
  25037. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25038. /**
  25039. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25040. * @param name defines the name of the mesh to create
  25041. * @param diameter sets the diameter size (float) of the torus (default 1)
  25042. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25043. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25044. * @param scene defines the hosting scene
  25045. * @param updatable defines if the mesh must be flagged as updatable
  25046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25047. * @returns a new Mesh
  25048. */
  25049. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25050. /**
  25051. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25052. * @param name defines the name of the mesh to create
  25053. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25054. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25055. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25056. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25057. * @param p the number of windings on X axis (positive integers, default 2)
  25058. * @param q the number of windings on Y axis (positive integers, default 3)
  25059. * @param scene defines the hosting scene
  25060. * @param updatable defines if the mesh must be flagged as updatable
  25061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25062. * @returns a new Mesh
  25063. */
  25064. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25065. /**
  25066. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25067. * @param name defines the name of the mesh to create
  25068. * @param points is an array successive Vector3
  25069. * @param scene defines the hosting scene
  25070. * @param updatable defines if the mesh must be flagged as updatable
  25071. * @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).
  25072. * @returns a new Mesh
  25073. */
  25074. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25075. /**
  25076. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25077. * @param name defines the name of the mesh to create
  25078. * @param points is an array successive Vector3
  25079. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25080. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25081. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25082. * @param scene defines the hosting scene
  25083. * @param updatable defines if the mesh must be flagged as updatable
  25084. * @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)
  25085. * @returns a new Mesh
  25086. */
  25087. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25088. /**
  25089. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25090. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25091. * 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.
  25092. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25093. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25094. * Remember you can only change the shape positions, not their number when updating a polygon.
  25095. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25096. * @param name defines the name of the mesh to create
  25097. * @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
  25098. * @param scene defines the hosting scene
  25099. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25100. * @param updatable defines if the mesh must be flagged as updatable
  25101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25102. * @param earcutInjection can be used to inject your own earcut reference
  25103. * @returns a new Mesh
  25104. */
  25105. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25106. /**
  25107. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25108. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25109. * @param name defines the name of the mesh to create
  25110. * @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
  25111. * @param depth defines the height of extrusion
  25112. * @param scene defines the hosting scene
  25113. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25114. * @param updatable defines if the mesh must be flagged as updatable
  25115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25116. * @param earcutInjection can be used to inject your own earcut reference
  25117. * @returns a new Mesh
  25118. */
  25119. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25120. /**
  25121. * Creates an extruded shape mesh.
  25122. * 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
  25123. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25124. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25125. * @param name defines the name of the mesh to create
  25126. * @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
  25127. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25128. * @param scale is the value to scale the shape
  25129. * @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
  25130. * @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
  25131. * @param scene defines the hosting scene
  25132. * @param updatable defines if the mesh must be flagged as updatable
  25133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25134. * @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)
  25135. * @returns a new Mesh
  25136. */
  25137. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25138. /**
  25139. * Creates an custom extruded shape mesh.
  25140. * The custom extrusion is a parametric shape.
  25141. * It has no predefined shape. Its final shape will depend on the input parameters.
  25142. * Please consider using the same method from the MeshBuilder class instead
  25143. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25144. * @param name defines the name of the mesh to create
  25145. * @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
  25146. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25147. * @param scaleFunction is a custom Javascript function called on each path point
  25148. * @param rotationFunction is a custom Javascript function called on each path point
  25149. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25150. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25151. * @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
  25152. * @param scene defines the hosting scene
  25153. * @param updatable defines if the mesh must be flagged as updatable
  25154. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25155. * @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)
  25156. * @returns a new Mesh
  25157. */
  25158. 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;
  25159. /**
  25160. * Creates lathe mesh.
  25161. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25162. * Please consider using the same method from the MeshBuilder class instead
  25163. * @param name defines the name of the mesh to create
  25164. * @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
  25165. * @param radius is the radius value of the lathe
  25166. * @param tessellation is the side number of the lathe.
  25167. * @param scene defines the hosting scene
  25168. * @param updatable defines if the mesh must be flagged as updatable
  25169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25170. * @returns a new Mesh
  25171. */
  25172. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25173. /**
  25174. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25175. * @param name defines the name of the mesh to create
  25176. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25177. * @param scene defines the hosting scene
  25178. * @param updatable defines if the mesh must be flagged as updatable
  25179. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25180. * @returns a new Mesh
  25181. */
  25182. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25183. /**
  25184. * Creates a ground mesh.
  25185. * Please consider using the same method from the MeshBuilder class instead
  25186. * @param name defines the name of the mesh to create
  25187. * @param width set the width of the ground
  25188. * @param height set the height of the ground
  25189. * @param subdivisions sets the number of subdivisions per side
  25190. * @param scene defines the hosting scene
  25191. * @param updatable defines if the mesh must be flagged as updatable
  25192. * @returns a new Mesh
  25193. */
  25194. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25195. /**
  25196. * Creates a tiled ground mesh.
  25197. * Please consider using the same method from the MeshBuilder class instead
  25198. * @param name defines the name of the mesh to create
  25199. * @param xmin set the ground minimum X coordinate
  25200. * @param zmin set the ground minimum Y coordinate
  25201. * @param xmax set the ground maximum X coordinate
  25202. * @param zmax set the ground maximum Z coordinate
  25203. * @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
  25204. * @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
  25205. * @param scene defines the hosting scene
  25206. * @param updatable defines if the mesh must be flagged as updatable
  25207. * @returns a new Mesh
  25208. */
  25209. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25210. w: number;
  25211. h: number;
  25212. }, precision: {
  25213. w: number;
  25214. h: number;
  25215. }, scene: Scene, updatable?: boolean): Mesh;
  25216. /**
  25217. * Creates a ground mesh from a height map.
  25218. * Please consider using the same method from the MeshBuilder class instead
  25219. * @see http://doc.babylonjs.com/babylon101/height_map
  25220. * @param name defines the name of the mesh to create
  25221. * @param url sets the URL of the height map image resource
  25222. * @param width set the ground width size
  25223. * @param height set the ground height size
  25224. * @param subdivisions sets the number of subdivision per side
  25225. * @param minHeight is the minimum altitude on the ground
  25226. * @param maxHeight is the maximum altitude on the ground
  25227. * @param scene defines the hosting scene
  25228. * @param updatable defines if the mesh must be flagged as updatable
  25229. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25230. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25231. * @returns a new Mesh
  25232. */
  25233. 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;
  25234. /**
  25235. * Creates a tube mesh.
  25236. * The tube is a parametric shape.
  25237. * It has no predefined shape. Its final shape will depend on the input parameters.
  25238. * Please consider using the same method from the MeshBuilder class instead
  25239. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25240. * @param name defines the name of the mesh to create
  25241. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25242. * @param radius sets the tube radius size
  25243. * @param tessellation is the number of sides on the tubular surface
  25244. * @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
  25245. * @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
  25246. * @param scene defines the hosting scene
  25247. * @param updatable defines if the mesh must be flagged as updatable
  25248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25249. * @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)
  25250. * @returns a new Mesh
  25251. */
  25252. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25253. (i: number, distance: number): number;
  25254. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25255. /**
  25256. * Creates a polyhedron mesh.
  25257. * Please consider using the same method from the MeshBuilder class instead.
  25258. * * 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
  25259. * * The parameter `size` (positive float, default 1) sets the polygon size
  25260. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25261. * * 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`
  25262. * * 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
  25263. * * 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)`)
  25264. * * 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
  25265. * * 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
  25266. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25267. * * 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
  25268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25269. * @param name defines the name of the mesh to create
  25270. * @param options defines the options used to create the mesh
  25271. * @param scene defines the hosting scene
  25272. * @returns a new Mesh
  25273. */
  25274. static CreatePolyhedron(name: string, options: {
  25275. type?: number;
  25276. size?: number;
  25277. sizeX?: number;
  25278. sizeY?: number;
  25279. sizeZ?: number;
  25280. custom?: any;
  25281. faceUV?: Vector4[];
  25282. faceColors?: Color4[];
  25283. updatable?: boolean;
  25284. sideOrientation?: number;
  25285. }, scene: Scene): Mesh;
  25286. /**
  25287. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25288. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25289. * * 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`)
  25290. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25291. * * 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
  25292. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25293. * * 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
  25294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25295. * @param name defines the name of the mesh
  25296. * @param options defines the options used to create the mesh
  25297. * @param scene defines the hosting scene
  25298. * @returns a new Mesh
  25299. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25300. */
  25301. static CreateIcoSphere(name: string, options: {
  25302. radius?: number;
  25303. flat?: boolean;
  25304. subdivisions?: number;
  25305. sideOrientation?: number;
  25306. updatable?: boolean;
  25307. }, scene: Scene): Mesh;
  25308. /**
  25309. * Creates a decal mesh.
  25310. * Please consider using the same method from the MeshBuilder class instead.
  25311. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25312. * @param name defines the name of the mesh
  25313. * @param sourceMesh defines the mesh receiving the decal
  25314. * @param position sets the position of the decal in world coordinates
  25315. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25316. * @param size sets the decal scaling
  25317. * @param angle sets the angle to rotate the decal
  25318. * @returns a new Mesh
  25319. */
  25320. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25321. /**
  25322. * Prepare internal position array for software CPU skinning
  25323. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25324. */
  25325. setPositionsForCPUSkinning(): Float32Array;
  25326. /**
  25327. * Prepare internal normal array for software CPU skinning
  25328. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25329. */
  25330. setNormalsForCPUSkinning(): Float32Array;
  25331. /**
  25332. * Updates the vertex buffer by applying transformation from the bones
  25333. * @param skeleton defines the skeleton to apply to current mesh
  25334. * @returns the current mesh
  25335. */
  25336. applySkeleton(skeleton: Skeleton): Mesh;
  25337. /**
  25338. * 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
  25339. * @param meshes defines the list of meshes to scan
  25340. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25341. */
  25342. static MinMax(meshes: AbstractMesh[]): {
  25343. min: Vector3;
  25344. max: Vector3;
  25345. };
  25346. /**
  25347. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25348. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25349. * @returns a vector3
  25350. */
  25351. static Center(meshesOrMinMaxVector: {
  25352. min: Vector3;
  25353. max: Vector3;
  25354. } | AbstractMesh[]): Vector3;
  25355. /**
  25356. * Merge the array of meshes into a single mesh for performance reasons.
  25357. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25358. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25359. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25360. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25361. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25362. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25363. * @returns a new mesh
  25364. */
  25365. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25366. /** @hidden */
  25367. addInstance(instance: InstancedMesh): void;
  25368. /** @hidden */
  25369. removeInstance(instance: InstancedMesh): void;
  25370. }
  25371. }
  25372. declare module BABYLON {
  25373. /**
  25374. * This is the base class of all the camera used in the application.
  25375. * @see http://doc.babylonjs.com/features/cameras
  25376. */
  25377. export class Camera extends Node {
  25378. /** @hidden */
  25379. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25380. /**
  25381. * This is the default projection mode used by the cameras.
  25382. * It helps recreating a feeling of perspective and better appreciate depth.
  25383. * This is the best way to simulate real life cameras.
  25384. */
  25385. static readonly PERSPECTIVE_CAMERA: number;
  25386. /**
  25387. * This helps creating camera with an orthographic mode.
  25388. * 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.
  25389. */
  25390. static readonly ORTHOGRAPHIC_CAMERA: number;
  25391. /**
  25392. * This is the default FOV mode for perspective cameras.
  25393. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25394. */
  25395. static readonly FOVMODE_VERTICAL_FIXED: number;
  25396. /**
  25397. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25398. */
  25399. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25400. /**
  25401. * This specifies ther is no need for a camera rig.
  25402. * Basically only one eye is rendered corresponding to the camera.
  25403. */
  25404. static readonly RIG_MODE_NONE: number;
  25405. /**
  25406. * Simulates a camera Rig with one blue eye and one red eye.
  25407. * This can be use with 3d blue and red glasses.
  25408. */
  25409. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25410. /**
  25411. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25412. */
  25413. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25414. /**
  25415. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25416. */
  25417. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25418. /**
  25419. * Defines that both eyes of the camera will be rendered over under each other.
  25420. */
  25421. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25422. /**
  25423. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25424. */
  25425. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25426. /**
  25427. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25428. */
  25429. static readonly RIG_MODE_VR: number;
  25430. /**
  25431. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25432. */
  25433. static readonly RIG_MODE_WEBVR: number;
  25434. /**
  25435. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25436. */
  25437. static readonly RIG_MODE_CUSTOM: number;
  25438. /**
  25439. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25440. */
  25441. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25442. /**
  25443. * Define the input manager associated with the camera.
  25444. */
  25445. inputs: CameraInputsManager<Camera>;
  25446. /** @hidden */
  25447. _position: Vector3;
  25448. /**
  25449. * Define the current local position of the camera in the scene
  25450. */
  25451. get position(): Vector3;
  25452. set position(newPosition: Vector3);
  25453. /**
  25454. * The vector the camera should consider as up.
  25455. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25456. */
  25457. upVector: Vector3;
  25458. /**
  25459. * Define the current limit on the left side for an orthographic camera
  25460. * In scene unit
  25461. */
  25462. orthoLeft: Nullable<number>;
  25463. /**
  25464. * Define the current limit on the right side for an orthographic camera
  25465. * In scene unit
  25466. */
  25467. orthoRight: Nullable<number>;
  25468. /**
  25469. * Define the current limit on the bottom side for an orthographic camera
  25470. * In scene unit
  25471. */
  25472. orthoBottom: Nullable<number>;
  25473. /**
  25474. * Define the current limit on the top side for an orthographic camera
  25475. * In scene unit
  25476. */
  25477. orthoTop: Nullable<number>;
  25478. /**
  25479. * Field Of View is set in Radians. (default is 0.8)
  25480. */
  25481. fov: number;
  25482. /**
  25483. * Define the minimum distance the camera can see from.
  25484. * This is important to note that the depth buffer are not infinite and the closer it starts
  25485. * the more your scene might encounter depth fighting issue.
  25486. */
  25487. minZ: number;
  25488. /**
  25489. * Define the maximum distance the camera can see to.
  25490. * This is important to note that the depth buffer are not infinite and the further it end
  25491. * the more your scene might encounter depth fighting issue.
  25492. */
  25493. maxZ: number;
  25494. /**
  25495. * Define the default inertia of the camera.
  25496. * This helps giving a smooth feeling to the camera movement.
  25497. */
  25498. inertia: number;
  25499. /**
  25500. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25501. */
  25502. mode: number;
  25503. /**
  25504. * Define whether the camera is intermediate.
  25505. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25506. */
  25507. isIntermediate: boolean;
  25508. /**
  25509. * Define the viewport of the camera.
  25510. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25511. */
  25512. viewport: Viewport;
  25513. /**
  25514. * Restricts the camera to viewing objects with the same layerMask.
  25515. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25516. */
  25517. layerMask: number;
  25518. /**
  25519. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25520. */
  25521. fovMode: number;
  25522. /**
  25523. * Rig mode of the camera.
  25524. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25525. * This is normally controlled byt the camera themselves as internal use.
  25526. */
  25527. cameraRigMode: number;
  25528. /**
  25529. * Defines the distance between both "eyes" in case of a RIG
  25530. */
  25531. interaxialDistance: number;
  25532. /**
  25533. * Defines if stereoscopic rendering is done side by side or over under.
  25534. */
  25535. isStereoscopicSideBySide: boolean;
  25536. /**
  25537. * 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
  25538. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25539. * else in the scene. (Eg. security camera)
  25540. *
  25541. * 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)
  25542. */
  25543. customRenderTargets: RenderTargetTexture[];
  25544. /**
  25545. * When set, the camera will render to this render target instead of the default canvas
  25546. *
  25547. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25548. */
  25549. outputRenderTarget: Nullable<RenderTargetTexture>;
  25550. /**
  25551. * Observable triggered when the camera view matrix has changed.
  25552. */
  25553. onViewMatrixChangedObservable: Observable<Camera>;
  25554. /**
  25555. * Observable triggered when the camera Projection matrix has changed.
  25556. */
  25557. onProjectionMatrixChangedObservable: Observable<Camera>;
  25558. /**
  25559. * Observable triggered when the inputs have been processed.
  25560. */
  25561. onAfterCheckInputsObservable: Observable<Camera>;
  25562. /**
  25563. * Observable triggered when reset has been called and applied to the camera.
  25564. */
  25565. onRestoreStateObservable: Observable<Camera>;
  25566. /**
  25567. * Is this camera a part of a rig system?
  25568. */
  25569. isRigCamera: boolean;
  25570. /**
  25571. * If isRigCamera set to true this will be set with the parent camera.
  25572. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25573. */
  25574. rigParent?: Camera;
  25575. /** @hidden */
  25576. _cameraRigParams: any;
  25577. /** @hidden */
  25578. _rigCameras: Camera[];
  25579. /** @hidden */
  25580. _rigPostProcess: Nullable<PostProcess>;
  25581. protected _webvrViewMatrix: Matrix;
  25582. /** @hidden */
  25583. _skipRendering: boolean;
  25584. /** @hidden */
  25585. _projectionMatrix: Matrix;
  25586. /** @hidden */
  25587. _postProcesses: Nullable<PostProcess>[];
  25588. /** @hidden */
  25589. _activeMeshes: SmartArray<AbstractMesh>;
  25590. protected _globalPosition: Vector3;
  25591. /** @hidden */
  25592. _computedViewMatrix: Matrix;
  25593. private _doNotComputeProjectionMatrix;
  25594. private _transformMatrix;
  25595. private _frustumPlanes;
  25596. private _refreshFrustumPlanes;
  25597. private _storedFov;
  25598. private _stateStored;
  25599. /**
  25600. * Instantiates a new camera object.
  25601. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25602. * @see http://doc.babylonjs.com/features/cameras
  25603. * @param name Defines the name of the camera in the scene
  25604. * @param position Defines the position of the camera
  25605. * @param scene Defines the scene the camera belongs too
  25606. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25607. */
  25608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25609. /**
  25610. * Store current camera state (fov, position, etc..)
  25611. * @returns the camera
  25612. */
  25613. storeState(): Camera;
  25614. /**
  25615. * Restores the camera state values if it has been stored. You must call storeState() first
  25616. */
  25617. protected _restoreStateValues(): boolean;
  25618. /**
  25619. * Restored camera state. You must call storeState() first.
  25620. * @returns true if restored and false otherwise
  25621. */
  25622. restoreState(): boolean;
  25623. /**
  25624. * Gets the class name of the camera.
  25625. * @returns the class name
  25626. */
  25627. getClassName(): string;
  25628. /** @hidden */
  25629. readonly _isCamera: boolean;
  25630. /**
  25631. * Gets a string representation of the camera useful for debug purpose.
  25632. * @param fullDetails Defines that a more verboe level of logging is required
  25633. * @returns the string representation
  25634. */
  25635. toString(fullDetails?: boolean): string;
  25636. /**
  25637. * Gets the current world space position of the camera.
  25638. */
  25639. get globalPosition(): Vector3;
  25640. /**
  25641. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25642. * @returns the active meshe list
  25643. */
  25644. getActiveMeshes(): SmartArray<AbstractMesh>;
  25645. /**
  25646. * Check whether a mesh is part of the current active mesh list of the camera
  25647. * @param mesh Defines the mesh to check
  25648. * @returns true if active, false otherwise
  25649. */
  25650. isActiveMesh(mesh: Mesh): boolean;
  25651. /**
  25652. * Is this camera ready to be used/rendered
  25653. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25654. * @return true if the camera is ready
  25655. */
  25656. isReady(completeCheck?: boolean): boolean;
  25657. /** @hidden */
  25658. _initCache(): void;
  25659. /** @hidden */
  25660. _updateCache(ignoreParentClass?: boolean): void;
  25661. /** @hidden */
  25662. _isSynchronized(): boolean;
  25663. /** @hidden */
  25664. _isSynchronizedViewMatrix(): boolean;
  25665. /** @hidden */
  25666. _isSynchronizedProjectionMatrix(): boolean;
  25667. /**
  25668. * Attach the input controls to a specific dom element to get the input from.
  25669. * @param element Defines the element the controls should be listened from
  25670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25671. */
  25672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25673. /**
  25674. * Detach the current controls from the specified dom element.
  25675. * @param element Defines the element to stop listening the inputs from
  25676. */
  25677. detachControl(element: HTMLElement): void;
  25678. /**
  25679. * Update the camera state according to the different inputs gathered during the frame.
  25680. */
  25681. update(): void;
  25682. /** @hidden */
  25683. _checkInputs(): void;
  25684. /** @hidden */
  25685. get rigCameras(): Camera[];
  25686. /**
  25687. * Gets the post process used by the rig cameras
  25688. */
  25689. get rigPostProcess(): Nullable<PostProcess>;
  25690. /**
  25691. * Internal, gets the first post proces.
  25692. * @returns the first post process to be run on this camera.
  25693. */
  25694. _getFirstPostProcess(): Nullable<PostProcess>;
  25695. private _cascadePostProcessesToRigCams;
  25696. /**
  25697. * Attach a post process to the camera.
  25698. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25699. * @param postProcess The post process to attach to the camera
  25700. * @param insertAt The position of the post process in case several of them are in use in the scene
  25701. * @returns the position the post process has been inserted at
  25702. */
  25703. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25704. /**
  25705. * Detach a post process to the camera.
  25706. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25707. * @param postProcess The post process to detach from the camera
  25708. */
  25709. detachPostProcess(postProcess: PostProcess): void;
  25710. /**
  25711. * Gets the current world matrix of the camera
  25712. */
  25713. getWorldMatrix(): Matrix;
  25714. /** @hidden */
  25715. _getViewMatrix(): Matrix;
  25716. /**
  25717. * Gets the current view matrix of the camera.
  25718. * @param force forces the camera to recompute the matrix without looking at the cached state
  25719. * @returns the view matrix
  25720. */
  25721. getViewMatrix(force?: boolean): Matrix;
  25722. /**
  25723. * Freeze the projection matrix.
  25724. * It will prevent the cache check of the camera projection compute and can speed up perf
  25725. * if no parameter of the camera are meant to change
  25726. * @param projection Defines manually a projection if necessary
  25727. */
  25728. freezeProjectionMatrix(projection?: Matrix): void;
  25729. /**
  25730. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25731. */
  25732. unfreezeProjectionMatrix(): void;
  25733. /**
  25734. * Gets the current projection matrix of the camera.
  25735. * @param force forces the camera to recompute the matrix without looking at the cached state
  25736. * @returns the projection matrix
  25737. */
  25738. getProjectionMatrix(force?: boolean): Matrix;
  25739. /**
  25740. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25741. * @returns a Matrix
  25742. */
  25743. getTransformationMatrix(): Matrix;
  25744. private _updateFrustumPlanes;
  25745. /**
  25746. * Checks if a cullable object (mesh...) is in the camera frustum
  25747. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25748. * @param target The object to check
  25749. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25750. * @returns true if the object is in frustum otherwise false
  25751. */
  25752. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25753. /**
  25754. * Checks if a cullable object (mesh...) is in the camera frustum
  25755. * Unlike isInFrustum this cheks the full bounding box
  25756. * @param target The object to check
  25757. * @returns true if the object is in frustum otherwise false
  25758. */
  25759. isCompletelyInFrustum(target: ICullable): boolean;
  25760. /**
  25761. * Gets a ray in the forward direction from the camera.
  25762. * @param length Defines the length of the ray to create
  25763. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25764. * @param origin Defines the start point of the ray which defaults to the camera position
  25765. * @returns the forward ray
  25766. */
  25767. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25768. /**
  25769. * Releases resources associated with this node.
  25770. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25771. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25772. */
  25773. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25774. /** @hidden */
  25775. _isLeftCamera: boolean;
  25776. /**
  25777. * Gets the left camera of a rig setup in case of Rigged Camera
  25778. */
  25779. get isLeftCamera(): boolean;
  25780. /** @hidden */
  25781. _isRightCamera: boolean;
  25782. /**
  25783. * Gets the right camera of a rig setup in case of Rigged Camera
  25784. */
  25785. get isRightCamera(): boolean;
  25786. /**
  25787. * Gets the left camera of a rig setup in case of Rigged Camera
  25788. */
  25789. get leftCamera(): Nullable<FreeCamera>;
  25790. /**
  25791. * Gets the right camera of a rig setup in case of Rigged Camera
  25792. */
  25793. get rightCamera(): Nullable<FreeCamera>;
  25794. /**
  25795. * Gets the left camera target of a rig setup in case of Rigged Camera
  25796. * @returns the target position
  25797. */
  25798. getLeftTarget(): Nullable<Vector3>;
  25799. /**
  25800. * Gets the right camera target of a rig setup in case of Rigged Camera
  25801. * @returns the target position
  25802. */
  25803. getRightTarget(): Nullable<Vector3>;
  25804. /**
  25805. * @hidden
  25806. */
  25807. setCameraRigMode(mode: number, rigParams: any): void;
  25808. /** @hidden */
  25809. static _setStereoscopicRigMode(camera: Camera): void;
  25810. /** @hidden */
  25811. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25812. /** @hidden */
  25813. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25814. /** @hidden */
  25815. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25816. /** @hidden */
  25817. _getVRProjectionMatrix(): Matrix;
  25818. protected _updateCameraRotationMatrix(): void;
  25819. protected _updateWebVRCameraRotationMatrix(): void;
  25820. /**
  25821. * This function MUST be overwritten by the different WebVR cameras available.
  25822. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25823. * @hidden
  25824. */
  25825. _getWebVRProjectionMatrix(): Matrix;
  25826. /**
  25827. * This function MUST be overwritten by the different WebVR cameras available.
  25828. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25829. * @hidden
  25830. */
  25831. _getWebVRViewMatrix(): Matrix;
  25832. /** @hidden */
  25833. setCameraRigParameter(name: string, value: any): void;
  25834. /**
  25835. * needs to be overridden by children so sub has required properties to be copied
  25836. * @hidden
  25837. */
  25838. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25839. /**
  25840. * May need to be overridden by children
  25841. * @hidden
  25842. */
  25843. _updateRigCameras(): void;
  25844. /** @hidden */
  25845. _setupInputs(): void;
  25846. /**
  25847. * Serialiaze the camera setup to a json represention
  25848. * @returns the JSON representation
  25849. */
  25850. serialize(): any;
  25851. /**
  25852. * Clones the current camera.
  25853. * @param name The cloned camera name
  25854. * @returns the cloned camera
  25855. */
  25856. clone(name: string): Camera;
  25857. /**
  25858. * Gets the direction of the camera relative to a given local axis.
  25859. * @param localAxis Defines the reference axis to provide a relative direction.
  25860. * @return the direction
  25861. */
  25862. getDirection(localAxis: Vector3): Vector3;
  25863. /**
  25864. * Returns the current camera absolute rotation
  25865. */
  25866. get absoluteRotation(): Quaternion;
  25867. /**
  25868. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25869. * @param localAxis Defines the reference axis to provide a relative direction.
  25870. * @param result Defines the vector to store the result in
  25871. */
  25872. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25873. /**
  25874. * Gets a camera constructor for a given camera type
  25875. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25876. * @param name The name of the camera the result will be able to instantiate
  25877. * @param scene The scene the result will construct the camera in
  25878. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25879. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25880. * @returns a factory method to construc the camera
  25881. */
  25882. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25883. /**
  25884. * Compute the world matrix of the camera.
  25885. * @returns the camera world matrix
  25886. */
  25887. computeWorldMatrix(): Matrix;
  25888. /**
  25889. * Parse a JSON and creates the camera from the parsed information
  25890. * @param parsedCamera The JSON to parse
  25891. * @param scene The scene to instantiate the camera in
  25892. * @returns the newly constructed camera
  25893. */
  25894. static Parse(parsedCamera: any, scene: Scene): Camera;
  25895. }
  25896. }
  25897. declare module BABYLON {
  25898. /**
  25899. * Class containing static functions to help procedurally build meshes
  25900. */
  25901. export class DiscBuilder {
  25902. /**
  25903. * Creates a plane polygonal mesh. By default, this is a disc
  25904. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25905. * * 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
  25906. * * 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
  25907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25908. * * 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
  25909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25910. * @param name defines the name of the mesh
  25911. * @param options defines the options used to create the mesh
  25912. * @param scene defines the hosting scene
  25913. * @returns the plane polygonal mesh
  25914. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25915. */
  25916. static CreateDisc(name: string, options: {
  25917. radius?: number;
  25918. tessellation?: number;
  25919. arc?: number;
  25920. updatable?: boolean;
  25921. sideOrientation?: number;
  25922. frontUVs?: Vector4;
  25923. backUVs?: Vector4;
  25924. }, scene?: Nullable<Scene>): Mesh;
  25925. }
  25926. }
  25927. declare module BABYLON {
  25928. /**
  25929. * This represents all the required information to add a fresnel effect on a material:
  25930. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25931. */
  25932. export class FresnelParameters {
  25933. private _isEnabled;
  25934. /**
  25935. * Define if the fresnel effect is enable or not.
  25936. */
  25937. get isEnabled(): boolean;
  25938. set isEnabled(value: boolean);
  25939. /**
  25940. * Define the color used on edges (grazing angle)
  25941. */
  25942. leftColor: Color3;
  25943. /**
  25944. * Define the color used on center
  25945. */
  25946. rightColor: Color3;
  25947. /**
  25948. * Define bias applied to computed fresnel term
  25949. */
  25950. bias: number;
  25951. /**
  25952. * Defined the power exponent applied to fresnel term
  25953. */
  25954. power: number;
  25955. /**
  25956. * Clones the current fresnel and its valuues
  25957. * @returns a clone fresnel configuration
  25958. */
  25959. clone(): FresnelParameters;
  25960. /**
  25961. * Serializes the current fresnel parameters to a JSON representation.
  25962. * @return the JSON serialization
  25963. */
  25964. serialize(): any;
  25965. /**
  25966. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25967. * @param parsedFresnelParameters Define the JSON representation
  25968. * @returns the parsed parameters
  25969. */
  25970. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25971. }
  25972. }
  25973. declare module BABYLON {
  25974. /**
  25975. * Base class of materials working in push mode in babylon JS
  25976. * @hidden
  25977. */
  25978. export class PushMaterial extends Material {
  25979. protected _activeEffect: Effect;
  25980. protected _normalMatrix: Matrix;
  25981. /**
  25982. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25983. * This means that the material can keep using a previous shader while a new one is being compiled.
  25984. * This is mostly used when shader parallel compilation is supported (true by default)
  25985. */
  25986. allowShaderHotSwapping: boolean;
  25987. constructor(name: string, scene: Scene);
  25988. getEffect(): Effect;
  25989. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25990. /**
  25991. * Binds the given world matrix to the active effect
  25992. *
  25993. * @param world the matrix to bind
  25994. */
  25995. bindOnlyWorldMatrix(world: Matrix): void;
  25996. /**
  25997. * Binds the given normal matrix to the active effect
  25998. *
  25999. * @param normalMatrix the matrix to bind
  26000. */
  26001. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26002. bind(world: Matrix, mesh?: Mesh): void;
  26003. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26004. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26005. }
  26006. }
  26007. declare module BABYLON {
  26008. /**
  26009. * This groups all the flags used to control the materials channel.
  26010. */
  26011. export class MaterialFlags {
  26012. private static _DiffuseTextureEnabled;
  26013. /**
  26014. * Are diffuse textures enabled in the application.
  26015. */
  26016. static get DiffuseTextureEnabled(): boolean;
  26017. static set DiffuseTextureEnabled(value: boolean);
  26018. private static _AmbientTextureEnabled;
  26019. /**
  26020. * Are ambient textures enabled in the application.
  26021. */
  26022. static get AmbientTextureEnabled(): boolean;
  26023. static set AmbientTextureEnabled(value: boolean);
  26024. private static _OpacityTextureEnabled;
  26025. /**
  26026. * Are opacity textures enabled in the application.
  26027. */
  26028. static get OpacityTextureEnabled(): boolean;
  26029. static set OpacityTextureEnabled(value: boolean);
  26030. private static _ReflectionTextureEnabled;
  26031. /**
  26032. * Are reflection textures enabled in the application.
  26033. */
  26034. static get ReflectionTextureEnabled(): boolean;
  26035. static set ReflectionTextureEnabled(value: boolean);
  26036. private static _EmissiveTextureEnabled;
  26037. /**
  26038. * Are emissive textures enabled in the application.
  26039. */
  26040. static get EmissiveTextureEnabled(): boolean;
  26041. static set EmissiveTextureEnabled(value: boolean);
  26042. private static _SpecularTextureEnabled;
  26043. /**
  26044. * Are specular textures enabled in the application.
  26045. */
  26046. static get SpecularTextureEnabled(): boolean;
  26047. static set SpecularTextureEnabled(value: boolean);
  26048. private static _BumpTextureEnabled;
  26049. /**
  26050. * Are bump textures enabled in the application.
  26051. */
  26052. static get BumpTextureEnabled(): boolean;
  26053. static set BumpTextureEnabled(value: boolean);
  26054. private static _LightmapTextureEnabled;
  26055. /**
  26056. * Are lightmap textures enabled in the application.
  26057. */
  26058. static get LightmapTextureEnabled(): boolean;
  26059. static set LightmapTextureEnabled(value: boolean);
  26060. private static _RefractionTextureEnabled;
  26061. /**
  26062. * Are refraction textures enabled in the application.
  26063. */
  26064. static get RefractionTextureEnabled(): boolean;
  26065. static set RefractionTextureEnabled(value: boolean);
  26066. private static _ColorGradingTextureEnabled;
  26067. /**
  26068. * Are color grading textures enabled in the application.
  26069. */
  26070. static get ColorGradingTextureEnabled(): boolean;
  26071. static set ColorGradingTextureEnabled(value: boolean);
  26072. private static _FresnelEnabled;
  26073. /**
  26074. * Are fresnels enabled in the application.
  26075. */
  26076. static get FresnelEnabled(): boolean;
  26077. static set FresnelEnabled(value: boolean);
  26078. private static _ClearCoatTextureEnabled;
  26079. /**
  26080. * Are clear coat textures enabled in the application.
  26081. */
  26082. static get ClearCoatTextureEnabled(): boolean;
  26083. static set ClearCoatTextureEnabled(value: boolean);
  26084. private static _ClearCoatBumpTextureEnabled;
  26085. /**
  26086. * Are clear coat bump textures enabled in the application.
  26087. */
  26088. static get ClearCoatBumpTextureEnabled(): boolean;
  26089. static set ClearCoatBumpTextureEnabled(value: boolean);
  26090. private static _ClearCoatTintTextureEnabled;
  26091. /**
  26092. * Are clear coat tint textures enabled in the application.
  26093. */
  26094. static get ClearCoatTintTextureEnabled(): boolean;
  26095. static set ClearCoatTintTextureEnabled(value: boolean);
  26096. private static _SheenTextureEnabled;
  26097. /**
  26098. * Are sheen textures enabled in the application.
  26099. */
  26100. static get SheenTextureEnabled(): boolean;
  26101. static set SheenTextureEnabled(value: boolean);
  26102. private static _AnisotropicTextureEnabled;
  26103. /**
  26104. * Are anisotropic textures enabled in the application.
  26105. */
  26106. static get AnisotropicTextureEnabled(): boolean;
  26107. static set AnisotropicTextureEnabled(value: boolean);
  26108. private static _ThicknessTextureEnabled;
  26109. /**
  26110. * Are thickness textures enabled in the application.
  26111. */
  26112. static get ThicknessTextureEnabled(): boolean;
  26113. static set ThicknessTextureEnabled(value: boolean);
  26114. }
  26115. }
  26116. declare module BABYLON {
  26117. /** @hidden */
  26118. export var defaultFragmentDeclaration: {
  26119. name: string;
  26120. shader: string;
  26121. };
  26122. }
  26123. declare module BABYLON {
  26124. /** @hidden */
  26125. export var defaultUboDeclaration: {
  26126. name: string;
  26127. shader: string;
  26128. };
  26129. }
  26130. declare module BABYLON {
  26131. /** @hidden */
  26132. export var lightFragmentDeclaration: {
  26133. name: string;
  26134. shader: string;
  26135. };
  26136. }
  26137. declare module BABYLON {
  26138. /** @hidden */
  26139. export var lightUboDeclaration: {
  26140. name: string;
  26141. shader: string;
  26142. };
  26143. }
  26144. declare module BABYLON {
  26145. /** @hidden */
  26146. export var lightsFragmentFunctions: {
  26147. name: string;
  26148. shader: string;
  26149. };
  26150. }
  26151. declare module BABYLON {
  26152. /** @hidden */
  26153. export var shadowsFragmentFunctions: {
  26154. name: string;
  26155. shader: string;
  26156. };
  26157. }
  26158. declare module BABYLON {
  26159. /** @hidden */
  26160. export var fresnelFunction: {
  26161. name: string;
  26162. shader: string;
  26163. };
  26164. }
  26165. declare module BABYLON {
  26166. /** @hidden */
  26167. export var reflectionFunction: {
  26168. name: string;
  26169. shader: string;
  26170. };
  26171. }
  26172. declare module BABYLON {
  26173. /** @hidden */
  26174. export var bumpFragmentFunctions: {
  26175. name: string;
  26176. shader: string;
  26177. };
  26178. }
  26179. declare module BABYLON {
  26180. /** @hidden */
  26181. export var logDepthDeclaration: {
  26182. name: string;
  26183. shader: string;
  26184. };
  26185. }
  26186. declare module BABYLON {
  26187. /** @hidden */
  26188. export var bumpFragment: {
  26189. name: string;
  26190. shader: string;
  26191. };
  26192. }
  26193. declare module BABYLON {
  26194. /** @hidden */
  26195. export var depthPrePass: {
  26196. name: string;
  26197. shader: string;
  26198. };
  26199. }
  26200. declare module BABYLON {
  26201. /** @hidden */
  26202. export var lightFragment: {
  26203. name: string;
  26204. shader: string;
  26205. };
  26206. }
  26207. declare module BABYLON {
  26208. /** @hidden */
  26209. export var logDepthFragment: {
  26210. name: string;
  26211. shader: string;
  26212. };
  26213. }
  26214. declare module BABYLON {
  26215. /** @hidden */
  26216. export var defaultPixelShader: {
  26217. name: string;
  26218. shader: string;
  26219. };
  26220. }
  26221. declare module BABYLON {
  26222. /** @hidden */
  26223. export var defaultVertexDeclaration: {
  26224. name: string;
  26225. shader: string;
  26226. };
  26227. }
  26228. declare module BABYLON {
  26229. /** @hidden */
  26230. export var bumpVertexDeclaration: {
  26231. name: string;
  26232. shader: string;
  26233. };
  26234. }
  26235. declare module BABYLON {
  26236. /** @hidden */
  26237. export var bumpVertex: {
  26238. name: string;
  26239. shader: string;
  26240. };
  26241. }
  26242. declare module BABYLON {
  26243. /** @hidden */
  26244. export var fogVertex: {
  26245. name: string;
  26246. shader: string;
  26247. };
  26248. }
  26249. declare module BABYLON {
  26250. /** @hidden */
  26251. export var shadowsVertex: {
  26252. name: string;
  26253. shader: string;
  26254. };
  26255. }
  26256. declare module BABYLON {
  26257. /** @hidden */
  26258. export var pointCloudVertex: {
  26259. name: string;
  26260. shader: string;
  26261. };
  26262. }
  26263. declare module BABYLON {
  26264. /** @hidden */
  26265. export var logDepthVertex: {
  26266. name: string;
  26267. shader: string;
  26268. };
  26269. }
  26270. declare module BABYLON {
  26271. /** @hidden */
  26272. export var defaultVertexShader: {
  26273. name: string;
  26274. shader: string;
  26275. };
  26276. }
  26277. declare module BABYLON {
  26278. /** @hidden */
  26279. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26280. MAINUV1: boolean;
  26281. MAINUV2: boolean;
  26282. DIFFUSE: boolean;
  26283. DIFFUSEDIRECTUV: number;
  26284. AMBIENT: boolean;
  26285. AMBIENTDIRECTUV: number;
  26286. OPACITY: boolean;
  26287. OPACITYDIRECTUV: number;
  26288. OPACITYRGB: boolean;
  26289. REFLECTION: boolean;
  26290. EMISSIVE: boolean;
  26291. EMISSIVEDIRECTUV: number;
  26292. SPECULAR: boolean;
  26293. SPECULARDIRECTUV: number;
  26294. BUMP: boolean;
  26295. BUMPDIRECTUV: number;
  26296. PARALLAX: boolean;
  26297. PARALLAXOCCLUSION: boolean;
  26298. SPECULAROVERALPHA: boolean;
  26299. CLIPPLANE: boolean;
  26300. CLIPPLANE2: boolean;
  26301. CLIPPLANE3: boolean;
  26302. CLIPPLANE4: boolean;
  26303. CLIPPLANE5: boolean;
  26304. CLIPPLANE6: boolean;
  26305. ALPHATEST: boolean;
  26306. DEPTHPREPASS: boolean;
  26307. ALPHAFROMDIFFUSE: boolean;
  26308. POINTSIZE: boolean;
  26309. FOG: boolean;
  26310. SPECULARTERM: boolean;
  26311. DIFFUSEFRESNEL: boolean;
  26312. OPACITYFRESNEL: boolean;
  26313. REFLECTIONFRESNEL: boolean;
  26314. REFRACTIONFRESNEL: boolean;
  26315. EMISSIVEFRESNEL: boolean;
  26316. FRESNEL: boolean;
  26317. NORMAL: boolean;
  26318. UV1: boolean;
  26319. UV2: boolean;
  26320. VERTEXCOLOR: boolean;
  26321. VERTEXALPHA: boolean;
  26322. NUM_BONE_INFLUENCERS: number;
  26323. BonesPerMesh: number;
  26324. BONETEXTURE: boolean;
  26325. INSTANCES: boolean;
  26326. GLOSSINESS: boolean;
  26327. ROUGHNESS: boolean;
  26328. EMISSIVEASILLUMINATION: boolean;
  26329. LINKEMISSIVEWITHDIFFUSE: boolean;
  26330. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26331. LIGHTMAP: boolean;
  26332. LIGHTMAPDIRECTUV: number;
  26333. OBJECTSPACE_NORMALMAP: boolean;
  26334. USELIGHTMAPASSHADOWMAP: boolean;
  26335. REFLECTIONMAP_3D: boolean;
  26336. REFLECTIONMAP_SPHERICAL: boolean;
  26337. REFLECTIONMAP_PLANAR: boolean;
  26338. REFLECTIONMAP_CUBIC: boolean;
  26339. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26340. REFLECTIONMAP_PROJECTION: boolean;
  26341. REFLECTIONMAP_SKYBOX: boolean;
  26342. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26343. REFLECTIONMAP_EXPLICIT: boolean;
  26344. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26345. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26346. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26347. INVERTCUBICMAP: boolean;
  26348. LOGARITHMICDEPTH: boolean;
  26349. REFRACTION: boolean;
  26350. REFRACTIONMAP_3D: boolean;
  26351. REFLECTIONOVERALPHA: boolean;
  26352. TWOSIDEDLIGHTING: boolean;
  26353. SHADOWFLOAT: boolean;
  26354. MORPHTARGETS: boolean;
  26355. MORPHTARGETS_NORMAL: boolean;
  26356. MORPHTARGETS_TANGENT: boolean;
  26357. MORPHTARGETS_UV: boolean;
  26358. NUM_MORPH_INFLUENCERS: number;
  26359. NONUNIFORMSCALING: boolean;
  26360. PREMULTIPLYALPHA: boolean;
  26361. IMAGEPROCESSING: boolean;
  26362. VIGNETTE: boolean;
  26363. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26364. VIGNETTEBLENDMODEOPAQUE: boolean;
  26365. TONEMAPPING: boolean;
  26366. TONEMAPPING_ACES: boolean;
  26367. CONTRAST: boolean;
  26368. COLORCURVES: boolean;
  26369. COLORGRADING: boolean;
  26370. COLORGRADING3D: boolean;
  26371. SAMPLER3DGREENDEPTH: boolean;
  26372. SAMPLER3DBGRMAP: boolean;
  26373. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26374. MULTIVIEW: boolean;
  26375. /**
  26376. * If the reflection texture on this material is in linear color space
  26377. * @hidden
  26378. */
  26379. IS_REFLECTION_LINEAR: boolean;
  26380. /**
  26381. * If the refraction texture on this material is in linear color space
  26382. * @hidden
  26383. */
  26384. IS_REFRACTION_LINEAR: boolean;
  26385. EXPOSURE: boolean;
  26386. constructor();
  26387. setReflectionMode(modeToEnable: string): void;
  26388. }
  26389. /**
  26390. * This is the default material used in Babylon. It is the best trade off between quality
  26391. * and performances.
  26392. * @see http://doc.babylonjs.com/babylon101/materials
  26393. */
  26394. export class StandardMaterial extends PushMaterial {
  26395. private _diffuseTexture;
  26396. /**
  26397. * The basic texture of the material as viewed under a light.
  26398. */
  26399. diffuseTexture: Nullable<BaseTexture>;
  26400. private _ambientTexture;
  26401. /**
  26402. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26403. */
  26404. ambientTexture: Nullable<BaseTexture>;
  26405. private _opacityTexture;
  26406. /**
  26407. * Define the transparency of the material from a texture.
  26408. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26409. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26410. */
  26411. opacityTexture: Nullable<BaseTexture>;
  26412. private _reflectionTexture;
  26413. /**
  26414. * Define the texture used to display the reflection.
  26415. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26416. */
  26417. reflectionTexture: Nullable<BaseTexture>;
  26418. private _emissiveTexture;
  26419. /**
  26420. * Define texture of the material as if self lit.
  26421. * This will be mixed in the final result even in the absence of light.
  26422. */
  26423. emissiveTexture: Nullable<BaseTexture>;
  26424. private _specularTexture;
  26425. /**
  26426. * Define how the color and intensity of the highlight given by the light in the material.
  26427. */
  26428. specularTexture: Nullable<BaseTexture>;
  26429. private _bumpTexture;
  26430. /**
  26431. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26432. * 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.
  26433. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26434. */
  26435. bumpTexture: Nullable<BaseTexture>;
  26436. private _lightmapTexture;
  26437. /**
  26438. * Complex lighting can be computationally expensive to compute at runtime.
  26439. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26440. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26441. */
  26442. lightmapTexture: Nullable<BaseTexture>;
  26443. private _refractionTexture;
  26444. /**
  26445. * Define the texture used to display the refraction.
  26446. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26447. */
  26448. refractionTexture: Nullable<BaseTexture>;
  26449. /**
  26450. * The color of the material lit by the environmental background lighting.
  26451. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26452. */
  26453. ambientColor: Color3;
  26454. /**
  26455. * The basic color of the material as viewed under a light.
  26456. */
  26457. diffuseColor: Color3;
  26458. /**
  26459. * Define how the color and intensity of the highlight given by the light in the material.
  26460. */
  26461. specularColor: Color3;
  26462. /**
  26463. * Define the color of the material as if self lit.
  26464. * This will be mixed in the final result even in the absence of light.
  26465. */
  26466. emissiveColor: Color3;
  26467. /**
  26468. * Defines how sharp are the highlights in the material.
  26469. * The bigger the value the sharper giving a more glossy feeling to the result.
  26470. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26471. */
  26472. specularPower: number;
  26473. private _useAlphaFromDiffuseTexture;
  26474. /**
  26475. * Does the transparency come from the diffuse texture alpha channel.
  26476. */
  26477. useAlphaFromDiffuseTexture: boolean;
  26478. private _useEmissiveAsIllumination;
  26479. /**
  26480. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26481. */
  26482. useEmissiveAsIllumination: boolean;
  26483. private _linkEmissiveWithDiffuse;
  26484. /**
  26485. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26486. * the emissive level when the final color is close to one.
  26487. */
  26488. linkEmissiveWithDiffuse: boolean;
  26489. private _useSpecularOverAlpha;
  26490. /**
  26491. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26492. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26493. */
  26494. useSpecularOverAlpha: boolean;
  26495. private _useReflectionOverAlpha;
  26496. /**
  26497. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26498. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26499. */
  26500. useReflectionOverAlpha: boolean;
  26501. private _disableLighting;
  26502. /**
  26503. * Does lights from the scene impacts this material.
  26504. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26505. */
  26506. disableLighting: boolean;
  26507. private _useObjectSpaceNormalMap;
  26508. /**
  26509. * Allows using an object space normal map (instead of tangent space).
  26510. */
  26511. useObjectSpaceNormalMap: boolean;
  26512. private _useParallax;
  26513. /**
  26514. * Is parallax enabled or not.
  26515. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26516. */
  26517. useParallax: boolean;
  26518. private _useParallaxOcclusion;
  26519. /**
  26520. * Is parallax occlusion enabled or not.
  26521. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26522. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26523. */
  26524. useParallaxOcclusion: boolean;
  26525. /**
  26526. * 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.
  26527. */
  26528. parallaxScaleBias: number;
  26529. private _roughness;
  26530. /**
  26531. * Helps to define how blurry the reflections should appears in the material.
  26532. */
  26533. roughness: number;
  26534. /**
  26535. * In case of refraction, define the value of the index of refraction.
  26536. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26537. */
  26538. indexOfRefraction: number;
  26539. /**
  26540. * Invert the refraction texture alongside the y axis.
  26541. * It can be useful with procedural textures or probe for instance.
  26542. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26543. */
  26544. invertRefractionY: boolean;
  26545. /**
  26546. * Defines the alpha limits in alpha test mode.
  26547. */
  26548. alphaCutOff: number;
  26549. private _useLightmapAsShadowmap;
  26550. /**
  26551. * In case of light mapping, define whether the map contains light or shadow informations.
  26552. */
  26553. useLightmapAsShadowmap: boolean;
  26554. private _diffuseFresnelParameters;
  26555. /**
  26556. * Define the diffuse fresnel parameters of the material.
  26557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26558. */
  26559. diffuseFresnelParameters: FresnelParameters;
  26560. private _opacityFresnelParameters;
  26561. /**
  26562. * Define the opacity fresnel parameters of the material.
  26563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26564. */
  26565. opacityFresnelParameters: FresnelParameters;
  26566. private _reflectionFresnelParameters;
  26567. /**
  26568. * Define the reflection fresnel parameters of the material.
  26569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26570. */
  26571. reflectionFresnelParameters: FresnelParameters;
  26572. private _refractionFresnelParameters;
  26573. /**
  26574. * Define the refraction fresnel parameters of the material.
  26575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26576. */
  26577. refractionFresnelParameters: FresnelParameters;
  26578. private _emissiveFresnelParameters;
  26579. /**
  26580. * Define the emissive fresnel parameters of the material.
  26581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26582. */
  26583. emissiveFresnelParameters: FresnelParameters;
  26584. private _useReflectionFresnelFromSpecular;
  26585. /**
  26586. * If true automatically deducts the fresnels values from the material specularity.
  26587. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26588. */
  26589. useReflectionFresnelFromSpecular: boolean;
  26590. private _useGlossinessFromSpecularMapAlpha;
  26591. /**
  26592. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26593. */
  26594. useGlossinessFromSpecularMapAlpha: boolean;
  26595. private _maxSimultaneousLights;
  26596. /**
  26597. * Defines the maximum number of lights that can be used in the material
  26598. */
  26599. maxSimultaneousLights: number;
  26600. private _invertNormalMapX;
  26601. /**
  26602. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26603. */
  26604. invertNormalMapX: boolean;
  26605. private _invertNormalMapY;
  26606. /**
  26607. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26608. */
  26609. invertNormalMapY: boolean;
  26610. private _twoSidedLighting;
  26611. /**
  26612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26613. */
  26614. twoSidedLighting: boolean;
  26615. /**
  26616. * Default configuration related to image processing available in the standard Material.
  26617. */
  26618. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26619. /**
  26620. * Gets the image processing configuration used either in this material.
  26621. */
  26622. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26623. /**
  26624. * Sets the Default image processing configuration used either in the this material.
  26625. *
  26626. * If sets to null, the scene one is in use.
  26627. */
  26628. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26629. /**
  26630. * Keep track of the image processing observer to allow dispose and replace.
  26631. */
  26632. private _imageProcessingObserver;
  26633. /**
  26634. * Attaches a new image processing configuration to the Standard Material.
  26635. * @param configuration
  26636. */
  26637. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26638. /**
  26639. * Gets wether the color curves effect is enabled.
  26640. */
  26641. get cameraColorCurvesEnabled(): boolean;
  26642. /**
  26643. * Sets wether the color curves effect is enabled.
  26644. */
  26645. set cameraColorCurvesEnabled(value: boolean);
  26646. /**
  26647. * Gets wether the color grading effect is enabled.
  26648. */
  26649. get cameraColorGradingEnabled(): boolean;
  26650. /**
  26651. * Gets wether the color grading effect is enabled.
  26652. */
  26653. set cameraColorGradingEnabled(value: boolean);
  26654. /**
  26655. * Gets wether tonemapping is enabled or not.
  26656. */
  26657. get cameraToneMappingEnabled(): boolean;
  26658. /**
  26659. * Sets wether tonemapping is enabled or not
  26660. */
  26661. set cameraToneMappingEnabled(value: boolean);
  26662. /**
  26663. * The camera exposure used on this material.
  26664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26665. * This corresponds to a photographic exposure.
  26666. */
  26667. get cameraExposure(): number;
  26668. /**
  26669. * The camera exposure used on this material.
  26670. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26671. * This corresponds to a photographic exposure.
  26672. */
  26673. set cameraExposure(value: number);
  26674. /**
  26675. * Gets The camera contrast used on this material.
  26676. */
  26677. get cameraContrast(): number;
  26678. /**
  26679. * Sets The camera contrast used on this material.
  26680. */
  26681. set cameraContrast(value: number);
  26682. /**
  26683. * Gets the Color Grading 2D Lookup Texture.
  26684. */
  26685. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26686. /**
  26687. * Sets the Color Grading 2D Lookup Texture.
  26688. */
  26689. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26690. /**
  26691. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26692. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26693. * 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;
  26694. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26695. */
  26696. get cameraColorCurves(): Nullable<ColorCurves>;
  26697. /**
  26698. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26699. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26700. * 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;
  26701. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26702. */
  26703. set cameraColorCurves(value: Nullable<ColorCurves>);
  26704. /**
  26705. * Custom callback helping to override the default shader used in the material.
  26706. */
  26707. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26708. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26709. protected _worldViewProjectionMatrix: Matrix;
  26710. protected _globalAmbientColor: Color3;
  26711. protected _useLogarithmicDepth: boolean;
  26712. protected _rebuildInParallel: boolean;
  26713. /**
  26714. * Instantiates a new standard material.
  26715. * This is the default material used in Babylon. It is the best trade off between quality
  26716. * and performances.
  26717. * @see http://doc.babylonjs.com/babylon101/materials
  26718. * @param name Define the name of the material in the scene
  26719. * @param scene Define the scene the material belong to
  26720. */
  26721. constructor(name: string, scene: Scene);
  26722. /**
  26723. * Gets a boolean indicating that current material needs to register RTT
  26724. */
  26725. get hasRenderTargetTextures(): boolean;
  26726. /**
  26727. * Gets the current class name of the material e.g. "StandardMaterial"
  26728. * Mainly use in serialization.
  26729. * @returns the class name
  26730. */
  26731. getClassName(): string;
  26732. /**
  26733. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26734. * You can try switching to logarithmic depth.
  26735. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26736. */
  26737. get useLogarithmicDepth(): boolean;
  26738. set useLogarithmicDepth(value: boolean);
  26739. /**
  26740. * Specifies if the material will require alpha blending
  26741. * @returns a boolean specifying if alpha blending is needed
  26742. */
  26743. needAlphaBlending(): boolean;
  26744. /**
  26745. * Specifies if this material should be rendered in alpha test mode
  26746. * @returns a boolean specifying if an alpha test is needed.
  26747. */
  26748. needAlphaTesting(): boolean;
  26749. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26750. /**
  26751. * Get the texture used for alpha test purpose.
  26752. * @returns the diffuse texture in case of the standard material.
  26753. */
  26754. getAlphaTestTexture(): Nullable<BaseTexture>;
  26755. /**
  26756. * Get if the submesh is ready to be used and all its information available.
  26757. * Child classes can use it to update shaders
  26758. * @param mesh defines the mesh to check
  26759. * @param subMesh defines which submesh to check
  26760. * @param useInstances specifies that instances should be used
  26761. * @returns a boolean indicating that the submesh is ready or not
  26762. */
  26763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26764. /**
  26765. * Builds the material UBO layouts.
  26766. * Used internally during the effect preparation.
  26767. */
  26768. buildUniformLayout(): void;
  26769. /**
  26770. * Unbinds the material from the mesh
  26771. */
  26772. unbind(): void;
  26773. /**
  26774. * Binds the submesh to this material by preparing the effect and shader to draw
  26775. * @param world defines the world transformation matrix
  26776. * @param mesh defines the mesh containing the submesh
  26777. * @param subMesh defines the submesh to bind the material to
  26778. */
  26779. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26780. /**
  26781. * Get the list of animatables in the material.
  26782. * @returns the list of animatables object used in the material
  26783. */
  26784. getAnimatables(): IAnimatable[];
  26785. /**
  26786. * Gets the active textures from the material
  26787. * @returns an array of textures
  26788. */
  26789. getActiveTextures(): BaseTexture[];
  26790. /**
  26791. * Specifies if the material uses a texture
  26792. * @param texture defines the texture to check against the material
  26793. * @returns a boolean specifying if the material uses the texture
  26794. */
  26795. hasTexture(texture: BaseTexture): boolean;
  26796. /**
  26797. * Disposes the material
  26798. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26799. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26800. */
  26801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26802. /**
  26803. * Makes a duplicate of the material, and gives it a new name
  26804. * @param name defines the new name for the duplicated material
  26805. * @returns the cloned material
  26806. */
  26807. clone(name: string): StandardMaterial;
  26808. /**
  26809. * Serializes this material in a JSON representation
  26810. * @returns the serialized material object
  26811. */
  26812. serialize(): any;
  26813. /**
  26814. * Creates a standard material from parsed material data
  26815. * @param source defines the JSON representation of the material
  26816. * @param scene defines the hosting scene
  26817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26818. * @returns a new standard material
  26819. */
  26820. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26821. /**
  26822. * Are diffuse textures enabled in the application.
  26823. */
  26824. static get DiffuseTextureEnabled(): boolean;
  26825. static set DiffuseTextureEnabled(value: boolean);
  26826. /**
  26827. * Are ambient textures enabled in the application.
  26828. */
  26829. static get AmbientTextureEnabled(): boolean;
  26830. static set AmbientTextureEnabled(value: boolean);
  26831. /**
  26832. * Are opacity textures enabled in the application.
  26833. */
  26834. static get OpacityTextureEnabled(): boolean;
  26835. static set OpacityTextureEnabled(value: boolean);
  26836. /**
  26837. * Are reflection textures enabled in the application.
  26838. */
  26839. static get ReflectionTextureEnabled(): boolean;
  26840. static set ReflectionTextureEnabled(value: boolean);
  26841. /**
  26842. * Are emissive textures enabled in the application.
  26843. */
  26844. static get EmissiveTextureEnabled(): boolean;
  26845. static set EmissiveTextureEnabled(value: boolean);
  26846. /**
  26847. * Are specular textures enabled in the application.
  26848. */
  26849. static get SpecularTextureEnabled(): boolean;
  26850. static set SpecularTextureEnabled(value: boolean);
  26851. /**
  26852. * Are bump textures enabled in the application.
  26853. */
  26854. static get BumpTextureEnabled(): boolean;
  26855. static set BumpTextureEnabled(value: boolean);
  26856. /**
  26857. * Are lightmap textures enabled in the application.
  26858. */
  26859. static get LightmapTextureEnabled(): boolean;
  26860. static set LightmapTextureEnabled(value: boolean);
  26861. /**
  26862. * Are refraction textures enabled in the application.
  26863. */
  26864. static get RefractionTextureEnabled(): boolean;
  26865. static set RefractionTextureEnabled(value: boolean);
  26866. /**
  26867. * Are color grading textures enabled in the application.
  26868. */
  26869. static get ColorGradingTextureEnabled(): boolean;
  26870. static set ColorGradingTextureEnabled(value: boolean);
  26871. /**
  26872. * Are fresnels enabled in the application.
  26873. */
  26874. static get FresnelEnabled(): boolean;
  26875. static set FresnelEnabled(value: boolean);
  26876. }
  26877. }
  26878. declare module BABYLON {
  26879. /**
  26880. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26881. *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.
  26882. * The SPS is also a particle system. It provides some methods to manage the particles.
  26883. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26884. *
  26885. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26886. */
  26887. export class SolidParticleSystem implements IDisposable {
  26888. /**
  26889. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26890. * Example : var p = SPS.particles[i];
  26891. */
  26892. particles: SolidParticle[];
  26893. /**
  26894. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26895. */
  26896. nbParticles: number;
  26897. /**
  26898. * If the particles must ever face the camera (default false). Useful for planar particles.
  26899. */
  26900. billboard: boolean;
  26901. /**
  26902. * Recompute normals when adding a shape
  26903. */
  26904. recomputeNormals: boolean;
  26905. /**
  26906. * This a counter ofr your own usage. It's not set by any SPS functions.
  26907. */
  26908. counter: number;
  26909. /**
  26910. * The SPS name. This name is also given to the underlying mesh.
  26911. */
  26912. name: string;
  26913. /**
  26914. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26915. */
  26916. mesh: Mesh;
  26917. /**
  26918. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26919. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26920. */
  26921. vars: any;
  26922. /**
  26923. * This array is populated when the SPS is set as 'pickable'.
  26924. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26925. * Each element of this array is an object `{idx: int, faceId: int}`.
  26926. * `idx` is the picked particle index in the `SPS.particles` array
  26927. * `faceId` is the picked face index counted within this particle.
  26928. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26929. */
  26930. pickedParticles: {
  26931. idx: number;
  26932. faceId: number;
  26933. }[];
  26934. /**
  26935. * This array is populated when `enableDepthSort` is set to true.
  26936. * Each element of this array is an instance of the class DepthSortedParticle.
  26937. */
  26938. depthSortedParticles: DepthSortedParticle[];
  26939. /**
  26940. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26941. * @hidden
  26942. */
  26943. _bSphereOnly: boolean;
  26944. /**
  26945. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26946. * @hidden
  26947. */
  26948. _bSphereRadiusFactor: number;
  26949. private _scene;
  26950. private _positions;
  26951. private _indices;
  26952. private _normals;
  26953. private _colors;
  26954. private _uvs;
  26955. private _indices32;
  26956. private _positions32;
  26957. private _normals32;
  26958. private _fixedNormal32;
  26959. private _colors32;
  26960. private _uvs32;
  26961. private _index;
  26962. private _updatable;
  26963. private _pickable;
  26964. private _isVisibilityBoxLocked;
  26965. private _alwaysVisible;
  26966. private _depthSort;
  26967. private _expandable;
  26968. private _shapeCounter;
  26969. private _copy;
  26970. private _color;
  26971. private _computeParticleColor;
  26972. private _computeParticleTexture;
  26973. private _computeParticleRotation;
  26974. private _computeParticleVertex;
  26975. private _computeBoundingBox;
  26976. private _depthSortParticles;
  26977. private _camera;
  26978. private _mustUnrotateFixedNormals;
  26979. private _particlesIntersect;
  26980. private _needs32Bits;
  26981. private _isNotBuilt;
  26982. private _lastParticleId;
  26983. private _idxOfId;
  26984. private _multimaterialEnabled;
  26985. private _useModelMaterial;
  26986. private _indicesByMaterial;
  26987. private _materialIndexes;
  26988. private _depthSortFunction;
  26989. private _materialSortFunction;
  26990. private _materials;
  26991. private _multimaterial;
  26992. private _materialIndexesById;
  26993. private _defaultMaterial;
  26994. private _autoUpdateSubMeshes;
  26995. /**
  26996. * Creates a SPS (Solid Particle System) object.
  26997. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26998. * @param scene (Scene) is the scene in which the SPS is added.
  26999. * @param options defines the options of the sps e.g.
  27000. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27001. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27002. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27003. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27004. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27005. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27006. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27007. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27008. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27009. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27010. */
  27011. constructor(name: string, scene: Scene, options?: {
  27012. updatable?: boolean;
  27013. isPickable?: boolean;
  27014. enableDepthSort?: boolean;
  27015. particleIntersection?: boolean;
  27016. boundingSphereOnly?: boolean;
  27017. bSphereRadiusFactor?: number;
  27018. expandable?: boolean;
  27019. useModelMaterial?: boolean;
  27020. enableMultiMaterial?: boolean;
  27021. });
  27022. /**
  27023. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27024. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27025. * @returns the created mesh
  27026. */
  27027. buildMesh(): Mesh;
  27028. /**
  27029. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27030. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27031. * Thus the particles generated from `digest()` have their property `position` set yet.
  27032. * @param mesh ( Mesh ) is the mesh to be digested
  27033. * @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
  27034. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27035. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27036. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27037. * @returns the current SPS
  27038. */
  27039. digest(mesh: Mesh, options?: {
  27040. facetNb?: number;
  27041. number?: number;
  27042. delta?: number;
  27043. storage?: [];
  27044. }): SolidParticleSystem;
  27045. /**
  27046. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27047. * @hidden
  27048. */
  27049. private _unrotateFixedNormals;
  27050. /**
  27051. * Resets the temporary working copy particle
  27052. * @hidden
  27053. */
  27054. private _resetCopy;
  27055. /**
  27056. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27057. * @param p the current index in the positions array to be updated
  27058. * @param ind the current index in the indices array
  27059. * @param shape a Vector3 array, the shape geometry
  27060. * @param positions the positions array to be updated
  27061. * @param meshInd the shape indices array
  27062. * @param indices the indices array to be updated
  27063. * @param meshUV the shape uv array
  27064. * @param uvs the uv array to be updated
  27065. * @param meshCol the shape color array
  27066. * @param colors the color array to be updated
  27067. * @param meshNor the shape normals array
  27068. * @param normals the normals array to be updated
  27069. * @param idx the particle index
  27070. * @param idxInShape the particle index in its shape
  27071. * @param options the addShape() method passed options
  27072. * @model the particle model
  27073. * @hidden
  27074. */
  27075. private _meshBuilder;
  27076. /**
  27077. * Returns a shape Vector3 array from positions float array
  27078. * @param positions float array
  27079. * @returns a vector3 array
  27080. * @hidden
  27081. */
  27082. private _posToShape;
  27083. /**
  27084. * Returns a shapeUV array from a float uvs (array deep copy)
  27085. * @param uvs as a float array
  27086. * @returns a shapeUV array
  27087. * @hidden
  27088. */
  27089. private _uvsToShapeUV;
  27090. /**
  27091. * Adds a new particle object in the particles array
  27092. * @param idx particle index in particles array
  27093. * @param id particle id
  27094. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27095. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27096. * @param model particle ModelShape object
  27097. * @param shapeId model shape identifier
  27098. * @param idxInShape index of the particle in the current model
  27099. * @param bInfo model bounding info object
  27100. * @param storage target storage array, if any
  27101. * @hidden
  27102. */
  27103. private _addParticle;
  27104. /**
  27105. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27106. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27107. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27108. * @param nb (positive integer) the number of particles to be created from this model
  27109. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27110. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27111. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27112. * @returns the number of shapes in the system
  27113. */
  27114. addShape(mesh: Mesh, nb: number, options?: {
  27115. positionFunction?: any;
  27116. vertexFunction?: any;
  27117. storage?: [];
  27118. }): number;
  27119. /**
  27120. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27121. * @hidden
  27122. */
  27123. private _rebuildParticle;
  27124. /**
  27125. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27126. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27127. * @returns the SPS.
  27128. */
  27129. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27130. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27131. * Returns an array with the removed particles.
  27132. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27133. * The SPS can't be empty so at least one particle needs to remain in place.
  27134. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27135. * @param start index of the first particle to remove
  27136. * @param end index of the last particle to remove (included)
  27137. * @returns an array populated with the removed particles
  27138. */
  27139. removeParticles(start: number, end: number): SolidParticle[];
  27140. /**
  27141. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27142. * @param solidParticleArray an array populated with Solid Particles objects
  27143. * @returns the SPS
  27144. */
  27145. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27146. /**
  27147. * Creates a new particle and modifies the SPS mesh geometry :
  27148. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27149. * - calls _addParticle() to populate the particle array
  27150. * factorized code from addShape() and insertParticlesFromArray()
  27151. * @param idx particle index in the particles array
  27152. * @param i particle index in its shape
  27153. * @param modelShape particle ModelShape object
  27154. * @param shape shape vertex array
  27155. * @param meshInd shape indices array
  27156. * @param meshUV shape uv array
  27157. * @param meshCol shape color array
  27158. * @param meshNor shape normals array
  27159. * @param bbInfo shape bounding info
  27160. * @param storage target particle storage
  27161. * @options addShape() passed options
  27162. * @hidden
  27163. */
  27164. private _insertNewParticle;
  27165. /**
  27166. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27167. * This method calls `updateParticle()` for each particle of the SPS.
  27168. * For an animated SPS, it is usually called within the render loop.
  27169. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27170. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27171. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27172. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27173. * @returns the SPS.
  27174. */
  27175. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27176. /**
  27177. * Disposes the SPS.
  27178. */
  27179. dispose(): void;
  27180. /**
  27181. * Returns a SolidParticle object from its identifier : particle.id
  27182. * @param id (integer) the particle Id
  27183. * @returns the searched particle or null if not found in the SPS.
  27184. */
  27185. getParticleById(id: number): Nullable<SolidParticle>;
  27186. /**
  27187. * Returns a new array populated with the particles having the passed shapeId.
  27188. * @param shapeId (integer) the shape identifier
  27189. * @returns a new solid particle array
  27190. */
  27191. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27192. /**
  27193. * Populates the passed array "ref" with the particles having the passed shapeId.
  27194. * @param shapeId the shape identifier
  27195. * @returns the SPS
  27196. * @param ref
  27197. */
  27198. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27199. /**
  27200. * Computes the required SubMeshes according the materials assigned to the particles.
  27201. * @returns the solid particle system.
  27202. * Does nothing if called before the SPS mesh is built.
  27203. */
  27204. computeSubMeshes(): SolidParticleSystem;
  27205. /**
  27206. * Sorts the solid particles by material when MultiMaterial is enabled.
  27207. * Updates the indices32 array.
  27208. * Updates the indicesByMaterial array.
  27209. * Updates the mesh indices array.
  27210. * @returns the SPS
  27211. * @hidden
  27212. */
  27213. private _sortParticlesByMaterial;
  27214. /**
  27215. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27216. * @hidden
  27217. */
  27218. private _setMaterialIndexesById;
  27219. /**
  27220. * Returns an array with unique values of Materials from the passed array
  27221. * @param array the material array to be checked and filtered
  27222. * @hidden
  27223. */
  27224. private _filterUniqueMaterialId;
  27225. /**
  27226. * Sets a new Standard Material as _defaultMaterial if not already set.
  27227. * @hidden
  27228. */
  27229. private _setDefaultMaterial;
  27230. /**
  27231. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27232. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27233. * @returns the SPS.
  27234. */
  27235. refreshVisibleSize(): SolidParticleSystem;
  27236. /**
  27237. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27238. * @param size the size (float) of the visibility box
  27239. * note : this doesn't lock the SPS mesh bounding box.
  27240. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27241. */
  27242. setVisibilityBox(size: number): void;
  27243. /**
  27244. * Gets whether the SPS as always visible or not
  27245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27246. */
  27247. get isAlwaysVisible(): boolean;
  27248. /**
  27249. * Sets the SPS as always visible or not
  27250. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27251. */
  27252. set isAlwaysVisible(val: boolean);
  27253. /**
  27254. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27255. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27256. */
  27257. set isVisibilityBoxLocked(val: boolean);
  27258. /**
  27259. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27260. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27261. */
  27262. get isVisibilityBoxLocked(): boolean;
  27263. /**
  27264. * Tells to `setParticles()` to compute the particle rotations or not.
  27265. * Default value : true. The SPS is faster when it's set to false.
  27266. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27267. */
  27268. set computeParticleRotation(val: boolean);
  27269. /**
  27270. * Tells to `setParticles()` to compute the particle colors or not.
  27271. * Default value : true. The SPS is faster when it's set to false.
  27272. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27273. */
  27274. set computeParticleColor(val: boolean);
  27275. set computeParticleTexture(val: boolean);
  27276. /**
  27277. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27278. * Default value : false. The SPS is faster when it's set to false.
  27279. * Note : the particle custom vertex positions aren't stored values.
  27280. */
  27281. set computeParticleVertex(val: boolean);
  27282. /**
  27283. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27284. */
  27285. set computeBoundingBox(val: boolean);
  27286. /**
  27287. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27288. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27289. * Default : `true`
  27290. */
  27291. set depthSortParticles(val: boolean);
  27292. /**
  27293. * Gets if `setParticles()` computes the particle rotations or not.
  27294. * Default value : true. The SPS is faster when it's set to false.
  27295. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27296. */
  27297. get computeParticleRotation(): boolean;
  27298. /**
  27299. * Gets if `setParticles()` computes the particle colors or not.
  27300. * Default value : true. The SPS is faster when it's set to false.
  27301. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27302. */
  27303. get computeParticleColor(): boolean;
  27304. /**
  27305. * Gets if `setParticles()` computes the particle textures or not.
  27306. * Default value : true. The SPS is faster when it's set to false.
  27307. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27308. */
  27309. get computeParticleTexture(): boolean;
  27310. /**
  27311. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27312. * Default value : false. The SPS is faster when it's set to false.
  27313. * Note : the particle custom vertex positions aren't stored values.
  27314. */
  27315. get computeParticleVertex(): boolean;
  27316. /**
  27317. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27318. */
  27319. get computeBoundingBox(): boolean;
  27320. /**
  27321. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27322. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27323. * Default : `true`
  27324. */
  27325. get depthSortParticles(): boolean;
  27326. /**
  27327. * Gets if the SPS is created as expandable at construction time.
  27328. * Default : `false`
  27329. */
  27330. get expandable(): boolean;
  27331. /**
  27332. * Gets if the SPS supports the Multi Materials
  27333. */
  27334. get multimaterialEnabled(): boolean;
  27335. /**
  27336. * Gets if the SPS uses the model materials for its own multimaterial.
  27337. */
  27338. get useModelMaterial(): boolean;
  27339. /**
  27340. * The SPS used material array.
  27341. */
  27342. get materials(): Material[];
  27343. /**
  27344. * Sets the SPS MultiMaterial from the passed materials.
  27345. * Note : the passed array is internally copied and not used then by reference.
  27346. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27347. */
  27348. setMultiMaterial(materials: Material[]): void;
  27349. /**
  27350. * The SPS computed multimaterial object
  27351. */
  27352. get multimaterial(): MultiMaterial;
  27353. set multimaterial(mm: MultiMaterial);
  27354. /**
  27355. * If the subMeshes must be updated on the next call to setParticles()
  27356. */
  27357. get autoUpdateSubMeshes(): boolean;
  27358. set autoUpdateSubMeshes(val: boolean);
  27359. /**
  27360. * This function does nothing. It may be overwritten to set all the particle first values.
  27361. * The SPS doesn't call this function, you may have to call it by your own.
  27362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27363. */
  27364. initParticles(): void;
  27365. /**
  27366. * This function does nothing. It may be overwritten to recycle a particle.
  27367. * The SPS doesn't call this function, you may have to call it by your own.
  27368. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27369. * @param particle The particle to recycle
  27370. * @returns the recycled particle
  27371. */
  27372. recycleParticle(particle: SolidParticle): SolidParticle;
  27373. /**
  27374. * Updates a particle : this function should be overwritten by the user.
  27375. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27376. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27377. * @example : just set a particle position or velocity and recycle conditions
  27378. * @param particle The particle to update
  27379. * @returns the updated particle
  27380. */
  27381. updateParticle(particle: SolidParticle): SolidParticle;
  27382. /**
  27383. * Updates a vertex of a particle : it can be overwritten by the user.
  27384. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27385. * @param particle the current particle
  27386. * @param vertex the current index of the current particle
  27387. * @param pt the index of the current vertex in the particle shape
  27388. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27389. * @example : just set a vertex particle position
  27390. * @returns the updated vertex
  27391. */
  27392. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27393. /**
  27394. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27395. * This does nothing and may be overwritten by the user.
  27396. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27398. * @param update the boolean update value actually passed to setParticles()
  27399. */
  27400. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27401. /**
  27402. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27403. * This will be passed three parameters.
  27404. * This does nothing and may be overwritten by the user.
  27405. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27406. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27407. * @param update the boolean update value actually passed to setParticles()
  27408. */
  27409. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27410. }
  27411. }
  27412. declare module BABYLON {
  27413. /**
  27414. * Represents one particle of a solid particle system.
  27415. */
  27416. export class SolidParticle {
  27417. /**
  27418. * particle global index
  27419. */
  27420. idx: number;
  27421. /**
  27422. * particle identifier
  27423. */
  27424. id: number;
  27425. /**
  27426. * The color of the particle
  27427. */
  27428. color: Nullable<Color4>;
  27429. /**
  27430. * The world space position of the particle.
  27431. */
  27432. position: Vector3;
  27433. /**
  27434. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27435. */
  27436. rotation: Vector3;
  27437. /**
  27438. * The world space rotation quaternion of the particle.
  27439. */
  27440. rotationQuaternion: Nullable<Quaternion>;
  27441. /**
  27442. * The scaling of the particle.
  27443. */
  27444. scaling: Vector3;
  27445. /**
  27446. * The uvs of the particle.
  27447. */
  27448. uvs: Vector4;
  27449. /**
  27450. * The current speed of the particle.
  27451. */
  27452. velocity: Vector3;
  27453. /**
  27454. * The pivot point in the particle local space.
  27455. */
  27456. pivot: Vector3;
  27457. /**
  27458. * Must the particle be translated from its pivot point in its local space ?
  27459. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27460. * Default : false
  27461. */
  27462. translateFromPivot: boolean;
  27463. /**
  27464. * Is the particle active or not ?
  27465. */
  27466. alive: boolean;
  27467. /**
  27468. * Is the particle visible or not ?
  27469. */
  27470. isVisible: boolean;
  27471. /**
  27472. * Index of this particle in the global "positions" array (Internal use)
  27473. * @hidden
  27474. */
  27475. _pos: number;
  27476. /**
  27477. * @hidden Index of this particle in the global "indices" array (Internal use)
  27478. */
  27479. _ind: number;
  27480. /**
  27481. * @hidden ModelShape of this particle (Internal use)
  27482. */
  27483. _model: ModelShape;
  27484. /**
  27485. * ModelShape id of this particle
  27486. */
  27487. shapeId: number;
  27488. /**
  27489. * Index of the particle in its shape id
  27490. */
  27491. idxInShape: number;
  27492. /**
  27493. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27494. */
  27495. _modelBoundingInfo: BoundingInfo;
  27496. /**
  27497. * @hidden Particle BoundingInfo object (Internal use)
  27498. */
  27499. _boundingInfo: BoundingInfo;
  27500. /**
  27501. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27502. */
  27503. _sps: SolidParticleSystem;
  27504. /**
  27505. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27506. */
  27507. _stillInvisible: boolean;
  27508. /**
  27509. * @hidden Last computed particle rotation matrix
  27510. */
  27511. _rotationMatrix: number[];
  27512. /**
  27513. * Parent particle Id, if any.
  27514. * Default null.
  27515. */
  27516. parentId: Nullable<number>;
  27517. /**
  27518. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27519. */
  27520. materialIndex: Nullable<number>;
  27521. /**
  27522. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27523. * The possible values are :
  27524. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27525. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27526. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27527. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27528. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27529. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27530. * */
  27531. cullingStrategy: number;
  27532. /**
  27533. * @hidden Internal global position in the SPS.
  27534. */
  27535. _globalPosition: Vector3;
  27536. /**
  27537. * Creates a Solid Particle object.
  27538. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27539. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27540. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27541. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27542. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27543. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27544. * @param shapeId (integer) is the model shape identifier in the SPS.
  27545. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27546. * @param sps defines the sps it is associated to
  27547. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27548. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27549. */
  27550. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27551. /**
  27552. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27553. * @param target the particle target
  27554. * @returns the current particle
  27555. */
  27556. copyToRef(target: SolidParticle): SolidParticle;
  27557. /**
  27558. * Legacy support, changed scale to scaling
  27559. */
  27560. get scale(): Vector3;
  27561. /**
  27562. * Legacy support, changed scale to scaling
  27563. */
  27564. set scale(scale: Vector3);
  27565. /**
  27566. * Legacy support, changed quaternion to rotationQuaternion
  27567. */
  27568. get quaternion(): Nullable<Quaternion>;
  27569. /**
  27570. * Legacy support, changed quaternion to rotationQuaternion
  27571. */
  27572. set quaternion(q: Nullable<Quaternion>);
  27573. /**
  27574. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27575. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27576. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27577. * @returns true if it intersects
  27578. */
  27579. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27580. /**
  27581. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27582. * A particle is in the frustum if its bounding box intersects the frustum
  27583. * @param frustumPlanes defines the frustum to test
  27584. * @returns true if the particle is in the frustum planes
  27585. */
  27586. isInFrustum(frustumPlanes: Plane[]): boolean;
  27587. /**
  27588. * get the rotation matrix of the particle
  27589. * @hidden
  27590. */
  27591. getRotationMatrix(m: Matrix): void;
  27592. }
  27593. /**
  27594. * Represents the shape of the model used by one particle of a solid particle system.
  27595. * SPS internal tool, don't use it manually.
  27596. */
  27597. export class ModelShape {
  27598. /**
  27599. * The shape id
  27600. * @hidden
  27601. */
  27602. shapeID: number;
  27603. /**
  27604. * flat array of model positions (internal use)
  27605. * @hidden
  27606. */
  27607. _shape: Vector3[];
  27608. /**
  27609. * flat array of model UVs (internal use)
  27610. * @hidden
  27611. */
  27612. _shapeUV: number[];
  27613. /**
  27614. * color array of the model
  27615. * @hidden
  27616. */
  27617. _shapeColors: number[];
  27618. /**
  27619. * indices array of the model
  27620. * @hidden
  27621. */
  27622. _indices: number[];
  27623. /**
  27624. * normals array of the model
  27625. * @hidden
  27626. */
  27627. _normals: number[];
  27628. /**
  27629. * length of the shape in the model indices array (internal use)
  27630. * @hidden
  27631. */
  27632. _indicesLength: number;
  27633. /**
  27634. * Custom position function (internal use)
  27635. * @hidden
  27636. */
  27637. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27638. /**
  27639. * Custom vertex function (internal use)
  27640. * @hidden
  27641. */
  27642. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27643. /**
  27644. * Model material (internal use)
  27645. * @hidden
  27646. */
  27647. _material: Nullable<Material>;
  27648. /**
  27649. * 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.
  27650. * SPS internal tool, don't use it manually.
  27651. * @hidden
  27652. */
  27653. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27654. }
  27655. /**
  27656. * Represents a Depth Sorted Particle in the solid particle system.
  27657. * @hidden
  27658. */
  27659. export class DepthSortedParticle {
  27660. /**
  27661. * Index of the particle in the "indices" array
  27662. */
  27663. ind: number;
  27664. /**
  27665. * Length of the particle shape in the "indices" array
  27666. */
  27667. indicesLength: number;
  27668. /**
  27669. * Squared distance from the particle to the camera
  27670. */
  27671. sqDistance: number;
  27672. /**
  27673. * Material index when used with MultiMaterials
  27674. */
  27675. materialIndex: number;
  27676. /**
  27677. * Creates a new sorted particle
  27678. * @param materialIndex
  27679. */
  27680. constructor(ind: number, indLength: number, materialIndex: number);
  27681. }
  27682. }
  27683. declare module BABYLON {
  27684. /**
  27685. * @hidden
  27686. */
  27687. export class _MeshCollisionData {
  27688. _checkCollisions: boolean;
  27689. _collisionMask: number;
  27690. _collisionGroup: number;
  27691. _collider: Nullable<Collider>;
  27692. _oldPositionForCollisions: Vector3;
  27693. _diffPositionForCollisions: Vector3;
  27694. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27695. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27696. }
  27697. }
  27698. declare module BABYLON {
  27699. /** @hidden */
  27700. class _FacetDataStorage {
  27701. facetPositions: Vector3[];
  27702. facetNormals: Vector3[];
  27703. facetPartitioning: number[][];
  27704. facetNb: number;
  27705. partitioningSubdivisions: number;
  27706. partitioningBBoxRatio: number;
  27707. facetDataEnabled: boolean;
  27708. facetParameters: any;
  27709. bbSize: Vector3;
  27710. subDiv: {
  27711. max: number;
  27712. X: number;
  27713. Y: number;
  27714. Z: number;
  27715. };
  27716. facetDepthSort: boolean;
  27717. facetDepthSortEnabled: boolean;
  27718. depthSortedIndices: IndicesArray;
  27719. depthSortedFacets: {
  27720. ind: number;
  27721. sqDistance: number;
  27722. }[];
  27723. facetDepthSortFunction: (f1: {
  27724. ind: number;
  27725. sqDistance: number;
  27726. }, f2: {
  27727. ind: number;
  27728. sqDistance: number;
  27729. }) => number;
  27730. facetDepthSortFrom: Vector3;
  27731. facetDepthSortOrigin: Vector3;
  27732. invertedMatrix: Matrix;
  27733. }
  27734. /**
  27735. * @hidden
  27736. **/
  27737. class _InternalAbstractMeshDataInfo {
  27738. _hasVertexAlpha: boolean;
  27739. _useVertexColors: boolean;
  27740. _numBoneInfluencers: number;
  27741. _applyFog: boolean;
  27742. _receiveShadows: boolean;
  27743. _facetData: _FacetDataStorage;
  27744. _visibility: number;
  27745. _skeleton: Nullable<Skeleton>;
  27746. _layerMask: number;
  27747. _computeBonesUsingShaders: boolean;
  27748. _isActive: boolean;
  27749. _onlyForInstances: boolean;
  27750. _isActiveIntermediate: boolean;
  27751. _onlyForInstancesIntermediate: boolean;
  27752. _actAsRegularMesh: boolean;
  27753. }
  27754. /**
  27755. * Class used to store all common mesh properties
  27756. */
  27757. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27758. /** No occlusion */
  27759. static OCCLUSION_TYPE_NONE: number;
  27760. /** Occlusion set to optimisitic */
  27761. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27762. /** Occlusion set to strict */
  27763. static OCCLUSION_TYPE_STRICT: number;
  27764. /** Use an accurante occlusion algorithm */
  27765. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27766. /** Use a conservative occlusion algorithm */
  27767. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27768. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27769. * Test order :
  27770. * Is the bounding sphere outside the frustum ?
  27771. * If not, are the bounding box vertices outside the frustum ?
  27772. * It not, then the cullable object is in the frustum.
  27773. */
  27774. static readonly CULLINGSTRATEGY_STANDARD: number;
  27775. /** Culling strategy : Bounding Sphere Only.
  27776. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27777. * It's also less accurate than the standard because some not visible objects can still be selected.
  27778. * Test : is the bounding sphere outside the frustum ?
  27779. * If not, then the cullable object is in the frustum.
  27780. */
  27781. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27782. /** Culling strategy : Optimistic Inclusion.
  27783. * This in an inclusion test first, then the standard exclusion test.
  27784. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27785. * 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.
  27786. * Anyway, it's as accurate as the standard strategy.
  27787. * Test :
  27788. * Is the cullable object bounding sphere center in the frustum ?
  27789. * If not, apply the default culling strategy.
  27790. */
  27791. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27792. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27793. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27794. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27795. * 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.
  27796. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27797. * Test :
  27798. * Is the cullable object bounding sphere center in the frustum ?
  27799. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27800. */
  27801. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27802. /**
  27803. * No billboard
  27804. */
  27805. static get BILLBOARDMODE_NONE(): number;
  27806. /** Billboard on X axis */
  27807. static get BILLBOARDMODE_X(): number;
  27808. /** Billboard on Y axis */
  27809. static get BILLBOARDMODE_Y(): number;
  27810. /** Billboard on Z axis */
  27811. static get BILLBOARDMODE_Z(): number;
  27812. /** Billboard on all axes */
  27813. static get BILLBOARDMODE_ALL(): number;
  27814. /** Billboard on using position instead of orientation */
  27815. static get BILLBOARDMODE_USE_POSITION(): number;
  27816. /** @hidden */
  27817. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27818. /**
  27819. * The culling strategy to use to check whether the mesh must be rendered or not.
  27820. * This value can be changed at any time and will be used on the next render mesh selection.
  27821. * The possible values are :
  27822. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27823. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27824. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27826. * Please read each static variable documentation to get details about the culling process.
  27827. * */
  27828. cullingStrategy: number;
  27829. /**
  27830. * Gets the number of facets in the mesh
  27831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27832. */
  27833. get facetNb(): number;
  27834. /**
  27835. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27837. */
  27838. get partitioningSubdivisions(): number;
  27839. set partitioningSubdivisions(nb: number);
  27840. /**
  27841. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27842. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27844. */
  27845. get partitioningBBoxRatio(): number;
  27846. set partitioningBBoxRatio(ratio: number);
  27847. /**
  27848. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27849. * Works only for updatable meshes.
  27850. * Doesn't work with multi-materials
  27851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27852. */
  27853. get mustDepthSortFacets(): boolean;
  27854. set mustDepthSortFacets(sort: boolean);
  27855. /**
  27856. * The location (Vector3) where the facet depth sort must be computed from.
  27857. * By default, the active camera position.
  27858. * Used only when facet depth sort is enabled
  27859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27860. */
  27861. get facetDepthSortFrom(): Vector3;
  27862. set facetDepthSortFrom(location: Vector3);
  27863. /**
  27864. * gets a boolean indicating if facetData is enabled
  27865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27866. */
  27867. get isFacetDataEnabled(): boolean;
  27868. /** @hidden */
  27869. _updateNonUniformScalingState(value: boolean): boolean;
  27870. /**
  27871. * An event triggered when this mesh collides with another one
  27872. */
  27873. onCollideObservable: Observable<AbstractMesh>;
  27874. /** Set a function to call when this mesh collides with another one */
  27875. set onCollide(callback: () => void);
  27876. /**
  27877. * An event triggered when the collision's position changes
  27878. */
  27879. onCollisionPositionChangeObservable: Observable<Vector3>;
  27880. /** Set a function to call when the collision's position changes */
  27881. set onCollisionPositionChange(callback: () => void);
  27882. /**
  27883. * An event triggered when material is changed
  27884. */
  27885. onMaterialChangedObservable: Observable<AbstractMesh>;
  27886. /**
  27887. * Gets or sets the orientation for POV movement & rotation
  27888. */
  27889. definedFacingForward: boolean;
  27890. /** @hidden */
  27891. _occlusionQuery: Nullable<WebGLQuery>;
  27892. /** @hidden */
  27893. _renderingGroup: Nullable<RenderingGroup>;
  27894. /**
  27895. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27896. */
  27897. get visibility(): number;
  27898. /**
  27899. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27900. */
  27901. set visibility(value: number);
  27902. /** Gets or sets the alpha index used to sort transparent meshes
  27903. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27904. */
  27905. alphaIndex: number;
  27906. /**
  27907. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27908. */
  27909. isVisible: boolean;
  27910. /**
  27911. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27912. */
  27913. isPickable: boolean;
  27914. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27915. showSubMeshesBoundingBox: boolean;
  27916. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27918. */
  27919. isBlocker: boolean;
  27920. /**
  27921. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27922. */
  27923. enablePointerMoveEvents: boolean;
  27924. /**
  27925. * Specifies the rendering group id for this mesh (0 by default)
  27926. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27927. */
  27928. renderingGroupId: number;
  27929. private _material;
  27930. /** Gets or sets current material */
  27931. get material(): Nullable<Material>;
  27932. set material(value: Nullable<Material>);
  27933. /**
  27934. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27935. * @see http://doc.babylonjs.com/babylon101/shadows
  27936. */
  27937. get receiveShadows(): boolean;
  27938. set receiveShadows(value: boolean);
  27939. /** Defines color to use when rendering outline */
  27940. outlineColor: Color3;
  27941. /** Define width to use when rendering outline */
  27942. outlineWidth: number;
  27943. /** Defines color to use when rendering overlay */
  27944. overlayColor: Color3;
  27945. /** Defines alpha to use when rendering overlay */
  27946. overlayAlpha: number;
  27947. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27948. get hasVertexAlpha(): boolean;
  27949. set hasVertexAlpha(value: boolean);
  27950. /** 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) */
  27951. get useVertexColors(): boolean;
  27952. set useVertexColors(value: boolean);
  27953. /**
  27954. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27955. */
  27956. get computeBonesUsingShaders(): boolean;
  27957. set computeBonesUsingShaders(value: boolean);
  27958. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27959. get numBoneInfluencers(): number;
  27960. set numBoneInfluencers(value: number);
  27961. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27962. get applyFog(): boolean;
  27963. set applyFog(value: boolean);
  27964. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27965. useOctreeForRenderingSelection: boolean;
  27966. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27967. useOctreeForPicking: boolean;
  27968. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27969. useOctreeForCollisions: boolean;
  27970. /**
  27971. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27972. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27973. */
  27974. get layerMask(): number;
  27975. set layerMask(value: number);
  27976. /**
  27977. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27978. */
  27979. alwaysSelectAsActiveMesh: boolean;
  27980. /**
  27981. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27982. */
  27983. doNotSyncBoundingInfo: boolean;
  27984. /**
  27985. * Gets or sets the current action manager
  27986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27987. */
  27988. actionManager: Nullable<AbstractActionManager>;
  27989. private _meshCollisionData;
  27990. /**
  27991. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27993. */
  27994. ellipsoid: Vector3;
  27995. /**
  27996. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27998. */
  27999. ellipsoidOffset: Vector3;
  28000. /**
  28001. * Gets or sets a collision mask used to mask collisions (default is -1).
  28002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28003. */
  28004. get collisionMask(): number;
  28005. set collisionMask(mask: number);
  28006. /**
  28007. * Gets or sets the current collision group mask (-1 by default).
  28008. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28009. */
  28010. get collisionGroup(): number;
  28011. set collisionGroup(mask: number);
  28012. /**
  28013. * Defines edge width used when edgesRenderer is enabled
  28014. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28015. */
  28016. edgesWidth: number;
  28017. /**
  28018. * Defines edge color used when edgesRenderer is enabled
  28019. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28020. */
  28021. edgesColor: Color4;
  28022. /** @hidden */
  28023. _edgesRenderer: Nullable<IEdgesRenderer>;
  28024. /** @hidden */
  28025. _masterMesh: Nullable<AbstractMesh>;
  28026. /** @hidden */
  28027. _boundingInfo: Nullable<BoundingInfo>;
  28028. /** @hidden */
  28029. _renderId: number;
  28030. /**
  28031. * Gets or sets the list of subMeshes
  28032. * @see http://doc.babylonjs.com/how_to/multi_materials
  28033. */
  28034. subMeshes: SubMesh[];
  28035. /** @hidden */
  28036. _intersectionsInProgress: AbstractMesh[];
  28037. /** @hidden */
  28038. _unIndexed: boolean;
  28039. /** @hidden */
  28040. _lightSources: Light[];
  28041. /** Gets the list of lights affecting that mesh */
  28042. get lightSources(): Light[];
  28043. /** @hidden */
  28044. get _positions(): Nullable<Vector3[]>;
  28045. /** @hidden */
  28046. _waitingData: {
  28047. lods: Nullable<any>;
  28048. actions: Nullable<any>;
  28049. freezeWorldMatrix: Nullable<boolean>;
  28050. };
  28051. /** @hidden */
  28052. _bonesTransformMatrices: Nullable<Float32Array>;
  28053. /** @hidden */
  28054. _transformMatrixTexture: Nullable<RawTexture>;
  28055. /**
  28056. * Gets or sets a skeleton to apply skining transformations
  28057. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28058. */
  28059. set skeleton(value: Nullable<Skeleton>);
  28060. get skeleton(): Nullable<Skeleton>;
  28061. /**
  28062. * An event triggered when the mesh is rebuilt.
  28063. */
  28064. onRebuildObservable: Observable<AbstractMesh>;
  28065. /**
  28066. * Creates a new AbstractMesh
  28067. * @param name defines the name of the mesh
  28068. * @param scene defines the hosting scene
  28069. */
  28070. constructor(name: string, scene?: Nullable<Scene>);
  28071. /**
  28072. * Returns the string "AbstractMesh"
  28073. * @returns "AbstractMesh"
  28074. */
  28075. getClassName(): string;
  28076. /**
  28077. * Gets a string representation of the current mesh
  28078. * @param fullDetails defines a boolean indicating if full details must be included
  28079. * @returns a string representation of the current mesh
  28080. */
  28081. toString(fullDetails?: boolean): string;
  28082. /**
  28083. * @hidden
  28084. */
  28085. protected _getEffectiveParent(): Nullable<Node>;
  28086. /** @hidden */
  28087. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28088. /** @hidden */
  28089. _rebuild(): void;
  28090. /** @hidden */
  28091. _resyncLightSources(): void;
  28092. /** @hidden */
  28093. _resyncLightSource(light: Light): void;
  28094. /** @hidden */
  28095. _unBindEffect(): void;
  28096. /** @hidden */
  28097. _removeLightSource(light: Light, dispose: boolean): void;
  28098. private _markSubMeshesAsDirty;
  28099. /** @hidden */
  28100. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28101. /** @hidden */
  28102. _markSubMeshesAsAttributesDirty(): void;
  28103. /** @hidden */
  28104. _markSubMeshesAsMiscDirty(): void;
  28105. /**
  28106. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28107. */
  28108. get scaling(): Vector3;
  28109. set scaling(newScaling: Vector3);
  28110. /**
  28111. * Returns true if the mesh is blocked. Implemented by child classes
  28112. */
  28113. get isBlocked(): boolean;
  28114. /**
  28115. * Returns the mesh itself by default. Implemented by child classes
  28116. * @param camera defines the camera to use to pick the right LOD level
  28117. * @returns the currentAbstractMesh
  28118. */
  28119. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28120. /**
  28121. * Returns 0 by default. Implemented by child classes
  28122. * @returns an integer
  28123. */
  28124. getTotalVertices(): number;
  28125. /**
  28126. * Returns a positive integer : the total number of indices in this mesh geometry.
  28127. * @returns the numner of indices or zero if the mesh has no geometry.
  28128. */
  28129. getTotalIndices(): number;
  28130. /**
  28131. * Returns null by default. Implemented by child classes
  28132. * @returns null
  28133. */
  28134. getIndices(): Nullable<IndicesArray>;
  28135. /**
  28136. * Returns the array of the requested vertex data kind. Implemented by child classes
  28137. * @param kind defines the vertex data kind to use
  28138. * @returns null
  28139. */
  28140. getVerticesData(kind: string): Nullable<FloatArray>;
  28141. /**
  28142. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28143. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28144. * Note that a new underlying VertexBuffer object is created each call.
  28145. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28146. * @param kind defines vertex data kind:
  28147. * * VertexBuffer.PositionKind
  28148. * * VertexBuffer.UVKind
  28149. * * VertexBuffer.UV2Kind
  28150. * * VertexBuffer.UV3Kind
  28151. * * VertexBuffer.UV4Kind
  28152. * * VertexBuffer.UV5Kind
  28153. * * VertexBuffer.UV6Kind
  28154. * * VertexBuffer.ColorKind
  28155. * * VertexBuffer.MatricesIndicesKind
  28156. * * VertexBuffer.MatricesIndicesExtraKind
  28157. * * VertexBuffer.MatricesWeightsKind
  28158. * * VertexBuffer.MatricesWeightsExtraKind
  28159. * @param data defines the data source
  28160. * @param updatable defines if the data must be flagged as updatable (or static)
  28161. * @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
  28162. * @returns the current mesh
  28163. */
  28164. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28165. /**
  28166. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28167. * If the mesh has no geometry, it is simply returned as it is.
  28168. * @param kind defines vertex data kind:
  28169. * * VertexBuffer.PositionKind
  28170. * * VertexBuffer.UVKind
  28171. * * VertexBuffer.UV2Kind
  28172. * * VertexBuffer.UV3Kind
  28173. * * VertexBuffer.UV4Kind
  28174. * * VertexBuffer.UV5Kind
  28175. * * VertexBuffer.UV6Kind
  28176. * * VertexBuffer.ColorKind
  28177. * * VertexBuffer.MatricesIndicesKind
  28178. * * VertexBuffer.MatricesIndicesExtraKind
  28179. * * VertexBuffer.MatricesWeightsKind
  28180. * * VertexBuffer.MatricesWeightsExtraKind
  28181. * @param data defines the data source
  28182. * @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
  28183. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28184. * @returns the current mesh
  28185. */
  28186. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28187. /**
  28188. * Sets the mesh indices,
  28189. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28190. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28191. * @param totalVertices Defines the total number of vertices
  28192. * @returns the current mesh
  28193. */
  28194. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28195. /**
  28196. * Gets a boolean indicating if specific vertex data is present
  28197. * @param kind defines the vertex data kind to use
  28198. * @returns true is data kind is present
  28199. */
  28200. isVerticesDataPresent(kind: string): boolean;
  28201. /**
  28202. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28203. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28204. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28205. * @returns a BoundingInfo
  28206. */
  28207. getBoundingInfo(): BoundingInfo;
  28208. /**
  28209. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28210. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28211. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28212. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28213. * @returns the current mesh
  28214. */
  28215. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28216. /**
  28217. * Overwrite the current bounding info
  28218. * @param boundingInfo defines the new bounding info
  28219. * @returns the current mesh
  28220. */
  28221. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28222. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28223. get useBones(): boolean;
  28224. /** @hidden */
  28225. _preActivate(): void;
  28226. /** @hidden */
  28227. _preActivateForIntermediateRendering(renderId: number): void;
  28228. /** @hidden */
  28229. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28230. /** @hidden */
  28231. _postActivate(): void;
  28232. /** @hidden */
  28233. _freeze(): void;
  28234. /** @hidden */
  28235. _unFreeze(): void;
  28236. /**
  28237. * Gets the current world matrix
  28238. * @returns a Matrix
  28239. */
  28240. getWorldMatrix(): Matrix;
  28241. /** @hidden */
  28242. _getWorldMatrixDeterminant(): number;
  28243. /**
  28244. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28245. */
  28246. get isAnInstance(): boolean;
  28247. /**
  28248. * Gets a boolean indicating if this mesh has instances
  28249. */
  28250. get hasInstances(): boolean;
  28251. /**
  28252. * Perform relative position change from the point of view of behind the front of the mesh.
  28253. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28254. * Supports definition of mesh facing forward or backward
  28255. * @param amountRight defines the distance on the right axis
  28256. * @param amountUp defines the distance on the up axis
  28257. * @param amountForward defines the distance on the forward axis
  28258. * @returns the current mesh
  28259. */
  28260. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28261. /**
  28262. * Calculate relative position change from the point of view of behind the front of the mesh.
  28263. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28264. * Supports definition of mesh facing forward or backward
  28265. * @param amountRight defines the distance on the right axis
  28266. * @param amountUp defines the distance on the up axis
  28267. * @param amountForward defines the distance on the forward axis
  28268. * @returns the new displacement vector
  28269. */
  28270. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28271. /**
  28272. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28273. * Supports definition of mesh facing forward or backward
  28274. * @param flipBack defines the flip
  28275. * @param twirlClockwise defines the twirl
  28276. * @param tiltRight defines the tilt
  28277. * @returns the current mesh
  28278. */
  28279. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28280. /**
  28281. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28282. * Supports definition of mesh facing forward or backward.
  28283. * @param flipBack defines the flip
  28284. * @param twirlClockwise defines the twirl
  28285. * @param tiltRight defines the tilt
  28286. * @returns the new rotation vector
  28287. */
  28288. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28289. /**
  28290. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28291. * This means the mesh underlying bounding box and sphere are recomputed.
  28292. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28293. * @returns the current mesh
  28294. */
  28295. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28296. /** @hidden */
  28297. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28298. /** @hidden */
  28299. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28300. /** @hidden */
  28301. _updateBoundingInfo(): AbstractMesh;
  28302. /** @hidden */
  28303. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28304. /** @hidden */
  28305. protected _afterComputeWorldMatrix(): void;
  28306. /** @hidden */
  28307. get _effectiveMesh(): AbstractMesh;
  28308. /**
  28309. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28310. * A mesh is in the frustum if its bounding box intersects the frustum
  28311. * @param frustumPlanes defines the frustum to test
  28312. * @returns true if the mesh is in the frustum planes
  28313. */
  28314. isInFrustum(frustumPlanes: Plane[]): boolean;
  28315. /**
  28316. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28317. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28318. * @param frustumPlanes defines the frustum to test
  28319. * @returns true if the mesh is completely in the frustum planes
  28320. */
  28321. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28322. /**
  28323. * True if the mesh intersects another mesh or a SolidParticle object
  28324. * @param mesh defines a target mesh or SolidParticle to test
  28325. * @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)
  28326. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28327. * @returns true if there is an intersection
  28328. */
  28329. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28330. /**
  28331. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28332. * @param point defines the point to test
  28333. * @returns true if there is an intersection
  28334. */
  28335. intersectsPoint(point: Vector3): boolean;
  28336. /**
  28337. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28339. */
  28340. get checkCollisions(): boolean;
  28341. set checkCollisions(collisionEnabled: boolean);
  28342. /**
  28343. * Gets Collider object used to compute collisions (not physics)
  28344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28345. */
  28346. get collider(): Nullable<Collider>;
  28347. /**
  28348. * Move the mesh using collision engine
  28349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28350. * @param displacement defines the requested displacement vector
  28351. * @returns the current mesh
  28352. */
  28353. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28354. private _onCollisionPositionChange;
  28355. /** @hidden */
  28356. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28357. /** @hidden */
  28358. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28359. /** @hidden */
  28360. _checkCollision(collider: Collider): AbstractMesh;
  28361. /** @hidden */
  28362. _generatePointsArray(): boolean;
  28363. /**
  28364. * Checks if the passed Ray intersects with the mesh
  28365. * @param ray defines the ray to use
  28366. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28367. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28368. * @returns the picking info
  28369. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28370. */
  28371. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28372. /**
  28373. * Clones the current mesh
  28374. * @param name defines the mesh name
  28375. * @param newParent defines the new mesh parent
  28376. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28377. * @returns the new mesh
  28378. */
  28379. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28380. /**
  28381. * Disposes all the submeshes of the current meshnp
  28382. * @returns the current mesh
  28383. */
  28384. releaseSubMeshes(): AbstractMesh;
  28385. /**
  28386. * Releases resources associated with this abstract mesh.
  28387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28389. */
  28390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28391. /**
  28392. * Adds the passed mesh as a child to the current mesh
  28393. * @param mesh defines the child mesh
  28394. * @returns the current mesh
  28395. */
  28396. addChild(mesh: AbstractMesh): AbstractMesh;
  28397. /**
  28398. * Removes the passed mesh from the current mesh children list
  28399. * @param mesh defines the child mesh
  28400. * @returns the current mesh
  28401. */
  28402. removeChild(mesh: AbstractMesh): AbstractMesh;
  28403. /** @hidden */
  28404. private _initFacetData;
  28405. /**
  28406. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28407. * This method can be called within the render loop.
  28408. * 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
  28409. * @returns the current mesh
  28410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28411. */
  28412. updateFacetData(): AbstractMesh;
  28413. /**
  28414. * Returns the facetLocalNormals array.
  28415. * The normals are expressed in the mesh local spac
  28416. * @returns an array of Vector3
  28417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28418. */
  28419. getFacetLocalNormals(): Vector3[];
  28420. /**
  28421. * Returns the facetLocalPositions array.
  28422. * The facet positions are expressed in the mesh local space
  28423. * @returns an array of Vector3
  28424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28425. */
  28426. getFacetLocalPositions(): Vector3[];
  28427. /**
  28428. * Returns the facetLocalPartioning array
  28429. * @returns an array of array of numbers
  28430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28431. */
  28432. getFacetLocalPartitioning(): number[][];
  28433. /**
  28434. * Returns the i-th facet position in the world system.
  28435. * This method allocates a new Vector3 per call
  28436. * @param i defines the facet index
  28437. * @returns a new Vector3
  28438. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28439. */
  28440. getFacetPosition(i: number): Vector3;
  28441. /**
  28442. * Sets the reference Vector3 with the i-th facet position in the world system
  28443. * @param i defines the facet index
  28444. * @param ref defines the target vector
  28445. * @returns the current mesh
  28446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28447. */
  28448. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28449. /**
  28450. * Returns the i-th facet normal in the world system.
  28451. * This method allocates a new Vector3 per call
  28452. * @param i defines the facet index
  28453. * @returns a new Vector3
  28454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28455. */
  28456. getFacetNormal(i: number): Vector3;
  28457. /**
  28458. * Sets the reference Vector3 with the i-th facet normal in the world system
  28459. * @param i defines the facet index
  28460. * @param ref defines the target vector
  28461. * @returns the current mesh
  28462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28463. */
  28464. getFacetNormalToRef(i: number, ref: Vector3): this;
  28465. /**
  28466. * 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)
  28467. * @param x defines x coordinate
  28468. * @param y defines y coordinate
  28469. * @param z defines z coordinate
  28470. * @returns the array of facet indexes
  28471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28472. */
  28473. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28474. /**
  28475. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28476. * @param projected sets as the (x,y,z) world projection on the facet
  28477. * @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
  28478. * @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
  28479. * @param x defines x coordinate
  28480. * @param y defines y coordinate
  28481. * @param z defines z coordinate
  28482. * @returns the face index if found (or null instead)
  28483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28484. */
  28485. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28486. /**
  28487. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28488. * @param projected sets as the (x,y,z) local projection on the facet
  28489. * @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
  28490. * @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
  28491. * @param x defines x coordinate
  28492. * @param y defines y coordinate
  28493. * @param z defines z coordinate
  28494. * @returns the face index if found (or null instead)
  28495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28496. */
  28497. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28498. /**
  28499. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28500. * @returns the parameters
  28501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28502. */
  28503. getFacetDataParameters(): any;
  28504. /**
  28505. * Disables the feature FacetData and frees the related memory
  28506. * @returns the current mesh
  28507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28508. */
  28509. disableFacetData(): AbstractMesh;
  28510. /**
  28511. * Updates the AbstractMesh indices array
  28512. * @param indices defines the data source
  28513. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28514. * @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)
  28515. * @returns the current mesh
  28516. */
  28517. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28518. /**
  28519. * Creates new normals data for the mesh
  28520. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28521. * @returns the current mesh
  28522. */
  28523. createNormals(updatable: boolean): AbstractMesh;
  28524. /**
  28525. * Align the mesh with a normal
  28526. * @param normal defines the normal to use
  28527. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28528. * @returns the current mesh
  28529. */
  28530. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28531. /** @hidden */
  28532. _checkOcclusionQuery(): boolean;
  28533. /**
  28534. * Disables the mesh edge rendering mode
  28535. * @returns the currentAbstractMesh
  28536. */
  28537. disableEdgesRendering(): AbstractMesh;
  28538. /**
  28539. * Enables the edge rendering mode on the mesh.
  28540. * This mode makes the mesh edges visible
  28541. * @param epsilon defines the maximal distance between two angles to detect a face
  28542. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28543. * @returns the currentAbstractMesh
  28544. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28545. */
  28546. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28547. }
  28548. }
  28549. declare module BABYLON {
  28550. /**
  28551. * Interface used to define ActionEvent
  28552. */
  28553. export interface IActionEvent {
  28554. /** The mesh or sprite that triggered the action */
  28555. source: any;
  28556. /** The X mouse cursor position at the time of the event */
  28557. pointerX: number;
  28558. /** The Y mouse cursor position at the time of the event */
  28559. pointerY: number;
  28560. /** The mesh that is currently pointed at (can be null) */
  28561. meshUnderPointer: Nullable<AbstractMesh>;
  28562. /** the original (browser) event that triggered the ActionEvent */
  28563. sourceEvent?: any;
  28564. /** additional data for the event */
  28565. additionalData?: any;
  28566. }
  28567. /**
  28568. * ActionEvent is the event being sent when an action is triggered.
  28569. */
  28570. export class ActionEvent implements IActionEvent {
  28571. /** The mesh or sprite that triggered the action */
  28572. source: any;
  28573. /** The X mouse cursor position at the time of the event */
  28574. pointerX: number;
  28575. /** The Y mouse cursor position at the time of the event */
  28576. pointerY: number;
  28577. /** The mesh that is currently pointed at (can be null) */
  28578. meshUnderPointer: Nullable<AbstractMesh>;
  28579. /** the original (browser) event that triggered the ActionEvent */
  28580. sourceEvent?: any;
  28581. /** additional data for the event */
  28582. additionalData?: any;
  28583. /**
  28584. * Creates a new ActionEvent
  28585. * @param source The mesh or sprite that triggered the action
  28586. * @param pointerX The X mouse cursor position at the time of the event
  28587. * @param pointerY The Y mouse cursor position at the time of the event
  28588. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28589. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28590. * @param additionalData additional data for the event
  28591. */
  28592. constructor(
  28593. /** The mesh or sprite that triggered the action */
  28594. source: any,
  28595. /** The X mouse cursor position at the time of the event */
  28596. pointerX: number,
  28597. /** The Y mouse cursor position at the time of the event */
  28598. pointerY: number,
  28599. /** The mesh that is currently pointed at (can be null) */
  28600. meshUnderPointer: Nullable<AbstractMesh>,
  28601. /** the original (browser) event that triggered the ActionEvent */
  28602. sourceEvent?: any,
  28603. /** additional data for the event */
  28604. additionalData?: any);
  28605. /**
  28606. * Helper function to auto-create an ActionEvent from a source mesh.
  28607. * @param source The source mesh that triggered the event
  28608. * @param evt The original (browser) event
  28609. * @param additionalData additional data for the event
  28610. * @returns the new ActionEvent
  28611. */
  28612. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28613. /**
  28614. * Helper function to auto-create an ActionEvent from a source sprite
  28615. * @param source The source sprite that triggered the event
  28616. * @param scene Scene associated with the sprite
  28617. * @param evt The original (browser) event
  28618. * @param additionalData additional data for the event
  28619. * @returns the new ActionEvent
  28620. */
  28621. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28622. /**
  28623. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28624. * @param scene the scene where the event occurred
  28625. * @param evt The original (browser) event
  28626. * @returns the new ActionEvent
  28627. */
  28628. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28629. /**
  28630. * Helper function to auto-create an ActionEvent from a primitive
  28631. * @param prim defines the target primitive
  28632. * @param pointerPos defines the pointer position
  28633. * @param evt The original (browser) event
  28634. * @param additionalData additional data for the event
  28635. * @returns the new ActionEvent
  28636. */
  28637. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28638. }
  28639. }
  28640. declare module BABYLON {
  28641. /**
  28642. * Abstract class used to decouple action Manager from scene and meshes.
  28643. * Do not instantiate.
  28644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28645. */
  28646. export abstract class AbstractActionManager implements IDisposable {
  28647. /** Gets the list of active triggers */
  28648. static Triggers: {
  28649. [key: string]: number;
  28650. };
  28651. /** Gets the cursor to use when hovering items */
  28652. hoverCursor: string;
  28653. /** Gets the list of actions */
  28654. actions: IAction[];
  28655. /**
  28656. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28657. */
  28658. isRecursive: boolean;
  28659. /**
  28660. * Releases all associated resources
  28661. */
  28662. abstract dispose(): void;
  28663. /**
  28664. * Does this action manager has pointer triggers
  28665. */
  28666. abstract get hasPointerTriggers(): boolean;
  28667. /**
  28668. * Does this action manager has pick triggers
  28669. */
  28670. abstract get hasPickTriggers(): boolean;
  28671. /**
  28672. * Process a specific trigger
  28673. * @param trigger defines the trigger to process
  28674. * @param evt defines the event details to be processed
  28675. */
  28676. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28677. /**
  28678. * Does this action manager handles actions of any of the given triggers
  28679. * @param triggers defines the triggers to be tested
  28680. * @return a boolean indicating whether one (or more) of the triggers is handled
  28681. */
  28682. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28683. /**
  28684. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28685. * speed.
  28686. * @param triggerA defines the trigger to be tested
  28687. * @param triggerB defines the trigger to be tested
  28688. * @return a boolean indicating whether one (or more) of the triggers is handled
  28689. */
  28690. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28691. /**
  28692. * Does this action manager handles actions of a given trigger
  28693. * @param trigger defines the trigger to be tested
  28694. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28695. * @return whether the trigger is handled
  28696. */
  28697. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28698. /**
  28699. * Serialize this manager to a JSON object
  28700. * @param name defines the property name to store this manager
  28701. * @returns a JSON representation of this manager
  28702. */
  28703. abstract serialize(name: string): any;
  28704. /**
  28705. * Registers an action to this action manager
  28706. * @param action defines the action to be registered
  28707. * @return the action amended (prepared) after registration
  28708. */
  28709. abstract registerAction(action: IAction): Nullable<IAction>;
  28710. /**
  28711. * Unregisters an action to this action manager
  28712. * @param action defines the action to be unregistered
  28713. * @return a boolean indicating whether the action has been unregistered
  28714. */
  28715. abstract unregisterAction(action: IAction): Boolean;
  28716. /**
  28717. * Does exist one action manager with at least one trigger
  28718. **/
  28719. static get HasTriggers(): boolean;
  28720. /**
  28721. * Does exist one action manager with at least one pick trigger
  28722. **/
  28723. static get HasPickTriggers(): boolean;
  28724. /**
  28725. * Does exist one action manager that handles actions of a given trigger
  28726. * @param trigger defines the trigger to be tested
  28727. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28728. **/
  28729. static HasSpecificTrigger(trigger: number): boolean;
  28730. }
  28731. }
  28732. declare module BABYLON {
  28733. /**
  28734. * Defines how a node can be built from a string name.
  28735. */
  28736. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28737. /**
  28738. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28739. */
  28740. export class Node implements IBehaviorAware<Node> {
  28741. /** @hidden */
  28742. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28743. private static _NodeConstructors;
  28744. /**
  28745. * Add a new node constructor
  28746. * @param type defines the type name of the node to construct
  28747. * @param constructorFunc defines the constructor function
  28748. */
  28749. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28750. /**
  28751. * Returns a node constructor based on type name
  28752. * @param type defines the type name
  28753. * @param name defines the new node name
  28754. * @param scene defines the hosting scene
  28755. * @param options defines optional options to transmit to constructors
  28756. * @returns the new constructor or null
  28757. */
  28758. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28759. /**
  28760. * Gets or sets the name of the node
  28761. */
  28762. name: string;
  28763. /**
  28764. * Gets or sets the id of the node
  28765. */
  28766. id: string;
  28767. /**
  28768. * Gets or sets the unique id of the node
  28769. */
  28770. uniqueId: number;
  28771. /**
  28772. * Gets or sets a string used to store user defined state for the node
  28773. */
  28774. state: string;
  28775. /**
  28776. * Gets or sets an object used to store user defined information for the node
  28777. */
  28778. metadata: any;
  28779. /**
  28780. * For internal use only. Please do not use.
  28781. */
  28782. reservedDataStore: any;
  28783. /**
  28784. * List of inspectable custom properties (used by the Inspector)
  28785. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28786. */
  28787. inspectableCustomProperties: IInspectable[];
  28788. private _doNotSerialize;
  28789. /**
  28790. * Gets or sets a boolean used to define if the node must be serialized
  28791. */
  28792. get doNotSerialize(): boolean;
  28793. set doNotSerialize(value: boolean);
  28794. /** @hidden */
  28795. _isDisposed: boolean;
  28796. /**
  28797. * Gets a list of Animations associated with the node
  28798. */
  28799. animations: Animation[];
  28800. protected _ranges: {
  28801. [name: string]: Nullable<AnimationRange>;
  28802. };
  28803. /**
  28804. * Callback raised when the node is ready to be used
  28805. */
  28806. onReady: Nullable<(node: Node) => void>;
  28807. private _isEnabled;
  28808. private _isParentEnabled;
  28809. private _isReady;
  28810. /** @hidden */
  28811. _currentRenderId: number;
  28812. private _parentUpdateId;
  28813. /** @hidden */
  28814. _childUpdateId: number;
  28815. /** @hidden */
  28816. _waitingParentId: Nullable<string>;
  28817. /** @hidden */
  28818. _scene: Scene;
  28819. /** @hidden */
  28820. _cache: any;
  28821. private _parentNode;
  28822. private _children;
  28823. /** @hidden */
  28824. _worldMatrix: Matrix;
  28825. /** @hidden */
  28826. _worldMatrixDeterminant: number;
  28827. /** @hidden */
  28828. _worldMatrixDeterminantIsDirty: boolean;
  28829. /** @hidden */
  28830. private _sceneRootNodesIndex;
  28831. /**
  28832. * Gets a boolean indicating if the node has been disposed
  28833. * @returns true if the node was disposed
  28834. */
  28835. isDisposed(): boolean;
  28836. /**
  28837. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28838. * @see https://doc.babylonjs.com/how_to/parenting
  28839. */
  28840. set parent(parent: Nullable<Node>);
  28841. get parent(): Nullable<Node>;
  28842. /** @hidden */
  28843. _addToSceneRootNodes(): void;
  28844. /** @hidden */
  28845. _removeFromSceneRootNodes(): void;
  28846. private _animationPropertiesOverride;
  28847. /**
  28848. * Gets or sets the animation properties override
  28849. */
  28850. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28851. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28852. /**
  28853. * Gets a string idenfifying the name of the class
  28854. * @returns "Node" string
  28855. */
  28856. getClassName(): string;
  28857. /** @hidden */
  28858. readonly _isNode: boolean;
  28859. /**
  28860. * An event triggered when the mesh is disposed
  28861. */
  28862. onDisposeObservable: Observable<Node>;
  28863. private _onDisposeObserver;
  28864. /**
  28865. * Sets a callback that will be raised when the node will be disposed
  28866. */
  28867. set onDispose(callback: () => void);
  28868. /**
  28869. * Creates a new Node
  28870. * @param name the name and id to be given to this node
  28871. * @param scene the scene this node will be added to
  28872. */
  28873. constructor(name: string, scene?: Nullable<Scene>);
  28874. /**
  28875. * Gets the scene of the node
  28876. * @returns a scene
  28877. */
  28878. getScene(): Scene;
  28879. /**
  28880. * Gets the engine of the node
  28881. * @returns a Engine
  28882. */
  28883. getEngine(): Engine;
  28884. private _behaviors;
  28885. /**
  28886. * Attach a behavior to the node
  28887. * @see http://doc.babylonjs.com/features/behaviour
  28888. * @param behavior defines the behavior to attach
  28889. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28890. * @returns the current Node
  28891. */
  28892. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28893. /**
  28894. * Remove an attached behavior
  28895. * @see http://doc.babylonjs.com/features/behaviour
  28896. * @param behavior defines the behavior to attach
  28897. * @returns the current Node
  28898. */
  28899. removeBehavior(behavior: Behavior<Node>): Node;
  28900. /**
  28901. * Gets the list of attached behaviors
  28902. * @see http://doc.babylonjs.com/features/behaviour
  28903. */
  28904. get behaviors(): Behavior<Node>[];
  28905. /**
  28906. * Gets an attached behavior by name
  28907. * @param name defines the name of the behavior to look for
  28908. * @see http://doc.babylonjs.com/features/behaviour
  28909. * @returns null if behavior was not found else the requested behavior
  28910. */
  28911. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28912. /**
  28913. * Returns the latest update of the World matrix
  28914. * @returns a Matrix
  28915. */
  28916. getWorldMatrix(): Matrix;
  28917. /** @hidden */
  28918. _getWorldMatrixDeterminant(): number;
  28919. /**
  28920. * Returns directly the latest state of the mesh World matrix.
  28921. * A Matrix is returned.
  28922. */
  28923. get worldMatrixFromCache(): Matrix;
  28924. /** @hidden */
  28925. _initCache(): void;
  28926. /** @hidden */
  28927. updateCache(force?: boolean): void;
  28928. /** @hidden */
  28929. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28930. /** @hidden */
  28931. _updateCache(ignoreParentClass?: boolean): void;
  28932. /** @hidden */
  28933. _isSynchronized(): boolean;
  28934. /** @hidden */
  28935. _markSyncedWithParent(): void;
  28936. /** @hidden */
  28937. isSynchronizedWithParent(): boolean;
  28938. /** @hidden */
  28939. isSynchronized(): boolean;
  28940. /**
  28941. * Is this node ready to be used/rendered
  28942. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28943. * @return true if the node is ready
  28944. */
  28945. isReady(completeCheck?: boolean): boolean;
  28946. /**
  28947. * Is this node enabled?
  28948. * 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
  28949. * @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
  28950. * @return whether this node (and its parent) is enabled
  28951. */
  28952. isEnabled(checkAncestors?: boolean): boolean;
  28953. /** @hidden */
  28954. protected _syncParentEnabledState(): void;
  28955. /**
  28956. * Set the enabled state of this node
  28957. * @param value defines the new enabled state
  28958. */
  28959. setEnabled(value: boolean): void;
  28960. /**
  28961. * Is this node a descendant of the given node?
  28962. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28963. * @param ancestor defines the parent node to inspect
  28964. * @returns a boolean indicating if this node is a descendant of the given node
  28965. */
  28966. isDescendantOf(ancestor: Node): boolean;
  28967. /** @hidden */
  28968. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28969. /**
  28970. * Will return all nodes that have this node as ascendant
  28971. * @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
  28972. * @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
  28973. * @return all children nodes of all types
  28974. */
  28975. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28976. /**
  28977. * Get all child-meshes of this node
  28978. * @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)
  28979. * @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
  28980. * @returns an array of AbstractMesh
  28981. */
  28982. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28983. /**
  28984. * Get all direct children of this node
  28985. * @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
  28986. * @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)
  28987. * @returns an array of Node
  28988. */
  28989. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28990. /** @hidden */
  28991. _setReady(state: boolean): void;
  28992. /**
  28993. * Get an animation by name
  28994. * @param name defines the name of the animation to look for
  28995. * @returns null if not found else the requested animation
  28996. */
  28997. getAnimationByName(name: string): Nullable<Animation>;
  28998. /**
  28999. * Creates an animation range for this node
  29000. * @param name defines the name of the range
  29001. * @param from defines the starting key
  29002. * @param to defines the end key
  29003. */
  29004. createAnimationRange(name: string, from: number, to: number): void;
  29005. /**
  29006. * Delete a specific animation range
  29007. * @param name defines the name of the range to delete
  29008. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29009. */
  29010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29011. /**
  29012. * Get an animation range by name
  29013. * @param name defines the name of the animation range to look for
  29014. * @returns null if not found else the requested animation range
  29015. */
  29016. getAnimationRange(name: string): Nullable<AnimationRange>;
  29017. /**
  29018. * Gets the list of all animation ranges defined on this node
  29019. * @returns an array
  29020. */
  29021. getAnimationRanges(): Nullable<AnimationRange>[];
  29022. /**
  29023. * Will start the animation sequence
  29024. * @param name defines the range frames for animation sequence
  29025. * @param loop defines if the animation should loop (false by default)
  29026. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29027. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29028. * @returns the object created for this animation. If range does not exist, it will return null
  29029. */
  29030. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29031. /**
  29032. * Serialize animation ranges into a JSON compatible object
  29033. * @returns serialization object
  29034. */
  29035. serializeAnimationRanges(): any;
  29036. /**
  29037. * Computes the world matrix of the node
  29038. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29039. * @returns the world matrix
  29040. */
  29041. computeWorldMatrix(force?: boolean): Matrix;
  29042. /**
  29043. * Releases resources associated with this node.
  29044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29046. */
  29047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29048. /**
  29049. * Parse animation range data from a serialization object and store them into a given node
  29050. * @param node defines where to store the animation ranges
  29051. * @param parsedNode defines the serialization object to read data from
  29052. * @param scene defines the hosting scene
  29053. */
  29054. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29055. /**
  29056. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29057. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29058. * @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
  29059. * @returns the new bounding vectors
  29060. */
  29061. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29062. min: Vector3;
  29063. max: Vector3;
  29064. };
  29065. }
  29066. }
  29067. declare module BABYLON {
  29068. /**
  29069. * @hidden
  29070. */
  29071. export class _IAnimationState {
  29072. key: number;
  29073. repeatCount: number;
  29074. workValue?: any;
  29075. loopMode?: number;
  29076. offsetValue?: any;
  29077. highLimitValue?: any;
  29078. }
  29079. /**
  29080. * Class used to store any kind of animation
  29081. */
  29082. export class Animation {
  29083. /**Name of the animation */
  29084. name: string;
  29085. /**Property to animate */
  29086. targetProperty: string;
  29087. /**The frames per second of the animation */
  29088. framePerSecond: number;
  29089. /**The data type of the animation */
  29090. dataType: number;
  29091. /**The loop mode of the animation */
  29092. loopMode?: number | undefined;
  29093. /**Specifies if blending should be enabled */
  29094. enableBlending?: boolean | undefined;
  29095. /**
  29096. * Use matrix interpolation instead of using direct key value when animating matrices
  29097. */
  29098. static AllowMatricesInterpolation: boolean;
  29099. /**
  29100. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29101. */
  29102. static AllowMatrixDecomposeForInterpolation: boolean;
  29103. /**
  29104. * Stores the key frames of the animation
  29105. */
  29106. private _keys;
  29107. /**
  29108. * Stores the easing function of the animation
  29109. */
  29110. private _easingFunction;
  29111. /**
  29112. * @hidden Internal use only
  29113. */
  29114. _runtimeAnimations: RuntimeAnimation[];
  29115. /**
  29116. * The set of event that will be linked to this animation
  29117. */
  29118. private _events;
  29119. /**
  29120. * Stores an array of target property paths
  29121. */
  29122. targetPropertyPath: string[];
  29123. /**
  29124. * Stores the blending speed of the animation
  29125. */
  29126. blendingSpeed: number;
  29127. /**
  29128. * Stores the animation ranges for the animation
  29129. */
  29130. private _ranges;
  29131. /**
  29132. * @hidden Internal use
  29133. */
  29134. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29135. /**
  29136. * Sets up an animation
  29137. * @param property The property to animate
  29138. * @param animationType The animation type to apply
  29139. * @param framePerSecond The frames per second of the animation
  29140. * @param easingFunction The easing function used in the animation
  29141. * @returns The created animation
  29142. */
  29143. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29144. /**
  29145. * Create and start an animation on a node
  29146. * @param name defines the name of the global animation that will be run on all nodes
  29147. * @param node defines the root node where the animation will take place
  29148. * @param targetProperty defines property to animate
  29149. * @param framePerSecond defines the number of frame per second yo use
  29150. * @param totalFrame defines the number of frames in total
  29151. * @param from defines the initial value
  29152. * @param to defines the final value
  29153. * @param loopMode defines which loop mode you want to use (off by default)
  29154. * @param easingFunction defines the easing function to use (linear by default)
  29155. * @param onAnimationEnd defines the callback to call when animation end
  29156. * @returns the animatable created for this animation
  29157. */
  29158. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29159. /**
  29160. * Create and start an animation on a node and its descendants
  29161. * @param name defines the name of the global animation that will be run on all nodes
  29162. * @param node defines the root node where the animation will take place
  29163. * @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
  29164. * @param targetProperty defines property to animate
  29165. * @param framePerSecond defines the number of frame per second to use
  29166. * @param totalFrame defines the number of frames in total
  29167. * @param from defines the initial value
  29168. * @param to defines the final value
  29169. * @param loopMode defines which loop mode you want to use (off by default)
  29170. * @param easingFunction defines the easing function to use (linear by default)
  29171. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29172. * @returns the list of animatables created for all nodes
  29173. * @example https://www.babylonjs-playground.com/#MH0VLI
  29174. */
  29175. 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[]>;
  29176. /**
  29177. * Creates a new animation, merges it with the existing animations and starts it
  29178. * @param name Name of the animation
  29179. * @param node Node which contains the scene that begins the animations
  29180. * @param targetProperty Specifies which property to animate
  29181. * @param framePerSecond The frames per second of the animation
  29182. * @param totalFrame The total number of frames
  29183. * @param from The frame at the beginning of the animation
  29184. * @param to The frame at the end of the animation
  29185. * @param loopMode Specifies the loop mode of the animation
  29186. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29187. * @param onAnimationEnd Callback to run once the animation is complete
  29188. * @returns Nullable animation
  29189. */
  29190. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29191. /**
  29192. * Transition property of an host to the target Value
  29193. * @param property The property to transition
  29194. * @param targetValue The target Value of the property
  29195. * @param host The object where the property to animate belongs
  29196. * @param scene Scene used to run the animation
  29197. * @param frameRate Framerate (in frame/s) to use
  29198. * @param transition The transition type we want to use
  29199. * @param duration The duration of the animation, in milliseconds
  29200. * @param onAnimationEnd Callback trigger at the end of the animation
  29201. * @returns Nullable animation
  29202. */
  29203. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29204. /**
  29205. * Return the array of runtime animations currently using this animation
  29206. */
  29207. get runtimeAnimations(): RuntimeAnimation[];
  29208. /**
  29209. * Specifies if any of the runtime animations are currently running
  29210. */
  29211. get hasRunningRuntimeAnimations(): boolean;
  29212. /**
  29213. * Initializes the animation
  29214. * @param name Name of the animation
  29215. * @param targetProperty Property to animate
  29216. * @param framePerSecond The frames per second of the animation
  29217. * @param dataType The data type of the animation
  29218. * @param loopMode The loop mode of the animation
  29219. * @param enableBlending Specifies if blending should be enabled
  29220. */
  29221. constructor(
  29222. /**Name of the animation */
  29223. name: string,
  29224. /**Property to animate */
  29225. targetProperty: string,
  29226. /**The frames per second of the animation */
  29227. framePerSecond: number,
  29228. /**The data type of the animation */
  29229. dataType: number,
  29230. /**The loop mode of the animation */
  29231. loopMode?: number | undefined,
  29232. /**Specifies if blending should be enabled */
  29233. enableBlending?: boolean | undefined);
  29234. /**
  29235. * Converts the animation to a string
  29236. * @param fullDetails support for multiple levels of logging within scene loading
  29237. * @returns String form of the animation
  29238. */
  29239. toString(fullDetails?: boolean): string;
  29240. /**
  29241. * Add an event to this animation
  29242. * @param event Event to add
  29243. */
  29244. addEvent(event: AnimationEvent): void;
  29245. /**
  29246. * Remove all events found at the given frame
  29247. * @param frame The frame to remove events from
  29248. */
  29249. removeEvents(frame: number): void;
  29250. /**
  29251. * Retrieves all the events from the animation
  29252. * @returns Events from the animation
  29253. */
  29254. getEvents(): AnimationEvent[];
  29255. /**
  29256. * Creates an animation range
  29257. * @param name Name of the animation range
  29258. * @param from Starting frame of the animation range
  29259. * @param to Ending frame of the animation
  29260. */
  29261. createRange(name: string, from: number, to: number): void;
  29262. /**
  29263. * Deletes an animation range by name
  29264. * @param name Name of the animation range to delete
  29265. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29266. */
  29267. deleteRange(name: string, deleteFrames?: boolean): void;
  29268. /**
  29269. * Gets the animation range by name, or null if not defined
  29270. * @param name Name of the animation range
  29271. * @returns Nullable animation range
  29272. */
  29273. getRange(name: string): Nullable<AnimationRange>;
  29274. /**
  29275. * Gets the key frames from the animation
  29276. * @returns The key frames of the animation
  29277. */
  29278. getKeys(): Array<IAnimationKey>;
  29279. /**
  29280. * Gets the highest frame rate of the animation
  29281. * @returns Highest frame rate of the animation
  29282. */
  29283. getHighestFrame(): number;
  29284. /**
  29285. * Gets the easing function of the animation
  29286. * @returns Easing function of the animation
  29287. */
  29288. getEasingFunction(): IEasingFunction;
  29289. /**
  29290. * Sets the easing function of the animation
  29291. * @param easingFunction A custom mathematical formula for animation
  29292. */
  29293. setEasingFunction(easingFunction: EasingFunction): void;
  29294. /**
  29295. * Interpolates a scalar linearly
  29296. * @param startValue Start value of the animation curve
  29297. * @param endValue End value of the animation curve
  29298. * @param gradient Scalar amount to interpolate
  29299. * @returns Interpolated scalar value
  29300. */
  29301. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29302. /**
  29303. * Interpolates a scalar cubically
  29304. * @param startValue Start value of the animation curve
  29305. * @param outTangent End tangent of the animation
  29306. * @param endValue End value of the animation curve
  29307. * @param inTangent Start tangent of the animation curve
  29308. * @param gradient Scalar amount to interpolate
  29309. * @returns Interpolated scalar value
  29310. */
  29311. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29312. /**
  29313. * Interpolates a quaternion using a spherical linear interpolation
  29314. * @param startValue Start value of the animation curve
  29315. * @param endValue End value of the animation curve
  29316. * @param gradient Scalar amount to interpolate
  29317. * @returns Interpolated quaternion value
  29318. */
  29319. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29320. /**
  29321. * Interpolates a quaternion cubically
  29322. * @param startValue Start value of the animation curve
  29323. * @param outTangent End tangent of the animation curve
  29324. * @param endValue End value of the animation curve
  29325. * @param inTangent Start tangent of the animation curve
  29326. * @param gradient Scalar amount to interpolate
  29327. * @returns Interpolated quaternion value
  29328. */
  29329. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29330. /**
  29331. * Interpolates a Vector3 linearl
  29332. * @param startValue Start value of the animation curve
  29333. * @param endValue End value of the animation curve
  29334. * @param gradient Scalar amount to interpolate
  29335. * @returns Interpolated scalar value
  29336. */
  29337. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29338. /**
  29339. * Interpolates a Vector3 cubically
  29340. * @param startValue Start value of the animation curve
  29341. * @param outTangent End tangent of the animation
  29342. * @param endValue End value of the animation curve
  29343. * @param inTangent Start tangent of the animation curve
  29344. * @param gradient Scalar amount to interpolate
  29345. * @returns InterpolatedVector3 value
  29346. */
  29347. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29348. /**
  29349. * Interpolates a Vector2 linearly
  29350. * @param startValue Start value of the animation curve
  29351. * @param endValue End value of the animation curve
  29352. * @param gradient Scalar amount to interpolate
  29353. * @returns Interpolated Vector2 value
  29354. */
  29355. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29356. /**
  29357. * Interpolates a Vector2 cubically
  29358. * @param startValue Start value of the animation curve
  29359. * @param outTangent End tangent of the animation
  29360. * @param endValue End value of the animation curve
  29361. * @param inTangent Start tangent of the animation curve
  29362. * @param gradient Scalar amount to interpolate
  29363. * @returns Interpolated Vector2 value
  29364. */
  29365. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29366. /**
  29367. * Interpolates a size linearly
  29368. * @param startValue Start value of the animation curve
  29369. * @param endValue End value of the animation curve
  29370. * @param gradient Scalar amount to interpolate
  29371. * @returns Interpolated Size value
  29372. */
  29373. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29374. /**
  29375. * Interpolates a Color3 linearly
  29376. * @param startValue Start value of the animation curve
  29377. * @param endValue End value of the animation curve
  29378. * @param gradient Scalar amount to interpolate
  29379. * @returns Interpolated Color3 value
  29380. */
  29381. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29382. /**
  29383. * Interpolates a Color4 linearly
  29384. * @param startValue Start value of the animation curve
  29385. * @param endValue End value of the animation curve
  29386. * @param gradient Scalar amount to interpolate
  29387. * @returns Interpolated Color3 value
  29388. */
  29389. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29390. /**
  29391. * @hidden Internal use only
  29392. */
  29393. _getKeyValue(value: any): any;
  29394. /**
  29395. * @hidden Internal use only
  29396. */
  29397. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29398. /**
  29399. * Defines the function to use to interpolate matrices
  29400. * @param startValue defines the start matrix
  29401. * @param endValue defines the end matrix
  29402. * @param gradient defines the gradient between both matrices
  29403. * @param result defines an optional target matrix where to store the interpolation
  29404. * @returns the interpolated matrix
  29405. */
  29406. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29407. /**
  29408. * Makes a copy of the animation
  29409. * @returns Cloned animation
  29410. */
  29411. clone(): Animation;
  29412. /**
  29413. * Sets the key frames of the animation
  29414. * @param values The animation key frames to set
  29415. */
  29416. setKeys(values: Array<IAnimationKey>): void;
  29417. /**
  29418. * Serializes the animation to an object
  29419. * @returns Serialized object
  29420. */
  29421. serialize(): any;
  29422. /**
  29423. * Float animation type
  29424. */
  29425. static readonly ANIMATIONTYPE_FLOAT: number;
  29426. /**
  29427. * Vector3 animation type
  29428. */
  29429. static readonly ANIMATIONTYPE_VECTOR3: number;
  29430. /**
  29431. * Quaternion animation type
  29432. */
  29433. static readonly ANIMATIONTYPE_QUATERNION: number;
  29434. /**
  29435. * Matrix animation type
  29436. */
  29437. static readonly ANIMATIONTYPE_MATRIX: number;
  29438. /**
  29439. * Color3 animation type
  29440. */
  29441. static readonly ANIMATIONTYPE_COLOR3: number;
  29442. /**
  29443. * Color3 animation type
  29444. */
  29445. static readonly ANIMATIONTYPE_COLOR4: number;
  29446. /**
  29447. * Vector2 animation type
  29448. */
  29449. static readonly ANIMATIONTYPE_VECTOR2: number;
  29450. /**
  29451. * Size animation type
  29452. */
  29453. static readonly ANIMATIONTYPE_SIZE: number;
  29454. /**
  29455. * Relative Loop Mode
  29456. */
  29457. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29458. /**
  29459. * Cycle Loop Mode
  29460. */
  29461. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29462. /**
  29463. * Constant Loop Mode
  29464. */
  29465. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29466. /** @hidden */
  29467. static _UniversalLerp(left: any, right: any, amount: number): any;
  29468. /**
  29469. * Parses an animation object and creates an animation
  29470. * @param parsedAnimation Parsed animation object
  29471. * @returns Animation object
  29472. */
  29473. static Parse(parsedAnimation: any): Animation;
  29474. /**
  29475. * Appends the serialized animations from the source animations
  29476. * @param source Source containing the animations
  29477. * @param destination Target to store the animations
  29478. */
  29479. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29480. }
  29481. }
  29482. declare module BABYLON {
  29483. /**
  29484. * Interface containing an array of animations
  29485. */
  29486. export interface IAnimatable {
  29487. /**
  29488. * Array of animations
  29489. */
  29490. animations: Nullable<Array<Animation>>;
  29491. }
  29492. }
  29493. declare module BABYLON {
  29494. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29495. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29502. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29503. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29504. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29505. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29506. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29507. /**
  29508. * Decorator used to define property that can be serialized as reference to a camera
  29509. * @param sourceName defines the name of the property to decorate
  29510. */
  29511. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29512. /**
  29513. * Class used to help serialization objects
  29514. */
  29515. export class SerializationHelper {
  29516. /** @hidden */
  29517. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29518. /** @hidden */
  29519. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29520. /** @hidden */
  29521. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29522. /** @hidden */
  29523. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29524. /**
  29525. * Appends the serialized animations from the source animations
  29526. * @param source Source containing the animations
  29527. * @param destination Target to store the animations
  29528. */
  29529. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29530. /**
  29531. * Static function used to serialized a specific entity
  29532. * @param entity defines the entity to serialize
  29533. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29534. * @returns a JSON compatible object representing the serialization of the entity
  29535. */
  29536. static Serialize<T>(entity: T, serializationObject?: any): any;
  29537. /**
  29538. * Creates a new entity from a serialization data object
  29539. * @param creationFunction defines a function used to instanciated the new entity
  29540. * @param source defines the source serialization data
  29541. * @param scene defines the hosting scene
  29542. * @param rootUrl defines the root url for resources
  29543. * @returns a new entity
  29544. */
  29545. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29546. /**
  29547. * Clones an object
  29548. * @param creationFunction defines the function used to instanciate the new object
  29549. * @param source defines the source object
  29550. * @returns the cloned object
  29551. */
  29552. static Clone<T>(creationFunction: () => T, source: T): T;
  29553. /**
  29554. * Instanciates a new object based on a source one (some data will be shared between both object)
  29555. * @param creationFunction defines the function used to instanciate the new object
  29556. * @param source defines the source object
  29557. * @returns the new object
  29558. */
  29559. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29560. }
  29561. }
  29562. declare module BABYLON {
  29563. /**
  29564. * Class used to manipulate GUIDs
  29565. */
  29566. export class GUID {
  29567. /**
  29568. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29569. * Be aware Math.random() could cause collisions, but:
  29570. * "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"
  29571. * @returns a pseudo random id
  29572. */
  29573. static RandomId(): string;
  29574. }
  29575. }
  29576. declare module BABYLON {
  29577. /**
  29578. * Base class of all the textures in babylon.
  29579. * It groups all the common properties the materials, post process, lights... might need
  29580. * in order to make a correct use of the texture.
  29581. */
  29582. export class BaseTexture implements IAnimatable {
  29583. /**
  29584. * Default anisotropic filtering level for the application.
  29585. * It is set to 4 as a good tradeoff between perf and quality.
  29586. */
  29587. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29588. /**
  29589. * Gets or sets the unique id of the texture
  29590. */
  29591. uniqueId: number;
  29592. /**
  29593. * Define the name of the texture.
  29594. */
  29595. name: string;
  29596. /**
  29597. * Gets or sets an object used to store user defined information.
  29598. */
  29599. metadata: any;
  29600. /**
  29601. * For internal use only. Please do not use.
  29602. */
  29603. reservedDataStore: any;
  29604. private _hasAlpha;
  29605. /**
  29606. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29607. */
  29608. set hasAlpha(value: boolean);
  29609. get hasAlpha(): boolean;
  29610. /**
  29611. * Defines if the alpha value should be determined via the rgb values.
  29612. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29613. */
  29614. getAlphaFromRGB: boolean;
  29615. /**
  29616. * Intensity or strength of the texture.
  29617. * It is commonly used by materials to fine tune the intensity of the texture
  29618. */
  29619. level: number;
  29620. /**
  29621. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29622. * This is part of the texture as textures usually maps to one uv set.
  29623. */
  29624. coordinatesIndex: number;
  29625. private _coordinatesMode;
  29626. /**
  29627. * How a texture is mapped.
  29628. *
  29629. * | Value | Type | Description |
  29630. * | ----- | ----------------------------------- | ----------- |
  29631. * | 0 | EXPLICIT_MODE | |
  29632. * | 1 | SPHERICAL_MODE | |
  29633. * | 2 | PLANAR_MODE | |
  29634. * | 3 | CUBIC_MODE | |
  29635. * | 4 | PROJECTION_MODE | |
  29636. * | 5 | SKYBOX_MODE | |
  29637. * | 6 | INVCUBIC_MODE | |
  29638. * | 7 | EQUIRECTANGULAR_MODE | |
  29639. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29640. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29641. */
  29642. set coordinatesMode(value: number);
  29643. get coordinatesMode(): number;
  29644. /**
  29645. * | Value | Type | Description |
  29646. * | ----- | ------------------ | ----------- |
  29647. * | 0 | CLAMP_ADDRESSMODE | |
  29648. * | 1 | WRAP_ADDRESSMODE | |
  29649. * | 2 | MIRROR_ADDRESSMODE | |
  29650. */
  29651. wrapU: number;
  29652. /**
  29653. * | Value | Type | Description |
  29654. * | ----- | ------------------ | ----------- |
  29655. * | 0 | CLAMP_ADDRESSMODE | |
  29656. * | 1 | WRAP_ADDRESSMODE | |
  29657. * | 2 | MIRROR_ADDRESSMODE | |
  29658. */
  29659. wrapV: number;
  29660. /**
  29661. * | Value | Type | Description |
  29662. * | ----- | ------------------ | ----------- |
  29663. * | 0 | CLAMP_ADDRESSMODE | |
  29664. * | 1 | WRAP_ADDRESSMODE | |
  29665. * | 2 | MIRROR_ADDRESSMODE | |
  29666. */
  29667. wrapR: number;
  29668. /**
  29669. * With compliant hardware and browser (supporting anisotropic filtering)
  29670. * this defines the level of anisotropic filtering in the texture.
  29671. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29672. */
  29673. anisotropicFilteringLevel: number;
  29674. /**
  29675. * Define if the texture is a cube texture or if false a 2d texture.
  29676. */
  29677. get isCube(): boolean;
  29678. set isCube(value: boolean);
  29679. /**
  29680. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29681. */
  29682. get is3D(): boolean;
  29683. set is3D(value: boolean);
  29684. /**
  29685. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29686. */
  29687. get is2DArray(): boolean;
  29688. set is2DArray(value: boolean);
  29689. /**
  29690. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29691. * HDR texture are usually stored in linear space.
  29692. * This only impacts the PBR and Background materials
  29693. */
  29694. gammaSpace: boolean;
  29695. /**
  29696. * Gets or sets whether or not the texture contains RGBD data.
  29697. */
  29698. get isRGBD(): boolean;
  29699. set isRGBD(value: boolean);
  29700. /**
  29701. * Is Z inverted in the texture (useful in a cube texture).
  29702. */
  29703. invertZ: boolean;
  29704. /**
  29705. * Are mip maps generated for this texture or not.
  29706. */
  29707. get noMipmap(): boolean;
  29708. /**
  29709. * @hidden
  29710. */
  29711. lodLevelInAlpha: boolean;
  29712. /**
  29713. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29714. */
  29715. get lodGenerationOffset(): number;
  29716. set lodGenerationOffset(value: number);
  29717. /**
  29718. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29719. */
  29720. get lodGenerationScale(): number;
  29721. set lodGenerationScale(value: number);
  29722. /**
  29723. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29724. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29725. * average roughness values.
  29726. */
  29727. get linearSpecularLOD(): boolean;
  29728. set linearSpecularLOD(value: boolean);
  29729. /**
  29730. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29731. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29732. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29733. */
  29734. get irradianceTexture(): Nullable<BaseTexture>;
  29735. set irradianceTexture(value: Nullable<BaseTexture>);
  29736. /**
  29737. * Define if the texture is a render target.
  29738. */
  29739. isRenderTarget: boolean;
  29740. /**
  29741. * Define the unique id of the texture in the scene.
  29742. */
  29743. get uid(): string;
  29744. /**
  29745. * Return a string representation of the texture.
  29746. * @returns the texture as a string
  29747. */
  29748. toString(): string;
  29749. /**
  29750. * Get the class name of the texture.
  29751. * @returns "BaseTexture"
  29752. */
  29753. getClassName(): string;
  29754. /**
  29755. * Define the list of animation attached to the texture.
  29756. */
  29757. animations: Animation[];
  29758. /**
  29759. * An event triggered when the texture is disposed.
  29760. */
  29761. onDisposeObservable: Observable<BaseTexture>;
  29762. private _onDisposeObserver;
  29763. /**
  29764. * Callback triggered when the texture has been disposed.
  29765. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29766. */
  29767. set onDispose(callback: () => void);
  29768. /**
  29769. * Define the current state of the loading sequence when in delayed load mode.
  29770. */
  29771. delayLoadState: number;
  29772. private _scene;
  29773. /** @hidden */
  29774. _texture: Nullable<InternalTexture>;
  29775. private _uid;
  29776. /**
  29777. * Define if the texture is preventinga material to render or not.
  29778. * If not and the texture is not ready, the engine will use a default black texture instead.
  29779. */
  29780. get isBlocking(): boolean;
  29781. /**
  29782. * Instantiates a new BaseTexture.
  29783. * Base class of all the textures in babylon.
  29784. * It groups all the common properties the materials, post process, lights... might need
  29785. * in order to make a correct use of the texture.
  29786. * @param scene Define the scene the texture blongs to
  29787. */
  29788. constructor(scene: Nullable<Scene>);
  29789. /**
  29790. * Get the scene the texture belongs to.
  29791. * @returns the scene or null if undefined
  29792. */
  29793. getScene(): Nullable<Scene>;
  29794. /**
  29795. * Get the texture transform matrix used to offset tile the texture for istance.
  29796. * @returns the transformation matrix
  29797. */
  29798. getTextureMatrix(): Matrix;
  29799. /**
  29800. * Get the texture reflection matrix used to rotate/transform the reflection.
  29801. * @returns the reflection matrix
  29802. */
  29803. getReflectionTextureMatrix(): Matrix;
  29804. /**
  29805. * Get the underlying lower level texture from Babylon.
  29806. * @returns the insternal texture
  29807. */
  29808. getInternalTexture(): Nullable<InternalTexture>;
  29809. /**
  29810. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29811. * @returns true if ready or not blocking
  29812. */
  29813. isReadyOrNotBlocking(): boolean;
  29814. /**
  29815. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29816. * @returns true if fully ready
  29817. */
  29818. isReady(): boolean;
  29819. private _cachedSize;
  29820. /**
  29821. * Get the size of the texture.
  29822. * @returns the texture size.
  29823. */
  29824. getSize(): ISize;
  29825. /**
  29826. * Get the base size of the texture.
  29827. * It can be different from the size if the texture has been resized for POT for instance
  29828. * @returns the base size
  29829. */
  29830. getBaseSize(): ISize;
  29831. /**
  29832. * Update the sampling mode of the texture.
  29833. * Default is Trilinear mode.
  29834. *
  29835. * | Value | Type | Description |
  29836. * | ----- | ------------------ | ----------- |
  29837. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29838. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29839. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29840. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29841. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29842. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29843. * | 7 | NEAREST_LINEAR | |
  29844. * | 8 | NEAREST_NEAREST | |
  29845. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29846. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29847. * | 11 | LINEAR_LINEAR | |
  29848. * | 12 | LINEAR_NEAREST | |
  29849. *
  29850. * > _mag_: magnification filter (close to the viewer)
  29851. * > _min_: minification filter (far from the viewer)
  29852. * > _mip_: filter used between mip map levels
  29853. *@param samplingMode Define the new sampling mode of the texture
  29854. */
  29855. updateSamplingMode(samplingMode: number): void;
  29856. /**
  29857. * Scales the texture if is `canRescale()`
  29858. * @param ratio the resize factor we want to use to rescale
  29859. */
  29860. scale(ratio: number): void;
  29861. /**
  29862. * Get if the texture can rescale.
  29863. */
  29864. get canRescale(): boolean;
  29865. /** @hidden */
  29866. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29867. /** @hidden */
  29868. _rebuild(): void;
  29869. /**
  29870. * Triggers the load sequence in delayed load mode.
  29871. */
  29872. delayLoad(): void;
  29873. /**
  29874. * Clones the texture.
  29875. * @returns the cloned texture
  29876. */
  29877. clone(): Nullable<BaseTexture>;
  29878. /**
  29879. * Get the texture underlying type (INT, FLOAT...)
  29880. */
  29881. get textureType(): number;
  29882. /**
  29883. * Get the texture underlying format (RGB, RGBA...)
  29884. */
  29885. get textureFormat(): number;
  29886. /**
  29887. * Indicates that textures need to be re-calculated for all materials
  29888. */
  29889. protected _markAllSubMeshesAsTexturesDirty(): void;
  29890. /**
  29891. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29892. * This will returns an RGBA array buffer containing either in values (0-255) or
  29893. * float values (0-1) depending of the underlying buffer type.
  29894. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29895. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29896. * @param buffer defines a user defined buffer to fill with data (can be null)
  29897. * @returns The Array buffer containing the pixels data.
  29898. */
  29899. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29900. /**
  29901. * Release and destroy the underlying lower level texture aka internalTexture.
  29902. */
  29903. releaseInternalTexture(): void;
  29904. /** @hidden */
  29905. get _lodTextureHigh(): Nullable<BaseTexture>;
  29906. /** @hidden */
  29907. get _lodTextureMid(): Nullable<BaseTexture>;
  29908. /** @hidden */
  29909. get _lodTextureLow(): Nullable<BaseTexture>;
  29910. /**
  29911. * Dispose the texture and release its associated resources.
  29912. */
  29913. dispose(): void;
  29914. /**
  29915. * Serialize the texture into a JSON representation that can be parsed later on.
  29916. * @returns the JSON representation of the texture
  29917. */
  29918. serialize(): any;
  29919. /**
  29920. * Helper function to be called back once a list of texture contains only ready textures.
  29921. * @param textures Define the list of textures to wait for
  29922. * @param callback Define the callback triggered once the entire list will be ready
  29923. */
  29924. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29925. }
  29926. }
  29927. declare module BABYLON {
  29928. /**
  29929. * Options to be used when creating an effect.
  29930. */
  29931. export interface IEffectCreationOptions {
  29932. /**
  29933. * Atrributes that will be used in the shader.
  29934. */
  29935. attributes: string[];
  29936. /**
  29937. * Uniform varible names that will be set in the shader.
  29938. */
  29939. uniformsNames: string[];
  29940. /**
  29941. * Uniform buffer variable names that will be set in the shader.
  29942. */
  29943. uniformBuffersNames: string[];
  29944. /**
  29945. * Sampler texture variable names that will be set in the shader.
  29946. */
  29947. samplers: string[];
  29948. /**
  29949. * Define statements that will be set in the shader.
  29950. */
  29951. defines: any;
  29952. /**
  29953. * Possible fallbacks for this effect to improve performance when needed.
  29954. */
  29955. fallbacks: Nullable<IEffectFallbacks>;
  29956. /**
  29957. * Callback that will be called when the shader is compiled.
  29958. */
  29959. onCompiled: Nullable<(effect: Effect) => void>;
  29960. /**
  29961. * Callback that will be called if an error occurs during shader compilation.
  29962. */
  29963. onError: Nullable<(effect: Effect, errors: string) => void>;
  29964. /**
  29965. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29966. */
  29967. indexParameters?: any;
  29968. /**
  29969. * Max number of lights that can be used in the shader.
  29970. */
  29971. maxSimultaneousLights?: number;
  29972. /**
  29973. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29974. */
  29975. transformFeedbackVaryings?: Nullable<string[]>;
  29976. }
  29977. /**
  29978. * Effect containing vertex and fragment shader that can be executed on an object.
  29979. */
  29980. export class Effect implements IDisposable {
  29981. /**
  29982. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29983. */
  29984. static ShadersRepository: string;
  29985. /**
  29986. * Name of the effect.
  29987. */
  29988. name: any;
  29989. /**
  29990. * String container all the define statements that should be set on the shader.
  29991. */
  29992. defines: string;
  29993. /**
  29994. * Callback that will be called when the shader is compiled.
  29995. */
  29996. onCompiled: Nullable<(effect: Effect) => void>;
  29997. /**
  29998. * Callback that will be called if an error occurs during shader compilation.
  29999. */
  30000. onError: Nullable<(effect: Effect, errors: string) => void>;
  30001. /**
  30002. * Callback that will be called when effect is bound.
  30003. */
  30004. onBind: Nullable<(effect: Effect) => void>;
  30005. /**
  30006. * Unique ID of the effect.
  30007. */
  30008. uniqueId: number;
  30009. /**
  30010. * Observable that will be called when the shader is compiled.
  30011. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30012. */
  30013. onCompileObservable: Observable<Effect>;
  30014. /**
  30015. * Observable that will be called if an error occurs during shader compilation.
  30016. */
  30017. onErrorObservable: Observable<Effect>;
  30018. /** @hidden */
  30019. _onBindObservable: Nullable<Observable<Effect>>;
  30020. /**
  30021. * @hidden
  30022. * Specifies if the effect was previously ready
  30023. */
  30024. _wasPreviouslyReady: boolean;
  30025. /**
  30026. * Observable that will be called when effect is bound.
  30027. */
  30028. get onBindObservable(): Observable<Effect>;
  30029. /** @hidden */
  30030. _bonesComputationForcedToCPU: boolean;
  30031. private static _uniqueIdSeed;
  30032. private _engine;
  30033. private _uniformBuffersNames;
  30034. private _uniformsNames;
  30035. private _samplerList;
  30036. private _samplers;
  30037. private _isReady;
  30038. private _compilationError;
  30039. private _allFallbacksProcessed;
  30040. private _attributesNames;
  30041. private _attributes;
  30042. private _attributeLocationByName;
  30043. private _uniforms;
  30044. /**
  30045. * Key for the effect.
  30046. * @hidden
  30047. */
  30048. _key: string;
  30049. private _indexParameters;
  30050. private _fallbacks;
  30051. private _vertexSourceCode;
  30052. private _fragmentSourceCode;
  30053. private _vertexSourceCodeOverride;
  30054. private _fragmentSourceCodeOverride;
  30055. private _transformFeedbackVaryings;
  30056. /**
  30057. * Compiled shader to webGL program.
  30058. * @hidden
  30059. */
  30060. _pipelineContext: Nullable<IPipelineContext>;
  30061. private _valueCache;
  30062. private static _baseCache;
  30063. /**
  30064. * Instantiates an effect.
  30065. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30066. * @param baseName Name of the effect.
  30067. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30068. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30069. * @param samplers List of sampler variables that will be passed to the shader.
  30070. * @param engine Engine to be used to render the effect
  30071. * @param defines Define statements to be added to the shader.
  30072. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30073. * @param onCompiled Callback that will be called when the shader is compiled.
  30074. * @param onError Callback that will be called if an error occurs during shader compilation.
  30075. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30076. */
  30077. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30078. private _useFinalCode;
  30079. /**
  30080. * Unique key for this effect
  30081. */
  30082. get key(): string;
  30083. /**
  30084. * If the effect has been compiled and prepared.
  30085. * @returns if the effect is compiled and prepared.
  30086. */
  30087. isReady(): boolean;
  30088. private _isReadyInternal;
  30089. /**
  30090. * The engine the effect was initialized with.
  30091. * @returns the engine.
  30092. */
  30093. getEngine(): Engine;
  30094. /**
  30095. * The pipeline context for this effect
  30096. * @returns the associated pipeline context
  30097. */
  30098. getPipelineContext(): Nullable<IPipelineContext>;
  30099. /**
  30100. * The set of names of attribute variables for the shader.
  30101. * @returns An array of attribute names.
  30102. */
  30103. getAttributesNames(): string[];
  30104. /**
  30105. * Returns the attribute at the given index.
  30106. * @param index The index of the attribute.
  30107. * @returns The location of the attribute.
  30108. */
  30109. getAttributeLocation(index: number): number;
  30110. /**
  30111. * Returns the attribute based on the name of the variable.
  30112. * @param name of the attribute to look up.
  30113. * @returns the attribute location.
  30114. */
  30115. getAttributeLocationByName(name: string): number;
  30116. /**
  30117. * The number of attributes.
  30118. * @returns the numnber of attributes.
  30119. */
  30120. getAttributesCount(): number;
  30121. /**
  30122. * Gets the index of a uniform variable.
  30123. * @param uniformName of the uniform to look up.
  30124. * @returns the index.
  30125. */
  30126. getUniformIndex(uniformName: string): number;
  30127. /**
  30128. * Returns the attribute based on the name of the variable.
  30129. * @param uniformName of the uniform to look up.
  30130. * @returns the location of the uniform.
  30131. */
  30132. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30133. /**
  30134. * Returns an array of sampler variable names
  30135. * @returns The array of sampler variable neames.
  30136. */
  30137. getSamplers(): string[];
  30138. /**
  30139. * The error from the last compilation.
  30140. * @returns the error string.
  30141. */
  30142. getCompilationError(): string;
  30143. /**
  30144. * Gets a boolean indicating that all fallbacks were used during compilation
  30145. * @returns true if all fallbacks were used
  30146. */
  30147. allFallbacksProcessed(): boolean;
  30148. /**
  30149. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30150. * @param func The callback to be used.
  30151. */
  30152. executeWhenCompiled(func: (effect: Effect) => void): void;
  30153. private _checkIsReady;
  30154. private _loadShader;
  30155. /**
  30156. * Recompiles the webGL program
  30157. * @param vertexSourceCode The source code for the vertex shader.
  30158. * @param fragmentSourceCode The source code for the fragment shader.
  30159. * @param onCompiled Callback called when completed.
  30160. * @param onError Callback called on error.
  30161. * @hidden
  30162. */
  30163. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30164. /**
  30165. * Prepares the effect
  30166. * @hidden
  30167. */
  30168. _prepareEffect(): void;
  30169. private _processCompilationErrors;
  30170. /**
  30171. * Checks if the effect is supported. (Must be called after compilation)
  30172. */
  30173. get isSupported(): boolean;
  30174. /**
  30175. * Binds a texture to the engine to be used as output of the shader.
  30176. * @param channel Name of the output variable.
  30177. * @param texture Texture to bind.
  30178. * @hidden
  30179. */
  30180. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30181. /**
  30182. * Sets a texture on the engine to be used in the shader.
  30183. * @param channel Name of the sampler variable.
  30184. * @param texture Texture to set.
  30185. */
  30186. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30187. /**
  30188. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30189. * @param channel Name of the sampler variable.
  30190. * @param texture Texture to set.
  30191. */
  30192. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30193. /**
  30194. * Sets an array of textures on the engine to be used in the shader.
  30195. * @param channel Name of the variable.
  30196. * @param textures Textures to set.
  30197. */
  30198. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30199. /**
  30200. * 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)
  30201. * @param channel Name of the sampler variable.
  30202. * @param postProcess Post process to get the input texture from.
  30203. */
  30204. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30205. /**
  30206. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30207. * 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)
  30208. * @param channel Name of the sampler variable.
  30209. * @param postProcess Post process to get the output texture from.
  30210. */
  30211. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30212. /** @hidden */
  30213. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30214. /** @hidden */
  30215. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30216. /** @hidden */
  30217. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30218. /** @hidden */
  30219. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30220. /**
  30221. * Binds a buffer to a uniform.
  30222. * @param buffer Buffer to bind.
  30223. * @param name Name of the uniform variable to bind to.
  30224. */
  30225. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30226. /**
  30227. * Binds block to a uniform.
  30228. * @param blockName Name of the block to bind.
  30229. * @param index Index to bind.
  30230. */
  30231. bindUniformBlock(blockName: string, index: number): void;
  30232. /**
  30233. * Sets an interger value on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param value Value to be set.
  30236. * @returns this effect.
  30237. */
  30238. setInt(uniformName: string, value: number): Effect;
  30239. /**
  30240. * Sets an int array on a uniform variable.
  30241. * @param uniformName Name of the variable.
  30242. * @param array array to be set.
  30243. * @returns this effect.
  30244. */
  30245. setIntArray(uniformName: string, array: Int32Array): Effect;
  30246. /**
  30247. * 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)
  30248. * @param uniformName Name of the variable.
  30249. * @param array array to be set.
  30250. * @returns this effect.
  30251. */
  30252. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30253. /**
  30254. * 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)
  30255. * @param uniformName Name of the variable.
  30256. * @param array array to be set.
  30257. * @returns this effect.
  30258. */
  30259. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30260. /**
  30261. * 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)
  30262. * @param uniformName Name of the variable.
  30263. * @param array array to be set.
  30264. * @returns this effect.
  30265. */
  30266. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30267. /**
  30268. * Sets an float array on a uniform variable.
  30269. * @param uniformName Name of the variable.
  30270. * @param array array to be set.
  30271. * @returns this effect.
  30272. */
  30273. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30274. /**
  30275. * 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)
  30276. * @param uniformName Name of the variable.
  30277. * @param array array to be set.
  30278. * @returns this effect.
  30279. */
  30280. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30281. /**
  30282. * 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)
  30283. * @param uniformName Name of the variable.
  30284. * @param array array to be set.
  30285. * @returns this effect.
  30286. */
  30287. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30288. /**
  30289. * 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)
  30290. * @param uniformName Name of the variable.
  30291. * @param array array to be set.
  30292. * @returns this effect.
  30293. */
  30294. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30295. /**
  30296. * Sets an array on a uniform variable.
  30297. * @param uniformName Name of the variable.
  30298. * @param array array to be set.
  30299. * @returns this effect.
  30300. */
  30301. setArray(uniformName: string, array: number[]): Effect;
  30302. /**
  30303. * 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)
  30304. * @param uniformName Name of the variable.
  30305. * @param array array to be set.
  30306. * @returns this effect.
  30307. */
  30308. setArray2(uniformName: string, array: number[]): Effect;
  30309. /**
  30310. * 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)
  30311. * @param uniformName Name of the variable.
  30312. * @param array array to be set.
  30313. * @returns this effect.
  30314. */
  30315. setArray3(uniformName: string, array: number[]): Effect;
  30316. /**
  30317. * 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)
  30318. * @param uniformName Name of the variable.
  30319. * @param array array to be set.
  30320. * @returns this effect.
  30321. */
  30322. setArray4(uniformName: string, array: number[]): Effect;
  30323. /**
  30324. * Sets matrices on a uniform variable.
  30325. * @param uniformName Name of the variable.
  30326. * @param matrices matrices to be set.
  30327. * @returns this effect.
  30328. */
  30329. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30330. /**
  30331. * Sets matrix on a uniform variable.
  30332. * @param uniformName Name of the variable.
  30333. * @param matrix matrix to be set.
  30334. * @returns this effect.
  30335. */
  30336. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30337. /**
  30338. * 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)
  30339. * @param uniformName Name of the variable.
  30340. * @param matrix matrix to be set.
  30341. * @returns this effect.
  30342. */
  30343. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30344. /**
  30345. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30346. * @param uniformName Name of the variable.
  30347. * @param matrix matrix to be set.
  30348. * @returns this effect.
  30349. */
  30350. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30351. /**
  30352. * Sets a float on a uniform variable.
  30353. * @param uniformName Name of the variable.
  30354. * @param value value to be set.
  30355. * @returns this effect.
  30356. */
  30357. setFloat(uniformName: string, value: number): Effect;
  30358. /**
  30359. * Sets a boolean on a uniform variable.
  30360. * @param uniformName Name of the variable.
  30361. * @param bool value to be set.
  30362. * @returns this effect.
  30363. */
  30364. setBool(uniformName: string, bool: boolean): Effect;
  30365. /**
  30366. * Sets a Vector2 on a uniform variable.
  30367. * @param uniformName Name of the variable.
  30368. * @param vector2 vector2 to be set.
  30369. * @returns this effect.
  30370. */
  30371. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30372. /**
  30373. * Sets a float2 on a uniform variable.
  30374. * @param uniformName Name of the variable.
  30375. * @param x First float in float2.
  30376. * @param y Second float in float2.
  30377. * @returns this effect.
  30378. */
  30379. setFloat2(uniformName: string, x: number, y: number): Effect;
  30380. /**
  30381. * Sets a Vector3 on a uniform variable.
  30382. * @param uniformName Name of the variable.
  30383. * @param vector3 Value to be set.
  30384. * @returns this effect.
  30385. */
  30386. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30387. /**
  30388. * Sets a float3 on a uniform variable.
  30389. * @param uniformName Name of the variable.
  30390. * @param x First float in float3.
  30391. * @param y Second float in float3.
  30392. * @param z Third float in float3.
  30393. * @returns this effect.
  30394. */
  30395. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30396. /**
  30397. * Sets a Vector4 on a uniform variable.
  30398. * @param uniformName Name of the variable.
  30399. * @param vector4 Value to be set.
  30400. * @returns this effect.
  30401. */
  30402. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30403. /**
  30404. * Sets a float4 on a uniform variable.
  30405. * @param uniformName Name of the variable.
  30406. * @param x First float in float4.
  30407. * @param y Second float in float4.
  30408. * @param z Third float in float4.
  30409. * @param w Fourth float in float4.
  30410. * @returns this effect.
  30411. */
  30412. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30413. /**
  30414. * Sets a Color3 on a uniform variable.
  30415. * @param uniformName Name of the variable.
  30416. * @param color3 Value to be set.
  30417. * @returns this effect.
  30418. */
  30419. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30420. /**
  30421. * Sets a Color4 on a uniform variable.
  30422. * @param uniformName Name of the variable.
  30423. * @param color3 Value to be set.
  30424. * @param alpha Alpha value to be set.
  30425. * @returns this effect.
  30426. */
  30427. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30428. /**
  30429. * Sets a Color4 on a uniform variable
  30430. * @param uniformName defines the name of the variable
  30431. * @param color4 defines the value to be set
  30432. * @returns this effect.
  30433. */
  30434. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30435. /** Release all associated resources */
  30436. dispose(): void;
  30437. /**
  30438. * This function will add a new shader to the shader store
  30439. * @param name the name of the shader
  30440. * @param pixelShader optional pixel shader content
  30441. * @param vertexShader optional vertex shader content
  30442. */
  30443. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30444. /**
  30445. * Store of each shader (The can be looked up using effect.key)
  30446. */
  30447. static ShadersStore: {
  30448. [key: string]: string;
  30449. };
  30450. /**
  30451. * Store of each included file for a shader (The can be looked up using effect.key)
  30452. */
  30453. static IncludesShadersStore: {
  30454. [key: string]: string;
  30455. };
  30456. /**
  30457. * Resets the cache of effects.
  30458. */
  30459. static ResetCache(): void;
  30460. }
  30461. }
  30462. declare module BABYLON {
  30463. /**
  30464. * Interface used to describe the capabilities of the engine relatively to the current browser
  30465. */
  30466. export interface EngineCapabilities {
  30467. /** Maximum textures units per fragment shader */
  30468. maxTexturesImageUnits: number;
  30469. /** Maximum texture units per vertex shader */
  30470. maxVertexTextureImageUnits: number;
  30471. /** Maximum textures units in the entire pipeline */
  30472. maxCombinedTexturesImageUnits: number;
  30473. /** Maximum texture size */
  30474. maxTextureSize: number;
  30475. /** Maximum texture samples */
  30476. maxSamples?: number;
  30477. /** Maximum cube texture size */
  30478. maxCubemapTextureSize: number;
  30479. /** Maximum render texture size */
  30480. maxRenderTextureSize: number;
  30481. /** Maximum number of vertex attributes */
  30482. maxVertexAttribs: number;
  30483. /** Maximum number of varyings */
  30484. maxVaryingVectors: number;
  30485. /** Maximum number of uniforms per vertex shader */
  30486. maxVertexUniformVectors: number;
  30487. /** Maximum number of uniforms per fragment shader */
  30488. maxFragmentUniformVectors: number;
  30489. /** Defines if standard derivates (dx/dy) are supported */
  30490. standardDerivatives: boolean;
  30491. /** Defines if s3tc texture compression is supported */
  30492. s3tc?: WEBGL_compressed_texture_s3tc;
  30493. /** Defines if pvrtc texture compression is supported */
  30494. pvrtc: any;
  30495. /** Defines if etc1 texture compression is supported */
  30496. etc1: any;
  30497. /** Defines if etc2 texture compression is supported */
  30498. etc2: any;
  30499. /** Defines if astc texture compression is supported */
  30500. astc: any;
  30501. /** Defines if float textures are supported */
  30502. textureFloat: boolean;
  30503. /** Defines if vertex array objects are supported */
  30504. vertexArrayObject: boolean;
  30505. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30506. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30507. /** Gets the maximum level of anisotropy supported */
  30508. maxAnisotropy: number;
  30509. /** Defines if instancing is supported */
  30510. instancedArrays: boolean;
  30511. /** Defines if 32 bits indices are supported */
  30512. uintIndices: boolean;
  30513. /** Defines if high precision shaders are supported */
  30514. highPrecisionShaderSupported: boolean;
  30515. /** Defines if depth reading in the fragment shader is supported */
  30516. fragmentDepthSupported: boolean;
  30517. /** Defines if float texture linear filtering is supported*/
  30518. textureFloatLinearFiltering: boolean;
  30519. /** Defines if rendering to float textures is supported */
  30520. textureFloatRender: boolean;
  30521. /** Defines if half float textures are supported*/
  30522. textureHalfFloat: boolean;
  30523. /** Defines if half float texture linear filtering is supported*/
  30524. textureHalfFloatLinearFiltering: boolean;
  30525. /** Defines if rendering to half float textures is supported */
  30526. textureHalfFloatRender: boolean;
  30527. /** Defines if textureLOD shader command is supported */
  30528. textureLOD: boolean;
  30529. /** Defines if draw buffers extension is supported */
  30530. drawBuffersExtension: boolean;
  30531. /** Defines if depth textures are supported */
  30532. depthTextureExtension: boolean;
  30533. /** Defines if float color buffer are supported */
  30534. colorBufferFloat: boolean;
  30535. /** Gets disjoint timer query extension (null if not supported) */
  30536. timerQuery?: EXT_disjoint_timer_query;
  30537. /** Defines if timestamp can be used with timer query */
  30538. canUseTimestampForTimerQuery: boolean;
  30539. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30540. multiview?: any;
  30541. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30542. oculusMultiview?: any;
  30543. /** Function used to let the system compiles shaders in background */
  30544. parallelShaderCompile?: {
  30545. COMPLETION_STATUS_KHR: number;
  30546. };
  30547. /** Max number of texture samples for MSAA */
  30548. maxMSAASamples: number;
  30549. /** Defines if the blend min max extension is supported */
  30550. blendMinMax: boolean;
  30551. }
  30552. }
  30553. declare module BABYLON {
  30554. /**
  30555. * @hidden
  30556. **/
  30557. export class DepthCullingState {
  30558. private _isDepthTestDirty;
  30559. private _isDepthMaskDirty;
  30560. private _isDepthFuncDirty;
  30561. private _isCullFaceDirty;
  30562. private _isCullDirty;
  30563. private _isZOffsetDirty;
  30564. private _isFrontFaceDirty;
  30565. private _depthTest;
  30566. private _depthMask;
  30567. private _depthFunc;
  30568. private _cull;
  30569. private _cullFace;
  30570. private _zOffset;
  30571. private _frontFace;
  30572. /**
  30573. * Initializes the state.
  30574. */
  30575. constructor();
  30576. get isDirty(): boolean;
  30577. get zOffset(): number;
  30578. set zOffset(value: number);
  30579. get cullFace(): Nullable<number>;
  30580. set cullFace(value: Nullable<number>);
  30581. get cull(): Nullable<boolean>;
  30582. set cull(value: Nullable<boolean>);
  30583. get depthFunc(): Nullable<number>;
  30584. set depthFunc(value: Nullable<number>);
  30585. get depthMask(): boolean;
  30586. set depthMask(value: boolean);
  30587. get depthTest(): boolean;
  30588. set depthTest(value: boolean);
  30589. get frontFace(): Nullable<number>;
  30590. set frontFace(value: Nullable<number>);
  30591. reset(): void;
  30592. apply(gl: WebGLRenderingContext): void;
  30593. }
  30594. }
  30595. declare module BABYLON {
  30596. /**
  30597. * @hidden
  30598. **/
  30599. export class StencilState {
  30600. /** 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 */
  30601. static readonly ALWAYS: number;
  30602. /** Passed to stencilOperation to specify that stencil value must be kept */
  30603. static readonly KEEP: number;
  30604. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30605. static readonly REPLACE: number;
  30606. private _isStencilTestDirty;
  30607. private _isStencilMaskDirty;
  30608. private _isStencilFuncDirty;
  30609. private _isStencilOpDirty;
  30610. private _stencilTest;
  30611. private _stencilMask;
  30612. private _stencilFunc;
  30613. private _stencilFuncRef;
  30614. private _stencilFuncMask;
  30615. private _stencilOpStencilFail;
  30616. private _stencilOpDepthFail;
  30617. private _stencilOpStencilDepthPass;
  30618. get isDirty(): boolean;
  30619. get stencilFunc(): number;
  30620. set stencilFunc(value: number);
  30621. get stencilFuncRef(): number;
  30622. set stencilFuncRef(value: number);
  30623. get stencilFuncMask(): number;
  30624. set stencilFuncMask(value: number);
  30625. get stencilOpStencilFail(): number;
  30626. set stencilOpStencilFail(value: number);
  30627. get stencilOpDepthFail(): number;
  30628. set stencilOpDepthFail(value: number);
  30629. get stencilOpStencilDepthPass(): number;
  30630. set stencilOpStencilDepthPass(value: number);
  30631. get stencilMask(): number;
  30632. set stencilMask(value: number);
  30633. get stencilTest(): boolean;
  30634. set stencilTest(value: boolean);
  30635. constructor();
  30636. reset(): void;
  30637. apply(gl: WebGLRenderingContext): void;
  30638. }
  30639. }
  30640. declare module BABYLON {
  30641. /**
  30642. * @hidden
  30643. **/
  30644. export class AlphaState {
  30645. private _isAlphaBlendDirty;
  30646. private _isBlendFunctionParametersDirty;
  30647. private _isBlendEquationParametersDirty;
  30648. private _isBlendConstantsDirty;
  30649. private _alphaBlend;
  30650. private _blendFunctionParameters;
  30651. private _blendEquationParameters;
  30652. private _blendConstants;
  30653. /**
  30654. * Initializes the state.
  30655. */
  30656. constructor();
  30657. get isDirty(): boolean;
  30658. get alphaBlend(): boolean;
  30659. set alphaBlend(value: boolean);
  30660. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30661. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30662. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30663. reset(): void;
  30664. apply(gl: WebGLRenderingContext): void;
  30665. }
  30666. }
  30667. declare module BABYLON {
  30668. /** @hidden */
  30669. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30670. attributeProcessor(attribute: string): string;
  30671. varyingProcessor(varying: string, isFragment: boolean): string;
  30672. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30673. }
  30674. }
  30675. declare module BABYLON {
  30676. /**
  30677. * Interface for attribute information associated with buffer instanciation
  30678. */
  30679. export interface InstancingAttributeInfo {
  30680. /**
  30681. * Name of the GLSL attribute
  30682. * if attribute index is not specified, this is used to retrieve the index from the effect
  30683. */
  30684. attributeName: string;
  30685. /**
  30686. * Index/offset of the attribute in the vertex shader
  30687. * if not specified, this will be computes from the name.
  30688. */
  30689. index?: number;
  30690. /**
  30691. * size of the attribute, 1, 2, 3 or 4
  30692. */
  30693. attributeSize: number;
  30694. /**
  30695. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30696. */
  30697. offset: number;
  30698. /**
  30699. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30700. * default to 1
  30701. */
  30702. divisor?: number;
  30703. /**
  30704. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30705. * default is FLOAT
  30706. */
  30707. attributeType?: number;
  30708. /**
  30709. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30710. */
  30711. normalized?: boolean;
  30712. }
  30713. }
  30714. declare module BABYLON {
  30715. interface ThinEngine {
  30716. /**
  30717. * Update a video texture
  30718. * @param texture defines the texture to update
  30719. * @param video defines the video element to use
  30720. * @param invertY defines if data must be stored with Y axis inverted
  30721. */
  30722. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30723. }
  30724. }
  30725. declare module BABYLON {
  30726. /**
  30727. * Settings for finer control over video usage
  30728. */
  30729. export interface VideoTextureSettings {
  30730. /**
  30731. * Applies `autoplay` to video, if specified
  30732. */
  30733. autoPlay?: boolean;
  30734. /**
  30735. * Applies `loop` to video, if specified
  30736. */
  30737. loop?: boolean;
  30738. /**
  30739. * Automatically updates internal texture from video at every frame in the render loop
  30740. */
  30741. autoUpdateTexture: boolean;
  30742. /**
  30743. * Image src displayed during the video loading or until the user interacts with the video.
  30744. */
  30745. poster?: string;
  30746. }
  30747. /**
  30748. * If you want to display a video in your scene, this is the special texture for that.
  30749. * This special texture works similar to other textures, with the exception of a few parameters.
  30750. * @see https://doc.babylonjs.com/how_to/video_texture
  30751. */
  30752. export class VideoTexture extends Texture {
  30753. /**
  30754. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30755. */
  30756. readonly autoUpdateTexture: boolean;
  30757. /**
  30758. * The video instance used by the texture internally
  30759. */
  30760. readonly video: HTMLVideoElement;
  30761. private _onUserActionRequestedObservable;
  30762. /**
  30763. * Event triggerd when a dom action is required by the user to play the video.
  30764. * This happens due to recent changes in browser policies preventing video to auto start.
  30765. */
  30766. get onUserActionRequestedObservable(): Observable<Texture>;
  30767. private _generateMipMaps;
  30768. private _engine;
  30769. private _stillImageCaptured;
  30770. private _displayingPosterTexture;
  30771. private _settings;
  30772. private _createInternalTextureOnEvent;
  30773. private _frameId;
  30774. private _currentSrc;
  30775. /**
  30776. * Creates a video texture.
  30777. * If you want to display a video in your scene, this is the special texture for that.
  30778. * This special texture works similar to other textures, with the exception of a few parameters.
  30779. * @see https://doc.babylonjs.com/how_to/video_texture
  30780. * @param name optional name, will detect from video source, if not defined
  30781. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30782. * @param scene is obviously the current scene.
  30783. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30784. * @param invertY is false by default but can be used to invert video on Y axis
  30785. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30786. * @param settings allows finer control over video usage
  30787. */
  30788. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30789. private _getName;
  30790. private _getVideo;
  30791. private _createInternalTexture;
  30792. private reset;
  30793. /**
  30794. * @hidden Internal method to initiate `update`.
  30795. */
  30796. _rebuild(): void;
  30797. /**
  30798. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30799. */
  30800. update(): void;
  30801. /**
  30802. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30803. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30804. */
  30805. updateTexture(isVisible: boolean): void;
  30806. protected _updateInternalTexture: () => void;
  30807. /**
  30808. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30809. * @param url New url.
  30810. */
  30811. updateURL(url: string): void;
  30812. /**
  30813. * Clones the texture.
  30814. * @returns the cloned texture
  30815. */
  30816. clone(): VideoTexture;
  30817. /**
  30818. * Dispose the texture and release its associated resources.
  30819. */
  30820. dispose(): void;
  30821. /**
  30822. * Creates a video texture straight from a stream.
  30823. * @param scene Define the scene the texture should be created in
  30824. * @param stream Define the stream the texture should be created from
  30825. * @returns The created video texture as a promise
  30826. */
  30827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30828. /**
  30829. * Creates a video texture straight from your WebCam video feed.
  30830. * @param scene Define the scene the texture should be created in
  30831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30833. * @returns The created video texture as a promise
  30834. */
  30835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30836. minWidth: number;
  30837. maxWidth: number;
  30838. minHeight: number;
  30839. maxHeight: number;
  30840. deviceId: string;
  30841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30842. /**
  30843. * Creates a video texture straight from your WebCam video feed.
  30844. * @param scene Define the scene the texture should be created in
  30845. * @param onReady Define a callback to triggered once the texture will be ready
  30846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30848. */
  30849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30850. minWidth: number;
  30851. maxWidth: number;
  30852. minHeight: number;
  30853. maxHeight: number;
  30854. deviceId: string;
  30855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30856. }
  30857. }
  30858. declare module BABYLON {
  30859. /**
  30860. * Defines the interface used by objects working like Scene
  30861. * @hidden
  30862. */
  30863. interface ISceneLike {
  30864. _addPendingData(data: any): void;
  30865. _removePendingData(data: any): void;
  30866. offlineProvider: IOfflineProvider;
  30867. }
  30868. /** Interface defining initialization parameters for Engine class */
  30869. export interface EngineOptions extends WebGLContextAttributes {
  30870. /**
  30871. * Defines if the engine should no exceed a specified device ratio
  30872. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30873. */
  30874. limitDeviceRatio?: number;
  30875. /**
  30876. * Defines if webvr should be enabled automatically
  30877. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30878. */
  30879. autoEnableWebVR?: boolean;
  30880. /**
  30881. * Defines if webgl2 should be turned off even if supported
  30882. * @see http://doc.babylonjs.com/features/webgl2
  30883. */
  30884. disableWebGL2Support?: boolean;
  30885. /**
  30886. * Defines if webaudio should be initialized as well
  30887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30888. */
  30889. audioEngine?: boolean;
  30890. /**
  30891. * Defines if animations should run using a deterministic lock step
  30892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30893. */
  30894. deterministicLockstep?: boolean;
  30895. /** Defines the maximum steps to use with deterministic lock step mode */
  30896. lockstepMaxSteps?: number;
  30897. /** Defines the seconds between each deterministic lock step */
  30898. timeStep?: number;
  30899. /**
  30900. * Defines that engine should ignore context lost events
  30901. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30902. */
  30903. doNotHandleContextLost?: boolean;
  30904. /**
  30905. * Defines that engine should ignore modifying touch action attribute and style
  30906. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30907. */
  30908. doNotHandleTouchAction?: boolean;
  30909. /**
  30910. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30911. */
  30912. useHighPrecisionFloats?: boolean;
  30913. }
  30914. /**
  30915. * The base engine class (root of all engines)
  30916. */
  30917. export class ThinEngine {
  30918. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30919. static ExceptionList: ({
  30920. key: string;
  30921. capture: string;
  30922. captureConstraint: number;
  30923. targets: string[];
  30924. } | {
  30925. key: string;
  30926. capture: null;
  30927. captureConstraint: null;
  30928. targets: string[];
  30929. })[];
  30930. /** @hidden */
  30931. static _TextureLoaders: IInternalTextureLoader[];
  30932. /**
  30933. * Returns the current npm package of the sdk
  30934. */
  30935. static get NpmPackage(): string;
  30936. /**
  30937. * Returns the current version of the framework
  30938. */
  30939. static get Version(): string;
  30940. /**
  30941. * Returns a string describing the current engine
  30942. */
  30943. get description(): string;
  30944. /**
  30945. * Gets or sets the epsilon value used by collision engine
  30946. */
  30947. static CollisionsEpsilon: number;
  30948. /**
  30949. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30950. */
  30951. static get ShadersRepository(): string;
  30952. static set ShadersRepository(value: string);
  30953. /**
  30954. * Gets or sets the textures that the engine should not attempt to load as compressed
  30955. */
  30956. protected _excludedCompressedTextures: string[];
  30957. /**
  30958. * Filters the compressed texture formats to only include
  30959. * files that are not included in the skippable list
  30960. *
  30961. * @param url the current extension
  30962. * @param textureFormatInUse the current compressed texture format
  30963. * @returns "format" string
  30964. */
  30965. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30966. /** @hidden */
  30967. _shaderProcessor: IShaderProcessor;
  30968. /**
  30969. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30970. */
  30971. forcePOTTextures: boolean;
  30972. /**
  30973. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30974. */
  30975. isFullscreen: boolean;
  30976. /**
  30977. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30978. */
  30979. cullBackFaces: boolean;
  30980. /**
  30981. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30982. */
  30983. renderEvenInBackground: boolean;
  30984. /**
  30985. * Gets or sets a boolean indicating that cache can be kept between frames
  30986. */
  30987. preventCacheWipeBetweenFrames: boolean;
  30988. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30989. validateShaderPrograms: boolean;
  30990. /**
  30991. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30992. * This can provide greater z depth for distant objects.
  30993. */
  30994. useReverseDepthBuffer: boolean;
  30995. /**
  30996. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30997. */
  30998. disableUniformBuffers: boolean;
  30999. /** @hidden */
  31000. _uniformBuffers: UniformBuffer[];
  31001. /**
  31002. * Gets a boolean indicating that the engine supports uniform buffers
  31003. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31004. */
  31005. get supportsUniformBuffers(): boolean;
  31006. /** @hidden */
  31007. _gl: WebGLRenderingContext;
  31008. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31009. protected _windowIsBackground: boolean;
  31010. protected _webGLVersion: number;
  31011. protected _creationOptions: EngineOptions;
  31012. protected _highPrecisionShadersAllowed: boolean;
  31013. /** @hidden */
  31014. get _shouldUseHighPrecisionShader(): boolean;
  31015. /**
  31016. * Gets a boolean indicating that only power of 2 textures are supported
  31017. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31018. */
  31019. get needPOTTextures(): boolean;
  31020. /** @hidden */
  31021. _badOS: boolean;
  31022. /** @hidden */
  31023. _badDesktopOS: boolean;
  31024. private _hardwareScalingLevel;
  31025. /** @hidden */
  31026. _caps: EngineCapabilities;
  31027. private _isStencilEnable;
  31028. private _glVersion;
  31029. private _glRenderer;
  31030. private _glVendor;
  31031. /** @hidden */
  31032. _videoTextureSupported: boolean;
  31033. protected _renderingQueueLaunched: boolean;
  31034. protected _activeRenderLoops: (() => void)[];
  31035. /**
  31036. * Observable signaled when a context lost event is raised
  31037. */
  31038. onContextLostObservable: Observable<ThinEngine>;
  31039. /**
  31040. * Observable signaled when a context restored event is raised
  31041. */
  31042. onContextRestoredObservable: Observable<ThinEngine>;
  31043. private _onContextLost;
  31044. private _onContextRestored;
  31045. protected _contextWasLost: boolean;
  31046. /** @hidden */
  31047. _doNotHandleContextLost: boolean;
  31048. /**
  31049. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31051. */
  31052. get doNotHandleContextLost(): boolean;
  31053. set doNotHandleContextLost(value: boolean);
  31054. /**
  31055. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31056. */
  31057. disableVertexArrayObjects: boolean;
  31058. /** @hidden */
  31059. protected _colorWrite: boolean;
  31060. /** @hidden */
  31061. protected _colorWriteChanged: boolean;
  31062. /** @hidden */
  31063. protected _depthCullingState: DepthCullingState;
  31064. /** @hidden */
  31065. protected _stencilState: StencilState;
  31066. /** @hidden */
  31067. _alphaState: AlphaState;
  31068. /** @hidden */
  31069. _alphaMode: number;
  31070. /** @hidden */
  31071. _alphaEquation: number;
  31072. /** @hidden */
  31073. _internalTexturesCache: InternalTexture[];
  31074. /** @hidden */
  31075. protected _activeChannel: number;
  31076. private _currentTextureChannel;
  31077. /** @hidden */
  31078. protected _boundTexturesCache: {
  31079. [key: string]: Nullable<InternalTexture>;
  31080. };
  31081. /** @hidden */
  31082. protected _currentEffect: Nullable<Effect>;
  31083. /** @hidden */
  31084. protected _currentProgram: Nullable<WebGLProgram>;
  31085. private _compiledEffects;
  31086. private _vertexAttribArraysEnabled;
  31087. /** @hidden */
  31088. protected _cachedViewport: Nullable<IViewportLike>;
  31089. private _cachedVertexArrayObject;
  31090. /** @hidden */
  31091. protected _cachedVertexBuffers: any;
  31092. /** @hidden */
  31093. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31094. /** @hidden */
  31095. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31096. /** @hidden */
  31097. _currentRenderTarget: Nullable<InternalTexture>;
  31098. private _uintIndicesCurrentlySet;
  31099. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31100. /** @hidden */
  31101. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31102. private _currentBufferPointers;
  31103. private _currentInstanceLocations;
  31104. private _currentInstanceBuffers;
  31105. private _textureUnits;
  31106. /** @hidden */
  31107. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31108. /** @hidden */
  31109. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31110. /** @hidden */
  31111. _boundRenderFunction: any;
  31112. private _vaoRecordInProgress;
  31113. private _mustWipeVertexAttributes;
  31114. private _emptyTexture;
  31115. private _emptyCubeTexture;
  31116. private _emptyTexture3D;
  31117. private _emptyTexture2DArray;
  31118. /** @hidden */
  31119. _frameHandler: number;
  31120. private _nextFreeTextureSlots;
  31121. private _maxSimultaneousTextures;
  31122. private _activeRequests;
  31123. protected _texturesSupported: string[];
  31124. /** @hidden */
  31125. _textureFormatInUse: Nullable<string>;
  31126. protected get _supportsHardwareTextureRescaling(): boolean;
  31127. /**
  31128. * Gets the list of texture formats supported
  31129. */
  31130. get texturesSupported(): Array<string>;
  31131. /**
  31132. * Gets the list of texture formats in use
  31133. */
  31134. get textureFormatInUse(): Nullable<string>;
  31135. /**
  31136. * Gets the current viewport
  31137. */
  31138. get currentViewport(): Nullable<IViewportLike>;
  31139. /**
  31140. * Gets the default empty texture
  31141. */
  31142. get emptyTexture(): InternalTexture;
  31143. /**
  31144. * Gets the default empty 3D texture
  31145. */
  31146. get emptyTexture3D(): InternalTexture;
  31147. /**
  31148. * Gets the default empty 2D array texture
  31149. */
  31150. get emptyTexture2DArray(): InternalTexture;
  31151. /**
  31152. * Gets the default empty cube texture
  31153. */
  31154. get emptyCubeTexture(): InternalTexture;
  31155. /**
  31156. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31157. */
  31158. readonly premultipliedAlpha: boolean;
  31159. /**
  31160. * Observable event triggered before each texture is initialized
  31161. */
  31162. onBeforeTextureInitObservable: Observable<Texture>;
  31163. /**
  31164. * Creates a new engine
  31165. * @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
  31166. * @param antialias defines enable antialiasing (default: false)
  31167. * @param options defines further options to be sent to the getContext() function
  31168. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31169. */
  31170. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31171. private _rebuildInternalTextures;
  31172. private _rebuildEffects;
  31173. /**
  31174. * Gets a boolean indicating if all created effects are ready
  31175. * @returns true if all effects are ready
  31176. */
  31177. areAllEffectsReady(): boolean;
  31178. protected _rebuildBuffers(): void;
  31179. private _initGLContext;
  31180. /**
  31181. * Gets version of the current webGL context
  31182. */
  31183. get webGLVersion(): number;
  31184. /**
  31185. * Gets a string idenfifying the name of the class
  31186. * @returns "Engine" string
  31187. */
  31188. getClassName(): string;
  31189. /**
  31190. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31191. */
  31192. get isStencilEnable(): boolean;
  31193. /** @hidden */
  31194. _prepareWorkingCanvas(): void;
  31195. /**
  31196. * Reset the texture cache to empty state
  31197. */
  31198. resetTextureCache(): void;
  31199. /**
  31200. * Gets an object containing information about the current webGL context
  31201. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31202. */
  31203. getGlInfo(): {
  31204. vendor: string;
  31205. renderer: string;
  31206. version: string;
  31207. };
  31208. /**
  31209. * Defines the hardware scaling level.
  31210. * By default the hardware scaling level is computed from the window device ratio.
  31211. * 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.
  31212. * @param level defines the level to use
  31213. */
  31214. setHardwareScalingLevel(level: number): void;
  31215. /**
  31216. * Gets the current hardware scaling level.
  31217. * By default the hardware scaling level is computed from the window device ratio.
  31218. * 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.
  31219. * @returns a number indicating the current hardware scaling level
  31220. */
  31221. getHardwareScalingLevel(): number;
  31222. /**
  31223. * Gets the list of loaded textures
  31224. * @returns an array containing all loaded textures
  31225. */
  31226. getLoadedTexturesCache(): InternalTexture[];
  31227. /**
  31228. * Gets the object containing all engine capabilities
  31229. * @returns the EngineCapabilities object
  31230. */
  31231. getCaps(): EngineCapabilities;
  31232. /**
  31233. * stop executing a render loop function and remove it from the execution array
  31234. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31235. */
  31236. stopRenderLoop(renderFunction?: () => void): void;
  31237. /** @hidden */
  31238. _renderLoop(): void;
  31239. /**
  31240. * Gets the HTML canvas attached with the current webGL context
  31241. * @returns a HTML canvas
  31242. */
  31243. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31244. /**
  31245. * Gets host window
  31246. * @returns the host window object
  31247. */
  31248. getHostWindow(): Nullable<Window>;
  31249. /**
  31250. * Gets the current render width
  31251. * @param useScreen defines if screen size must be used (or the current render target if any)
  31252. * @returns a number defining the current render width
  31253. */
  31254. getRenderWidth(useScreen?: boolean): number;
  31255. /**
  31256. * Gets the current render height
  31257. * @param useScreen defines if screen size must be used (or the current render target if any)
  31258. * @returns a number defining the current render height
  31259. */
  31260. getRenderHeight(useScreen?: boolean): number;
  31261. /**
  31262. * Can be used to override the current requestAnimationFrame requester.
  31263. * @hidden
  31264. */
  31265. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31266. /**
  31267. * Register and execute a render loop. The engine can have more than one render function
  31268. * @param renderFunction defines the function to continuously execute
  31269. */
  31270. runRenderLoop(renderFunction: () => void): void;
  31271. /**
  31272. * Clear the current render buffer or the current render target (if any is set up)
  31273. * @param color defines the color to use
  31274. * @param backBuffer defines if the back buffer must be cleared
  31275. * @param depth defines if the depth buffer must be cleared
  31276. * @param stencil defines if the stencil buffer must be cleared
  31277. */
  31278. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31279. private _viewportCached;
  31280. /** @hidden */
  31281. _viewport(x: number, y: number, width: number, height: number): void;
  31282. /**
  31283. * Set the WebGL's viewport
  31284. * @param viewport defines the viewport element to be used
  31285. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31286. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31287. */
  31288. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31289. /**
  31290. * Begin a new frame
  31291. */
  31292. beginFrame(): void;
  31293. /**
  31294. * Enf the current frame
  31295. */
  31296. endFrame(): void;
  31297. /**
  31298. * Resize the view according to the canvas' size
  31299. */
  31300. resize(): void;
  31301. /**
  31302. * Force a specific size of the canvas
  31303. * @param width defines the new canvas' width
  31304. * @param height defines the new canvas' height
  31305. */
  31306. setSize(width: number, height: number): void;
  31307. /**
  31308. * Binds the frame buffer to the specified texture.
  31309. * @param texture The texture to render to or null for the default canvas
  31310. * @param faceIndex The face of the texture to render to in case of cube texture
  31311. * @param requiredWidth The width of the target to render to
  31312. * @param requiredHeight The height of the target to render to
  31313. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31314. * @param lodLevel defines the lod level to bind to the frame buffer
  31315. * @param layer defines the 2d array index to bind to frame buffer to
  31316. */
  31317. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31318. /** @hidden */
  31319. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31320. /**
  31321. * Unbind the current render target texture from the webGL context
  31322. * @param texture defines the render target texture to unbind
  31323. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31324. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31325. */
  31326. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31327. /**
  31328. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31329. */
  31330. flushFramebuffer(): void;
  31331. /**
  31332. * Unbind the current render target and bind the default framebuffer
  31333. */
  31334. restoreDefaultFramebuffer(): void;
  31335. /** @hidden */
  31336. protected _resetVertexBufferBinding(): void;
  31337. /**
  31338. * Creates a vertex buffer
  31339. * @param data the data for the vertex buffer
  31340. * @returns the new WebGL static buffer
  31341. */
  31342. createVertexBuffer(data: DataArray): DataBuffer;
  31343. private _createVertexBuffer;
  31344. /**
  31345. * Creates a dynamic vertex buffer
  31346. * @param data the data for the dynamic vertex buffer
  31347. * @returns the new WebGL dynamic buffer
  31348. */
  31349. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31350. protected _resetIndexBufferBinding(): void;
  31351. /**
  31352. * Creates a new index buffer
  31353. * @param indices defines the content of the index buffer
  31354. * @param updatable defines if the index buffer must be updatable
  31355. * @returns a new webGL buffer
  31356. */
  31357. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31358. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31359. /**
  31360. * Bind a webGL buffer to the webGL context
  31361. * @param buffer defines the buffer to bind
  31362. */
  31363. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31364. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31365. private bindBuffer;
  31366. /**
  31367. * update the bound buffer with the given data
  31368. * @param data defines the data to update
  31369. */
  31370. updateArrayBuffer(data: Float32Array): void;
  31371. private _vertexAttribPointer;
  31372. /** @hidden */
  31373. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31374. private _bindVertexBuffersAttributes;
  31375. /**
  31376. * Records a vertex array object
  31377. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31378. * @param vertexBuffers defines the list of vertex buffers to store
  31379. * @param indexBuffer defines the index buffer to store
  31380. * @param effect defines the effect to store
  31381. * @returns the new vertex array object
  31382. */
  31383. recordVertexArrayObject(vertexBuffers: {
  31384. [key: string]: VertexBuffer;
  31385. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31386. /**
  31387. * Bind a specific vertex array object
  31388. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31389. * @param vertexArrayObject defines the vertex array object to bind
  31390. * @param indexBuffer defines the index buffer to bind
  31391. */
  31392. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31393. /**
  31394. * Bind webGl buffers directly to the webGL context
  31395. * @param vertexBuffer defines the vertex buffer to bind
  31396. * @param indexBuffer defines the index buffer to bind
  31397. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31398. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31399. * @param effect defines the effect associated with the vertex buffer
  31400. */
  31401. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31402. private _unbindVertexArrayObject;
  31403. /**
  31404. * Bind a list of vertex buffers to the webGL context
  31405. * @param vertexBuffers defines the list of vertex buffers to bind
  31406. * @param indexBuffer defines the index buffer to bind
  31407. * @param effect defines the effect associated with the vertex buffers
  31408. */
  31409. bindBuffers(vertexBuffers: {
  31410. [key: string]: Nullable<VertexBuffer>;
  31411. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31412. /**
  31413. * Unbind all instance attributes
  31414. */
  31415. unbindInstanceAttributes(): void;
  31416. /**
  31417. * Release and free the memory of a vertex array object
  31418. * @param vao defines the vertex array object to delete
  31419. */
  31420. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31421. /** @hidden */
  31422. _releaseBuffer(buffer: DataBuffer): boolean;
  31423. protected _deleteBuffer(buffer: DataBuffer): void;
  31424. /**
  31425. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31426. * @param instancesBuffer defines the webGL buffer to update and bind
  31427. * @param data defines the data to store in the buffer
  31428. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31429. */
  31430. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31431. /**
  31432. * Bind the content of a webGL buffer used with instantiation
  31433. * @param instancesBuffer defines the webGL buffer to bind
  31434. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31435. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31436. */
  31437. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31438. /**
  31439. * Disable the instance attribute corresponding to the name in parameter
  31440. * @param name defines the name of the attribute to disable
  31441. */
  31442. disableInstanceAttributeByName(name: string): void;
  31443. /**
  31444. * Disable the instance attribute corresponding to the location in parameter
  31445. * @param attributeLocation defines the attribute location of the attribute to disable
  31446. */
  31447. disableInstanceAttribute(attributeLocation: number): void;
  31448. /**
  31449. * Disable the attribute corresponding to the location in parameter
  31450. * @param attributeLocation defines the attribute location of the attribute to disable
  31451. */
  31452. disableAttributeByIndex(attributeLocation: number): void;
  31453. /**
  31454. * Send a draw order
  31455. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31456. * @param indexStart defines the starting index
  31457. * @param indexCount defines the number of index to draw
  31458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31459. */
  31460. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31461. /**
  31462. * Draw a list of points
  31463. * @param verticesStart defines the index of first vertex to draw
  31464. * @param verticesCount defines the count of vertices to draw
  31465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31466. */
  31467. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31468. /**
  31469. * Draw a list of unindexed primitives
  31470. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31471. * @param verticesStart defines the index of first vertex to draw
  31472. * @param verticesCount defines the count of vertices to draw
  31473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31474. */
  31475. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31476. /**
  31477. * Draw a list of indexed primitives
  31478. * @param fillMode defines the primitive to use
  31479. * @param indexStart defines the starting index
  31480. * @param indexCount defines the number of index to draw
  31481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31482. */
  31483. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31484. /**
  31485. * Draw a list of unindexed primitives
  31486. * @param fillMode defines the primitive to use
  31487. * @param verticesStart defines the index of first vertex to draw
  31488. * @param verticesCount defines the count of vertices to draw
  31489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31490. */
  31491. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31492. private _drawMode;
  31493. /** @hidden */
  31494. protected _reportDrawCall(): void;
  31495. /** @hidden */
  31496. _releaseEffect(effect: Effect): void;
  31497. /** @hidden */
  31498. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31499. /**
  31500. * Create a new effect (used to store vertex/fragment shaders)
  31501. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31502. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31503. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31504. * @param samplers defines an array of string used to represent textures
  31505. * @param defines defines the string containing the defines to use to compile the shaders
  31506. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31507. * @param onCompiled defines a function to call when the effect creation is successful
  31508. * @param onError defines a function to call when the effect creation has failed
  31509. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31510. * @returns the new Effect
  31511. */
  31512. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31513. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31514. private _compileShader;
  31515. private _compileRawShader;
  31516. /**
  31517. * Directly creates a webGL program
  31518. * @param pipelineContext defines the pipeline context to attach to
  31519. * @param vertexCode defines the vertex shader code to use
  31520. * @param fragmentCode defines the fragment shader code to use
  31521. * @param context defines the webGL context to use (if not set, the current one will be used)
  31522. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31523. * @returns the new webGL program
  31524. */
  31525. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31526. /**
  31527. * Creates a webGL program
  31528. * @param pipelineContext defines the pipeline context to attach to
  31529. * @param vertexCode defines the vertex shader code to use
  31530. * @param fragmentCode defines the fragment shader code to use
  31531. * @param defines defines the string containing the defines to use to compile the shaders
  31532. * @param context defines the webGL context to use (if not set, the current one will be used)
  31533. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31534. * @returns the new webGL program
  31535. */
  31536. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31537. /**
  31538. * Creates a new pipeline context
  31539. * @returns the new pipeline
  31540. */
  31541. createPipelineContext(): IPipelineContext;
  31542. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31543. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31544. /** @hidden */
  31545. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31546. /** @hidden */
  31547. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31548. /** @hidden */
  31549. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31550. /**
  31551. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31552. * @param pipelineContext defines the pipeline context to use
  31553. * @param uniformsNames defines the list of uniform names
  31554. * @returns an array of webGL uniform locations
  31555. */
  31556. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31557. /**
  31558. * Gets the lsit of active attributes for a given webGL program
  31559. * @param pipelineContext defines the pipeline context to use
  31560. * @param attributesNames defines the list of attribute names to get
  31561. * @returns an array of indices indicating the offset of each attribute
  31562. */
  31563. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31564. /**
  31565. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31566. * @param effect defines the effect to activate
  31567. */
  31568. enableEffect(effect: Nullable<Effect>): void;
  31569. /**
  31570. * Set the value of an uniform to a number (int)
  31571. * @param uniform defines the webGL uniform location where to store the value
  31572. * @param value defines the int number to store
  31573. */
  31574. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31575. /**
  31576. * Set the value of an uniform to an array of int32
  31577. * @param uniform defines the webGL uniform location where to store the value
  31578. * @param array defines the array of int32 to store
  31579. */
  31580. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31581. /**
  31582. * Set the value of an uniform to an array of int32 (stored as vec2)
  31583. * @param uniform defines the webGL uniform location where to store the value
  31584. * @param array defines the array of int32 to store
  31585. */
  31586. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31587. /**
  31588. * Set the value of an uniform to an array of int32 (stored as vec3)
  31589. * @param uniform defines the webGL uniform location where to store the value
  31590. * @param array defines the array of int32 to store
  31591. */
  31592. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31593. /**
  31594. * Set the value of an uniform to an array of int32 (stored as vec4)
  31595. * @param uniform defines the webGL uniform location where to store the value
  31596. * @param array defines the array of int32 to store
  31597. */
  31598. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31599. /**
  31600. * Set the value of an uniform to an array of number
  31601. * @param uniform defines the webGL uniform location where to store the value
  31602. * @param array defines the array of number to store
  31603. */
  31604. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31605. /**
  31606. * Set the value of an uniform to an array of number (stored as vec2)
  31607. * @param uniform defines the webGL uniform location where to store the value
  31608. * @param array defines the array of number to store
  31609. */
  31610. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31611. /**
  31612. * Set the value of an uniform to an array of number (stored as vec3)
  31613. * @param uniform defines the webGL uniform location where to store the value
  31614. * @param array defines the array of number to store
  31615. */
  31616. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31617. /**
  31618. * Set the value of an uniform to an array of number (stored as vec4)
  31619. * @param uniform defines the webGL uniform location where to store the value
  31620. * @param array defines the array of number to store
  31621. */
  31622. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31623. /**
  31624. * Set the value of an uniform to an array of float32 (stored as matrices)
  31625. * @param uniform defines the webGL uniform location where to store the value
  31626. * @param matrices defines the array of float32 to store
  31627. */
  31628. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31629. /**
  31630. * Set the value of an uniform to a matrix (3x3)
  31631. * @param uniform defines the webGL uniform location where to store the value
  31632. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31633. */
  31634. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31635. /**
  31636. * Set the value of an uniform to a matrix (2x2)
  31637. * @param uniform defines the webGL uniform location where to store the value
  31638. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31639. */
  31640. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31641. /**
  31642. * Set the value of an uniform to a number (float)
  31643. * @param uniform defines the webGL uniform location where to store the value
  31644. * @param value defines the float number to store
  31645. */
  31646. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31647. /**
  31648. * Set the value of an uniform to a vec2
  31649. * @param uniform defines the webGL uniform location where to store the value
  31650. * @param x defines the 1st component of the value
  31651. * @param y defines the 2nd component of the value
  31652. */
  31653. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31654. /**
  31655. * Set the value of an uniform to a vec3
  31656. * @param uniform defines the webGL uniform location where to store the value
  31657. * @param x defines the 1st component of the value
  31658. * @param y defines the 2nd component of the value
  31659. * @param z defines the 3rd component of the value
  31660. */
  31661. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31662. /**
  31663. * Set the value of an uniform to a vec4
  31664. * @param uniform defines the webGL uniform location where to store the value
  31665. * @param x defines the 1st component of the value
  31666. * @param y defines the 2nd component of the value
  31667. * @param z defines the 3rd component of the value
  31668. * @param w defines the 4th component of the value
  31669. */
  31670. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31671. /**
  31672. * Apply all cached states (depth, culling, stencil and alpha)
  31673. */
  31674. applyStates(): void;
  31675. /**
  31676. * Enable or disable color writing
  31677. * @param enable defines the state to set
  31678. */
  31679. setColorWrite(enable: boolean): void;
  31680. /**
  31681. * Gets a boolean indicating if color writing is enabled
  31682. * @returns the current color writing state
  31683. */
  31684. getColorWrite(): boolean;
  31685. /**
  31686. * Gets the depth culling state manager
  31687. */
  31688. get depthCullingState(): DepthCullingState;
  31689. /**
  31690. * Gets the alpha state manager
  31691. */
  31692. get alphaState(): AlphaState;
  31693. /**
  31694. * Gets the stencil state manager
  31695. */
  31696. get stencilState(): StencilState;
  31697. /**
  31698. * Clears the list of texture accessible through engine.
  31699. * This can help preventing texture load conflict due to name collision.
  31700. */
  31701. clearInternalTexturesCache(): void;
  31702. /**
  31703. * Force the entire cache to be cleared
  31704. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31705. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31706. */
  31707. wipeCaches(bruteForce?: boolean): void;
  31708. /** @hidden */
  31709. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31710. min: number;
  31711. mag: number;
  31712. };
  31713. /** @hidden */
  31714. _createTexture(): WebGLTexture;
  31715. /**
  31716. * Usually called from Texture.ts.
  31717. * Passed information to create a WebGLTexture
  31718. * @param urlArg defines a value which contains one of the following:
  31719. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31720. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31721. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31723. * @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)
  31724. * @param scene needed for loading to the correct scene
  31725. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31726. * @param onLoad optional callback to be called upon successful completion
  31727. * @param onError optional callback to be called upon failure
  31728. * @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
  31729. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31730. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31731. * @param forcedExtension defines the extension to use to pick the right loader
  31732. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31733. * @param mimeType defines an optional mime type
  31734. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31735. */
  31736. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31737. /**
  31738. * Loads an image as an HTMLImageElement.
  31739. * @param input url string, ArrayBuffer, or Blob to load
  31740. * @param onLoad callback called when the image successfully loads
  31741. * @param onError callback called when the image fails to load
  31742. * @param offlineProvider offline provider for caching
  31743. * @param mimeType optional mime type
  31744. * @returns the HTMLImageElement of the loaded image
  31745. * @hidden
  31746. */
  31747. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31748. /**
  31749. * @hidden
  31750. */
  31751. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31752. /**
  31753. * Creates a raw texture
  31754. * @param data defines the data to store in the texture
  31755. * @param width defines the width of the texture
  31756. * @param height defines the height of the texture
  31757. * @param format defines the format of the data
  31758. * @param generateMipMaps defines if the engine should generate the mip levels
  31759. * @param invertY defines if data must be stored with Y axis inverted
  31760. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31761. * @param compression defines the compression used (null by default)
  31762. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31763. * @returns the raw texture inside an InternalTexture
  31764. */
  31765. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31766. /**
  31767. * Creates a new raw cube texture
  31768. * @param data defines the array of data to use to create each face
  31769. * @param size defines the size of the textures
  31770. * @param format defines the format of the data
  31771. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31772. * @param generateMipMaps defines if the engine should generate the mip levels
  31773. * @param invertY defines if data must be stored with Y axis inverted
  31774. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31775. * @param compression defines the compression used (null by default)
  31776. * @returns the cube texture as an InternalTexture
  31777. */
  31778. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31779. /**
  31780. * Creates a new raw 3D texture
  31781. * @param data defines the data used to create the texture
  31782. * @param width defines the width of the texture
  31783. * @param height defines the height of the texture
  31784. * @param depth defines the depth of the texture
  31785. * @param format defines the format of the texture
  31786. * @param generateMipMaps defines if the engine must generate mip levels
  31787. * @param invertY defines if data must be stored with Y axis inverted
  31788. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31789. * @param compression defines the compressed used (can be null)
  31790. * @param textureType defines the compressed used (can be null)
  31791. * @returns a new raw 3D texture (stored in an InternalTexture)
  31792. */
  31793. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31794. /**
  31795. * Creates a new raw 2D array texture
  31796. * @param data defines the data used to create the texture
  31797. * @param width defines the width of the texture
  31798. * @param height defines the height of the texture
  31799. * @param depth defines the number of layers of the texture
  31800. * @param format defines the format of the texture
  31801. * @param generateMipMaps defines if the engine must generate mip levels
  31802. * @param invertY defines if data must be stored with Y axis inverted
  31803. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31804. * @param compression defines the compressed used (can be null)
  31805. * @param textureType defines the compressed used (can be null)
  31806. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31807. */
  31808. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31809. private _unpackFlipYCached;
  31810. /**
  31811. * In case you are sharing the context with other applications, it might
  31812. * be interested to not cache the unpack flip y state to ensure a consistent
  31813. * value would be set.
  31814. */
  31815. enableUnpackFlipYCached: boolean;
  31816. /** @hidden */
  31817. _unpackFlipY(value: boolean): void;
  31818. /** @hidden */
  31819. _getUnpackAlignement(): number;
  31820. private _getTextureTarget;
  31821. /**
  31822. * Update the sampling mode of a given texture
  31823. * @param samplingMode defines the required sampling mode
  31824. * @param texture defines the texture to update
  31825. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31826. */
  31827. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31828. /**
  31829. * Update the sampling mode of a given texture
  31830. * @param texture defines the texture to update
  31831. * @param wrapU defines the texture wrap mode of the u coordinates
  31832. * @param wrapV defines the texture wrap mode of the v coordinates
  31833. * @param wrapR defines the texture wrap mode of the r coordinates
  31834. */
  31835. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31836. /** @hidden */
  31837. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31838. width: number;
  31839. height: number;
  31840. layers?: number;
  31841. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31842. /** @hidden */
  31843. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31844. /** @hidden */
  31845. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31846. /**
  31847. * Update a portion of an internal texture
  31848. * @param texture defines the texture to update
  31849. * @param imageData defines the data to store into the texture
  31850. * @param xOffset defines the x coordinates of the update rectangle
  31851. * @param yOffset defines the y coordinates of the update rectangle
  31852. * @param width defines the width of the update rectangle
  31853. * @param height defines the height of the update rectangle
  31854. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31855. * @param lod defines the lod level to update (0 by default)
  31856. */
  31857. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31858. /** @hidden */
  31859. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31860. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31861. private _prepareWebGLTexture;
  31862. /** @hidden */
  31863. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31864. private _getDepthStencilBuffer;
  31865. /** @hidden */
  31866. _releaseFramebufferObjects(texture: InternalTexture): void;
  31867. /** @hidden */
  31868. _releaseTexture(texture: InternalTexture): void;
  31869. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31870. protected _setProgram(program: WebGLProgram): void;
  31871. protected _boundUniforms: {
  31872. [key: number]: WebGLUniformLocation;
  31873. };
  31874. /**
  31875. * Binds an effect to the webGL context
  31876. * @param effect defines the effect to bind
  31877. */
  31878. bindSamplers(effect: Effect): void;
  31879. private _activateCurrentTexture;
  31880. /** @hidden */
  31881. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31882. /** @hidden */
  31883. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31884. /**
  31885. * Unbind all textures from the webGL context
  31886. */
  31887. unbindAllTextures(): void;
  31888. /**
  31889. * Sets a texture to the according uniform.
  31890. * @param channel The texture channel
  31891. * @param uniform The uniform to set
  31892. * @param texture The texture to apply
  31893. */
  31894. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31895. private _bindSamplerUniformToChannel;
  31896. private _getTextureWrapMode;
  31897. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31898. /**
  31899. * Sets an array of texture to the webGL context
  31900. * @param channel defines the channel where the texture array must be set
  31901. * @param uniform defines the associated uniform location
  31902. * @param textures defines the array of textures to bind
  31903. */
  31904. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31905. /** @hidden */
  31906. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31907. private _setTextureParameterFloat;
  31908. private _setTextureParameterInteger;
  31909. /**
  31910. * Unbind all vertex attributes from the webGL context
  31911. */
  31912. unbindAllAttributes(): void;
  31913. /**
  31914. * 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
  31915. */
  31916. releaseEffects(): void;
  31917. /**
  31918. * Dispose and release all associated resources
  31919. */
  31920. dispose(): void;
  31921. /**
  31922. * Attach a new callback raised when context lost event is fired
  31923. * @param callback defines the callback to call
  31924. */
  31925. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31926. /**
  31927. * Attach a new callback raised when context restored event is fired
  31928. * @param callback defines the callback to call
  31929. */
  31930. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31931. /**
  31932. * Get the current error code of the webGL context
  31933. * @returns the error code
  31934. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31935. */
  31936. getError(): number;
  31937. private _canRenderToFloatFramebuffer;
  31938. private _canRenderToHalfFloatFramebuffer;
  31939. private _canRenderToFramebuffer;
  31940. /** @hidden */
  31941. _getWebGLTextureType(type: number): number;
  31942. /** @hidden */
  31943. _getInternalFormat(format: number): number;
  31944. /** @hidden */
  31945. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31946. /** @hidden */
  31947. _getRGBAMultiSampleBufferFormat(type: number): number;
  31948. /** @hidden */
  31949. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31950. /**
  31951. * Loads a file from a url
  31952. * @param url url to load
  31953. * @param onSuccess callback called when the file successfully loads
  31954. * @param onProgress callback called while file is loading (if the server supports this mode)
  31955. * @param offlineProvider defines the offline provider for caching
  31956. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31957. * @param onError callback called when the file fails to load
  31958. * @returns a file request object
  31959. * @hidden
  31960. */
  31961. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  31962. /**
  31963. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31964. * @param x defines the x coordinate of the rectangle where pixels must be read
  31965. * @param y defines the y coordinate of the rectangle where pixels must be read
  31966. * @param width defines the width of the rectangle where pixels must be read
  31967. * @param height defines the height of the rectangle where pixels must be read
  31968. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31969. * @returns a Uint8Array containing RGBA colors
  31970. */
  31971. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31972. private static _isSupported;
  31973. /**
  31974. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31975. * @returns true if the engine can be created
  31976. * @ignorenaming
  31977. */
  31978. static isSupported(): boolean;
  31979. /**
  31980. * Find the next highest power of two.
  31981. * @param x Number to start search from.
  31982. * @return Next highest power of two.
  31983. */
  31984. static CeilingPOT(x: number): number;
  31985. /**
  31986. * Find the next lowest power of two.
  31987. * @param x Number to start search from.
  31988. * @return Next lowest power of two.
  31989. */
  31990. static FloorPOT(x: number): number;
  31991. /**
  31992. * Find the nearest power of two.
  31993. * @param x Number to start search from.
  31994. * @return Next nearest power of two.
  31995. */
  31996. static NearestPOT(x: number): number;
  31997. /**
  31998. * Get the closest exponent of two
  31999. * @param value defines the value to approximate
  32000. * @param max defines the maximum value to return
  32001. * @param mode defines how to define the closest value
  32002. * @returns closest exponent of two of the given value
  32003. */
  32004. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32005. /**
  32006. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32007. * @param func - the function to be called
  32008. * @param requester - the object that will request the next frame. Falls back to window.
  32009. * @returns frame number
  32010. */
  32011. static QueueNewFrame(func: () => void, requester?: any): number;
  32012. /**
  32013. * Gets host document
  32014. * @returns the host document object
  32015. */
  32016. getHostDocument(): Nullable<Document>;
  32017. }
  32018. }
  32019. declare module BABYLON {
  32020. /**
  32021. * Class representing spherical harmonics coefficients to the 3rd degree
  32022. */
  32023. export class SphericalHarmonics {
  32024. /**
  32025. * Defines whether or not the harmonics have been prescaled for rendering.
  32026. */
  32027. preScaled: boolean;
  32028. /**
  32029. * The l0,0 coefficients of the spherical harmonics
  32030. */
  32031. l00: Vector3;
  32032. /**
  32033. * The l1,-1 coefficients of the spherical harmonics
  32034. */
  32035. l1_1: Vector3;
  32036. /**
  32037. * The l1,0 coefficients of the spherical harmonics
  32038. */
  32039. l10: Vector3;
  32040. /**
  32041. * The l1,1 coefficients of the spherical harmonics
  32042. */
  32043. l11: Vector3;
  32044. /**
  32045. * The l2,-2 coefficients of the spherical harmonics
  32046. */
  32047. l2_2: Vector3;
  32048. /**
  32049. * The l2,-1 coefficients of the spherical harmonics
  32050. */
  32051. l2_1: Vector3;
  32052. /**
  32053. * The l2,0 coefficients of the spherical harmonics
  32054. */
  32055. l20: Vector3;
  32056. /**
  32057. * The l2,1 coefficients of the spherical harmonics
  32058. */
  32059. l21: Vector3;
  32060. /**
  32061. * The l2,2 coefficients of the spherical harmonics
  32062. */
  32063. l22: Vector3;
  32064. /**
  32065. * Adds a light to the spherical harmonics
  32066. * @param direction the direction of the light
  32067. * @param color the color of the light
  32068. * @param deltaSolidAngle the delta solid angle of the light
  32069. */
  32070. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32071. /**
  32072. * Scales the spherical harmonics by the given amount
  32073. * @param scale the amount to scale
  32074. */
  32075. scaleInPlace(scale: number): void;
  32076. /**
  32077. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32078. *
  32079. * ```
  32080. * E_lm = A_l * L_lm
  32081. * ```
  32082. *
  32083. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32084. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32085. * the scaling factors are given in equation 9.
  32086. */
  32087. convertIncidentRadianceToIrradiance(): void;
  32088. /**
  32089. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32090. *
  32091. * ```
  32092. * L = (1/pi) * E * rho
  32093. * ```
  32094. *
  32095. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32096. */
  32097. convertIrradianceToLambertianRadiance(): void;
  32098. /**
  32099. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32100. * required operations at run time.
  32101. *
  32102. * This is simply done by scaling back the SH with Ylm constants parameter.
  32103. * The trigonometric part being applied by the shader at run time.
  32104. */
  32105. preScaleForRendering(): void;
  32106. /**
  32107. * Constructs a spherical harmonics from an array.
  32108. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32109. * @returns the spherical harmonics
  32110. */
  32111. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32112. /**
  32113. * Gets the spherical harmonics from polynomial
  32114. * @param polynomial the spherical polynomial
  32115. * @returns the spherical harmonics
  32116. */
  32117. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32118. }
  32119. /**
  32120. * Class representing spherical polynomial coefficients to the 3rd degree
  32121. */
  32122. export class SphericalPolynomial {
  32123. private _harmonics;
  32124. /**
  32125. * The spherical harmonics used to create the polynomials.
  32126. */
  32127. get preScaledHarmonics(): SphericalHarmonics;
  32128. /**
  32129. * The x coefficients of the spherical polynomial
  32130. */
  32131. x: Vector3;
  32132. /**
  32133. * The y coefficients of the spherical polynomial
  32134. */
  32135. y: Vector3;
  32136. /**
  32137. * The z coefficients of the spherical polynomial
  32138. */
  32139. z: Vector3;
  32140. /**
  32141. * The xx coefficients of the spherical polynomial
  32142. */
  32143. xx: Vector3;
  32144. /**
  32145. * The yy coefficients of the spherical polynomial
  32146. */
  32147. yy: Vector3;
  32148. /**
  32149. * The zz coefficients of the spherical polynomial
  32150. */
  32151. zz: Vector3;
  32152. /**
  32153. * The xy coefficients of the spherical polynomial
  32154. */
  32155. xy: Vector3;
  32156. /**
  32157. * The yz coefficients of the spherical polynomial
  32158. */
  32159. yz: Vector3;
  32160. /**
  32161. * The zx coefficients of the spherical polynomial
  32162. */
  32163. zx: Vector3;
  32164. /**
  32165. * Adds an ambient color to the spherical polynomial
  32166. * @param color the color to add
  32167. */
  32168. addAmbient(color: Color3): void;
  32169. /**
  32170. * Scales the spherical polynomial by the given amount
  32171. * @param scale the amount to scale
  32172. */
  32173. scaleInPlace(scale: number): void;
  32174. /**
  32175. * Gets the spherical polynomial from harmonics
  32176. * @param harmonics the spherical harmonics
  32177. * @returns the spherical polynomial
  32178. */
  32179. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32180. /**
  32181. * Constructs a spherical polynomial from an array.
  32182. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32183. * @returns the spherical polynomial
  32184. */
  32185. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32186. }
  32187. }
  32188. declare module BABYLON {
  32189. /**
  32190. * Defines the source of the internal texture
  32191. */
  32192. export enum InternalTextureSource {
  32193. /**
  32194. * The source of the texture data is unknown
  32195. */
  32196. Unknown = 0,
  32197. /**
  32198. * Texture data comes from an URL
  32199. */
  32200. Url = 1,
  32201. /**
  32202. * Texture data is only used for temporary storage
  32203. */
  32204. Temp = 2,
  32205. /**
  32206. * Texture data comes from raw data (ArrayBuffer)
  32207. */
  32208. Raw = 3,
  32209. /**
  32210. * Texture content is dynamic (video or dynamic texture)
  32211. */
  32212. Dynamic = 4,
  32213. /**
  32214. * Texture content is generated by rendering to it
  32215. */
  32216. RenderTarget = 5,
  32217. /**
  32218. * Texture content is part of a multi render target process
  32219. */
  32220. MultiRenderTarget = 6,
  32221. /**
  32222. * Texture data comes from a cube data file
  32223. */
  32224. Cube = 7,
  32225. /**
  32226. * Texture data comes from a raw cube data
  32227. */
  32228. CubeRaw = 8,
  32229. /**
  32230. * Texture data come from a prefiltered cube data file
  32231. */
  32232. CubePrefiltered = 9,
  32233. /**
  32234. * Texture content is raw 3D data
  32235. */
  32236. Raw3D = 10,
  32237. /**
  32238. * Texture content is raw 2D array data
  32239. */
  32240. Raw2DArray = 11,
  32241. /**
  32242. * Texture content is a depth texture
  32243. */
  32244. Depth = 12,
  32245. /**
  32246. * Texture data comes from a raw cube data encoded with RGBD
  32247. */
  32248. CubeRawRGBD = 13
  32249. }
  32250. /**
  32251. * Class used to store data associated with WebGL texture data for the engine
  32252. * This class should not be used directly
  32253. */
  32254. export class InternalTexture {
  32255. /** @hidden */
  32256. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32257. /**
  32258. * Defines if the texture is ready
  32259. */
  32260. isReady: boolean;
  32261. /**
  32262. * Defines if the texture is a cube texture
  32263. */
  32264. isCube: boolean;
  32265. /**
  32266. * Defines if the texture contains 3D data
  32267. */
  32268. is3D: boolean;
  32269. /**
  32270. * Defines if the texture contains 2D array data
  32271. */
  32272. is2DArray: boolean;
  32273. /**
  32274. * Defines if the texture contains multiview data
  32275. */
  32276. isMultiview: boolean;
  32277. /**
  32278. * Gets the URL used to load this texture
  32279. */
  32280. url: string;
  32281. /**
  32282. * Gets the sampling mode of the texture
  32283. */
  32284. samplingMode: number;
  32285. /**
  32286. * Gets a boolean indicating if the texture needs mipmaps generation
  32287. */
  32288. generateMipMaps: boolean;
  32289. /**
  32290. * Gets the number of samples used by the texture (WebGL2+ only)
  32291. */
  32292. samples: number;
  32293. /**
  32294. * Gets the type of the texture (int, float...)
  32295. */
  32296. type: number;
  32297. /**
  32298. * Gets the format of the texture (RGB, RGBA...)
  32299. */
  32300. format: number;
  32301. /**
  32302. * Observable called when the texture is loaded
  32303. */
  32304. onLoadedObservable: Observable<InternalTexture>;
  32305. /**
  32306. * Gets the width of the texture
  32307. */
  32308. width: number;
  32309. /**
  32310. * Gets the height of the texture
  32311. */
  32312. height: number;
  32313. /**
  32314. * Gets the depth of the texture
  32315. */
  32316. depth: number;
  32317. /**
  32318. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32319. */
  32320. baseWidth: number;
  32321. /**
  32322. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32323. */
  32324. baseHeight: number;
  32325. /**
  32326. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32327. */
  32328. baseDepth: number;
  32329. /**
  32330. * Gets a boolean indicating if the texture is inverted on Y axis
  32331. */
  32332. invertY: boolean;
  32333. /** @hidden */
  32334. _invertVScale: boolean;
  32335. /** @hidden */
  32336. _associatedChannel: number;
  32337. /** @hidden */
  32338. _source: InternalTextureSource;
  32339. /** @hidden */
  32340. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32341. /** @hidden */
  32342. _bufferView: Nullable<ArrayBufferView>;
  32343. /** @hidden */
  32344. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32345. /** @hidden */
  32346. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32347. /** @hidden */
  32348. _size: number;
  32349. /** @hidden */
  32350. _extension: string;
  32351. /** @hidden */
  32352. _files: Nullable<string[]>;
  32353. /** @hidden */
  32354. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32355. /** @hidden */
  32356. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32357. /** @hidden */
  32358. _framebuffer: Nullable<WebGLFramebuffer>;
  32359. /** @hidden */
  32360. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32361. /** @hidden */
  32362. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32363. /** @hidden */
  32364. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32365. /** @hidden */
  32366. _attachments: Nullable<number[]>;
  32367. /** @hidden */
  32368. _cachedCoordinatesMode: Nullable<number>;
  32369. /** @hidden */
  32370. _cachedWrapU: Nullable<number>;
  32371. /** @hidden */
  32372. _cachedWrapV: Nullable<number>;
  32373. /** @hidden */
  32374. _cachedWrapR: Nullable<number>;
  32375. /** @hidden */
  32376. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32377. /** @hidden */
  32378. _isDisabled: boolean;
  32379. /** @hidden */
  32380. _compression: Nullable<string>;
  32381. /** @hidden */
  32382. _generateStencilBuffer: boolean;
  32383. /** @hidden */
  32384. _generateDepthBuffer: boolean;
  32385. /** @hidden */
  32386. _comparisonFunction: number;
  32387. /** @hidden */
  32388. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32389. /** @hidden */
  32390. _lodGenerationScale: number;
  32391. /** @hidden */
  32392. _lodGenerationOffset: number;
  32393. /** @hidden */
  32394. _depthStencilTexture: Nullable<InternalTexture>;
  32395. /** @hidden */
  32396. _colorTextureArray: Nullable<WebGLTexture>;
  32397. /** @hidden */
  32398. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32399. /** @hidden */
  32400. _lodTextureHigh: Nullable<BaseTexture>;
  32401. /** @hidden */
  32402. _lodTextureMid: Nullable<BaseTexture>;
  32403. /** @hidden */
  32404. _lodTextureLow: Nullable<BaseTexture>;
  32405. /** @hidden */
  32406. _isRGBD: boolean;
  32407. /** @hidden */
  32408. _linearSpecularLOD: boolean;
  32409. /** @hidden */
  32410. _irradianceTexture: Nullable<BaseTexture>;
  32411. /** @hidden */
  32412. _webGLTexture: Nullable<WebGLTexture>;
  32413. /** @hidden */
  32414. _references: number;
  32415. private _engine;
  32416. /**
  32417. * Gets the Engine the texture belongs to.
  32418. * @returns The babylon engine
  32419. */
  32420. getEngine(): ThinEngine;
  32421. /**
  32422. * Gets the data source type of the texture
  32423. */
  32424. get source(): InternalTextureSource;
  32425. /**
  32426. * Creates a new InternalTexture
  32427. * @param engine defines the engine to use
  32428. * @param source defines the type of data that will be used
  32429. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32430. */
  32431. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32432. /**
  32433. * Increments the number of references (ie. the number of Texture that point to it)
  32434. */
  32435. incrementReferences(): void;
  32436. /**
  32437. * Change the size of the texture (not the size of the content)
  32438. * @param width defines the new width
  32439. * @param height defines the new height
  32440. * @param depth defines the new depth (1 by default)
  32441. */
  32442. updateSize(width: int, height: int, depth?: int): void;
  32443. /** @hidden */
  32444. _rebuild(): void;
  32445. /** @hidden */
  32446. _swapAndDie(target: InternalTexture): void;
  32447. /**
  32448. * Dispose the current allocated resources
  32449. */
  32450. dispose(): void;
  32451. }
  32452. }
  32453. declare module BABYLON {
  32454. /**
  32455. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32457. */
  32458. export class Analyser {
  32459. /**
  32460. * Gets or sets the smoothing
  32461. * @ignorenaming
  32462. */
  32463. SMOOTHING: number;
  32464. /**
  32465. * Gets or sets the FFT table size
  32466. * @ignorenaming
  32467. */
  32468. FFT_SIZE: number;
  32469. /**
  32470. * Gets or sets the bar graph amplitude
  32471. * @ignorenaming
  32472. */
  32473. BARGRAPHAMPLITUDE: number;
  32474. /**
  32475. * Gets or sets the position of the debug canvas
  32476. * @ignorenaming
  32477. */
  32478. DEBUGCANVASPOS: {
  32479. x: number;
  32480. y: number;
  32481. };
  32482. /**
  32483. * Gets or sets the debug canvas size
  32484. * @ignorenaming
  32485. */
  32486. DEBUGCANVASSIZE: {
  32487. width: number;
  32488. height: number;
  32489. };
  32490. private _byteFreqs;
  32491. private _byteTime;
  32492. private _floatFreqs;
  32493. private _webAudioAnalyser;
  32494. private _debugCanvas;
  32495. private _debugCanvasContext;
  32496. private _scene;
  32497. private _registerFunc;
  32498. private _audioEngine;
  32499. /**
  32500. * Creates a new analyser
  32501. * @param scene defines hosting scene
  32502. */
  32503. constructor(scene: Scene);
  32504. /**
  32505. * Get the number of data values you will have to play with for the visualization
  32506. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32507. * @returns a number
  32508. */
  32509. getFrequencyBinCount(): number;
  32510. /**
  32511. * Gets the current frequency data as a byte array
  32512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32513. * @returns a Uint8Array
  32514. */
  32515. getByteFrequencyData(): Uint8Array;
  32516. /**
  32517. * Gets the current waveform as a byte array
  32518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32519. * @returns a Uint8Array
  32520. */
  32521. getByteTimeDomainData(): Uint8Array;
  32522. /**
  32523. * Gets the current frequency data as a float array
  32524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32525. * @returns a Float32Array
  32526. */
  32527. getFloatFrequencyData(): Float32Array;
  32528. /**
  32529. * Renders the debug canvas
  32530. */
  32531. drawDebugCanvas(): void;
  32532. /**
  32533. * Stops rendering the debug canvas and removes it
  32534. */
  32535. stopDebugCanvas(): void;
  32536. /**
  32537. * Connects two audio nodes
  32538. * @param inputAudioNode defines first node to connect
  32539. * @param outputAudioNode defines second node to connect
  32540. */
  32541. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32542. /**
  32543. * Releases all associated resources
  32544. */
  32545. dispose(): void;
  32546. }
  32547. }
  32548. declare module BABYLON {
  32549. /**
  32550. * This represents an audio engine and it is responsible
  32551. * to play, synchronize and analyse sounds throughout the application.
  32552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32553. */
  32554. export interface IAudioEngine extends IDisposable {
  32555. /**
  32556. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32557. */
  32558. readonly canUseWebAudio: boolean;
  32559. /**
  32560. * Gets the current AudioContext if available.
  32561. */
  32562. readonly audioContext: Nullable<AudioContext>;
  32563. /**
  32564. * The master gain node defines the global audio volume of your audio engine.
  32565. */
  32566. readonly masterGain: GainNode;
  32567. /**
  32568. * Gets whether or not mp3 are supported by your browser.
  32569. */
  32570. readonly isMP3supported: boolean;
  32571. /**
  32572. * Gets whether or not ogg are supported by your browser.
  32573. */
  32574. readonly isOGGsupported: boolean;
  32575. /**
  32576. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32577. * @ignoreNaming
  32578. */
  32579. WarnedWebAudioUnsupported: boolean;
  32580. /**
  32581. * Defines if the audio engine relies on a custom unlocked button.
  32582. * In this case, the embedded button will not be displayed.
  32583. */
  32584. useCustomUnlockedButton: boolean;
  32585. /**
  32586. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32587. */
  32588. readonly unlocked: boolean;
  32589. /**
  32590. * Event raised when audio has been unlocked on the browser.
  32591. */
  32592. onAudioUnlockedObservable: Observable<AudioEngine>;
  32593. /**
  32594. * Event raised when audio has been locked on the browser.
  32595. */
  32596. onAudioLockedObservable: Observable<AudioEngine>;
  32597. /**
  32598. * Flags the audio engine in Locked state.
  32599. * This happens due to new browser policies preventing audio to autoplay.
  32600. */
  32601. lock(): void;
  32602. /**
  32603. * Unlocks the audio engine once a user action has been done on the dom.
  32604. * This is helpful to resume play once browser policies have been satisfied.
  32605. */
  32606. unlock(): void;
  32607. }
  32608. /**
  32609. * This represents the default audio engine used in babylon.
  32610. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32612. */
  32613. export class AudioEngine implements IAudioEngine {
  32614. private _audioContext;
  32615. private _audioContextInitialized;
  32616. private _muteButton;
  32617. private _hostElement;
  32618. /**
  32619. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32620. */
  32621. canUseWebAudio: boolean;
  32622. /**
  32623. * The master gain node defines the global audio volume of your audio engine.
  32624. */
  32625. masterGain: GainNode;
  32626. /**
  32627. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32628. * @ignoreNaming
  32629. */
  32630. WarnedWebAudioUnsupported: boolean;
  32631. /**
  32632. * Gets whether or not mp3 are supported by your browser.
  32633. */
  32634. isMP3supported: boolean;
  32635. /**
  32636. * Gets whether or not ogg are supported by your browser.
  32637. */
  32638. isOGGsupported: boolean;
  32639. /**
  32640. * Gets whether audio has been unlocked on the device.
  32641. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32642. * a user interaction has happened.
  32643. */
  32644. unlocked: boolean;
  32645. /**
  32646. * Defines if the audio engine relies on a custom unlocked button.
  32647. * In this case, the embedded button will not be displayed.
  32648. */
  32649. useCustomUnlockedButton: boolean;
  32650. /**
  32651. * Event raised when audio has been unlocked on the browser.
  32652. */
  32653. onAudioUnlockedObservable: Observable<AudioEngine>;
  32654. /**
  32655. * Event raised when audio has been locked on the browser.
  32656. */
  32657. onAudioLockedObservable: Observable<AudioEngine>;
  32658. /**
  32659. * Gets the current AudioContext if available.
  32660. */
  32661. get audioContext(): Nullable<AudioContext>;
  32662. private _connectedAnalyser;
  32663. /**
  32664. * Instantiates a new audio engine.
  32665. *
  32666. * There should be only one per page as some browsers restrict the number
  32667. * of audio contexts you can create.
  32668. * @param hostElement defines the host element where to display the mute icon if necessary
  32669. */
  32670. constructor(hostElement?: Nullable<HTMLElement>);
  32671. /**
  32672. * Flags the audio engine in Locked state.
  32673. * This happens due to new browser policies preventing audio to autoplay.
  32674. */
  32675. lock(): void;
  32676. /**
  32677. * Unlocks the audio engine once a user action has been done on the dom.
  32678. * This is helpful to resume play once browser policies have been satisfied.
  32679. */
  32680. unlock(): void;
  32681. private _resumeAudioContext;
  32682. private _initializeAudioContext;
  32683. private _tryToRun;
  32684. private _triggerRunningState;
  32685. private _triggerSuspendedState;
  32686. private _displayMuteButton;
  32687. private _moveButtonToTopLeft;
  32688. private _onResize;
  32689. private _hideMuteButton;
  32690. /**
  32691. * Destroy and release the resources associated with the audio ccontext.
  32692. */
  32693. dispose(): void;
  32694. /**
  32695. * Gets the global volume sets on the master gain.
  32696. * @returns the global volume if set or -1 otherwise
  32697. */
  32698. getGlobalVolume(): number;
  32699. /**
  32700. * Sets the global volume of your experience (sets on the master gain).
  32701. * @param newVolume Defines the new global volume of the application
  32702. */
  32703. setGlobalVolume(newVolume: number): void;
  32704. /**
  32705. * Connect the audio engine to an audio analyser allowing some amazing
  32706. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32708. * @param analyser The analyser to connect to the engine
  32709. */
  32710. connectToAnalyser(analyser: Analyser): void;
  32711. }
  32712. }
  32713. declare module BABYLON {
  32714. /**
  32715. * Interface used to present a loading screen while loading a scene
  32716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32717. */
  32718. export interface ILoadingScreen {
  32719. /**
  32720. * Function called to display the loading screen
  32721. */
  32722. displayLoadingUI: () => void;
  32723. /**
  32724. * Function called to hide the loading screen
  32725. */
  32726. hideLoadingUI: () => void;
  32727. /**
  32728. * Gets or sets the color to use for the background
  32729. */
  32730. loadingUIBackgroundColor: string;
  32731. /**
  32732. * Gets or sets the text to display while loading
  32733. */
  32734. loadingUIText: string;
  32735. }
  32736. /**
  32737. * Class used for the default loading screen
  32738. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32739. */
  32740. export class DefaultLoadingScreen implements ILoadingScreen {
  32741. private _renderingCanvas;
  32742. private _loadingText;
  32743. private _loadingDivBackgroundColor;
  32744. private _loadingDiv;
  32745. private _loadingTextDiv;
  32746. /** Gets or sets the logo url to use for the default loading screen */
  32747. static DefaultLogoUrl: string;
  32748. /** Gets or sets the spinner url to use for the default loading screen */
  32749. static DefaultSpinnerUrl: string;
  32750. /**
  32751. * Creates a new default loading screen
  32752. * @param _renderingCanvas defines the canvas used to render the scene
  32753. * @param _loadingText defines the default text to display
  32754. * @param _loadingDivBackgroundColor defines the default background color
  32755. */
  32756. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32757. /**
  32758. * Function called to display the loading screen
  32759. */
  32760. displayLoadingUI(): void;
  32761. /**
  32762. * Function called to hide the loading screen
  32763. */
  32764. hideLoadingUI(): void;
  32765. /**
  32766. * Gets or sets the text to display while loading
  32767. */
  32768. set loadingUIText(text: string);
  32769. get loadingUIText(): string;
  32770. /**
  32771. * Gets or sets the color to use for the background
  32772. */
  32773. get loadingUIBackgroundColor(): string;
  32774. set loadingUIBackgroundColor(color: string);
  32775. private _resizeLoadingUI;
  32776. }
  32777. }
  32778. declare module BABYLON {
  32779. /**
  32780. * Interface for any object that can request an animation frame
  32781. */
  32782. export interface ICustomAnimationFrameRequester {
  32783. /**
  32784. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32785. */
  32786. renderFunction?: Function;
  32787. /**
  32788. * Called to request the next frame to render to
  32789. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32790. */
  32791. requestAnimationFrame: Function;
  32792. /**
  32793. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32794. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32795. */
  32796. requestID?: number;
  32797. }
  32798. }
  32799. declare module BABYLON {
  32800. /**
  32801. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32802. */
  32803. export class PerformanceMonitor {
  32804. private _enabled;
  32805. private _rollingFrameTime;
  32806. private _lastFrameTimeMs;
  32807. /**
  32808. * constructor
  32809. * @param frameSampleSize The number of samples required to saturate the sliding window
  32810. */
  32811. constructor(frameSampleSize?: number);
  32812. /**
  32813. * Samples current frame
  32814. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32815. */
  32816. sampleFrame(timeMs?: number): void;
  32817. /**
  32818. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32819. */
  32820. get averageFrameTime(): number;
  32821. /**
  32822. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32823. */
  32824. get averageFrameTimeVariance(): number;
  32825. /**
  32826. * Returns the frame time of the most recent frame
  32827. */
  32828. get instantaneousFrameTime(): number;
  32829. /**
  32830. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32831. */
  32832. get averageFPS(): number;
  32833. /**
  32834. * Returns the average framerate in frames per second using the most recent frame time
  32835. */
  32836. get instantaneousFPS(): number;
  32837. /**
  32838. * Returns true if enough samples have been taken to completely fill the sliding window
  32839. */
  32840. get isSaturated(): boolean;
  32841. /**
  32842. * Enables contributions to the sliding window sample set
  32843. */
  32844. enable(): void;
  32845. /**
  32846. * Disables contributions to the sliding window sample set
  32847. * Samples will not be interpolated over the disabled period
  32848. */
  32849. disable(): void;
  32850. /**
  32851. * Returns true if sampling is enabled
  32852. */
  32853. get isEnabled(): boolean;
  32854. /**
  32855. * Resets performance monitor
  32856. */
  32857. reset(): void;
  32858. }
  32859. /**
  32860. * RollingAverage
  32861. *
  32862. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32863. */
  32864. export class RollingAverage {
  32865. /**
  32866. * Current average
  32867. */
  32868. average: number;
  32869. /**
  32870. * Current variance
  32871. */
  32872. variance: number;
  32873. protected _samples: Array<number>;
  32874. protected _sampleCount: number;
  32875. protected _pos: number;
  32876. protected _m2: number;
  32877. /**
  32878. * constructor
  32879. * @param length The number of samples required to saturate the sliding window
  32880. */
  32881. constructor(length: number);
  32882. /**
  32883. * Adds a sample to the sample set
  32884. * @param v The sample value
  32885. */
  32886. add(v: number): void;
  32887. /**
  32888. * Returns previously added values or null if outside of history or outside the sliding window domain
  32889. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32890. * @return Value previously recorded with add() or null if outside of range
  32891. */
  32892. history(i: number): number;
  32893. /**
  32894. * Returns true if enough samples have been taken to completely fill the sliding window
  32895. * @return true if sample-set saturated
  32896. */
  32897. isSaturated(): boolean;
  32898. /**
  32899. * Resets the rolling average (equivalent to 0 samples taken so far)
  32900. */
  32901. reset(): void;
  32902. /**
  32903. * Wraps a value around the sample range boundaries
  32904. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32905. * @return Wrapped position in sample range
  32906. */
  32907. protected _wrapPosition(i: number): number;
  32908. }
  32909. }
  32910. declare module BABYLON {
  32911. /**
  32912. * This class is used to track a performance counter which is number based.
  32913. * The user has access to many properties which give statistics of different nature.
  32914. *
  32915. * The implementer can track two kinds of Performance Counter: time and count.
  32916. * 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.
  32917. * 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.
  32918. */
  32919. export class PerfCounter {
  32920. /**
  32921. * Gets or sets a global boolean to turn on and off all the counters
  32922. */
  32923. static Enabled: boolean;
  32924. /**
  32925. * Returns the smallest value ever
  32926. */
  32927. get min(): number;
  32928. /**
  32929. * Returns the biggest value ever
  32930. */
  32931. get max(): number;
  32932. /**
  32933. * Returns the average value since the performance counter is running
  32934. */
  32935. get average(): number;
  32936. /**
  32937. * Returns the average value of the last second the counter was monitored
  32938. */
  32939. get lastSecAverage(): number;
  32940. /**
  32941. * Returns the current value
  32942. */
  32943. get current(): number;
  32944. /**
  32945. * Gets the accumulated total
  32946. */
  32947. get total(): number;
  32948. /**
  32949. * Gets the total value count
  32950. */
  32951. get count(): number;
  32952. /**
  32953. * Creates a new counter
  32954. */
  32955. constructor();
  32956. /**
  32957. * Call this method to start monitoring a new frame.
  32958. * 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.
  32959. */
  32960. fetchNewFrame(): void;
  32961. /**
  32962. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32963. * @param newCount the count value to add to the monitored count
  32964. * @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.
  32965. */
  32966. addCount(newCount: number, fetchResult: boolean): void;
  32967. /**
  32968. * Start monitoring this performance counter
  32969. */
  32970. beginMonitoring(): void;
  32971. /**
  32972. * Compute the time lapsed since the previous beginMonitoring() call.
  32973. * @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
  32974. */
  32975. endMonitoring(newFrame?: boolean): void;
  32976. private _fetchResult;
  32977. private _startMonitoringTime;
  32978. private _min;
  32979. private _max;
  32980. private _average;
  32981. private _current;
  32982. private _totalValueCount;
  32983. private _totalAccumulated;
  32984. private _lastSecAverage;
  32985. private _lastSecAccumulated;
  32986. private _lastSecTime;
  32987. private _lastSecValueCount;
  32988. }
  32989. }
  32990. declare module BABYLON {
  32991. interface ThinEngine {
  32992. /**
  32993. * Sets alpha constants used by some alpha blending modes
  32994. * @param r defines the red component
  32995. * @param g defines the green component
  32996. * @param b defines the blue component
  32997. * @param a defines the alpha component
  32998. */
  32999. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33000. /**
  33001. * Sets the current alpha mode
  33002. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33003. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33004. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33005. */
  33006. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33007. /**
  33008. * Gets the current alpha mode
  33009. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33010. * @returns the current alpha mode
  33011. */
  33012. getAlphaMode(): number;
  33013. /**
  33014. * Sets the current alpha equation
  33015. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33016. */
  33017. setAlphaEquation(equation: number): void;
  33018. /**
  33019. * Gets the current alpha equation.
  33020. * @returns the current alpha equation
  33021. */
  33022. getAlphaEquation(): number;
  33023. }
  33024. }
  33025. declare module BABYLON {
  33026. /**
  33027. * Defines the interface used by display changed events
  33028. */
  33029. export interface IDisplayChangedEventArgs {
  33030. /** Gets the vrDisplay object (if any) */
  33031. vrDisplay: Nullable<any>;
  33032. /** Gets a boolean indicating if webVR is supported */
  33033. vrSupported: boolean;
  33034. }
  33035. /**
  33036. * Defines the interface used by objects containing a viewport (like a camera)
  33037. */
  33038. interface IViewportOwnerLike {
  33039. /**
  33040. * Gets or sets the viewport
  33041. */
  33042. viewport: IViewportLike;
  33043. }
  33044. /**
  33045. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33046. */
  33047. export class Engine extends ThinEngine {
  33048. /** Defines that alpha blending is disabled */
  33049. static readonly ALPHA_DISABLE: number;
  33050. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33051. static readonly ALPHA_ADD: number;
  33052. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33053. static readonly ALPHA_COMBINE: number;
  33054. /** Defines that alpha blending to DEST - SRC * DEST */
  33055. static readonly ALPHA_SUBTRACT: number;
  33056. /** Defines that alpha blending to SRC * DEST */
  33057. static readonly ALPHA_MULTIPLY: number;
  33058. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33059. static readonly ALPHA_MAXIMIZED: number;
  33060. /** Defines that alpha blending to SRC + DEST */
  33061. static readonly ALPHA_ONEONE: number;
  33062. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33063. static readonly ALPHA_PREMULTIPLIED: number;
  33064. /**
  33065. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33066. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33067. */
  33068. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33069. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33070. static readonly ALPHA_INTERPOLATE: number;
  33071. /**
  33072. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33073. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33074. */
  33075. static readonly ALPHA_SCREENMODE: number;
  33076. /** Defines that the ressource is not delayed*/
  33077. static readonly DELAYLOADSTATE_NONE: number;
  33078. /** Defines that the ressource was successfully delay loaded */
  33079. static readonly DELAYLOADSTATE_LOADED: number;
  33080. /** Defines that the ressource is currently delay loading */
  33081. static readonly DELAYLOADSTATE_LOADING: number;
  33082. /** Defines that the ressource is delayed and has not started loading */
  33083. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33085. static readonly NEVER: number;
  33086. /** 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 */
  33087. static readonly ALWAYS: number;
  33088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33089. static readonly LESS: number;
  33090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33091. static readonly EQUAL: number;
  33092. /** 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 */
  33093. static readonly LEQUAL: number;
  33094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33095. static readonly GREATER: number;
  33096. /** 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 */
  33097. static readonly GEQUAL: number;
  33098. /** 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 */
  33099. static readonly NOTEQUAL: number;
  33100. /** Passed to stencilOperation to specify that stencil value must be kept */
  33101. static readonly KEEP: number;
  33102. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33103. static readonly REPLACE: number;
  33104. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33105. static readonly INCR: number;
  33106. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33107. static readonly DECR: number;
  33108. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33109. static readonly INVERT: number;
  33110. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33111. static readonly INCR_WRAP: number;
  33112. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33113. static readonly DECR_WRAP: number;
  33114. /** Texture is not repeating outside of 0..1 UVs */
  33115. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33116. /** Texture is repeating outside of 0..1 UVs */
  33117. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33118. /** Texture is repeating and mirrored */
  33119. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33120. /** ALPHA */
  33121. static readonly TEXTUREFORMAT_ALPHA: number;
  33122. /** LUMINANCE */
  33123. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33124. /** LUMINANCE_ALPHA */
  33125. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33126. /** RGB */
  33127. static readonly TEXTUREFORMAT_RGB: number;
  33128. /** RGBA */
  33129. static readonly TEXTUREFORMAT_RGBA: number;
  33130. /** RED */
  33131. static readonly TEXTUREFORMAT_RED: number;
  33132. /** RED (2nd reference) */
  33133. static readonly TEXTUREFORMAT_R: number;
  33134. /** RG */
  33135. static readonly TEXTUREFORMAT_RG: number;
  33136. /** RED_INTEGER */
  33137. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33138. /** RED_INTEGER (2nd reference) */
  33139. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33140. /** RG_INTEGER */
  33141. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33142. /** RGB_INTEGER */
  33143. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33144. /** RGBA_INTEGER */
  33145. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33146. /** UNSIGNED_BYTE */
  33147. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33148. /** UNSIGNED_BYTE (2nd reference) */
  33149. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33150. /** FLOAT */
  33151. static readonly TEXTURETYPE_FLOAT: number;
  33152. /** HALF_FLOAT */
  33153. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33154. /** BYTE */
  33155. static readonly TEXTURETYPE_BYTE: number;
  33156. /** SHORT */
  33157. static readonly TEXTURETYPE_SHORT: number;
  33158. /** UNSIGNED_SHORT */
  33159. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33160. /** INT */
  33161. static readonly TEXTURETYPE_INT: number;
  33162. /** UNSIGNED_INT */
  33163. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33164. /** UNSIGNED_SHORT_4_4_4_4 */
  33165. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33166. /** UNSIGNED_SHORT_5_5_5_1 */
  33167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33168. /** UNSIGNED_SHORT_5_6_5 */
  33169. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33170. /** UNSIGNED_INT_2_10_10_10_REV */
  33171. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33172. /** UNSIGNED_INT_24_8 */
  33173. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33174. /** UNSIGNED_INT_10F_11F_11F_REV */
  33175. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33176. /** UNSIGNED_INT_5_9_9_9_REV */
  33177. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33178. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33179. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33180. /** nearest is mag = nearest and min = nearest and mip = linear */
  33181. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33183. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33184. /** Trilinear is mag = linear and min = linear and mip = linear */
  33185. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33186. /** nearest is mag = nearest and min = nearest and mip = linear */
  33187. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33189. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33190. /** Trilinear is mag = linear and min = linear and mip = linear */
  33191. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33192. /** mag = nearest and min = nearest and mip = nearest */
  33193. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33194. /** mag = nearest and min = linear and mip = nearest */
  33195. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33196. /** mag = nearest and min = linear and mip = linear */
  33197. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33198. /** mag = nearest and min = linear and mip = none */
  33199. static readonly TEXTURE_NEAREST_LINEAR: number;
  33200. /** mag = nearest and min = nearest and mip = none */
  33201. static readonly TEXTURE_NEAREST_NEAREST: number;
  33202. /** mag = linear and min = nearest and mip = nearest */
  33203. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33204. /** mag = linear and min = nearest and mip = linear */
  33205. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33206. /** mag = linear and min = linear and mip = none */
  33207. static readonly TEXTURE_LINEAR_LINEAR: number;
  33208. /** mag = linear and min = nearest and mip = none */
  33209. static readonly TEXTURE_LINEAR_NEAREST: number;
  33210. /** Explicit coordinates mode */
  33211. static readonly TEXTURE_EXPLICIT_MODE: number;
  33212. /** Spherical coordinates mode */
  33213. static readonly TEXTURE_SPHERICAL_MODE: number;
  33214. /** Planar coordinates mode */
  33215. static readonly TEXTURE_PLANAR_MODE: number;
  33216. /** Cubic coordinates mode */
  33217. static readonly TEXTURE_CUBIC_MODE: number;
  33218. /** Projection coordinates mode */
  33219. static readonly TEXTURE_PROJECTION_MODE: number;
  33220. /** Skybox coordinates mode */
  33221. static readonly TEXTURE_SKYBOX_MODE: number;
  33222. /** Inverse Cubic coordinates mode */
  33223. static readonly TEXTURE_INVCUBIC_MODE: number;
  33224. /** Equirectangular coordinates mode */
  33225. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33226. /** Equirectangular Fixed coordinates mode */
  33227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33228. /** Equirectangular Fixed Mirrored coordinates mode */
  33229. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33230. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33231. static readonly SCALEMODE_FLOOR: number;
  33232. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33233. static readonly SCALEMODE_NEAREST: number;
  33234. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33235. static readonly SCALEMODE_CEILING: number;
  33236. /**
  33237. * Returns the current npm package of the sdk
  33238. */
  33239. static get NpmPackage(): string;
  33240. /**
  33241. * Returns the current version of the framework
  33242. */
  33243. static get Version(): string;
  33244. /** Gets the list of created engines */
  33245. static get Instances(): Engine[];
  33246. /**
  33247. * Gets the latest created engine
  33248. */
  33249. static get LastCreatedEngine(): Nullable<Engine>;
  33250. /**
  33251. * Gets the latest created scene
  33252. */
  33253. static get LastCreatedScene(): Nullable<Scene>;
  33254. /**
  33255. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33256. * @param flag defines which part of the materials must be marked as dirty
  33257. * @param predicate defines a predicate used to filter which materials should be affected
  33258. */
  33259. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33260. /**
  33261. * Method called to create the default loading screen.
  33262. * This can be overriden in your own app.
  33263. * @param canvas The rendering canvas element
  33264. * @returns The loading screen
  33265. */
  33266. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33267. /**
  33268. * Method called to create the default rescale post process on each engine.
  33269. */
  33270. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33271. /**
  33272. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33273. **/
  33274. enableOfflineSupport: boolean;
  33275. /**
  33276. * 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)
  33277. **/
  33278. disableManifestCheck: boolean;
  33279. /**
  33280. * Gets the list of created scenes
  33281. */
  33282. scenes: Scene[];
  33283. /**
  33284. * Event raised when a new scene is created
  33285. */
  33286. onNewSceneAddedObservable: Observable<Scene>;
  33287. /**
  33288. * Gets the list of created postprocesses
  33289. */
  33290. postProcesses: PostProcess[];
  33291. /**
  33292. * Gets a boolean indicating if the pointer is currently locked
  33293. */
  33294. isPointerLock: boolean;
  33295. /**
  33296. * Observable event triggered each time the rendering canvas is resized
  33297. */
  33298. onResizeObservable: Observable<Engine>;
  33299. /**
  33300. * Observable event triggered each time the canvas loses focus
  33301. */
  33302. onCanvasBlurObservable: Observable<Engine>;
  33303. /**
  33304. * Observable event triggered each time the canvas gains focus
  33305. */
  33306. onCanvasFocusObservable: Observable<Engine>;
  33307. /**
  33308. * Observable event triggered each time the canvas receives pointerout event
  33309. */
  33310. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33311. /**
  33312. * Observable raised when the engine begins a new frame
  33313. */
  33314. onBeginFrameObservable: Observable<Engine>;
  33315. /**
  33316. * If set, will be used to request the next animation frame for the render loop
  33317. */
  33318. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33319. /**
  33320. * Observable raised when the engine ends the current frame
  33321. */
  33322. onEndFrameObservable: Observable<Engine>;
  33323. /**
  33324. * Observable raised when the engine is about to compile a shader
  33325. */
  33326. onBeforeShaderCompilationObservable: Observable<Engine>;
  33327. /**
  33328. * Observable raised when the engine has jsut compiled a shader
  33329. */
  33330. onAfterShaderCompilationObservable: Observable<Engine>;
  33331. /**
  33332. * Gets the audio engine
  33333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33334. * @ignorenaming
  33335. */
  33336. static audioEngine: IAudioEngine;
  33337. /**
  33338. * Default AudioEngine factory responsible of creating the Audio Engine.
  33339. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33340. */
  33341. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33342. /**
  33343. * Default offline support factory responsible of creating a tool used to store data locally.
  33344. * By default, this will create a Database object if the workload has been embedded.
  33345. */
  33346. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33347. private _loadingScreen;
  33348. private _pointerLockRequested;
  33349. private _dummyFramebuffer;
  33350. private _rescalePostProcess;
  33351. private _deterministicLockstep;
  33352. private _lockstepMaxSteps;
  33353. private _timeStep;
  33354. protected get _supportsHardwareTextureRescaling(): boolean;
  33355. private _fps;
  33356. private _deltaTime;
  33357. /** @hidden */
  33358. _drawCalls: PerfCounter;
  33359. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33360. canvasTabIndex: number;
  33361. /**
  33362. * Turn this value on if you want to pause FPS computation when in background
  33363. */
  33364. disablePerformanceMonitorInBackground: boolean;
  33365. private _performanceMonitor;
  33366. /**
  33367. * Gets the performance monitor attached to this engine
  33368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33369. */
  33370. get performanceMonitor(): PerformanceMonitor;
  33371. private _onFocus;
  33372. private _onBlur;
  33373. private _onCanvasPointerOut;
  33374. private _onCanvasBlur;
  33375. private _onCanvasFocus;
  33376. private _onFullscreenChange;
  33377. private _onPointerLockChange;
  33378. /**
  33379. * Gets the HTML element used to attach event listeners
  33380. * @returns a HTML element
  33381. */
  33382. getInputElement(): Nullable<HTMLElement>;
  33383. /**
  33384. * Creates a new engine
  33385. * @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
  33386. * @param antialias defines enable antialiasing (default: false)
  33387. * @param options defines further options to be sent to the getContext() function
  33388. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33389. */
  33390. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33391. /**
  33392. * Gets current aspect ratio
  33393. * @param viewportOwner defines the camera to use to get the aspect ratio
  33394. * @param useScreen defines if screen size must be used (or the current render target if any)
  33395. * @returns a number defining the aspect ratio
  33396. */
  33397. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33398. /**
  33399. * Gets current screen aspect ratio
  33400. * @returns a number defining the aspect ratio
  33401. */
  33402. getScreenAspectRatio(): number;
  33403. /**
  33404. * Gets the client rect of the HTML canvas attached with the current webGL context
  33405. * @returns a client rectanglee
  33406. */
  33407. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33408. /**
  33409. * Gets the client rect of the HTML element used for events
  33410. * @returns a client rectanglee
  33411. */
  33412. getInputElementClientRect(): Nullable<ClientRect>;
  33413. /**
  33414. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33416. * @returns true if engine is in deterministic lock step mode
  33417. */
  33418. isDeterministicLockStep(): boolean;
  33419. /**
  33420. * Gets the max steps when engine is running in deterministic lock step
  33421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33422. * @returns the max steps
  33423. */
  33424. getLockstepMaxSteps(): number;
  33425. /**
  33426. * Returns the time in ms between steps when using deterministic lock step.
  33427. * @returns time step in (ms)
  33428. */
  33429. getTimeStep(): number;
  33430. /**
  33431. * Force the mipmap generation for the given render target texture
  33432. * @param texture defines the render target texture to use
  33433. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33434. */
  33435. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33436. /** States */
  33437. /**
  33438. * Set various states to the webGL context
  33439. * @param culling defines backface culling state
  33440. * @param zOffset defines the value to apply to zOffset (0 by default)
  33441. * @param force defines if states must be applied even if cache is up to date
  33442. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33443. */
  33444. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33445. /**
  33446. * Set the z offset to apply to current rendering
  33447. * @param value defines the offset to apply
  33448. */
  33449. setZOffset(value: number): void;
  33450. /**
  33451. * Gets the current value of the zOffset
  33452. * @returns the current zOffset state
  33453. */
  33454. getZOffset(): number;
  33455. /**
  33456. * Enable or disable depth buffering
  33457. * @param enable defines the state to set
  33458. */
  33459. setDepthBuffer(enable: boolean): void;
  33460. /**
  33461. * Gets a boolean indicating if depth writing is enabled
  33462. * @returns the current depth writing state
  33463. */
  33464. getDepthWrite(): boolean;
  33465. /**
  33466. * Enable or disable depth writing
  33467. * @param enable defines the state to set
  33468. */
  33469. setDepthWrite(enable: boolean): void;
  33470. /**
  33471. * Gets a boolean indicating if stencil buffer is enabled
  33472. * @returns the current stencil buffer state
  33473. */
  33474. getStencilBuffer(): boolean;
  33475. /**
  33476. * Enable or disable the stencil buffer
  33477. * @param enable defines if the stencil buffer must be enabled or disabled
  33478. */
  33479. setStencilBuffer(enable: boolean): void;
  33480. /**
  33481. * Gets the current stencil mask
  33482. * @returns a number defining the new stencil mask to use
  33483. */
  33484. getStencilMask(): number;
  33485. /**
  33486. * Sets the current stencil mask
  33487. * @param mask defines the new stencil mask to use
  33488. */
  33489. setStencilMask(mask: number): void;
  33490. /**
  33491. * Gets the current stencil function
  33492. * @returns a number defining the stencil function to use
  33493. */
  33494. getStencilFunction(): number;
  33495. /**
  33496. * Gets the current stencil reference value
  33497. * @returns a number defining the stencil reference value to use
  33498. */
  33499. getStencilFunctionReference(): number;
  33500. /**
  33501. * Gets the current stencil mask
  33502. * @returns a number defining the stencil mask to use
  33503. */
  33504. getStencilFunctionMask(): number;
  33505. /**
  33506. * Sets the current stencil function
  33507. * @param stencilFunc defines the new stencil function to use
  33508. */
  33509. setStencilFunction(stencilFunc: number): void;
  33510. /**
  33511. * Sets the current stencil reference
  33512. * @param reference defines the new stencil reference to use
  33513. */
  33514. setStencilFunctionReference(reference: number): void;
  33515. /**
  33516. * Sets the current stencil mask
  33517. * @param mask defines the new stencil mask to use
  33518. */
  33519. setStencilFunctionMask(mask: number): void;
  33520. /**
  33521. * Gets the current stencil operation when stencil fails
  33522. * @returns a number defining stencil operation to use when stencil fails
  33523. */
  33524. getStencilOperationFail(): number;
  33525. /**
  33526. * Gets the current stencil operation when depth fails
  33527. * @returns a number defining stencil operation to use when depth fails
  33528. */
  33529. getStencilOperationDepthFail(): number;
  33530. /**
  33531. * Gets the current stencil operation when stencil passes
  33532. * @returns a number defining stencil operation to use when stencil passes
  33533. */
  33534. getStencilOperationPass(): number;
  33535. /**
  33536. * Sets the stencil operation to use when stencil fails
  33537. * @param operation defines the stencil operation to use when stencil fails
  33538. */
  33539. setStencilOperationFail(operation: number): void;
  33540. /**
  33541. * Sets the stencil operation to use when depth fails
  33542. * @param operation defines the stencil operation to use when depth fails
  33543. */
  33544. setStencilOperationDepthFail(operation: number): void;
  33545. /**
  33546. * Sets the stencil operation to use when stencil passes
  33547. * @param operation defines the stencil operation to use when stencil passes
  33548. */
  33549. setStencilOperationPass(operation: number): void;
  33550. /**
  33551. * Sets a boolean indicating if the dithering state is enabled or disabled
  33552. * @param value defines the dithering state
  33553. */
  33554. setDitheringState(value: boolean): void;
  33555. /**
  33556. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33557. * @param value defines the rasterizer state
  33558. */
  33559. setRasterizerState(value: boolean): void;
  33560. /**
  33561. * Gets the current depth function
  33562. * @returns a number defining the depth function
  33563. */
  33564. getDepthFunction(): Nullable<number>;
  33565. /**
  33566. * Sets the current depth function
  33567. * @param depthFunc defines the function to use
  33568. */
  33569. setDepthFunction(depthFunc: number): void;
  33570. /**
  33571. * Sets the current depth function to GREATER
  33572. */
  33573. setDepthFunctionToGreater(): void;
  33574. /**
  33575. * Sets the current depth function to GEQUAL
  33576. */
  33577. setDepthFunctionToGreaterOrEqual(): void;
  33578. /**
  33579. * Sets the current depth function to LESS
  33580. */
  33581. setDepthFunctionToLess(): void;
  33582. /**
  33583. * Sets the current depth function to LEQUAL
  33584. */
  33585. setDepthFunctionToLessOrEqual(): void;
  33586. private _cachedStencilBuffer;
  33587. private _cachedStencilFunction;
  33588. private _cachedStencilMask;
  33589. private _cachedStencilOperationPass;
  33590. private _cachedStencilOperationFail;
  33591. private _cachedStencilOperationDepthFail;
  33592. private _cachedStencilReference;
  33593. /**
  33594. * Caches the the state of the stencil buffer
  33595. */
  33596. cacheStencilState(): void;
  33597. /**
  33598. * Restores the state of the stencil buffer
  33599. */
  33600. restoreStencilState(): void;
  33601. /**
  33602. * Directly set the WebGL Viewport
  33603. * @param x defines the x coordinate of the viewport (in screen space)
  33604. * @param y defines the y coordinate of the viewport (in screen space)
  33605. * @param width defines the width of the viewport (in screen space)
  33606. * @param height defines the height of the viewport (in screen space)
  33607. * @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
  33608. */
  33609. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33610. /**
  33611. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33612. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33613. * @param y defines the y-coordinate of the corner of the clear rectangle
  33614. * @param width defines the width of the clear rectangle
  33615. * @param height defines the height of the clear rectangle
  33616. * @param clearColor defines the clear color
  33617. */
  33618. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33619. /**
  33620. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33621. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33622. * @param y defines the y-coordinate of the corner of the clear rectangle
  33623. * @param width defines the width of the clear rectangle
  33624. * @param height defines the height of the clear rectangle
  33625. */
  33626. enableScissor(x: number, y: number, width: number, height: number): void;
  33627. /**
  33628. * Disable previously set scissor test rectangle
  33629. */
  33630. disableScissor(): void;
  33631. protected _reportDrawCall(): void;
  33632. /**
  33633. * Initializes a webVR display and starts listening to display change events
  33634. * The onVRDisplayChangedObservable will be notified upon these changes
  33635. * @returns The onVRDisplayChangedObservable
  33636. */
  33637. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33638. /** @hidden */
  33639. _prepareVRComponent(): void;
  33640. /** @hidden */
  33641. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33642. /** @hidden */
  33643. _submitVRFrame(): void;
  33644. /**
  33645. * Call this function to leave webVR mode
  33646. * Will do nothing if webVR is not supported or if there is no webVR device
  33647. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33648. */
  33649. disableVR(): void;
  33650. /**
  33651. * Gets a boolean indicating that the system is in VR mode and is presenting
  33652. * @returns true if VR mode is engaged
  33653. */
  33654. isVRPresenting(): boolean;
  33655. /** @hidden */
  33656. _requestVRFrame(): void;
  33657. /** @hidden */
  33658. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33659. /**
  33660. * Gets the source code of the vertex shader associated with a specific webGL program
  33661. * @param program defines the program to use
  33662. * @returns a string containing the source code of the vertex shader associated with the program
  33663. */
  33664. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33665. /**
  33666. * Gets the source code of the fragment shader associated with a specific webGL program
  33667. * @param program defines the program to use
  33668. * @returns a string containing the source code of the fragment shader associated with the program
  33669. */
  33670. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33671. /**
  33672. * Sets a depth stencil texture from a render target to the according uniform.
  33673. * @param channel The texture channel
  33674. * @param uniform The uniform to set
  33675. * @param texture The render target texture containing the depth stencil texture to apply
  33676. */
  33677. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33678. /**
  33679. * Sets a texture to the webGL context from a postprocess
  33680. * @param channel defines the channel to use
  33681. * @param postProcess defines the source postprocess
  33682. */
  33683. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33684. /**
  33685. * Binds the output of the passed in post process to the texture channel specified
  33686. * @param channel The channel the texture should be bound to
  33687. * @param postProcess The post process which's output should be bound
  33688. */
  33689. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33690. /** @hidden */
  33691. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33692. protected _rebuildBuffers(): void;
  33693. /** @hidden */
  33694. _renderFrame(): void;
  33695. _renderLoop(): void;
  33696. /** @hidden */
  33697. _renderViews(): boolean;
  33698. /**
  33699. * Toggle full screen mode
  33700. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33701. */
  33702. switchFullscreen(requestPointerLock: boolean): void;
  33703. /**
  33704. * Enters full screen mode
  33705. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33706. */
  33707. enterFullscreen(requestPointerLock: boolean): void;
  33708. /**
  33709. * Exits full screen mode
  33710. */
  33711. exitFullscreen(): void;
  33712. /**
  33713. * Enters Pointerlock mode
  33714. */
  33715. enterPointerlock(): void;
  33716. /**
  33717. * Exits Pointerlock mode
  33718. */
  33719. exitPointerlock(): void;
  33720. /**
  33721. * Begin a new frame
  33722. */
  33723. beginFrame(): void;
  33724. /**
  33725. * Enf the current frame
  33726. */
  33727. endFrame(): void;
  33728. resize(): void;
  33729. /**
  33730. * Set the compressed texture format to use, based on the formats you have, and the formats
  33731. * supported by the hardware / browser.
  33732. *
  33733. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33734. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33735. * to API arguments needed to compressed textures. This puts the burden on the container
  33736. * generator to house the arcane code for determining these for current & future formats.
  33737. *
  33738. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33739. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33740. *
  33741. * Note: The result of this call is not taken into account when a texture is base64.
  33742. *
  33743. * @param formatsAvailable defines the list of those format families you have created
  33744. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33745. *
  33746. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33747. * @returns The extension selected.
  33748. */
  33749. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33750. /**
  33751. * Set the compressed texture extensions or file names to skip.
  33752. *
  33753. * @param skippedFiles defines the list of those texture files you want to skip
  33754. * Example: [".dds", ".env", "myfile.png"]
  33755. */
  33756. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33757. /**
  33758. * Force a specific size of the canvas
  33759. * @param width defines the new canvas' width
  33760. * @param height defines the new canvas' height
  33761. */
  33762. setSize(width: number, height: number): void;
  33763. /**
  33764. * Updates a dynamic vertex buffer.
  33765. * @param vertexBuffer the vertex buffer to update
  33766. * @param data the data used to update the vertex buffer
  33767. * @param byteOffset the byte offset of the data
  33768. * @param byteLength the byte length of the data
  33769. */
  33770. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33771. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33772. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33773. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33774. _releaseTexture(texture: InternalTexture): void;
  33775. /**
  33776. * @hidden
  33777. * Rescales a texture
  33778. * @param source input texutre
  33779. * @param destination destination texture
  33780. * @param scene scene to use to render the resize
  33781. * @param internalFormat format to use when resizing
  33782. * @param onComplete callback to be called when resize has completed
  33783. */
  33784. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33785. /**
  33786. * Gets the current framerate
  33787. * @returns a number representing the framerate
  33788. */
  33789. getFps(): number;
  33790. /**
  33791. * Gets the time spent between current and previous frame
  33792. * @returns a number representing the delta time in ms
  33793. */
  33794. getDeltaTime(): number;
  33795. private _measureFps;
  33796. /** @hidden */
  33797. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33798. /**
  33799. * Update a dynamic index buffer
  33800. * @param indexBuffer defines the target index buffer
  33801. * @param indices defines the data to update
  33802. * @param offset defines the offset in the target index buffer where update should start
  33803. */
  33804. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33805. /**
  33806. * Updates the sample count of a render target texture
  33807. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33808. * @param texture defines the texture to update
  33809. * @param samples defines the sample count to set
  33810. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33811. */
  33812. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33813. /**
  33814. * Updates a depth texture Comparison Mode and Function.
  33815. * If the comparison Function is equal to 0, the mode will be set to none.
  33816. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33817. * @param texture The texture to set the comparison function for
  33818. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33819. */
  33820. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33821. /**
  33822. * Creates a webGL buffer to use with instanciation
  33823. * @param capacity defines the size of the buffer
  33824. * @returns the webGL buffer
  33825. */
  33826. createInstancesBuffer(capacity: number): DataBuffer;
  33827. /**
  33828. * Delete a webGL buffer used with instanciation
  33829. * @param buffer defines the webGL buffer to delete
  33830. */
  33831. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33832. /** @hidden */
  33833. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33834. dispose(): void;
  33835. private _disableTouchAction;
  33836. /**
  33837. * Display the loading screen
  33838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33839. */
  33840. displayLoadingUI(): void;
  33841. /**
  33842. * Hide the loading screen
  33843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33844. */
  33845. hideLoadingUI(): void;
  33846. /**
  33847. * Gets the current loading screen object
  33848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33849. */
  33850. get loadingScreen(): ILoadingScreen;
  33851. /**
  33852. * Sets the current loading screen object
  33853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33854. */
  33855. set loadingScreen(loadingScreen: ILoadingScreen);
  33856. /**
  33857. * Sets the current loading screen text
  33858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33859. */
  33860. set loadingUIText(text: string);
  33861. /**
  33862. * Sets the current loading screen background color
  33863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33864. */
  33865. set loadingUIBackgroundColor(color: string);
  33866. /** Pointerlock and fullscreen */
  33867. /**
  33868. * Ask the browser to promote the current element to pointerlock mode
  33869. * @param element defines the DOM element to promote
  33870. */
  33871. static _RequestPointerlock(element: HTMLElement): void;
  33872. /**
  33873. * Asks the browser to exit pointerlock mode
  33874. */
  33875. static _ExitPointerlock(): void;
  33876. /**
  33877. * Ask the browser to promote the current element to fullscreen rendering mode
  33878. * @param element defines the DOM element to promote
  33879. */
  33880. static _RequestFullscreen(element: HTMLElement): void;
  33881. /**
  33882. * Asks the browser to exit fullscreen mode
  33883. */
  33884. static _ExitFullscreen(): void;
  33885. }
  33886. }
  33887. declare module BABYLON {
  33888. /**
  33889. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33890. * during the life time of the application.
  33891. */
  33892. export class EngineStore {
  33893. /** Gets the list of created engines */
  33894. static Instances: Engine[];
  33895. /** @hidden */
  33896. static _LastCreatedScene: Nullable<Scene>;
  33897. /**
  33898. * Gets the latest created engine
  33899. */
  33900. static get LastCreatedEngine(): Nullable<Engine>;
  33901. /**
  33902. * Gets the latest created scene
  33903. */
  33904. static get LastCreatedScene(): Nullable<Scene>;
  33905. /**
  33906. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33907. * @ignorenaming
  33908. */
  33909. static UseFallbackTexture: boolean;
  33910. /**
  33911. * Texture content used if a texture cannot loaded
  33912. * @ignorenaming
  33913. */
  33914. static FallbackTexture: string;
  33915. }
  33916. }
  33917. declare module BABYLON {
  33918. /**
  33919. * Helper class that provides a small promise polyfill
  33920. */
  33921. export class PromisePolyfill {
  33922. /**
  33923. * Static function used to check if the polyfill is required
  33924. * If this is the case then the function will inject the polyfill to window.Promise
  33925. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33926. */
  33927. static Apply(force?: boolean): void;
  33928. }
  33929. }
  33930. declare module BABYLON {
  33931. /**
  33932. * Interface for screenshot methods with describe argument called `size` as object with options
  33933. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33934. */
  33935. export interface IScreenshotSize {
  33936. /**
  33937. * number in pixels for canvas height
  33938. */
  33939. height?: number;
  33940. /**
  33941. * multiplier allowing render at a higher or lower resolution
  33942. * If value is defined then height and width will be ignored and taken from camera
  33943. */
  33944. precision?: number;
  33945. /**
  33946. * number in pixels for canvas width
  33947. */
  33948. width?: number;
  33949. }
  33950. }
  33951. declare module BABYLON {
  33952. interface IColor4Like {
  33953. r: float;
  33954. g: float;
  33955. b: float;
  33956. a: float;
  33957. }
  33958. /**
  33959. * Class containing a set of static utilities functions
  33960. */
  33961. export class Tools {
  33962. /**
  33963. * Gets or sets the base URL to use to load assets
  33964. */
  33965. static get BaseUrl(): string;
  33966. static set BaseUrl(value: string);
  33967. /**
  33968. * Enable/Disable Custom HTTP Request Headers globally.
  33969. * default = false
  33970. * @see CustomRequestHeaders
  33971. */
  33972. static UseCustomRequestHeaders: boolean;
  33973. /**
  33974. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33975. * i.e. when loading files, where the server/service expects an Authorization header
  33976. */
  33977. static CustomRequestHeaders: {
  33978. [key: string]: string;
  33979. };
  33980. /**
  33981. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33982. */
  33983. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33984. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33985. /**
  33986. * Default behaviour for cors in the application.
  33987. * It can be a string if the expected behavior is identical in the entire app.
  33988. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33989. */
  33990. static CorsBehavior: string | ((url: string | string[]) => string);
  33991. /**
  33992. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33993. * @ignorenaming
  33994. */
  33995. static get UseFallbackTexture(): boolean;
  33996. static set UseFallbackTexture(value: boolean);
  33997. /**
  33998. * Use this object to register external classes like custom textures or material
  33999. * to allow the laoders to instantiate them
  34000. */
  34001. static get RegisteredExternalClasses(): {
  34002. [key: string]: Object;
  34003. };
  34004. static set RegisteredExternalClasses(classes: {
  34005. [key: string]: Object;
  34006. });
  34007. /**
  34008. * Texture content used if a texture cannot loaded
  34009. * @ignorenaming
  34010. */
  34011. static get fallbackTexture(): string;
  34012. static set fallbackTexture(value: string);
  34013. /**
  34014. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34015. * @param u defines the coordinate on X axis
  34016. * @param v defines the coordinate on Y axis
  34017. * @param width defines the width of the source data
  34018. * @param height defines the height of the source data
  34019. * @param pixels defines the source byte array
  34020. * @param color defines the output color
  34021. */
  34022. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34023. /**
  34024. * Interpolates between a and b via alpha
  34025. * @param a The lower value (returned when alpha = 0)
  34026. * @param b The upper value (returned when alpha = 1)
  34027. * @param alpha The interpolation-factor
  34028. * @return The mixed value
  34029. */
  34030. static Mix(a: number, b: number, alpha: number): number;
  34031. /**
  34032. * Tries to instantiate a new object from a given class name
  34033. * @param className defines the class name to instantiate
  34034. * @returns the new object or null if the system was not able to do the instantiation
  34035. */
  34036. static Instantiate(className: string): any;
  34037. /**
  34038. * Provides a slice function that will work even on IE
  34039. * @param data defines the array to slice
  34040. * @param start defines the start of the data (optional)
  34041. * @param end defines the end of the data (optional)
  34042. * @returns the new sliced array
  34043. */
  34044. static Slice<T>(data: T, start?: number, end?: number): T;
  34045. /**
  34046. * Polyfill for setImmediate
  34047. * @param action defines the action to execute after the current execution block
  34048. */
  34049. static SetImmediate(action: () => void): void;
  34050. /**
  34051. * Function indicating if a number is an exponent of 2
  34052. * @param value defines the value to test
  34053. * @returns true if the value is an exponent of 2
  34054. */
  34055. static IsExponentOfTwo(value: number): boolean;
  34056. private static _tmpFloatArray;
  34057. /**
  34058. * Returns the nearest 32-bit single precision float representation of a Number
  34059. * @param value A Number. If the parameter is of a different type, it will get converted
  34060. * to a number or to NaN if it cannot be converted
  34061. * @returns number
  34062. */
  34063. static FloatRound(value: number): number;
  34064. /**
  34065. * Extracts the filename from a path
  34066. * @param path defines the path to use
  34067. * @returns the filename
  34068. */
  34069. static GetFilename(path: string): string;
  34070. /**
  34071. * Extracts the "folder" part of a path (everything before the filename).
  34072. * @param uri The URI to extract the info from
  34073. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34074. * @returns The "folder" part of the path
  34075. */
  34076. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34077. /**
  34078. * Extracts text content from a DOM element hierarchy
  34079. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34080. */
  34081. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34082. /**
  34083. * Convert an angle in radians to degrees
  34084. * @param angle defines the angle to convert
  34085. * @returns the angle in degrees
  34086. */
  34087. static ToDegrees(angle: number): number;
  34088. /**
  34089. * Convert an angle in degrees to radians
  34090. * @param angle defines the angle to convert
  34091. * @returns the angle in radians
  34092. */
  34093. static ToRadians(angle: number): number;
  34094. /**
  34095. * Returns an array if obj is not an array
  34096. * @param obj defines the object to evaluate as an array
  34097. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34098. * @returns either obj directly if obj is an array or a new array containing obj
  34099. */
  34100. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34101. /**
  34102. * Gets the pointer prefix to use
  34103. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34104. */
  34105. static GetPointerPrefix(): string;
  34106. /**
  34107. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34108. * @param url define the url we are trying
  34109. * @param element define the dom element where to configure the cors policy
  34110. */
  34111. static SetCorsBehavior(url: string | string[], element: {
  34112. crossOrigin: string | null;
  34113. }): void;
  34114. /**
  34115. * Removes unwanted characters from an url
  34116. * @param url defines the url to clean
  34117. * @returns the cleaned url
  34118. */
  34119. static CleanUrl(url: string): string;
  34120. /**
  34121. * Gets or sets a function used to pre-process url before using them to load assets
  34122. */
  34123. static get PreprocessUrl(): (url: string) => string;
  34124. static set PreprocessUrl(processor: (url: string) => string);
  34125. /**
  34126. * Loads an image as an HTMLImageElement.
  34127. * @param input url string, ArrayBuffer, or Blob to load
  34128. * @param onLoad callback called when the image successfully loads
  34129. * @param onError callback called when the image fails to load
  34130. * @param offlineProvider offline provider for caching
  34131. * @param mimeType optional mime type
  34132. * @returns the HTMLImageElement of the loaded image
  34133. */
  34134. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34135. /**
  34136. * Loads a file from a url
  34137. * @param url url string, ArrayBuffer, or Blob to load
  34138. * @param onSuccess callback called when the file successfully loads
  34139. * @param onProgress callback called while file is loading (if the server supports this mode)
  34140. * @param offlineProvider defines the offline provider for caching
  34141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34142. * @param onError callback called when the file fails to load
  34143. * @returns a file request object
  34144. */
  34145. 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;
  34146. /**
  34147. * Loads a file from a url
  34148. * @param url the file url to load
  34149. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34150. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34151. */
  34152. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34153. /**
  34154. * Load a script (identified by an url). When the url returns, the
  34155. * content of this file is added into a new script element, attached to the DOM (body element)
  34156. * @param scriptUrl defines the url of the script to laod
  34157. * @param onSuccess defines the callback called when the script is loaded
  34158. * @param onError defines the callback to call if an error occurs
  34159. * @param scriptId defines the id of the script element
  34160. */
  34161. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34162. /**
  34163. * Load an asynchronous script (identified by an url). When the url returns, the
  34164. * content of this file is added into a new script element, attached to the DOM (body element)
  34165. * @param scriptUrl defines the url of the script to laod
  34166. * @param scriptId defines the id of the script element
  34167. * @returns a promise request object
  34168. */
  34169. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34170. /**
  34171. * Loads a file from a blob
  34172. * @param fileToLoad defines the blob to use
  34173. * @param callback defines the callback to call when data is loaded
  34174. * @param progressCallback defines the callback to call during loading process
  34175. * @returns a file request object
  34176. */
  34177. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34178. /**
  34179. * Reads a file from a File object
  34180. * @param file defines the file to load
  34181. * @param onSuccess defines the callback to call when data is loaded
  34182. * @param onProgress defines the callback to call during loading process
  34183. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34184. * @param onError defines the callback to call when an error occurs
  34185. * @returns a file request object
  34186. */
  34187. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34188. /**
  34189. * Creates a data url from a given string content
  34190. * @param content defines the content to convert
  34191. * @returns the new data url link
  34192. */
  34193. static FileAsURL(content: string): string;
  34194. /**
  34195. * Format the given number to a specific decimal format
  34196. * @param value defines the number to format
  34197. * @param decimals defines the number of decimals to use
  34198. * @returns the formatted string
  34199. */
  34200. static Format(value: number, decimals?: number): string;
  34201. /**
  34202. * Tries to copy an object by duplicating every property
  34203. * @param source defines the source object
  34204. * @param destination defines the target object
  34205. * @param doNotCopyList defines a list of properties to avoid
  34206. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34207. */
  34208. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34209. /**
  34210. * Gets a boolean indicating if the given object has no own property
  34211. * @param obj defines the object to test
  34212. * @returns true if object has no own property
  34213. */
  34214. static IsEmpty(obj: any): boolean;
  34215. /**
  34216. * Function used to register events at window level
  34217. * @param windowElement defines the Window object to use
  34218. * @param events defines the events to register
  34219. */
  34220. static RegisterTopRootEvents(windowElement: Window, events: {
  34221. name: string;
  34222. handler: Nullable<(e: FocusEvent) => any>;
  34223. }[]): void;
  34224. /**
  34225. * Function used to unregister events from window level
  34226. * @param windowElement defines the Window object to use
  34227. * @param events defines the events to unregister
  34228. */
  34229. static UnregisterTopRootEvents(windowElement: Window, events: {
  34230. name: string;
  34231. handler: Nullable<(e: FocusEvent) => any>;
  34232. }[]): void;
  34233. /**
  34234. * @ignore
  34235. */
  34236. static _ScreenshotCanvas: HTMLCanvasElement;
  34237. /**
  34238. * Dumps the current bound framebuffer
  34239. * @param width defines the rendering width
  34240. * @param height defines the rendering height
  34241. * @param engine defines the hosting engine
  34242. * @param successCallback defines the callback triggered once the data are available
  34243. * @param mimeType defines the mime type of the result
  34244. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34245. */
  34246. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34247. /**
  34248. * Converts the canvas data to blob.
  34249. * This acts as a polyfill for browsers not supporting the to blob function.
  34250. * @param canvas Defines the canvas to extract the data from
  34251. * @param successCallback Defines the callback triggered once the data are available
  34252. * @param mimeType Defines the mime type of the result
  34253. */
  34254. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34255. /**
  34256. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34257. * @param successCallback defines the callback triggered once the data are available
  34258. * @param mimeType defines the mime type of the result
  34259. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34260. */
  34261. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34262. /**
  34263. * Downloads a blob in the browser
  34264. * @param blob defines the blob to download
  34265. * @param fileName defines the name of the downloaded file
  34266. */
  34267. static Download(blob: Blob, fileName: string): void;
  34268. /**
  34269. * Captures a screenshot of the current rendering
  34270. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34271. * @param engine defines the rendering engine
  34272. * @param camera defines the source camera
  34273. * @param size This parameter can be set to a single number or to an object with the
  34274. * following (optional) properties: precision, width, height. If a single number is passed,
  34275. * it will be used for both width and height. If an object is passed, the screenshot size
  34276. * will be derived from the parameters. The precision property is a multiplier allowing
  34277. * rendering at a higher or lower resolution
  34278. * @param successCallback defines the callback receives a single parameter which contains the
  34279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34280. * src parameter of an <img> to display it
  34281. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34282. * Check your browser for supported MIME types
  34283. */
  34284. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34285. /**
  34286. * Captures a screenshot of the current rendering
  34287. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34288. * @param engine defines the rendering engine
  34289. * @param camera defines the source camera
  34290. * @param size This parameter can be set to a single number or to an object with the
  34291. * following (optional) properties: precision, width, height. If a single number is passed,
  34292. * it will be used for both width and height. If an object is passed, the screenshot size
  34293. * will be derived from the parameters. The precision property is a multiplier allowing
  34294. * rendering at a higher or lower resolution
  34295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34296. * Check your browser for supported MIME types
  34297. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34298. * to the src parameter of an <img> to display it
  34299. */
  34300. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34301. /**
  34302. * Generates an image screenshot from the specified camera.
  34303. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34304. * @param engine The engine to use for rendering
  34305. * @param camera The camera to use for rendering
  34306. * @param size This parameter can be set to a single number or to an object with the
  34307. * following (optional) properties: precision, width, height. If a single number is passed,
  34308. * it will be used for both width and height. If an object is passed, the screenshot size
  34309. * will be derived from the parameters. The precision property is a multiplier allowing
  34310. * rendering at a higher or lower resolution
  34311. * @param successCallback The callback receives a single parameter which contains the
  34312. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34313. * src parameter of an <img> to display it
  34314. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34315. * Check your browser for supported MIME types
  34316. * @param samples Texture samples (default: 1)
  34317. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34318. * @param fileName A name for for the downloaded file.
  34319. */
  34320. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34321. /**
  34322. * Generates an image screenshot from the specified camera.
  34323. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34324. * @param engine The engine to use for rendering
  34325. * @param camera The camera to use for rendering
  34326. * @param size This parameter can be set to a single number or to an object with the
  34327. * following (optional) properties: precision, width, height. If a single number is passed,
  34328. * it will be used for both width and height. If an object is passed, the screenshot size
  34329. * will be derived from the parameters. The precision property is a multiplier allowing
  34330. * rendering at a higher or lower resolution
  34331. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34332. * Check your browser for supported MIME types
  34333. * @param samples Texture samples (default: 1)
  34334. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34335. * @param fileName A name for for the downloaded file.
  34336. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34337. * to the src parameter of an <img> to display it
  34338. */
  34339. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34340. /**
  34341. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34342. * Be aware Math.random() could cause collisions, but:
  34343. * "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"
  34344. * @returns a pseudo random id
  34345. */
  34346. static RandomId(): string;
  34347. /**
  34348. * Test if the given uri is a base64 string
  34349. * @param uri The uri to test
  34350. * @return True if the uri is a base64 string or false otherwise
  34351. */
  34352. static IsBase64(uri: string): boolean;
  34353. /**
  34354. * Decode the given base64 uri.
  34355. * @param uri The uri to decode
  34356. * @return The decoded base64 data.
  34357. */
  34358. static DecodeBase64(uri: string): ArrayBuffer;
  34359. /**
  34360. * Gets the absolute url.
  34361. * @param url the input url
  34362. * @return the absolute url
  34363. */
  34364. static GetAbsoluteUrl(url: string): string;
  34365. /**
  34366. * No log
  34367. */
  34368. static readonly NoneLogLevel: number;
  34369. /**
  34370. * Only message logs
  34371. */
  34372. static readonly MessageLogLevel: number;
  34373. /**
  34374. * Only warning logs
  34375. */
  34376. static readonly WarningLogLevel: number;
  34377. /**
  34378. * Only error logs
  34379. */
  34380. static readonly ErrorLogLevel: number;
  34381. /**
  34382. * All logs
  34383. */
  34384. static readonly AllLogLevel: number;
  34385. /**
  34386. * Gets a value indicating the number of loading errors
  34387. * @ignorenaming
  34388. */
  34389. static get errorsCount(): number;
  34390. /**
  34391. * Callback called when a new log is added
  34392. */
  34393. static OnNewCacheEntry: (entry: string) => void;
  34394. /**
  34395. * Log a message to the console
  34396. * @param message defines the message to log
  34397. */
  34398. static Log(message: string): void;
  34399. /**
  34400. * Write a warning message to the console
  34401. * @param message defines the message to log
  34402. */
  34403. static Warn(message: string): void;
  34404. /**
  34405. * Write an error message to the console
  34406. * @param message defines the message to log
  34407. */
  34408. static Error(message: string): void;
  34409. /**
  34410. * Gets current log cache (list of logs)
  34411. */
  34412. static get LogCache(): string;
  34413. /**
  34414. * Clears the log cache
  34415. */
  34416. static ClearLogCache(): void;
  34417. /**
  34418. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34419. */
  34420. static set LogLevels(level: number);
  34421. /**
  34422. * Checks if the window object exists
  34423. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34424. */
  34425. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34426. /**
  34427. * No performance log
  34428. */
  34429. static readonly PerformanceNoneLogLevel: number;
  34430. /**
  34431. * Use user marks to log performance
  34432. */
  34433. static readonly PerformanceUserMarkLogLevel: number;
  34434. /**
  34435. * Log performance to the console
  34436. */
  34437. static readonly PerformanceConsoleLogLevel: number;
  34438. private static _performance;
  34439. /**
  34440. * Sets the current performance log level
  34441. */
  34442. static set PerformanceLogLevel(level: number);
  34443. private static _StartPerformanceCounterDisabled;
  34444. private static _EndPerformanceCounterDisabled;
  34445. private static _StartUserMark;
  34446. private static _EndUserMark;
  34447. private static _StartPerformanceConsole;
  34448. private static _EndPerformanceConsole;
  34449. /**
  34450. * Starts a performance counter
  34451. */
  34452. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34453. /**
  34454. * Ends a specific performance coutner
  34455. */
  34456. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34457. /**
  34458. * Gets either window.performance.now() if supported or Date.now() else
  34459. */
  34460. static get Now(): number;
  34461. /**
  34462. * This method will return the name of the class used to create the instance of the given object.
  34463. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34464. * @param object the object to get the class name from
  34465. * @param isType defines if the object is actually a type
  34466. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34467. */
  34468. static GetClassName(object: any, isType?: boolean): string;
  34469. /**
  34470. * Gets the first element of an array satisfying a given predicate
  34471. * @param array defines the array to browse
  34472. * @param predicate defines the predicate to use
  34473. * @returns null if not found or the element
  34474. */
  34475. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34476. /**
  34477. * This method will return the name of the full name of the class, including its owning module (if any).
  34478. * 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).
  34479. * @param object the object to get the class name from
  34480. * @param isType defines if the object is actually a type
  34481. * @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.
  34482. * @ignorenaming
  34483. */
  34484. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34485. /**
  34486. * Returns a promise that resolves after the given amount of time.
  34487. * @param delay Number of milliseconds to delay
  34488. * @returns Promise that resolves after the given amount of time
  34489. */
  34490. static DelayAsync(delay: number): Promise<void>;
  34491. /**
  34492. * Utility function to detect if the current user agent is Safari
  34493. * @returns whether or not the current user agent is safari
  34494. */
  34495. static IsSafari(): boolean;
  34496. }
  34497. /**
  34498. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34499. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34500. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34501. * @param name The name of the class, case should be preserved
  34502. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34503. */
  34504. export function className(name: string, module?: string): (target: Object) => void;
  34505. /**
  34506. * An implementation of a loop for asynchronous functions.
  34507. */
  34508. export class AsyncLoop {
  34509. /**
  34510. * Defines the number of iterations for the loop
  34511. */
  34512. iterations: number;
  34513. /**
  34514. * Defines the current index of the loop.
  34515. */
  34516. index: number;
  34517. private _done;
  34518. private _fn;
  34519. private _successCallback;
  34520. /**
  34521. * Constructor.
  34522. * @param iterations the number of iterations.
  34523. * @param func the function to run each iteration
  34524. * @param successCallback the callback that will be called upon succesful execution
  34525. * @param offset starting offset.
  34526. */
  34527. constructor(
  34528. /**
  34529. * Defines the number of iterations for the loop
  34530. */
  34531. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34532. /**
  34533. * Execute the next iteration. Must be called after the last iteration was finished.
  34534. */
  34535. executeNext(): void;
  34536. /**
  34537. * Break the loop and run the success callback.
  34538. */
  34539. breakLoop(): void;
  34540. /**
  34541. * Create and run an async loop.
  34542. * @param iterations the number of iterations.
  34543. * @param fn the function to run each iteration
  34544. * @param successCallback the callback that will be called upon succesful execution
  34545. * @param offset starting offset.
  34546. * @returns the created async loop object
  34547. */
  34548. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34549. /**
  34550. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34551. * @param iterations total number of iterations
  34552. * @param syncedIterations number of synchronous iterations in each async iteration.
  34553. * @param fn the function to call each iteration.
  34554. * @param callback a success call back that will be called when iterating stops.
  34555. * @param breakFunction a break condition (optional)
  34556. * @param timeout timeout settings for the setTimeout function. default - 0.
  34557. * @returns the created async loop object
  34558. */
  34559. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34560. }
  34561. }
  34562. declare module BABYLON {
  34563. /**
  34564. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34565. * The underlying implementation relies on an associative array to ensure the best performances.
  34566. * The value can be anything including 'null' but except 'undefined'
  34567. */
  34568. export class StringDictionary<T> {
  34569. /**
  34570. * This will clear this dictionary and copy the content from the 'source' one.
  34571. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34572. * @param source the dictionary to take the content from and copy to this dictionary
  34573. */
  34574. copyFrom(source: StringDictionary<T>): void;
  34575. /**
  34576. * Get a value based from its key
  34577. * @param key the given key to get the matching value from
  34578. * @return the value if found, otherwise undefined is returned
  34579. */
  34580. get(key: string): T | undefined;
  34581. /**
  34582. * Get a value from its key or add it if it doesn't exist.
  34583. * This method will ensure you that a given key/data will be present in the dictionary.
  34584. * @param key the given key to get the matching value from
  34585. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34586. * The factory will only be invoked if there's no data for the given key.
  34587. * @return the value corresponding to the key.
  34588. */
  34589. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34590. /**
  34591. * Get a value from its key if present in the dictionary otherwise add it
  34592. * @param key the key to get the value from
  34593. * @param val if there's no such key/value pair in the dictionary add it with this value
  34594. * @return the value corresponding to the key
  34595. */
  34596. getOrAdd(key: string, val: T): T;
  34597. /**
  34598. * Check if there's a given key in the dictionary
  34599. * @param key the key to check for
  34600. * @return true if the key is present, false otherwise
  34601. */
  34602. contains(key: string): boolean;
  34603. /**
  34604. * Add a new key and its corresponding value
  34605. * @param key the key to add
  34606. * @param value the value corresponding to the key
  34607. * @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
  34608. */
  34609. add(key: string, value: T): boolean;
  34610. /**
  34611. * Update a specific value associated to a key
  34612. * @param key defines the key to use
  34613. * @param value defines the value to store
  34614. * @returns true if the value was updated (or false if the key was not found)
  34615. */
  34616. set(key: string, value: T): boolean;
  34617. /**
  34618. * Get the element of the given key and remove it from the dictionary
  34619. * @param key defines the key to search
  34620. * @returns the value associated with the key or null if not found
  34621. */
  34622. getAndRemove(key: string): Nullable<T>;
  34623. /**
  34624. * Remove a key/value from the dictionary.
  34625. * @param key the key to remove
  34626. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34627. */
  34628. remove(key: string): boolean;
  34629. /**
  34630. * Clear the whole content of the dictionary
  34631. */
  34632. clear(): void;
  34633. /**
  34634. * Gets the current count
  34635. */
  34636. get count(): number;
  34637. /**
  34638. * Execute a callback on each key/val of the dictionary.
  34639. * Note that you can remove any element in this dictionary in the callback implementation
  34640. * @param callback the callback to execute on a given key/value pair
  34641. */
  34642. forEach(callback: (key: string, val: T) => void): void;
  34643. /**
  34644. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34645. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34646. * Note that you can remove any element in this dictionary in the callback implementation
  34647. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34648. * @returns the first item
  34649. */
  34650. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34651. private _count;
  34652. private _data;
  34653. }
  34654. }
  34655. declare module BABYLON {
  34656. /** @hidden */
  34657. export interface ICollisionCoordinator {
  34658. createCollider(): Collider;
  34659. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34660. init(scene: Scene): void;
  34661. }
  34662. /** @hidden */
  34663. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34664. private _scene;
  34665. private _scaledPosition;
  34666. private _scaledVelocity;
  34667. private _finalPosition;
  34668. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34669. createCollider(): Collider;
  34670. init(scene: Scene): void;
  34671. private _collideWithWorld;
  34672. }
  34673. }
  34674. declare module BABYLON {
  34675. /**
  34676. * Class used to manage all inputs for the scene.
  34677. */
  34678. export class InputManager {
  34679. /** The distance in pixel that you have to move to prevent some events */
  34680. static DragMovementThreshold: number;
  34681. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34682. static LongPressDelay: number;
  34683. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34684. static DoubleClickDelay: number;
  34685. /** If you need to check double click without raising a single click at first click, enable this flag */
  34686. static ExclusiveDoubleClickMode: boolean;
  34687. private _wheelEventName;
  34688. private _onPointerMove;
  34689. private _onPointerDown;
  34690. private _onPointerUp;
  34691. private _initClickEvent;
  34692. private _initActionManager;
  34693. private _delayedSimpleClick;
  34694. private _delayedSimpleClickTimeout;
  34695. private _previousDelayedSimpleClickTimeout;
  34696. private _meshPickProceed;
  34697. private _previousButtonPressed;
  34698. private _currentPickResult;
  34699. private _previousPickResult;
  34700. private _totalPointersPressed;
  34701. private _doubleClickOccured;
  34702. private _pointerOverMesh;
  34703. private _pickedDownMesh;
  34704. private _pickedUpMesh;
  34705. private _pointerX;
  34706. private _pointerY;
  34707. private _unTranslatedPointerX;
  34708. private _unTranslatedPointerY;
  34709. private _startingPointerPosition;
  34710. private _previousStartingPointerPosition;
  34711. private _startingPointerTime;
  34712. private _previousStartingPointerTime;
  34713. private _pointerCaptures;
  34714. private _onKeyDown;
  34715. private _onKeyUp;
  34716. private _onCanvasFocusObserver;
  34717. private _onCanvasBlurObserver;
  34718. private _scene;
  34719. /**
  34720. * Creates a new InputManager
  34721. * @param scene defines the hosting scene
  34722. */
  34723. constructor(scene: Scene);
  34724. /**
  34725. * Gets the mesh that is currently under the pointer
  34726. */
  34727. get meshUnderPointer(): Nullable<AbstractMesh>;
  34728. /**
  34729. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34730. */
  34731. get unTranslatedPointer(): Vector2;
  34732. /**
  34733. * Gets or sets the current on-screen X position of the pointer
  34734. */
  34735. get pointerX(): number;
  34736. set pointerX(value: number);
  34737. /**
  34738. * Gets or sets the current on-screen Y position of the pointer
  34739. */
  34740. get pointerY(): number;
  34741. set pointerY(value: number);
  34742. private _updatePointerPosition;
  34743. private _processPointerMove;
  34744. private _setRayOnPointerInfo;
  34745. private _checkPrePointerObservable;
  34746. /**
  34747. * Use this method to simulate a pointer move on a mesh
  34748. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34749. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34750. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34751. */
  34752. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34753. /**
  34754. * Use this method to simulate a pointer down on a mesh
  34755. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34756. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34757. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34758. */
  34759. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34760. private _processPointerDown;
  34761. /** @hidden */
  34762. _isPointerSwiping(): boolean;
  34763. /**
  34764. * Use this method to simulate a pointer up on a mesh
  34765. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34766. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34767. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34768. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34769. */
  34770. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34771. private _processPointerUp;
  34772. /**
  34773. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34774. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34775. * @returns true if the pointer was captured
  34776. */
  34777. isPointerCaptured(pointerId?: number): boolean;
  34778. /**
  34779. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34780. * @param attachUp defines if you want to attach events to pointerup
  34781. * @param attachDown defines if you want to attach events to pointerdown
  34782. * @param attachMove defines if you want to attach events to pointermove
  34783. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34784. */
  34785. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34786. /**
  34787. * Detaches all event handlers
  34788. */
  34789. detachControl(): void;
  34790. /**
  34791. * Force the value of meshUnderPointer
  34792. * @param mesh defines the mesh to use
  34793. */
  34794. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34795. /**
  34796. * Gets the mesh under the pointer
  34797. * @returns a Mesh or null if no mesh is under the pointer
  34798. */
  34799. getPointerOverMesh(): Nullable<AbstractMesh>;
  34800. }
  34801. }
  34802. declare module BABYLON {
  34803. /**
  34804. * Helper class used to generate session unique ID
  34805. */
  34806. export class UniqueIdGenerator {
  34807. private static _UniqueIdCounter;
  34808. /**
  34809. * Gets an unique (relatively to the current scene) Id
  34810. */
  34811. static get UniqueId(): number;
  34812. }
  34813. }
  34814. declare module BABYLON {
  34815. /**
  34816. * This class defines the direct association between an animation and a target
  34817. */
  34818. export class TargetedAnimation {
  34819. /**
  34820. * Animation to perform
  34821. */
  34822. animation: Animation;
  34823. /**
  34824. * Target to animate
  34825. */
  34826. target: any;
  34827. /**
  34828. * Serialize the object
  34829. * @returns the JSON object representing the current entity
  34830. */
  34831. serialize(): any;
  34832. }
  34833. /**
  34834. * Use this class to create coordinated animations on multiple targets
  34835. */
  34836. export class AnimationGroup implements IDisposable {
  34837. /** The name of the animation group */
  34838. name: string;
  34839. private _scene;
  34840. private _targetedAnimations;
  34841. private _animatables;
  34842. private _from;
  34843. private _to;
  34844. private _isStarted;
  34845. private _isPaused;
  34846. private _speedRatio;
  34847. private _loopAnimation;
  34848. /**
  34849. * Gets or sets the unique id of the node
  34850. */
  34851. uniqueId: number;
  34852. /**
  34853. * This observable will notify when one animation have ended
  34854. */
  34855. onAnimationEndObservable: Observable<TargetedAnimation>;
  34856. /**
  34857. * Observer raised when one animation loops
  34858. */
  34859. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34860. /**
  34861. * Observer raised when all animations have looped
  34862. */
  34863. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34864. /**
  34865. * This observable will notify when all animations have ended.
  34866. */
  34867. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34868. /**
  34869. * This observable will notify when all animations have paused.
  34870. */
  34871. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34872. /**
  34873. * This observable will notify when all animations are playing.
  34874. */
  34875. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34876. /**
  34877. * Gets the first frame
  34878. */
  34879. get from(): number;
  34880. /**
  34881. * Gets the last frame
  34882. */
  34883. get to(): number;
  34884. /**
  34885. * Define if the animations are started
  34886. */
  34887. get isStarted(): boolean;
  34888. /**
  34889. * Gets a value indicating that the current group is playing
  34890. */
  34891. get isPlaying(): boolean;
  34892. /**
  34893. * Gets or sets the speed ratio to use for all animations
  34894. */
  34895. get speedRatio(): number;
  34896. /**
  34897. * Gets or sets the speed ratio to use for all animations
  34898. */
  34899. set speedRatio(value: number);
  34900. /**
  34901. * Gets or sets if all animations should loop or not
  34902. */
  34903. get loopAnimation(): boolean;
  34904. set loopAnimation(value: boolean);
  34905. /**
  34906. * Gets the targeted animations for this animation group
  34907. */
  34908. get targetedAnimations(): Array<TargetedAnimation>;
  34909. /**
  34910. * returning the list of animatables controlled by this animation group.
  34911. */
  34912. get animatables(): Array<Animatable>;
  34913. /**
  34914. * Instantiates a new Animation Group.
  34915. * This helps managing several animations at once.
  34916. * @see http://doc.babylonjs.com/how_to/group
  34917. * @param name Defines the name of the group
  34918. * @param scene Defines the scene the group belongs to
  34919. */
  34920. constructor(
  34921. /** The name of the animation group */
  34922. name: string, scene?: Nullable<Scene>);
  34923. /**
  34924. * Add an animation (with its target) in the group
  34925. * @param animation defines the animation we want to add
  34926. * @param target defines the target of the animation
  34927. * @returns the TargetedAnimation object
  34928. */
  34929. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34930. /**
  34931. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34932. * It can add constant keys at begin or end
  34933. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34934. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34935. * @returns the animation group
  34936. */
  34937. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34938. private _animationLoopCount;
  34939. private _animationLoopFlags;
  34940. private _processLoop;
  34941. /**
  34942. * Start all animations on given targets
  34943. * @param loop defines if animations must loop
  34944. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34945. * @param from defines the from key (optional)
  34946. * @param to defines the to key (optional)
  34947. * @returns the current animation group
  34948. */
  34949. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34950. /**
  34951. * Pause all animations
  34952. * @returns the animation group
  34953. */
  34954. pause(): AnimationGroup;
  34955. /**
  34956. * Play all animations to initial state
  34957. * This function will start() the animations if they were not started or will restart() them if they were paused
  34958. * @param loop defines if animations must loop
  34959. * @returns the animation group
  34960. */
  34961. play(loop?: boolean): AnimationGroup;
  34962. /**
  34963. * Reset all animations to initial state
  34964. * @returns the animation group
  34965. */
  34966. reset(): AnimationGroup;
  34967. /**
  34968. * Restart animations from key 0
  34969. * @returns the animation group
  34970. */
  34971. restart(): AnimationGroup;
  34972. /**
  34973. * Stop all animations
  34974. * @returns the animation group
  34975. */
  34976. stop(): AnimationGroup;
  34977. /**
  34978. * Set animation weight for all animatables
  34979. * @param weight defines the weight to use
  34980. * @return the animationGroup
  34981. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34982. */
  34983. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34984. /**
  34985. * Synchronize and normalize all animatables with a source animatable
  34986. * @param root defines the root animatable to synchronize with
  34987. * @return the animationGroup
  34988. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34989. */
  34990. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34991. /**
  34992. * Goes to a specific frame in this animation group
  34993. * @param frame the frame number to go to
  34994. * @return the animationGroup
  34995. */
  34996. goToFrame(frame: number): AnimationGroup;
  34997. /**
  34998. * Dispose all associated resources
  34999. */
  35000. dispose(): void;
  35001. private _checkAnimationGroupEnded;
  35002. /**
  35003. * Clone the current animation group and returns a copy
  35004. * @param newName defines the name of the new group
  35005. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35006. * @returns the new aniamtion group
  35007. */
  35008. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35009. /**
  35010. * Serializes the animationGroup to an object
  35011. * @returns Serialized object
  35012. */
  35013. serialize(): any;
  35014. /**
  35015. * Returns a new AnimationGroup object parsed from the source provided.
  35016. * @param parsedAnimationGroup defines the source
  35017. * @param scene defines the scene that will receive the animationGroup
  35018. * @returns a new AnimationGroup
  35019. */
  35020. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35021. /**
  35022. * Returns the string "AnimationGroup"
  35023. * @returns "AnimationGroup"
  35024. */
  35025. getClassName(): string;
  35026. /**
  35027. * Creates a detailled string about the object
  35028. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35029. * @returns a string representing the object
  35030. */
  35031. toString(fullDetails?: boolean): string;
  35032. }
  35033. }
  35034. declare module BABYLON {
  35035. /**
  35036. * Define an interface for all classes that will hold resources
  35037. */
  35038. export interface IDisposable {
  35039. /**
  35040. * Releases all held resources
  35041. */
  35042. dispose(): void;
  35043. }
  35044. /** Interface defining initialization parameters for Scene class */
  35045. export interface SceneOptions {
  35046. /**
  35047. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35048. * It will improve performance when the number of geometries becomes important.
  35049. */
  35050. useGeometryUniqueIdsMap?: boolean;
  35051. /**
  35052. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35053. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35054. */
  35055. useMaterialMeshMap?: boolean;
  35056. /**
  35057. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35058. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35059. */
  35060. useClonedMeshMap?: boolean;
  35061. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35062. virtual?: boolean;
  35063. }
  35064. /**
  35065. * Represents a scene to be rendered by the engine.
  35066. * @see http://doc.babylonjs.com/features/scene
  35067. */
  35068. export class Scene extends AbstractScene implements IAnimatable {
  35069. /** The fog is deactivated */
  35070. static readonly FOGMODE_NONE: number;
  35071. /** The fog density is following an exponential function */
  35072. static readonly FOGMODE_EXP: number;
  35073. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35074. static readonly FOGMODE_EXP2: number;
  35075. /** The fog density is following a linear function. */
  35076. static readonly FOGMODE_LINEAR: number;
  35077. /**
  35078. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35080. */
  35081. static MinDeltaTime: number;
  35082. /**
  35083. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35084. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35085. */
  35086. static MaxDeltaTime: number;
  35087. /**
  35088. * Factory used to create the default material.
  35089. * @param name The name of the material to create
  35090. * @param scene The scene to create the material for
  35091. * @returns The default material
  35092. */
  35093. static DefaultMaterialFactory(scene: Scene): Material;
  35094. /**
  35095. * Factory used to create the a collision coordinator.
  35096. * @returns The collision coordinator
  35097. */
  35098. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35099. /** @hidden */
  35100. _inputManager: InputManager;
  35101. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35102. cameraToUseForPointers: Nullable<Camera>;
  35103. /** @hidden */
  35104. readonly _isScene: boolean;
  35105. /**
  35106. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35107. */
  35108. autoClear: boolean;
  35109. /**
  35110. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35111. */
  35112. autoClearDepthAndStencil: boolean;
  35113. /**
  35114. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35115. */
  35116. clearColor: Color4;
  35117. /**
  35118. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35119. */
  35120. ambientColor: Color3;
  35121. /**
  35122. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35123. * It should only be one of the following (if not the default embedded one):
  35124. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35125. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35126. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35127. * The material properties need to be setup according to the type of texture in use.
  35128. */
  35129. environmentBRDFTexture: BaseTexture;
  35130. /** @hidden */
  35131. protected _environmentTexture: Nullable<BaseTexture>;
  35132. /**
  35133. * Texture used in all pbr material as the reflection texture.
  35134. * As in the majority of the scene they are the same (exception for multi room and so on),
  35135. * this is easier to reference from here than from all the materials.
  35136. */
  35137. get environmentTexture(): Nullable<BaseTexture>;
  35138. /**
  35139. * Texture used in all pbr material as the reflection texture.
  35140. * As in the majority of the scene they are the same (exception for multi room and so on),
  35141. * this is easier to set here than in all the materials.
  35142. */
  35143. set environmentTexture(value: Nullable<BaseTexture>);
  35144. /** @hidden */
  35145. protected _environmentIntensity: number;
  35146. /**
  35147. * Intensity of the environment in all pbr material.
  35148. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35149. * As in the majority of the scene they are the same (exception for multi room and so on),
  35150. * this is easier to reference from here than from all the materials.
  35151. */
  35152. get environmentIntensity(): number;
  35153. /**
  35154. * Intensity of the environment in all pbr material.
  35155. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35156. * As in the majority of the scene they are the same (exception for multi room and so on),
  35157. * this is easier to set here than in all the materials.
  35158. */
  35159. set environmentIntensity(value: number);
  35160. /** @hidden */
  35161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35162. /**
  35163. * Default image processing configuration used either in the rendering
  35164. * Forward main pass or through the imageProcessingPostProcess if present.
  35165. * As in the majority of the scene they are the same (exception for multi camera),
  35166. * this is easier to reference from here than from all the materials and post process.
  35167. *
  35168. * No setter as we it is a shared configuration, you can set the values instead.
  35169. */
  35170. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35171. private _forceWireframe;
  35172. /**
  35173. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35174. */
  35175. set forceWireframe(value: boolean);
  35176. get forceWireframe(): boolean;
  35177. private _skipFrustumClipping;
  35178. /**
  35179. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35180. */
  35181. set skipFrustumClipping(value: boolean);
  35182. get skipFrustumClipping(): boolean;
  35183. private _forcePointsCloud;
  35184. /**
  35185. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35186. */
  35187. set forcePointsCloud(value: boolean);
  35188. get forcePointsCloud(): boolean;
  35189. /**
  35190. * Gets or sets the active clipplane 1
  35191. */
  35192. clipPlane: Nullable<Plane>;
  35193. /**
  35194. * Gets or sets the active clipplane 2
  35195. */
  35196. clipPlane2: Nullable<Plane>;
  35197. /**
  35198. * Gets or sets the active clipplane 3
  35199. */
  35200. clipPlane3: Nullable<Plane>;
  35201. /**
  35202. * Gets or sets the active clipplane 4
  35203. */
  35204. clipPlane4: Nullable<Plane>;
  35205. /**
  35206. * Gets or sets the active clipplane 5
  35207. */
  35208. clipPlane5: Nullable<Plane>;
  35209. /**
  35210. * Gets or sets the active clipplane 6
  35211. */
  35212. clipPlane6: Nullable<Plane>;
  35213. /**
  35214. * Gets or sets a boolean indicating if animations are enabled
  35215. */
  35216. animationsEnabled: boolean;
  35217. private _animationPropertiesOverride;
  35218. /**
  35219. * Gets or sets the animation properties override
  35220. */
  35221. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35222. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35223. /**
  35224. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35225. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35226. */
  35227. useConstantAnimationDeltaTime: boolean;
  35228. /**
  35229. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35230. * Please note that it requires to run a ray cast through the scene on every frame
  35231. */
  35232. constantlyUpdateMeshUnderPointer: boolean;
  35233. /**
  35234. * Defines the HTML cursor to use when hovering over interactive elements
  35235. */
  35236. hoverCursor: string;
  35237. /**
  35238. * Defines the HTML default cursor to use (empty by default)
  35239. */
  35240. defaultCursor: string;
  35241. /**
  35242. * Defines whether cursors are handled by the scene.
  35243. */
  35244. doNotHandleCursors: boolean;
  35245. /**
  35246. * This is used to call preventDefault() on pointer down
  35247. * in order to block unwanted artifacts like system double clicks
  35248. */
  35249. preventDefaultOnPointerDown: boolean;
  35250. /**
  35251. * This is used to call preventDefault() on pointer up
  35252. * in order to block unwanted artifacts like system double clicks
  35253. */
  35254. preventDefaultOnPointerUp: boolean;
  35255. /**
  35256. * Gets or sets user defined metadata
  35257. */
  35258. metadata: any;
  35259. /**
  35260. * For internal use only. Please do not use.
  35261. */
  35262. reservedDataStore: any;
  35263. /**
  35264. * Gets the name of the plugin used to load this scene (null by default)
  35265. */
  35266. loadingPluginName: string;
  35267. /**
  35268. * Use this array to add regular expressions used to disable offline support for specific urls
  35269. */
  35270. disableOfflineSupportExceptionRules: RegExp[];
  35271. /**
  35272. * An event triggered when the scene is disposed.
  35273. */
  35274. onDisposeObservable: Observable<Scene>;
  35275. private _onDisposeObserver;
  35276. /** Sets a function to be executed when this scene is disposed. */
  35277. set onDispose(callback: () => void);
  35278. /**
  35279. * An event triggered before rendering the scene (right after animations and physics)
  35280. */
  35281. onBeforeRenderObservable: Observable<Scene>;
  35282. private _onBeforeRenderObserver;
  35283. /** Sets a function to be executed before rendering this scene */
  35284. set beforeRender(callback: Nullable<() => void>);
  35285. /**
  35286. * An event triggered after rendering the scene
  35287. */
  35288. onAfterRenderObservable: Observable<Scene>;
  35289. /**
  35290. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35291. */
  35292. onAfterRenderCameraObservable: Observable<Camera>;
  35293. private _onAfterRenderObserver;
  35294. /** Sets a function to be executed after rendering this scene */
  35295. set afterRender(callback: Nullable<() => void>);
  35296. /**
  35297. * An event triggered before animating the scene
  35298. */
  35299. onBeforeAnimationsObservable: Observable<Scene>;
  35300. /**
  35301. * An event triggered after animations processing
  35302. */
  35303. onAfterAnimationsObservable: Observable<Scene>;
  35304. /**
  35305. * An event triggered before draw calls are ready to be sent
  35306. */
  35307. onBeforeDrawPhaseObservable: Observable<Scene>;
  35308. /**
  35309. * An event triggered after draw calls have been sent
  35310. */
  35311. onAfterDrawPhaseObservable: Observable<Scene>;
  35312. /**
  35313. * An event triggered when the scene is ready
  35314. */
  35315. onReadyObservable: Observable<Scene>;
  35316. /**
  35317. * An event triggered before rendering a camera
  35318. */
  35319. onBeforeCameraRenderObservable: Observable<Camera>;
  35320. private _onBeforeCameraRenderObserver;
  35321. /** Sets a function to be executed before rendering a camera*/
  35322. set beforeCameraRender(callback: () => void);
  35323. /**
  35324. * An event triggered after rendering a camera
  35325. */
  35326. onAfterCameraRenderObservable: Observable<Camera>;
  35327. private _onAfterCameraRenderObserver;
  35328. /** Sets a function to be executed after rendering a camera*/
  35329. set afterCameraRender(callback: () => void);
  35330. /**
  35331. * An event triggered when active meshes evaluation is about to start
  35332. */
  35333. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35334. /**
  35335. * An event triggered when active meshes evaluation is done
  35336. */
  35337. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35338. /**
  35339. * An event triggered when particles rendering is about to start
  35340. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35341. */
  35342. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35343. /**
  35344. * An event triggered when particles rendering is done
  35345. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35346. */
  35347. onAfterParticlesRenderingObservable: Observable<Scene>;
  35348. /**
  35349. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35350. */
  35351. onDataLoadedObservable: Observable<Scene>;
  35352. /**
  35353. * An event triggered when a camera is created
  35354. */
  35355. onNewCameraAddedObservable: Observable<Camera>;
  35356. /**
  35357. * An event triggered when a camera is removed
  35358. */
  35359. onCameraRemovedObservable: Observable<Camera>;
  35360. /**
  35361. * An event triggered when a light is created
  35362. */
  35363. onNewLightAddedObservable: Observable<Light>;
  35364. /**
  35365. * An event triggered when a light is removed
  35366. */
  35367. onLightRemovedObservable: Observable<Light>;
  35368. /**
  35369. * An event triggered when a geometry is created
  35370. */
  35371. onNewGeometryAddedObservable: Observable<Geometry>;
  35372. /**
  35373. * An event triggered when a geometry is removed
  35374. */
  35375. onGeometryRemovedObservable: Observable<Geometry>;
  35376. /**
  35377. * An event triggered when a transform node is created
  35378. */
  35379. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35380. /**
  35381. * An event triggered when a transform node is removed
  35382. */
  35383. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35384. /**
  35385. * An event triggered when a mesh is created
  35386. */
  35387. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35388. /**
  35389. * An event triggered when a mesh is removed
  35390. */
  35391. onMeshRemovedObservable: Observable<AbstractMesh>;
  35392. /**
  35393. * An event triggered when a skeleton is created
  35394. */
  35395. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35396. /**
  35397. * An event triggered when a skeleton is removed
  35398. */
  35399. onSkeletonRemovedObservable: Observable<Skeleton>;
  35400. /**
  35401. * An event triggered when a material is created
  35402. */
  35403. onNewMaterialAddedObservable: Observable<Material>;
  35404. /**
  35405. * An event triggered when a material is removed
  35406. */
  35407. onMaterialRemovedObservable: Observable<Material>;
  35408. /**
  35409. * An event triggered when a texture is created
  35410. */
  35411. onNewTextureAddedObservable: Observable<BaseTexture>;
  35412. /**
  35413. * An event triggered when a texture is removed
  35414. */
  35415. onTextureRemovedObservable: Observable<BaseTexture>;
  35416. /**
  35417. * An event triggered when render targets are about to be rendered
  35418. * Can happen multiple times per frame.
  35419. */
  35420. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35421. /**
  35422. * An event triggered when render targets were rendered.
  35423. * Can happen multiple times per frame.
  35424. */
  35425. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35426. /**
  35427. * An event triggered before calculating deterministic simulation step
  35428. */
  35429. onBeforeStepObservable: Observable<Scene>;
  35430. /**
  35431. * An event triggered after calculating deterministic simulation step
  35432. */
  35433. onAfterStepObservable: Observable<Scene>;
  35434. /**
  35435. * An event triggered when the activeCamera property is updated
  35436. */
  35437. onActiveCameraChanged: Observable<Scene>;
  35438. /**
  35439. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35440. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35441. * 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)
  35442. */
  35443. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35444. /**
  35445. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35446. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35447. * 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)
  35448. */
  35449. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35450. /**
  35451. * This Observable will when a mesh has been imported into the scene.
  35452. */
  35453. onMeshImportedObservable: Observable<AbstractMesh>;
  35454. /**
  35455. * This Observable will when an animation file has been imported into the scene.
  35456. */
  35457. onAnimationFileImportedObservable: Observable<Scene>;
  35458. /**
  35459. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35460. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35461. */
  35462. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35463. /** @hidden */
  35464. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35465. /**
  35466. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35467. */
  35468. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35469. /**
  35470. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35471. */
  35472. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35473. /**
  35474. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35475. */
  35476. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35477. /** Callback called when a pointer move is detected */
  35478. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35479. /** Callback called when a pointer down is detected */
  35480. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35481. /** Callback called when a pointer up is detected */
  35482. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35483. /** Callback called when a pointer pick is detected */
  35484. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35485. /**
  35486. * 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).
  35487. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35488. */
  35489. onPrePointerObservable: Observable<PointerInfoPre>;
  35490. /**
  35491. * Observable event triggered each time an input event is received from the rendering canvas
  35492. */
  35493. onPointerObservable: Observable<PointerInfo>;
  35494. /**
  35495. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35496. */
  35497. get unTranslatedPointer(): Vector2;
  35498. /**
  35499. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35500. */
  35501. static get DragMovementThreshold(): number;
  35502. static set DragMovementThreshold(value: number);
  35503. /**
  35504. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35505. */
  35506. static get LongPressDelay(): number;
  35507. static set LongPressDelay(value: number);
  35508. /**
  35509. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35510. */
  35511. static get DoubleClickDelay(): number;
  35512. static set DoubleClickDelay(value: number);
  35513. /** If you need to check double click without raising a single click at first click, enable this flag */
  35514. static get ExclusiveDoubleClickMode(): boolean;
  35515. static set ExclusiveDoubleClickMode(value: boolean);
  35516. /** @hidden */
  35517. _mirroredCameraPosition: Nullable<Vector3>;
  35518. /**
  35519. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35520. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35521. */
  35522. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35523. /**
  35524. * Observable event triggered each time an keyboard event is received from the hosting window
  35525. */
  35526. onKeyboardObservable: Observable<KeyboardInfo>;
  35527. private _useRightHandedSystem;
  35528. /**
  35529. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35530. */
  35531. set useRightHandedSystem(value: boolean);
  35532. get useRightHandedSystem(): boolean;
  35533. private _timeAccumulator;
  35534. private _currentStepId;
  35535. private _currentInternalStep;
  35536. /**
  35537. * Sets the step Id used by deterministic lock step
  35538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35539. * @param newStepId defines the step Id
  35540. */
  35541. setStepId(newStepId: number): void;
  35542. /**
  35543. * Gets the step Id used by deterministic lock step
  35544. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35545. * @returns the step Id
  35546. */
  35547. getStepId(): number;
  35548. /**
  35549. * Gets the internal step used by deterministic lock step
  35550. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35551. * @returns the internal step
  35552. */
  35553. getInternalStep(): number;
  35554. private _fogEnabled;
  35555. /**
  35556. * Gets or sets a boolean indicating if fog is enabled on this scene
  35557. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35558. * (Default is true)
  35559. */
  35560. set fogEnabled(value: boolean);
  35561. get fogEnabled(): boolean;
  35562. private _fogMode;
  35563. /**
  35564. * Gets or sets the fog mode to use
  35565. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35566. * | mode | value |
  35567. * | --- | --- |
  35568. * | FOGMODE_NONE | 0 |
  35569. * | FOGMODE_EXP | 1 |
  35570. * | FOGMODE_EXP2 | 2 |
  35571. * | FOGMODE_LINEAR | 3 |
  35572. */
  35573. set fogMode(value: number);
  35574. get fogMode(): number;
  35575. /**
  35576. * Gets or sets the fog color to use
  35577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35578. * (Default is Color3(0.2, 0.2, 0.3))
  35579. */
  35580. fogColor: Color3;
  35581. /**
  35582. * Gets or sets the fog density to use
  35583. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35584. * (Default is 0.1)
  35585. */
  35586. fogDensity: number;
  35587. /**
  35588. * Gets or sets the fog start distance to use
  35589. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35590. * (Default is 0)
  35591. */
  35592. fogStart: number;
  35593. /**
  35594. * Gets or sets the fog end distance to use
  35595. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35596. * (Default is 1000)
  35597. */
  35598. fogEnd: number;
  35599. private _shadowsEnabled;
  35600. /**
  35601. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35602. */
  35603. set shadowsEnabled(value: boolean);
  35604. get shadowsEnabled(): boolean;
  35605. private _lightsEnabled;
  35606. /**
  35607. * Gets or sets a boolean indicating if lights are enabled on this scene
  35608. */
  35609. set lightsEnabled(value: boolean);
  35610. get lightsEnabled(): boolean;
  35611. /** All of the active cameras added to this scene. */
  35612. activeCameras: Camera[];
  35613. /** @hidden */
  35614. _activeCamera: Nullable<Camera>;
  35615. /** Gets or sets the current active camera */
  35616. get activeCamera(): Nullable<Camera>;
  35617. set activeCamera(value: Nullable<Camera>);
  35618. private _defaultMaterial;
  35619. /** The default material used on meshes when no material is affected */
  35620. get defaultMaterial(): Material;
  35621. /** The default material used on meshes when no material is affected */
  35622. set defaultMaterial(value: Material);
  35623. private _texturesEnabled;
  35624. /**
  35625. * Gets or sets a boolean indicating if textures are enabled on this scene
  35626. */
  35627. set texturesEnabled(value: boolean);
  35628. get texturesEnabled(): boolean;
  35629. /**
  35630. * Gets or sets a boolean indicating if particles are enabled on this scene
  35631. */
  35632. particlesEnabled: boolean;
  35633. /**
  35634. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35635. */
  35636. spritesEnabled: boolean;
  35637. private _skeletonsEnabled;
  35638. /**
  35639. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35640. */
  35641. set skeletonsEnabled(value: boolean);
  35642. get skeletonsEnabled(): boolean;
  35643. /**
  35644. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35645. */
  35646. lensFlaresEnabled: boolean;
  35647. /**
  35648. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35650. */
  35651. collisionsEnabled: boolean;
  35652. private _collisionCoordinator;
  35653. /** @hidden */
  35654. get collisionCoordinator(): ICollisionCoordinator;
  35655. /**
  35656. * Defines the gravity applied to this scene (used only for collisions)
  35657. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35658. */
  35659. gravity: Vector3;
  35660. /**
  35661. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35662. */
  35663. postProcessesEnabled: boolean;
  35664. /**
  35665. * The list of postprocesses added to the scene
  35666. */
  35667. postProcesses: PostProcess[];
  35668. /**
  35669. * Gets the current postprocess manager
  35670. */
  35671. postProcessManager: PostProcessManager;
  35672. /**
  35673. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35674. */
  35675. renderTargetsEnabled: boolean;
  35676. /**
  35677. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35678. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35679. */
  35680. dumpNextRenderTargets: boolean;
  35681. /**
  35682. * The list of user defined render targets added to the scene
  35683. */
  35684. customRenderTargets: RenderTargetTexture[];
  35685. /**
  35686. * Defines if texture loading must be delayed
  35687. * If true, textures will only be loaded when they need to be rendered
  35688. */
  35689. useDelayedTextureLoading: boolean;
  35690. /**
  35691. * Gets the list of meshes imported to the scene through SceneLoader
  35692. */
  35693. importedMeshesFiles: String[];
  35694. /**
  35695. * Gets or sets a boolean indicating if probes are enabled on this scene
  35696. */
  35697. probesEnabled: boolean;
  35698. /**
  35699. * Gets or sets the current offline provider to use to store scene data
  35700. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35701. */
  35702. offlineProvider: IOfflineProvider;
  35703. /**
  35704. * Gets or sets the action manager associated with the scene
  35705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35706. */
  35707. actionManager: AbstractActionManager;
  35708. private _meshesForIntersections;
  35709. /**
  35710. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35711. */
  35712. proceduralTexturesEnabled: boolean;
  35713. private _engine;
  35714. private _totalVertices;
  35715. /** @hidden */
  35716. _activeIndices: PerfCounter;
  35717. /** @hidden */
  35718. _activeParticles: PerfCounter;
  35719. /** @hidden */
  35720. _activeBones: PerfCounter;
  35721. private _animationRatio;
  35722. /** @hidden */
  35723. _animationTimeLast: number;
  35724. /** @hidden */
  35725. _animationTime: number;
  35726. /**
  35727. * Gets or sets a general scale for animation speed
  35728. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35729. */
  35730. animationTimeScale: number;
  35731. /** @hidden */
  35732. _cachedMaterial: Nullable<Material>;
  35733. /** @hidden */
  35734. _cachedEffect: Nullable<Effect>;
  35735. /** @hidden */
  35736. _cachedVisibility: Nullable<number>;
  35737. private _renderId;
  35738. private _frameId;
  35739. private _executeWhenReadyTimeoutId;
  35740. private _intermediateRendering;
  35741. private _viewUpdateFlag;
  35742. private _projectionUpdateFlag;
  35743. /** @hidden */
  35744. _toBeDisposed: Nullable<IDisposable>[];
  35745. private _activeRequests;
  35746. /** @hidden */
  35747. _pendingData: any[];
  35748. private _isDisposed;
  35749. /**
  35750. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35751. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35752. */
  35753. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35754. private _activeMeshes;
  35755. private _processedMaterials;
  35756. private _renderTargets;
  35757. /** @hidden */
  35758. _activeParticleSystems: SmartArray<IParticleSystem>;
  35759. private _activeSkeletons;
  35760. private _softwareSkinnedMeshes;
  35761. private _renderingManager;
  35762. /** @hidden */
  35763. _activeAnimatables: Animatable[];
  35764. private _transformMatrix;
  35765. private _sceneUbo;
  35766. /** @hidden */
  35767. _viewMatrix: Matrix;
  35768. private _projectionMatrix;
  35769. /** @hidden */
  35770. _forcedViewPosition: Nullable<Vector3>;
  35771. /** @hidden */
  35772. _frustumPlanes: Plane[];
  35773. /**
  35774. * Gets the list of frustum planes (built from the active camera)
  35775. */
  35776. get frustumPlanes(): Plane[];
  35777. /**
  35778. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35779. * This is useful if there are more lights that the maximum simulteanous authorized
  35780. */
  35781. requireLightSorting: boolean;
  35782. /** @hidden */
  35783. readonly useMaterialMeshMap: boolean;
  35784. /** @hidden */
  35785. readonly useClonedMeshMap: boolean;
  35786. private _externalData;
  35787. private _uid;
  35788. /**
  35789. * @hidden
  35790. * Backing store of defined scene components.
  35791. */
  35792. _components: ISceneComponent[];
  35793. /**
  35794. * @hidden
  35795. * Backing store of defined scene components.
  35796. */
  35797. _serializableComponents: ISceneSerializableComponent[];
  35798. /**
  35799. * List of components to register on the next registration step.
  35800. */
  35801. private _transientComponents;
  35802. /**
  35803. * Registers the transient components if needed.
  35804. */
  35805. private _registerTransientComponents;
  35806. /**
  35807. * @hidden
  35808. * Add a component to the scene.
  35809. * Note that the ccomponent could be registered on th next frame if this is called after
  35810. * the register component stage.
  35811. * @param component Defines the component to add to the scene
  35812. */
  35813. _addComponent(component: ISceneComponent): void;
  35814. /**
  35815. * @hidden
  35816. * Gets a component from the scene.
  35817. * @param name defines the name of the component to retrieve
  35818. * @returns the component or null if not present
  35819. */
  35820. _getComponent(name: string): Nullable<ISceneComponent>;
  35821. /**
  35822. * @hidden
  35823. * Defines the actions happening before camera updates.
  35824. */
  35825. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35826. /**
  35827. * @hidden
  35828. * Defines the actions happening before clear the canvas.
  35829. */
  35830. _beforeClearStage: Stage<SimpleStageAction>;
  35831. /**
  35832. * @hidden
  35833. * Defines the actions when collecting render targets for the frame.
  35834. */
  35835. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35836. /**
  35837. * @hidden
  35838. * Defines the actions happening for one camera in the frame.
  35839. */
  35840. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35841. /**
  35842. * @hidden
  35843. * Defines the actions happening during the per mesh ready checks.
  35844. */
  35845. _isReadyForMeshStage: Stage<MeshStageAction>;
  35846. /**
  35847. * @hidden
  35848. * Defines the actions happening before evaluate active mesh checks.
  35849. */
  35850. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35851. /**
  35852. * @hidden
  35853. * Defines the actions happening during the evaluate sub mesh checks.
  35854. */
  35855. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35856. /**
  35857. * @hidden
  35858. * Defines the actions happening during the active mesh stage.
  35859. */
  35860. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35861. /**
  35862. * @hidden
  35863. * Defines the actions happening during the per camera render target step.
  35864. */
  35865. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35866. /**
  35867. * @hidden
  35868. * Defines the actions happening just before the active camera is drawing.
  35869. */
  35870. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35871. /**
  35872. * @hidden
  35873. * Defines the actions happening just before a render target is drawing.
  35874. */
  35875. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35876. /**
  35877. * @hidden
  35878. * Defines the actions happening just before a rendering group is drawing.
  35879. */
  35880. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35881. /**
  35882. * @hidden
  35883. * Defines the actions happening just before a mesh is drawing.
  35884. */
  35885. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35886. /**
  35887. * @hidden
  35888. * Defines the actions happening just after a mesh has been drawn.
  35889. */
  35890. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35891. /**
  35892. * @hidden
  35893. * Defines the actions happening just after a rendering group has been drawn.
  35894. */
  35895. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35896. /**
  35897. * @hidden
  35898. * Defines the actions happening just after the active camera has been drawn.
  35899. */
  35900. _afterCameraDrawStage: Stage<CameraStageAction>;
  35901. /**
  35902. * @hidden
  35903. * Defines the actions happening just after a render target has been drawn.
  35904. */
  35905. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35906. /**
  35907. * @hidden
  35908. * Defines the actions happening just after rendering all cameras and computing intersections.
  35909. */
  35910. _afterRenderStage: Stage<SimpleStageAction>;
  35911. /**
  35912. * @hidden
  35913. * Defines the actions happening when a pointer move event happens.
  35914. */
  35915. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35916. /**
  35917. * @hidden
  35918. * Defines the actions happening when a pointer down event happens.
  35919. */
  35920. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35921. /**
  35922. * @hidden
  35923. * Defines the actions happening when a pointer up event happens.
  35924. */
  35925. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35926. /**
  35927. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35928. */
  35929. private geometriesByUniqueId;
  35930. /**
  35931. * Creates a new Scene
  35932. * @param engine defines the engine to use to render this scene
  35933. * @param options defines the scene options
  35934. */
  35935. constructor(engine: Engine, options?: SceneOptions);
  35936. /**
  35937. * Gets a string idenfifying the name of the class
  35938. * @returns "Scene" string
  35939. */
  35940. getClassName(): string;
  35941. private _defaultMeshCandidates;
  35942. /**
  35943. * @hidden
  35944. */
  35945. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35946. private _defaultSubMeshCandidates;
  35947. /**
  35948. * @hidden
  35949. */
  35950. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35951. /**
  35952. * Sets the default candidate providers for the scene.
  35953. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35954. * and getCollidingSubMeshCandidates to their default function
  35955. */
  35956. setDefaultCandidateProviders(): void;
  35957. /**
  35958. * Gets the mesh that is currently under the pointer
  35959. */
  35960. get meshUnderPointer(): Nullable<AbstractMesh>;
  35961. /**
  35962. * Gets or sets the current on-screen X position of the pointer
  35963. */
  35964. get pointerX(): number;
  35965. set pointerX(value: number);
  35966. /**
  35967. * Gets or sets the current on-screen Y position of the pointer
  35968. */
  35969. get pointerY(): number;
  35970. set pointerY(value: number);
  35971. /**
  35972. * Gets the cached material (ie. the latest rendered one)
  35973. * @returns the cached material
  35974. */
  35975. getCachedMaterial(): Nullable<Material>;
  35976. /**
  35977. * Gets the cached effect (ie. the latest rendered one)
  35978. * @returns the cached effect
  35979. */
  35980. getCachedEffect(): Nullable<Effect>;
  35981. /**
  35982. * Gets the cached visibility state (ie. the latest rendered one)
  35983. * @returns the cached visibility state
  35984. */
  35985. getCachedVisibility(): Nullable<number>;
  35986. /**
  35987. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35988. * @param material defines the current material
  35989. * @param effect defines the current effect
  35990. * @param visibility defines the current visibility state
  35991. * @returns true if one parameter is not cached
  35992. */
  35993. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35994. /**
  35995. * Gets the engine associated with the scene
  35996. * @returns an Engine
  35997. */
  35998. getEngine(): Engine;
  35999. /**
  36000. * Gets the total number of vertices rendered per frame
  36001. * @returns the total number of vertices rendered per frame
  36002. */
  36003. getTotalVertices(): number;
  36004. /**
  36005. * Gets the performance counter for total vertices
  36006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36007. */
  36008. get totalVerticesPerfCounter(): PerfCounter;
  36009. /**
  36010. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36011. * @returns the total number of active indices rendered per frame
  36012. */
  36013. getActiveIndices(): number;
  36014. /**
  36015. * Gets the performance counter for active indices
  36016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36017. */
  36018. get totalActiveIndicesPerfCounter(): PerfCounter;
  36019. /**
  36020. * Gets the total number of active particles rendered per frame
  36021. * @returns the total number of active particles rendered per frame
  36022. */
  36023. getActiveParticles(): number;
  36024. /**
  36025. * Gets the performance counter for active particles
  36026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36027. */
  36028. get activeParticlesPerfCounter(): PerfCounter;
  36029. /**
  36030. * Gets the total number of active bones rendered per frame
  36031. * @returns the total number of active bones rendered per frame
  36032. */
  36033. getActiveBones(): number;
  36034. /**
  36035. * Gets the performance counter for active bones
  36036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36037. */
  36038. get activeBonesPerfCounter(): PerfCounter;
  36039. /**
  36040. * Gets the array of active meshes
  36041. * @returns an array of AbstractMesh
  36042. */
  36043. getActiveMeshes(): SmartArray<AbstractMesh>;
  36044. /**
  36045. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36046. * @returns a number
  36047. */
  36048. getAnimationRatio(): number;
  36049. /**
  36050. * Gets an unique Id for the current render phase
  36051. * @returns a number
  36052. */
  36053. getRenderId(): number;
  36054. /**
  36055. * Gets an unique Id for the current frame
  36056. * @returns a number
  36057. */
  36058. getFrameId(): number;
  36059. /** Call this function if you want to manually increment the render Id*/
  36060. incrementRenderId(): void;
  36061. private _createUbo;
  36062. /**
  36063. * Use this method to simulate a pointer move on a mesh
  36064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36067. * @returns the current scene
  36068. */
  36069. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36070. /**
  36071. * Use this method to simulate a pointer down on a mesh
  36072. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36073. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36074. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36075. * @returns the current scene
  36076. */
  36077. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36078. /**
  36079. * Use this method to simulate a pointer up on a mesh
  36080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36083. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36084. * @returns the current scene
  36085. */
  36086. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36087. /**
  36088. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36089. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36090. * @returns true if the pointer was captured
  36091. */
  36092. isPointerCaptured(pointerId?: number): boolean;
  36093. /**
  36094. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36095. * @param attachUp defines if you want to attach events to pointerup
  36096. * @param attachDown defines if you want to attach events to pointerdown
  36097. * @param attachMove defines if you want to attach events to pointermove
  36098. */
  36099. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36100. /** Detaches all event handlers*/
  36101. detachControl(): void;
  36102. /**
  36103. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36104. * Delay loaded resources are not taking in account
  36105. * @return true if all required resources are ready
  36106. */
  36107. isReady(): boolean;
  36108. /** Resets all cached information relative to material (including effect and visibility) */
  36109. resetCachedMaterial(): void;
  36110. /**
  36111. * Registers a function to be called before every frame render
  36112. * @param func defines the function to register
  36113. */
  36114. registerBeforeRender(func: () => void): void;
  36115. /**
  36116. * Unregisters a function called before every frame render
  36117. * @param func defines the function to unregister
  36118. */
  36119. unregisterBeforeRender(func: () => void): void;
  36120. /**
  36121. * Registers a function to be called after every frame render
  36122. * @param func defines the function to register
  36123. */
  36124. registerAfterRender(func: () => void): void;
  36125. /**
  36126. * Unregisters a function called after every frame render
  36127. * @param func defines the function to unregister
  36128. */
  36129. unregisterAfterRender(func: () => void): void;
  36130. private _executeOnceBeforeRender;
  36131. /**
  36132. * The provided function will run before render once and will be disposed afterwards.
  36133. * A timeout delay can be provided so that the function will be executed in N ms.
  36134. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36135. * @param func The function to be executed.
  36136. * @param timeout optional delay in ms
  36137. */
  36138. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36139. /** @hidden */
  36140. _addPendingData(data: any): void;
  36141. /** @hidden */
  36142. _removePendingData(data: any): void;
  36143. /**
  36144. * Returns the number of items waiting to be loaded
  36145. * @returns the number of items waiting to be loaded
  36146. */
  36147. getWaitingItemsCount(): number;
  36148. /**
  36149. * Returns a boolean indicating if the scene is still loading data
  36150. */
  36151. get isLoading(): boolean;
  36152. /**
  36153. * Registers a function to be executed when the scene is ready
  36154. * @param {Function} func - the function to be executed
  36155. */
  36156. executeWhenReady(func: () => void): void;
  36157. /**
  36158. * Returns a promise that resolves when the scene is ready
  36159. * @returns A promise that resolves when the scene is ready
  36160. */
  36161. whenReadyAsync(): Promise<void>;
  36162. /** @hidden */
  36163. _checkIsReady(): void;
  36164. /**
  36165. * Gets all animatable attached to the scene
  36166. */
  36167. get animatables(): Animatable[];
  36168. /**
  36169. * Resets the last animation time frame.
  36170. * Useful to override when animations start running when loading a scene for the first time.
  36171. */
  36172. resetLastAnimationTimeFrame(): void;
  36173. /**
  36174. * Gets the current view matrix
  36175. * @returns a Matrix
  36176. */
  36177. getViewMatrix(): Matrix;
  36178. /**
  36179. * Gets the current projection matrix
  36180. * @returns a Matrix
  36181. */
  36182. getProjectionMatrix(): Matrix;
  36183. /**
  36184. * Gets the current transform matrix
  36185. * @returns a Matrix made of View * Projection
  36186. */
  36187. getTransformMatrix(): Matrix;
  36188. /**
  36189. * Sets the current transform matrix
  36190. * @param viewL defines the View matrix to use
  36191. * @param projectionL defines the Projection matrix to use
  36192. * @param viewR defines the right View matrix to use (if provided)
  36193. * @param projectionR defines the right Projection matrix to use (if provided)
  36194. */
  36195. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36196. /**
  36197. * Gets the uniform buffer used to store scene data
  36198. * @returns a UniformBuffer
  36199. */
  36200. getSceneUniformBuffer(): UniformBuffer;
  36201. /**
  36202. * Gets an unique (relatively to the current scene) Id
  36203. * @returns an unique number for the scene
  36204. */
  36205. getUniqueId(): number;
  36206. /**
  36207. * Add a mesh to the list of scene's meshes
  36208. * @param newMesh defines the mesh to add
  36209. * @param recursive if all child meshes should also be added to the scene
  36210. */
  36211. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36212. /**
  36213. * Remove a mesh for the list of scene's meshes
  36214. * @param toRemove defines the mesh to remove
  36215. * @param recursive if all child meshes should also be removed from the scene
  36216. * @returns the index where the mesh was in the mesh list
  36217. */
  36218. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36219. /**
  36220. * Add a transform node to the list of scene's transform nodes
  36221. * @param newTransformNode defines the transform node to add
  36222. */
  36223. addTransformNode(newTransformNode: TransformNode): void;
  36224. /**
  36225. * Remove a transform node for the list of scene's transform nodes
  36226. * @param toRemove defines the transform node to remove
  36227. * @returns the index where the transform node was in the transform node list
  36228. */
  36229. removeTransformNode(toRemove: TransformNode): number;
  36230. /**
  36231. * Remove a skeleton for the list of scene's skeletons
  36232. * @param toRemove defines the skeleton to remove
  36233. * @returns the index where the skeleton was in the skeleton list
  36234. */
  36235. removeSkeleton(toRemove: Skeleton): number;
  36236. /**
  36237. * Remove a morph target for the list of scene's morph targets
  36238. * @param toRemove defines the morph target to remove
  36239. * @returns the index where the morph target was in the morph target list
  36240. */
  36241. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36242. /**
  36243. * Remove a light for the list of scene's lights
  36244. * @param toRemove defines the light to remove
  36245. * @returns the index where the light was in the light list
  36246. */
  36247. removeLight(toRemove: Light): number;
  36248. /**
  36249. * Remove a camera for the list of scene's cameras
  36250. * @param toRemove defines the camera to remove
  36251. * @returns the index where the camera was in the camera list
  36252. */
  36253. removeCamera(toRemove: Camera): number;
  36254. /**
  36255. * Remove a particle system for the list of scene's particle systems
  36256. * @param toRemove defines the particle system to remove
  36257. * @returns the index where the particle system was in the particle system list
  36258. */
  36259. removeParticleSystem(toRemove: IParticleSystem): number;
  36260. /**
  36261. * Remove a animation for the list of scene's animations
  36262. * @param toRemove defines the animation to remove
  36263. * @returns the index where the animation was in the animation list
  36264. */
  36265. removeAnimation(toRemove: Animation): number;
  36266. /**
  36267. * Will stop the animation of the given target
  36268. * @param target - the target
  36269. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36270. * @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)
  36271. */
  36272. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36273. /**
  36274. * Removes the given animation group from this scene.
  36275. * @param toRemove The animation group to remove
  36276. * @returns The index of the removed animation group
  36277. */
  36278. removeAnimationGroup(toRemove: AnimationGroup): number;
  36279. /**
  36280. * Removes the given multi-material from this scene.
  36281. * @param toRemove The multi-material to remove
  36282. * @returns The index of the removed multi-material
  36283. */
  36284. removeMultiMaterial(toRemove: MultiMaterial): number;
  36285. /**
  36286. * Removes the given material from this scene.
  36287. * @param toRemove The material to remove
  36288. * @returns The index of the removed material
  36289. */
  36290. removeMaterial(toRemove: Material): number;
  36291. /**
  36292. * Removes the given action manager from this scene.
  36293. * @param toRemove The action manager to remove
  36294. * @returns The index of the removed action manager
  36295. */
  36296. removeActionManager(toRemove: AbstractActionManager): number;
  36297. /**
  36298. * Removes the given texture from this scene.
  36299. * @param toRemove The texture to remove
  36300. * @returns The index of the removed texture
  36301. */
  36302. removeTexture(toRemove: BaseTexture): number;
  36303. /**
  36304. * Adds the given light to this scene
  36305. * @param newLight The light to add
  36306. */
  36307. addLight(newLight: Light): void;
  36308. /**
  36309. * Sorts the list list based on light priorities
  36310. */
  36311. sortLightsByPriority(): void;
  36312. /**
  36313. * Adds the given camera to this scene
  36314. * @param newCamera The camera to add
  36315. */
  36316. addCamera(newCamera: Camera): void;
  36317. /**
  36318. * Adds the given skeleton to this scene
  36319. * @param newSkeleton The skeleton to add
  36320. */
  36321. addSkeleton(newSkeleton: Skeleton): void;
  36322. /**
  36323. * Adds the given particle system to this scene
  36324. * @param newParticleSystem The particle system to add
  36325. */
  36326. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36327. /**
  36328. * Adds the given animation to this scene
  36329. * @param newAnimation The animation to add
  36330. */
  36331. addAnimation(newAnimation: Animation): void;
  36332. /**
  36333. * Adds the given animation group to this scene.
  36334. * @param newAnimationGroup The animation group to add
  36335. */
  36336. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36337. /**
  36338. * Adds the given multi-material to this scene
  36339. * @param newMultiMaterial The multi-material to add
  36340. */
  36341. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36342. /**
  36343. * Adds the given material to this scene
  36344. * @param newMaterial The material to add
  36345. */
  36346. addMaterial(newMaterial: Material): void;
  36347. /**
  36348. * Adds the given morph target to this scene
  36349. * @param newMorphTargetManager The morph target to add
  36350. */
  36351. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36352. /**
  36353. * Adds the given geometry to this scene
  36354. * @param newGeometry The geometry to add
  36355. */
  36356. addGeometry(newGeometry: Geometry): void;
  36357. /**
  36358. * Adds the given action manager to this scene
  36359. * @param newActionManager The action manager to add
  36360. */
  36361. addActionManager(newActionManager: AbstractActionManager): void;
  36362. /**
  36363. * Adds the given texture to this scene.
  36364. * @param newTexture The texture to add
  36365. */
  36366. addTexture(newTexture: BaseTexture): void;
  36367. /**
  36368. * Switch active camera
  36369. * @param newCamera defines the new active camera
  36370. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36371. */
  36372. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36373. /**
  36374. * sets the active camera of the scene using its ID
  36375. * @param id defines the camera's ID
  36376. * @return the new active camera or null if none found.
  36377. */
  36378. setActiveCameraByID(id: string): Nullable<Camera>;
  36379. /**
  36380. * sets the active camera of the scene using its name
  36381. * @param name defines the camera's name
  36382. * @returns the new active camera or null if none found.
  36383. */
  36384. setActiveCameraByName(name: string): Nullable<Camera>;
  36385. /**
  36386. * get an animation group using its name
  36387. * @param name defines the material's name
  36388. * @return the animation group or null if none found.
  36389. */
  36390. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36391. /**
  36392. * Get a material using its unique id
  36393. * @param uniqueId defines the material's unique id
  36394. * @return the material or null if none found.
  36395. */
  36396. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36397. /**
  36398. * get a material using its id
  36399. * @param id defines the material's ID
  36400. * @return the material or null if none found.
  36401. */
  36402. getMaterialByID(id: string): Nullable<Material>;
  36403. /**
  36404. * Gets a the last added material using a given id
  36405. * @param id defines the material's ID
  36406. * @return the last material with the given id or null if none found.
  36407. */
  36408. getLastMaterialByID(id: string): Nullable<Material>;
  36409. /**
  36410. * Gets a material using its name
  36411. * @param name defines the material's name
  36412. * @return the material or null if none found.
  36413. */
  36414. getMaterialByName(name: string): Nullable<Material>;
  36415. /**
  36416. * Get a texture using its unique id
  36417. * @param uniqueId defines the texture's unique id
  36418. * @return the texture or null if none found.
  36419. */
  36420. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36421. /**
  36422. * Gets a camera using its id
  36423. * @param id defines the id to look for
  36424. * @returns the camera or null if not found
  36425. */
  36426. getCameraByID(id: string): Nullable<Camera>;
  36427. /**
  36428. * Gets a camera using its unique id
  36429. * @param uniqueId defines the unique id to look for
  36430. * @returns the camera or null if not found
  36431. */
  36432. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36433. /**
  36434. * Gets a camera using its name
  36435. * @param name defines the camera's name
  36436. * @return the camera or null if none found.
  36437. */
  36438. getCameraByName(name: string): Nullable<Camera>;
  36439. /**
  36440. * Gets a bone using its id
  36441. * @param id defines the bone's id
  36442. * @return the bone or null if not found
  36443. */
  36444. getBoneByID(id: string): Nullable<Bone>;
  36445. /**
  36446. * Gets a bone using its id
  36447. * @param name defines the bone's name
  36448. * @return the bone or null if not found
  36449. */
  36450. getBoneByName(name: string): Nullable<Bone>;
  36451. /**
  36452. * Gets a light node using its name
  36453. * @param name defines the the light's name
  36454. * @return the light or null if none found.
  36455. */
  36456. getLightByName(name: string): Nullable<Light>;
  36457. /**
  36458. * Gets a light node using its id
  36459. * @param id defines the light's id
  36460. * @return the light or null if none found.
  36461. */
  36462. getLightByID(id: string): Nullable<Light>;
  36463. /**
  36464. * Gets a light node using its scene-generated unique ID
  36465. * @param uniqueId defines the light's unique id
  36466. * @return the light or null if none found.
  36467. */
  36468. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36469. /**
  36470. * Gets a particle system by id
  36471. * @param id defines the particle system id
  36472. * @return the corresponding system or null if none found
  36473. */
  36474. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36475. /**
  36476. * Gets a geometry using its ID
  36477. * @param id defines the geometry's id
  36478. * @return the geometry or null if none found.
  36479. */
  36480. getGeometryByID(id: string): Nullable<Geometry>;
  36481. private _getGeometryByUniqueID;
  36482. /**
  36483. * Add a new geometry to this scene
  36484. * @param geometry defines the geometry to be added to the scene.
  36485. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36486. * @return a boolean defining if the geometry was added or not
  36487. */
  36488. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36489. /**
  36490. * Removes an existing geometry
  36491. * @param geometry defines the geometry to be removed from the scene
  36492. * @return a boolean defining if the geometry was removed or not
  36493. */
  36494. removeGeometry(geometry: Geometry): boolean;
  36495. /**
  36496. * Gets the list of geometries attached to the scene
  36497. * @returns an array of Geometry
  36498. */
  36499. getGeometries(): Geometry[];
  36500. /**
  36501. * Gets the first added mesh found of a given ID
  36502. * @param id defines the id to search for
  36503. * @return the mesh found or null if not found at all
  36504. */
  36505. getMeshByID(id: string): Nullable<AbstractMesh>;
  36506. /**
  36507. * Gets a list of meshes using their id
  36508. * @param id defines the id to search for
  36509. * @returns a list of meshes
  36510. */
  36511. getMeshesByID(id: string): Array<AbstractMesh>;
  36512. /**
  36513. * Gets the first added transform node found of a given ID
  36514. * @param id defines the id to search for
  36515. * @return the found transform node or null if not found at all.
  36516. */
  36517. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36518. /**
  36519. * Gets a transform node with its auto-generated unique id
  36520. * @param uniqueId efines the unique id to search for
  36521. * @return the found transform node or null if not found at all.
  36522. */
  36523. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36524. /**
  36525. * Gets a list of transform nodes using their id
  36526. * @param id defines the id to search for
  36527. * @returns a list of transform nodes
  36528. */
  36529. getTransformNodesByID(id: string): Array<TransformNode>;
  36530. /**
  36531. * Gets a mesh with its auto-generated unique id
  36532. * @param uniqueId defines the unique id to search for
  36533. * @return the found mesh or null if not found at all.
  36534. */
  36535. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36536. /**
  36537. * Gets a the last added mesh using a given id
  36538. * @param id defines the id to search for
  36539. * @return the found mesh or null if not found at all.
  36540. */
  36541. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36542. /**
  36543. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36544. * @param id defines the id to search for
  36545. * @return the found node or null if not found at all
  36546. */
  36547. getLastEntryByID(id: string): Nullable<Node>;
  36548. /**
  36549. * Gets a node (Mesh, Camera, Light) using a given id
  36550. * @param id defines the id to search for
  36551. * @return the found node or null if not found at all
  36552. */
  36553. getNodeByID(id: string): Nullable<Node>;
  36554. /**
  36555. * Gets a node (Mesh, Camera, Light) using a given name
  36556. * @param name defines the name to search for
  36557. * @return the found node or null if not found at all.
  36558. */
  36559. getNodeByName(name: string): Nullable<Node>;
  36560. /**
  36561. * Gets a mesh using a given name
  36562. * @param name defines the name to search for
  36563. * @return the found mesh or null if not found at all.
  36564. */
  36565. getMeshByName(name: string): Nullable<AbstractMesh>;
  36566. /**
  36567. * Gets a transform node using a given name
  36568. * @param name defines the name to search for
  36569. * @return the found transform node or null if not found at all.
  36570. */
  36571. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36572. /**
  36573. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36574. * @param id defines the id to search for
  36575. * @return the found skeleton or null if not found at all.
  36576. */
  36577. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36578. /**
  36579. * Gets a skeleton using a given auto generated unique id
  36580. * @param uniqueId defines the unique id to search for
  36581. * @return the found skeleton or null if not found at all.
  36582. */
  36583. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36584. /**
  36585. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36586. * @param id defines the id to search for
  36587. * @return the found skeleton or null if not found at all.
  36588. */
  36589. getSkeletonById(id: string): Nullable<Skeleton>;
  36590. /**
  36591. * Gets a skeleton using a given name
  36592. * @param name defines the name to search for
  36593. * @return the found skeleton or null if not found at all.
  36594. */
  36595. getSkeletonByName(name: string): Nullable<Skeleton>;
  36596. /**
  36597. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36598. * @param id defines the id to search for
  36599. * @return the found morph target manager or null if not found at all.
  36600. */
  36601. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36602. /**
  36603. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36604. * @param id defines the id to search for
  36605. * @return the found morph target or null if not found at all.
  36606. */
  36607. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36608. /**
  36609. * Gets a boolean indicating if the given mesh is active
  36610. * @param mesh defines the mesh to look for
  36611. * @returns true if the mesh is in the active list
  36612. */
  36613. isActiveMesh(mesh: AbstractMesh): boolean;
  36614. /**
  36615. * Return a unique id as a string which can serve as an identifier for the scene
  36616. */
  36617. get uid(): string;
  36618. /**
  36619. * Add an externaly attached data from its key.
  36620. * This method call will fail and return false, if such key already exists.
  36621. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36622. * @param key the unique key that identifies the data
  36623. * @param data the data object to associate to the key for this Engine instance
  36624. * @return true if no such key were already present and the data was added successfully, false otherwise
  36625. */
  36626. addExternalData<T>(key: string, data: T): boolean;
  36627. /**
  36628. * Get an externaly attached data from its key
  36629. * @param key the unique key that identifies the data
  36630. * @return the associated data, if present (can be null), or undefined if not present
  36631. */
  36632. getExternalData<T>(key: string): Nullable<T>;
  36633. /**
  36634. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36635. * @param key the unique key that identifies the data
  36636. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36637. * @return the associated data, can be null if the factory returned null.
  36638. */
  36639. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36640. /**
  36641. * Remove an externaly attached data from the Engine instance
  36642. * @param key the unique key that identifies the data
  36643. * @return true if the data was successfully removed, false if it doesn't exist
  36644. */
  36645. removeExternalData(key: string): boolean;
  36646. private _evaluateSubMesh;
  36647. /**
  36648. * Clear the processed materials smart array preventing retention point in material dispose.
  36649. */
  36650. freeProcessedMaterials(): void;
  36651. private _preventFreeActiveMeshesAndRenderingGroups;
  36652. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36653. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36654. * when disposing several meshes in a row or a hierarchy of meshes.
  36655. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36656. */
  36657. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36658. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36659. /**
  36660. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36661. */
  36662. freeActiveMeshes(): void;
  36663. /**
  36664. * Clear the info related to rendering groups preventing retention points during dispose.
  36665. */
  36666. freeRenderingGroups(): void;
  36667. /** @hidden */
  36668. _isInIntermediateRendering(): boolean;
  36669. /**
  36670. * Lambda returning the list of potentially active meshes.
  36671. */
  36672. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36673. /**
  36674. * Lambda returning the list of potentially active sub meshes.
  36675. */
  36676. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36677. /**
  36678. * Lambda returning the list of potentially intersecting sub meshes.
  36679. */
  36680. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36681. /**
  36682. * Lambda returning the list of potentially colliding sub meshes.
  36683. */
  36684. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36685. private _activeMeshesFrozen;
  36686. private _skipEvaluateActiveMeshesCompletely;
  36687. /**
  36688. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36689. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36690. * @returns the current scene
  36691. */
  36692. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36693. /**
  36694. * Use this function to restart evaluating active meshes on every frame
  36695. * @returns the current scene
  36696. */
  36697. unfreezeActiveMeshes(): Scene;
  36698. private _evaluateActiveMeshes;
  36699. private _activeMesh;
  36700. /**
  36701. * Update the transform matrix to update from the current active camera
  36702. * @param force defines a boolean used to force the update even if cache is up to date
  36703. */
  36704. updateTransformMatrix(force?: boolean): void;
  36705. private _bindFrameBuffer;
  36706. /** @hidden */
  36707. _allowPostProcessClearColor: boolean;
  36708. /** @hidden */
  36709. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36710. private _processSubCameras;
  36711. private _checkIntersections;
  36712. /** @hidden */
  36713. _advancePhysicsEngineStep(step: number): void;
  36714. /**
  36715. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36716. */
  36717. getDeterministicFrameTime: () => number;
  36718. /** @hidden */
  36719. _animate(): void;
  36720. /** Execute all animations (for a frame) */
  36721. animate(): void;
  36722. /**
  36723. * Render the scene
  36724. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36725. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36726. */
  36727. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36728. /**
  36729. * Freeze all materials
  36730. * A frozen material will not be updatable but should be faster to render
  36731. */
  36732. freezeMaterials(): void;
  36733. /**
  36734. * Unfreeze all materials
  36735. * A frozen material will not be updatable but should be faster to render
  36736. */
  36737. unfreezeMaterials(): void;
  36738. /**
  36739. * Releases all held ressources
  36740. */
  36741. dispose(): void;
  36742. /**
  36743. * Gets if the scene is already disposed
  36744. */
  36745. get isDisposed(): boolean;
  36746. /**
  36747. * Call this function to reduce memory footprint of the scene.
  36748. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36749. */
  36750. clearCachedVertexData(): void;
  36751. /**
  36752. * This function will remove the local cached buffer data from texture.
  36753. * It will save memory but will prevent the texture from being rebuilt
  36754. */
  36755. cleanCachedTextureBuffer(): void;
  36756. /**
  36757. * Get the world extend vectors with an optional filter
  36758. *
  36759. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36760. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36761. */
  36762. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36763. min: Vector3;
  36764. max: Vector3;
  36765. };
  36766. /**
  36767. * Creates a ray that can be used to pick in the scene
  36768. * @param x defines the x coordinate of the origin (on-screen)
  36769. * @param y defines the y coordinate of the origin (on-screen)
  36770. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36771. * @param camera defines the camera to use for the picking
  36772. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36773. * @returns a Ray
  36774. */
  36775. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36776. /**
  36777. * Creates a ray that can be used to pick in the scene
  36778. * @param x defines the x coordinate of the origin (on-screen)
  36779. * @param y defines the y coordinate of the origin (on-screen)
  36780. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36781. * @param result defines the ray where to store the picking ray
  36782. * @param camera defines the camera to use for the picking
  36783. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36784. * @returns the current scene
  36785. */
  36786. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36787. /**
  36788. * Creates a ray that can be used to pick in the scene
  36789. * @param x defines the x coordinate of the origin (on-screen)
  36790. * @param y defines the y coordinate of the origin (on-screen)
  36791. * @param camera defines the camera to use for the picking
  36792. * @returns a Ray
  36793. */
  36794. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36795. /**
  36796. * Creates a ray that can be used to pick in the scene
  36797. * @param x defines the x coordinate of the origin (on-screen)
  36798. * @param y defines the y coordinate of the origin (on-screen)
  36799. * @param result defines the ray where to store the picking ray
  36800. * @param camera defines the camera to use for the picking
  36801. * @returns the current scene
  36802. */
  36803. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36804. /** Launch a ray to try to pick a mesh in the scene
  36805. * @param x position on screen
  36806. * @param y position on screen
  36807. * @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
  36808. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36809. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36810. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36811. * @returns a PickingInfo
  36812. */
  36813. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36814. /** Use the given ray to pick a mesh in the scene
  36815. * @param ray The ray to use to pick meshes
  36816. * @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
  36817. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36818. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36819. * @returns a PickingInfo
  36820. */
  36821. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36822. /**
  36823. * Launch a ray to try to pick a mesh in the scene
  36824. * @param x X position on screen
  36825. * @param y Y position on screen
  36826. * @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
  36827. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36828. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36829. * @returns an array of PickingInfo
  36830. */
  36831. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36832. /**
  36833. * Launch a ray to try to pick a mesh in the scene
  36834. * @param ray Ray to use
  36835. * @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
  36836. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36837. * @returns an array of PickingInfo
  36838. */
  36839. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36840. /**
  36841. * Force the value of meshUnderPointer
  36842. * @param mesh defines the mesh to use
  36843. */
  36844. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36845. /**
  36846. * Gets the mesh under the pointer
  36847. * @returns a Mesh or null if no mesh is under the pointer
  36848. */
  36849. getPointerOverMesh(): Nullable<AbstractMesh>;
  36850. /** @hidden */
  36851. _rebuildGeometries(): void;
  36852. /** @hidden */
  36853. _rebuildTextures(): void;
  36854. private _getByTags;
  36855. /**
  36856. * Get a list of meshes by tags
  36857. * @param tagsQuery defines the tags query to use
  36858. * @param forEach defines a predicate used to filter results
  36859. * @returns an array of Mesh
  36860. */
  36861. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36862. /**
  36863. * Get a list of cameras by tags
  36864. * @param tagsQuery defines the tags query to use
  36865. * @param forEach defines a predicate used to filter results
  36866. * @returns an array of Camera
  36867. */
  36868. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36869. /**
  36870. * Get a list of lights by tags
  36871. * @param tagsQuery defines the tags query to use
  36872. * @param forEach defines a predicate used to filter results
  36873. * @returns an array of Light
  36874. */
  36875. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36876. /**
  36877. * Get a list of materials by tags
  36878. * @param tagsQuery defines the tags query to use
  36879. * @param forEach defines a predicate used to filter results
  36880. * @returns an array of Material
  36881. */
  36882. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36883. /**
  36884. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36885. * This allowed control for front to back rendering or reversly depending of the special needs.
  36886. *
  36887. * @param renderingGroupId The rendering group id corresponding to its index
  36888. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36889. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36890. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36891. */
  36892. 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;
  36893. /**
  36894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36895. *
  36896. * @param renderingGroupId The rendering group id corresponding to its index
  36897. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36898. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36899. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36900. */
  36901. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36902. /**
  36903. * Gets the current auto clear configuration for one rendering group of the rendering
  36904. * manager.
  36905. * @param index the rendering group index to get the information for
  36906. * @returns The auto clear setup for the requested rendering group
  36907. */
  36908. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36909. private _blockMaterialDirtyMechanism;
  36910. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36911. get blockMaterialDirtyMechanism(): boolean;
  36912. set blockMaterialDirtyMechanism(value: boolean);
  36913. /**
  36914. * Will flag all materials as dirty to trigger new shader compilation
  36915. * @param flag defines the flag used to specify which material part must be marked as dirty
  36916. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36917. */
  36918. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36919. /** @hidden */
  36920. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36921. /** @hidden */
  36922. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36923. /** @hidden */
  36924. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36925. /** @hidden */
  36926. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36927. /** @hidden */
  36928. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36929. /** @hidden */
  36930. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36931. }
  36932. }
  36933. declare module BABYLON {
  36934. /**
  36935. * Set of assets to keep when moving a scene into an asset container.
  36936. */
  36937. export class KeepAssets extends AbstractScene {
  36938. }
  36939. /**
  36940. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36941. */
  36942. export class InstantiatedEntries {
  36943. /**
  36944. * List of new root nodes (eg. nodes with no parent)
  36945. */
  36946. rootNodes: TransformNode[];
  36947. /**
  36948. * List of new skeletons
  36949. */
  36950. skeletons: Skeleton[];
  36951. /**
  36952. * List of new animation groups
  36953. */
  36954. animationGroups: AnimationGroup[];
  36955. }
  36956. /**
  36957. * Container with a set of assets that can be added or removed from a scene.
  36958. */
  36959. export class AssetContainer extends AbstractScene {
  36960. /**
  36961. * The scene the AssetContainer belongs to.
  36962. */
  36963. scene: Scene;
  36964. /**
  36965. * Instantiates an AssetContainer.
  36966. * @param scene The scene the AssetContainer belongs to.
  36967. */
  36968. constructor(scene: Scene);
  36969. /**
  36970. * Instantiate or clone all meshes and add the new ones to the scene.
  36971. * Skeletons and animation groups will all be cloned
  36972. * @param nameFunction defines an optional function used to get new names for clones
  36973. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36974. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36975. */
  36976. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36977. /**
  36978. * Adds all the assets from the container to the scene.
  36979. */
  36980. addAllToScene(): void;
  36981. /**
  36982. * Removes all the assets in the container from the scene
  36983. */
  36984. removeAllFromScene(): void;
  36985. /**
  36986. * Disposes all the assets in the container
  36987. */
  36988. dispose(): void;
  36989. private _moveAssets;
  36990. /**
  36991. * Removes all the assets contained in the scene and adds them to the container.
  36992. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36993. */
  36994. moveAllFromScene(keepAssets?: KeepAssets): void;
  36995. /**
  36996. * 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.
  36997. * @returns the root mesh
  36998. */
  36999. createRootMesh(): Mesh;
  37000. /**
  37001. * Merge animations from this asset container into a scene
  37002. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37003. * @param animatables set of animatables to retarget to a node from the scene
  37004. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37005. */
  37006. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37007. }
  37008. }
  37009. declare module BABYLON {
  37010. /**
  37011. * Defines how the parser contract is defined.
  37012. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37013. */
  37014. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37015. /**
  37016. * Defines how the individual parser contract is defined.
  37017. * These parser can parse an individual asset
  37018. */
  37019. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37020. /**
  37021. * Base class of the scene acting as a container for the different elements composing a scene.
  37022. * This class is dynamically extended by the different components of the scene increasing
  37023. * flexibility and reducing coupling
  37024. */
  37025. export abstract class AbstractScene {
  37026. /**
  37027. * Stores the list of available parsers in the application.
  37028. */
  37029. private static _BabylonFileParsers;
  37030. /**
  37031. * Stores the list of available individual parsers in the application.
  37032. */
  37033. private static _IndividualBabylonFileParsers;
  37034. /**
  37035. * Adds a parser in the list of available ones
  37036. * @param name Defines the name of the parser
  37037. * @param parser Defines the parser to add
  37038. */
  37039. static AddParser(name: string, parser: BabylonFileParser): void;
  37040. /**
  37041. * Gets a general parser from the list of avaialble ones
  37042. * @param name Defines the name of the parser
  37043. * @returns the requested parser or null
  37044. */
  37045. static GetParser(name: string): Nullable<BabylonFileParser>;
  37046. /**
  37047. * Adds n individual parser in the list of available ones
  37048. * @param name Defines the name of the parser
  37049. * @param parser Defines the parser to add
  37050. */
  37051. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37052. /**
  37053. * Gets an individual parser from the list of avaialble ones
  37054. * @param name Defines the name of the parser
  37055. * @returns the requested parser or null
  37056. */
  37057. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37058. /**
  37059. * Parser json data and populate both a scene and its associated container object
  37060. * @param jsonData Defines the data to parse
  37061. * @param scene Defines the scene to parse the data for
  37062. * @param container Defines the container attached to the parsing sequence
  37063. * @param rootUrl Defines the root url of the data
  37064. */
  37065. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37066. /**
  37067. * Gets the list of root nodes (ie. nodes with no parent)
  37068. */
  37069. rootNodes: Node[];
  37070. /** All of the cameras added to this scene
  37071. * @see http://doc.babylonjs.com/babylon101/cameras
  37072. */
  37073. cameras: Camera[];
  37074. /**
  37075. * All of the lights added to this scene
  37076. * @see http://doc.babylonjs.com/babylon101/lights
  37077. */
  37078. lights: Light[];
  37079. /**
  37080. * All of the (abstract) meshes added to this scene
  37081. */
  37082. meshes: AbstractMesh[];
  37083. /**
  37084. * The list of skeletons added to the scene
  37085. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37086. */
  37087. skeletons: Skeleton[];
  37088. /**
  37089. * All of the particle systems added to this scene
  37090. * @see http://doc.babylonjs.com/babylon101/particles
  37091. */
  37092. particleSystems: IParticleSystem[];
  37093. /**
  37094. * Gets a list of Animations associated with the scene
  37095. */
  37096. animations: Animation[];
  37097. /**
  37098. * All of the animation groups added to this scene
  37099. * @see http://doc.babylonjs.com/how_to/group
  37100. */
  37101. animationGroups: AnimationGroup[];
  37102. /**
  37103. * All of the multi-materials added to this scene
  37104. * @see http://doc.babylonjs.com/how_to/multi_materials
  37105. */
  37106. multiMaterials: MultiMaterial[];
  37107. /**
  37108. * All of the materials added to this scene
  37109. * In the context of a Scene, it is not supposed to be modified manually.
  37110. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37111. * Note also that the order of the Material within the array is not significant and might change.
  37112. * @see http://doc.babylonjs.com/babylon101/materials
  37113. */
  37114. materials: Material[];
  37115. /**
  37116. * The list of morph target managers added to the scene
  37117. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37118. */
  37119. morphTargetManagers: MorphTargetManager[];
  37120. /**
  37121. * The list of geometries used in the scene.
  37122. */
  37123. geometries: Geometry[];
  37124. /**
  37125. * All of the tranform nodes added to this scene
  37126. * In the context of a Scene, it is not supposed to be modified manually.
  37127. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37128. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37129. * @see http://doc.babylonjs.com/how_to/transformnode
  37130. */
  37131. transformNodes: TransformNode[];
  37132. /**
  37133. * ActionManagers available on the scene.
  37134. */
  37135. actionManagers: AbstractActionManager[];
  37136. /**
  37137. * Textures to keep.
  37138. */
  37139. textures: BaseTexture[];
  37140. /**
  37141. * Environment texture for the scene
  37142. */
  37143. environmentTexture: Nullable<BaseTexture>;
  37144. /**
  37145. * @returns all meshes, lights, cameras, transformNodes and bones
  37146. */
  37147. getNodes(): Array<Node>;
  37148. }
  37149. }
  37150. declare module BABYLON {
  37151. /**
  37152. * Interface used to define options for Sound class
  37153. */
  37154. export interface ISoundOptions {
  37155. /**
  37156. * Does the sound autoplay once loaded.
  37157. */
  37158. autoplay?: boolean;
  37159. /**
  37160. * Does the sound loop after it finishes playing once.
  37161. */
  37162. loop?: boolean;
  37163. /**
  37164. * Sound's volume
  37165. */
  37166. volume?: number;
  37167. /**
  37168. * Is it a spatial sound?
  37169. */
  37170. spatialSound?: boolean;
  37171. /**
  37172. * Maximum distance to hear that sound
  37173. */
  37174. maxDistance?: number;
  37175. /**
  37176. * Uses user defined attenuation function
  37177. */
  37178. useCustomAttenuation?: boolean;
  37179. /**
  37180. * Define the roll off factor of spatial sounds.
  37181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37182. */
  37183. rolloffFactor?: number;
  37184. /**
  37185. * Define the reference distance the sound should be heard perfectly.
  37186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37187. */
  37188. refDistance?: number;
  37189. /**
  37190. * Define the distance attenuation model the sound will follow.
  37191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37192. */
  37193. distanceModel?: string;
  37194. /**
  37195. * Defines the playback speed (1 by default)
  37196. */
  37197. playbackRate?: number;
  37198. /**
  37199. * Defines if the sound is from a streaming source
  37200. */
  37201. streaming?: boolean;
  37202. /**
  37203. * Defines an optional length (in seconds) inside the sound file
  37204. */
  37205. length?: number;
  37206. /**
  37207. * Defines an optional offset (in seconds) inside the sound file
  37208. */
  37209. offset?: number;
  37210. /**
  37211. * If true, URLs will not be required to state the audio file codec to use.
  37212. */
  37213. skipCodecCheck?: boolean;
  37214. }
  37215. /**
  37216. * Defines a sound that can be played in the application.
  37217. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37219. */
  37220. export class Sound {
  37221. /**
  37222. * The name of the sound in the scene.
  37223. */
  37224. name: string;
  37225. /**
  37226. * Does the sound autoplay once loaded.
  37227. */
  37228. autoplay: boolean;
  37229. /**
  37230. * Does the sound loop after it finishes playing once.
  37231. */
  37232. loop: boolean;
  37233. /**
  37234. * Does the sound use a custom attenuation curve to simulate the falloff
  37235. * happening when the source gets further away from the camera.
  37236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37237. */
  37238. useCustomAttenuation: boolean;
  37239. /**
  37240. * The sound track id this sound belongs to.
  37241. */
  37242. soundTrackId: number;
  37243. /**
  37244. * Is this sound currently played.
  37245. */
  37246. isPlaying: boolean;
  37247. /**
  37248. * Is this sound currently paused.
  37249. */
  37250. isPaused: boolean;
  37251. /**
  37252. * Does this sound enables spatial sound.
  37253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37254. */
  37255. spatialSound: boolean;
  37256. /**
  37257. * Define the reference distance the sound should be heard perfectly.
  37258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37259. */
  37260. refDistance: number;
  37261. /**
  37262. * Define the roll off factor of spatial sounds.
  37263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37264. */
  37265. rolloffFactor: number;
  37266. /**
  37267. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37269. */
  37270. maxDistance: number;
  37271. /**
  37272. * Define the distance attenuation model the sound will follow.
  37273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37274. */
  37275. distanceModel: string;
  37276. /**
  37277. * @hidden
  37278. * Back Compat
  37279. **/
  37280. onended: () => any;
  37281. /**
  37282. * Observable event when the current playing sound finishes.
  37283. */
  37284. onEndedObservable: Observable<Sound>;
  37285. private _panningModel;
  37286. private _playbackRate;
  37287. private _streaming;
  37288. private _startTime;
  37289. private _startOffset;
  37290. private _position;
  37291. /** @hidden */
  37292. _positionInEmitterSpace: boolean;
  37293. private _localDirection;
  37294. private _volume;
  37295. private _isReadyToPlay;
  37296. private _isDirectional;
  37297. private _readyToPlayCallback;
  37298. private _audioBuffer;
  37299. private _soundSource;
  37300. private _streamingSource;
  37301. private _soundPanner;
  37302. private _soundGain;
  37303. private _inputAudioNode;
  37304. private _outputAudioNode;
  37305. private _coneInnerAngle;
  37306. private _coneOuterAngle;
  37307. private _coneOuterGain;
  37308. private _scene;
  37309. private _connectedTransformNode;
  37310. private _customAttenuationFunction;
  37311. private _registerFunc;
  37312. private _isOutputConnected;
  37313. private _htmlAudioElement;
  37314. private _urlType;
  37315. private _length?;
  37316. private _offset?;
  37317. /** @hidden */
  37318. static _SceneComponentInitialization: (scene: Scene) => void;
  37319. /**
  37320. * Create a sound and attach it to a scene
  37321. * @param name Name of your sound
  37322. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37323. * @param scene defines the scene the sound belongs to
  37324. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37325. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37326. */
  37327. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37328. /**
  37329. * Release the sound and its associated resources
  37330. */
  37331. dispose(): void;
  37332. /**
  37333. * Gets if the sounds is ready to be played or not.
  37334. * @returns true if ready, otherwise false
  37335. */
  37336. isReady(): boolean;
  37337. private _soundLoaded;
  37338. /**
  37339. * Sets the data of the sound from an audiobuffer
  37340. * @param audioBuffer The audioBuffer containing the data
  37341. */
  37342. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37343. /**
  37344. * Updates the current sounds options such as maxdistance, loop...
  37345. * @param options A JSON object containing values named as the object properties
  37346. */
  37347. updateOptions(options: ISoundOptions): void;
  37348. private _createSpatialParameters;
  37349. private _updateSpatialParameters;
  37350. /**
  37351. * Switch the panning model to HRTF:
  37352. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37354. */
  37355. switchPanningModelToHRTF(): void;
  37356. /**
  37357. * Switch the panning model to Equal Power:
  37358. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37360. */
  37361. switchPanningModelToEqualPower(): void;
  37362. private _switchPanningModel;
  37363. /**
  37364. * Connect this sound to a sound track audio node like gain...
  37365. * @param soundTrackAudioNode the sound track audio node to connect to
  37366. */
  37367. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37368. /**
  37369. * Transform this sound into a directional source
  37370. * @param coneInnerAngle Size of the inner cone in degree
  37371. * @param coneOuterAngle Size of the outer cone in degree
  37372. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37373. */
  37374. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37375. /**
  37376. * Gets or sets the inner angle for the directional cone.
  37377. */
  37378. get directionalConeInnerAngle(): number;
  37379. /**
  37380. * Gets or sets the inner angle for the directional cone.
  37381. */
  37382. set directionalConeInnerAngle(value: number);
  37383. /**
  37384. * Gets or sets the outer angle for the directional cone.
  37385. */
  37386. get directionalConeOuterAngle(): number;
  37387. /**
  37388. * Gets or sets the outer angle for the directional cone.
  37389. */
  37390. set directionalConeOuterAngle(value: number);
  37391. /**
  37392. * Sets the position of the emitter if spatial sound is enabled
  37393. * @param newPosition Defines the new posisiton
  37394. */
  37395. setPosition(newPosition: Vector3): void;
  37396. /**
  37397. * Sets the local direction of the emitter if spatial sound is enabled
  37398. * @param newLocalDirection Defines the new local direction
  37399. */
  37400. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37401. private _updateDirection;
  37402. /** @hidden */
  37403. updateDistanceFromListener(): void;
  37404. /**
  37405. * Sets a new custom attenuation function for the sound.
  37406. * @param callback Defines the function used for the attenuation
  37407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37408. */
  37409. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37410. /**
  37411. * Play the sound
  37412. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37413. * @param offset (optional) Start the sound at a specific time in seconds
  37414. * @param length (optional) Sound duration (in seconds)
  37415. */
  37416. play(time?: number, offset?: number, length?: number): void;
  37417. private _onended;
  37418. /**
  37419. * Stop the sound
  37420. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37421. */
  37422. stop(time?: number): void;
  37423. /**
  37424. * Put the sound in pause
  37425. */
  37426. pause(): void;
  37427. /**
  37428. * Sets a dedicated volume for this sounds
  37429. * @param newVolume Define the new volume of the sound
  37430. * @param time Define time for gradual change to new volume
  37431. */
  37432. setVolume(newVolume: number, time?: number): void;
  37433. /**
  37434. * Set the sound play back rate
  37435. * @param newPlaybackRate Define the playback rate the sound should be played at
  37436. */
  37437. setPlaybackRate(newPlaybackRate: number): void;
  37438. /**
  37439. * Gets the volume of the sound.
  37440. * @returns the volume of the sound
  37441. */
  37442. getVolume(): number;
  37443. /**
  37444. * Attach the sound to a dedicated mesh
  37445. * @param transformNode The transform node to connect the sound with
  37446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37447. */
  37448. attachToMesh(transformNode: TransformNode): void;
  37449. /**
  37450. * Detach the sound from the previously attached mesh
  37451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37452. */
  37453. detachFromMesh(): void;
  37454. private _onRegisterAfterWorldMatrixUpdate;
  37455. /**
  37456. * Clone the current sound in the scene.
  37457. * @returns the new sound clone
  37458. */
  37459. clone(): Nullable<Sound>;
  37460. /**
  37461. * Gets the current underlying audio buffer containing the data
  37462. * @returns the audio buffer
  37463. */
  37464. getAudioBuffer(): Nullable<AudioBuffer>;
  37465. /**
  37466. * Serializes the Sound in a JSON representation
  37467. * @returns the JSON representation of the sound
  37468. */
  37469. serialize(): any;
  37470. /**
  37471. * Parse a JSON representation of a sound to innstantiate in a given scene
  37472. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37473. * @param scene Define the scene the new parsed sound should be created in
  37474. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37475. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37476. * @returns the newly parsed sound
  37477. */
  37478. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37479. }
  37480. }
  37481. declare module BABYLON {
  37482. /**
  37483. * This defines an action helpful to play a defined sound on a triggered action.
  37484. */
  37485. export class PlaySoundAction extends Action {
  37486. private _sound;
  37487. /**
  37488. * Instantiate the action
  37489. * @param triggerOptions defines the trigger options
  37490. * @param sound defines the sound to play
  37491. * @param condition defines the trigger related conditions
  37492. */
  37493. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37494. /** @hidden */
  37495. _prepare(): void;
  37496. /**
  37497. * Execute the action and play the sound.
  37498. */
  37499. execute(): void;
  37500. /**
  37501. * Serializes the actions and its related information.
  37502. * @param parent defines the object to serialize in
  37503. * @returns the serialized object
  37504. */
  37505. serialize(parent: any): any;
  37506. }
  37507. /**
  37508. * This defines an action helpful to stop a defined sound on a triggered action.
  37509. */
  37510. export class StopSoundAction extends Action {
  37511. private _sound;
  37512. /**
  37513. * Instantiate the action
  37514. * @param triggerOptions defines the trigger options
  37515. * @param sound defines the sound to stop
  37516. * @param condition defines the trigger related conditions
  37517. */
  37518. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37519. /** @hidden */
  37520. _prepare(): void;
  37521. /**
  37522. * Execute the action and stop the sound.
  37523. */
  37524. execute(): void;
  37525. /**
  37526. * Serializes the actions and its related information.
  37527. * @param parent defines the object to serialize in
  37528. * @returns the serialized object
  37529. */
  37530. serialize(parent: any): any;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /**
  37535. * This defines an action responsible to change the value of a property
  37536. * by interpolating between its current value and the newly set one once triggered.
  37537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37538. */
  37539. export class InterpolateValueAction extends Action {
  37540. /**
  37541. * Defines the path of the property where the value should be interpolated
  37542. */
  37543. propertyPath: string;
  37544. /**
  37545. * Defines the target value at the end of the interpolation.
  37546. */
  37547. value: any;
  37548. /**
  37549. * Defines the time it will take for the property to interpolate to the value.
  37550. */
  37551. duration: number;
  37552. /**
  37553. * Defines if the other scene animations should be stopped when the action has been triggered
  37554. */
  37555. stopOtherAnimations?: boolean;
  37556. /**
  37557. * Defines a callback raised once the interpolation animation has been done.
  37558. */
  37559. onInterpolationDone?: () => void;
  37560. /**
  37561. * Observable triggered once the interpolation animation has been done.
  37562. */
  37563. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37564. private _target;
  37565. private _effectiveTarget;
  37566. private _property;
  37567. /**
  37568. * Instantiate the action
  37569. * @param triggerOptions defines the trigger options
  37570. * @param target defines the object containing the value to interpolate
  37571. * @param propertyPath defines the path to the property in the target object
  37572. * @param value defines the target value at the end of the interpolation
  37573. * @param duration deines the time it will take for the property to interpolate to the value.
  37574. * @param condition defines the trigger related conditions
  37575. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37576. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37577. */
  37578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37579. /** @hidden */
  37580. _prepare(): void;
  37581. /**
  37582. * Execute the action starts the value interpolation.
  37583. */
  37584. execute(): void;
  37585. /**
  37586. * Serializes the actions and its related information.
  37587. * @param parent defines the object to serialize in
  37588. * @returns the serialized object
  37589. */
  37590. serialize(parent: any): any;
  37591. }
  37592. }
  37593. declare module BABYLON {
  37594. /**
  37595. * Options allowed during the creation of a sound track.
  37596. */
  37597. export interface ISoundTrackOptions {
  37598. /**
  37599. * The volume the sound track should take during creation
  37600. */
  37601. volume?: number;
  37602. /**
  37603. * Define if the sound track is the main sound track of the scene
  37604. */
  37605. mainTrack?: boolean;
  37606. }
  37607. /**
  37608. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37609. * It will be also used in a future release to apply effects on a specific track.
  37610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37611. */
  37612. export class SoundTrack {
  37613. /**
  37614. * The unique identifier of the sound track in the scene.
  37615. */
  37616. id: number;
  37617. /**
  37618. * The list of sounds included in the sound track.
  37619. */
  37620. soundCollection: Array<Sound>;
  37621. private _outputAudioNode;
  37622. private _scene;
  37623. private _connectedAnalyser;
  37624. private _options;
  37625. private _isInitialized;
  37626. /**
  37627. * Creates a new sound track.
  37628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37629. * @param scene Define the scene the sound track belongs to
  37630. * @param options
  37631. */
  37632. constructor(scene: Scene, options?: ISoundTrackOptions);
  37633. private _initializeSoundTrackAudioGraph;
  37634. /**
  37635. * Release the sound track and its associated resources
  37636. */
  37637. dispose(): void;
  37638. /**
  37639. * Adds a sound to this sound track
  37640. * @param sound define the cound to add
  37641. * @ignoreNaming
  37642. */
  37643. AddSound(sound: Sound): void;
  37644. /**
  37645. * Removes a sound to this sound track
  37646. * @param sound define the cound to remove
  37647. * @ignoreNaming
  37648. */
  37649. RemoveSound(sound: Sound): void;
  37650. /**
  37651. * Set a global volume for the full sound track.
  37652. * @param newVolume Define the new volume of the sound track
  37653. */
  37654. setVolume(newVolume: number): void;
  37655. /**
  37656. * Switch the panning model to HRTF:
  37657. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37659. */
  37660. switchPanningModelToHRTF(): void;
  37661. /**
  37662. * Switch the panning model to Equal Power:
  37663. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37665. */
  37666. switchPanningModelToEqualPower(): void;
  37667. /**
  37668. * Connect the sound track to an audio analyser allowing some amazing
  37669. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37671. * @param analyser The analyser to connect to the engine
  37672. */
  37673. connectToAnalyser(analyser: Analyser): void;
  37674. }
  37675. }
  37676. declare module BABYLON {
  37677. interface AbstractScene {
  37678. /**
  37679. * The list of sounds used in the scene.
  37680. */
  37681. sounds: Nullable<Array<Sound>>;
  37682. }
  37683. interface Scene {
  37684. /**
  37685. * @hidden
  37686. * Backing field
  37687. */
  37688. _mainSoundTrack: SoundTrack;
  37689. /**
  37690. * The main sound track played by the scene.
  37691. * It cotains your primary collection of sounds.
  37692. */
  37693. mainSoundTrack: SoundTrack;
  37694. /**
  37695. * The list of sound tracks added to the scene
  37696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37697. */
  37698. soundTracks: Nullable<Array<SoundTrack>>;
  37699. /**
  37700. * Gets a sound using a given name
  37701. * @param name defines the name to search for
  37702. * @return the found sound or null if not found at all.
  37703. */
  37704. getSoundByName(name: string): Nullable<Sound>;
  37705. /**
  37706. * Gets or sets if audio support is enabled
  37707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37708. */
  37709. audioEnabled: boolean;
  37710. /**
  37711. * Gets or sets if audio will be output to headphones
  37712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37713. */
  37714. headphone: boolean;
  37715. /**
  37716. * Gets or sets custom audio listener position provider
  37717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37718. */
  37719. audioListenerPositionProvider: Nullable<() => Vector3>;
  37720. /**
  37721. * Gets or sets a refresh rate when using 3D audio positioning
  37722. */
  37723. audioPositioningRefreshRate: number;
  37724. }
  37725. /**
  37726. * Defines the sound scene component responsible to manage any sounds
  37727. * in a given scene.
  37728. */
  37729. export class AudioSceneComponent implements ISceneSerializableComponent {
  37730. /**
  37731. * The component name helpfull to identify the component in the list of scene components.
  37732. */
  37733. readonly name: string;
  37734. /**
  37735. * The scene the component belongs to.
  37736. */
  37737. scene: Scene;
  37738. private _audioEnabled;
  37739. /**
  37740. * Gets whether audio is enabled or not.
  37741. * Please use related enable/disable method to switch state.
  37742. */
  37743. get audioEnabled(): boolean;
  37744. private _headphone;
  37745. /**
  37746. * Gets whether audio is outputing to headphone or not.
  37747. * Please use the according Switch methods to change output.
  37748. */
  37749. get headphone(): boolean;
  37750. /**
  37751. * Gets or sets a refresh rate when using 3D audio positioning
  37752. */
  37753. audioPositioningRefreshRate: number;
  37754. private _audioListenerPositionProvider;
  37755. /**
  37756. * Gets the current audio listener position provider
  37757. */
  37758. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37759. /**
  37760. * Sets a custom listener position for all sounds in the scene
  37761. * By default, this is the position of the first active camera
  37762. */
  37763. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37764. /**
  37765. * Creates a new instance of the component for the given scene
  37766. * @param scene Defines the scene to register the component in
  37767. */
  37768. constructor(scene: Scene);
  37769. /**
  37770. * Registers the component in a given scene
  37771. */
  37772. register(): void;
  37773. /**
  37774. * Rebuilds the elements related to this component in case of
  37775. * context lost for instance.
  37776. */
  37777. rebuild(): void;
  37778. /**
  37779. * Serializes the component data to the specified json object
  37780. * @param serializationObject The object to serialize to
  37781. */
  37782. serialize(serializationObject: any): void;
  37783. /**
  37784. * Adds all the elements from the container to the scene
  37785. * @param container the container holding the elements
  37786. */
  37787. addFromContainer(container: AbstractScene): void;
  37788. /**
  37789. * Removes all the elements in the container from the scene
  37790. * @param container contains the elements to remove
  37791. * @param dispose if the removed element should be disposed (default: false)
  37792. */
  37793. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37794. /**
  37795. * Disposes the component and the associated ressources.
  37796. */
  37797. dispose(): void;
  37798. /**
  37799. * Disables audio in the associated scene.
  37800. */
  37801. disableAudio(): void;
  37802. /**
  37803. * Enables audio in the associated scene.
  37804. */
  37805. enableAudio(): void;
  37806. /**
  37807. * Switch audio to headphone output.
  37808. */
  37809. switchAudioModeForHeadphones(): void;
  37810. /**
  37811. * Switch audio to normal speakers.
  37812. */
  37813. switchAudioModeForNormalSpeakers(): void;
  37814. private _cachedCameraDirection;
  37815. private _cachedCameraPosition;
  37816. private _lastCheck;
  37817. private _afterRender;
  37818. }
  37819. }
  37820. declare module BABYLON {
  37821. /**
  37822. * Wraps one or more Sound objects and selects one with random weight for playback.
  37823. */
  37824. export class WeightedSound {
  37825. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37826. loop: boolean;
  37827. private _coneInnerAngle;
  37828. private _coneOuterAngle;
  37829. private _volume;
  37830. /** A Sound is currently playing. */
  37831. isPlaying: boolean;
  37832. /** A Sound is currently paused. */
  37833. isPaused: boolean;
  37834. private _sounds;
  37835. private _weights;
  37836. private _currentIndex?;
  37837. /**
  37838. * Creates a new WeightedSound from the list of sounds given.
  37839. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37840. * @param sounds Array of Sounds that will be selected from.
  37841. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37842. */
  37843. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37844. /**
  37845. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37846. */
  37847. get directionalConeInnerAngle(): number;
  37848. /**
  37849. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37850. */
  37851. set directionalConeInnerAngle(value: number);
  37852. /**
  37853. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37854. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37855. */
  37856. get directionalConeOuterAngle(): number;
  37857. /**
  37858. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37859. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37860. */
  37861. set directionalConeOuterAngle(value: number);
  37862. /**
  37863. * Playback volume.
  37864. */
  37865. get volume(): number;
  37866. /**
  37867. * Playback volume.
  37868. */
  37869. set volume(value: number);
  37870. private _onended;
  37871. /**
  37872. * Suspend playback
  37873. */
  37874. pause(): void;
  37875. /**
  37876. * Stop playback
  37877. */
  37878. stop(): void;
  37879. /**
  37880. * Start playback.
  37881. * @param startOffset Position the clip head at a specific time in seconds.
  37882. */
  37883. play(startOffset?: number): void;
  37884. }
  37885. }
  37886. declare module BABYLON {
  37887. /**
  37888. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37890. */
  37891. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37892. /**
  37893. * Gets the name of the behavior.
  37894. */
  37895. get name(): string;
  37896. /**
  37897. * The easing function used by animations
  37898. */
  37899. static EasingFunction: BackEase;
  37900. /**
  37901. * The easing mode used by animations
  37902. */
  37903. static EasingMode: number;
  37904. /**
  37905. * The duration of the animation, in milliseconds
  37906. */
  37907. transitionDuration: number;
  37908. /**
  37909. * Length of the distance animated by the transition when lower radius is reached
  37910. */
  37911. lowerRadiusTransitionRange: number;
  37912. /**
  37913. * Length of the distance animated by the transition when upper radius is reached
  37914. */
  37915. upperRadiusTransitionRange: number;
  37916. private _autoTransitionRange;
  37917. /**
  37918. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37919. */
  37920. get autoTransitionRange(): boolean;
  37921. /**
  37922. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37923. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37924. */
  37925. set autoTransitionRange(value: boolean);
  37926. private _attachedCamera;
  37927. private _onAfterCheckInputsObserver;
  37928. private _onMeshTargetChangedObserver;
  37929. /**
  37930. * Initializes the behavior.
  37931. */
  37932. init(): void;
  37933. /**
  37934. * Attaches the behavior to its arc rotate camera.
  37935. * @param camera Defines the camera to attach the behavior to
  37936. */
  37937. attach(camera: ArcRotateCamera): void;
  37938. /**
  37939. * Detaches the behavior from its current arc rotate camera.
  37940. */
  37941. detach(): void;
  37942. private _radiusIsAnimating;
  37943. private _radiusBounceTransition;
  37944. private _animatables;
  37945. private _cachedWheelPrecision;
  37946. /**
  37947. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37948. * @param radiusLimit The limit to check against.
  37949. * @return Bool to indicate if at limit.
  37950. */
  37951. private _isRadiusAtLimit;
  37952. /**
  37953. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37954. * @param radiusDelta The delta by which to animate to. Can be negative.
  37955. */
  37956. private _applyBoundRadiusAnimation;
  37957. /**
  37958. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37959. */
  37960. protected _clearAnimationLocks(): void;
  37961. /**
  37962. * Stops and removes all animations that have been applied to the camera
  37963. */
  37964. stopAllAnimations(): void;
  37965. }
  37966. }
  37967. declare module BABYLON {
  37968. /**
  37969. * 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.
  37970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37971. */
  37972. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37973. /**
  37974. * Gets the name of the behavior.
  37975. */
  37976. get name(): string;
  37977. private _mode;
  37978. private _radiusScale;
  37979. private _positionScale;
  37980. private _defaultElevation;
  37981. private _elevationReturnTime;
  37982. private _elevationReturnWaitTime;
  37983. private _zoomStopsAnimation;
  37984. private _framingTime;
  37985. /**
  37986. * The easing function used by animations
  37987. */
  37988. static EasingFunction: ExponentialEase;
  37989. /**
  37990. * The easing mode used by animations
  37991. */
  37992. static EasingMode: number;
  37993. /**
  37994. * Sets the current mode used by the behavior
  37995. */
  37996. set mode(mode: number);
  37997. /**
  37998. * Gets current mode used by the behavior.
  37999. */
  38000. get mode(): number;
  38001. /**
  38002. * Sets the scale applied to the radius (1 by default)
  38003. */
  38004. set radiusScale(radius: number);
  38005. /**
  38006. * Gets the scale applied to the radius
  38007. */
  38008. get radiusScale(): number;
  38009. /**
  38010. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38011. */
  38012. set positionScale(scale: number);
  38013. /**
  38014. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38015. */
  38016. get positionScale(): number;
  38017. /**
  38018. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38019. * behaviour is triggered, in radians.
  38020. */
  38021. set defaultElevation(elevation: number);
  38022. /**
  38023. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38024. * behaviour is triggered, in radians.
  38025. */
  38026. get defaultElevation(): number;
  38027. /**
  38028. * Sets the time (in milliseconds) taken to return to the default beta position.
  38029. * Negative value indicates camera should not return to default.
  38030. */
  38031. set elevationReturnTime(speed: number);
  38032. /**
  38033. * Gets the time (in milliseconds) taken to return to the default beta position.
  38034. * Negative value indicates camera should not return to default.
  38035. */
  38036. get elevationReturnTime(): number;
  38037. /**
  38038. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38039. */
  38040. set elevationReturnWaitTime(time: number);
  38041. /**
  38042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38043. */
  38044. get elevationReturnWaitTime(): number;
  38045. /**
  38046. * Sets the flag that indicates if user zooming should stop animation.
  38047. */
  38048. set zoomStopsAnimation(flag: boolean);
  38049. /**
  38050. * Gets the flag that indicates if user zooming should stop animation.
  38051. */
  38052. get zoomStopsAnimation(): boolean;
  38053. /**
  38054. * Sets the transition time when framing the mesh, in milliseconds
  38055. */
  38056. set framingTime(time: number);
  38057. /**
  38058. * Gets the transition time when framing the mesh, in milliseconds
  38059. */
  38060. get framingTime(): number;
  38061. /**
  38062. * Define if the behavior should automatically change the configured
  38063. * camera limits and sensibilities.
  38064. */
  38065. autoCorrectCameraLimitsAndSensibility: boolean;
  38066. private _onPrePointerObservableObserver;
  38067. private _onAfterCheckInputsObserver;
  38068. private _onMeshTargetChangedObserver;
  38069. private _attachedCamera;
  38070. private _isPointerDown;
  38071. private _lastInteractionTime;
  38072. /**
  38073. * Initializes the behavior.
  38074. */
  38075. init(): void;
  38076. /**
  38077. * Attaches the behavior to its arc rotate camera.
  38078. * @param camera Defines the camera to attach the behavior to
  38079. */
  38080. attach(camera: ArcRotateCamera): void;
  38081. /**
  38082. * Detaches the behavior from its current arc rotate camera.
  38083. */
  38084. detach(): void;
  38085. private _animatables;
  38086. private _betaIsAnimating;
  38087. private _betaTransition;
  38088. private _radiusTransition;
  38089. private _vectorTransition;
  38090. /**
  38091. * Targets the given mesh and updates zoom level accordingly.
  38092. * @param mesh The mesh to target.
  38093. * @param radius Optional. If a cached radius position already exists, overrides default.
  38094. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38095. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38096. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38097. */
  38098. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38099. /**
  38100. * Targets the given mesh with its children and updates zoom level accordingly.
  38101. * @param mesh The mesh to target.
  38102. * @param radius Optional. If a cached radius position already exists, overrides default.
  38103. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38104. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38105. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38106. */
  38107. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38108. /**
  38109. * Targets the given meshes with their children and updates zoom level accordingly.
  38110. * @param meshes The mesh to target.
  38111. * @param radius Optional. If a cached radius position already exists, overrides default.
  38112. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38113. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38114. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38115. */
  38116. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38117. /**
  38118. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38119. * @param minimumWorld Determines the smaller position of the bounding box extend
  38120. * @param maximumWorld Determines the bigger position of the bounding box extend
  38121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38123. */
  38124. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38125. /**
  38126. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38127. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38128. * frustum width.
  38129. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38130. * to fully enclose the mesh in the viewing frustum.
  38131. */
  38132. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38133. /**
  38134. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38135. * is automatically returned to its default position (expected to be above ground plane).
  38136. */
  38137. private _maintainCameraAboveGround;
  38138. /**
  38139. * Returns the frustum slope based on the canvas ratio and camera FOV
  38140. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38141. */
  38142. private _getFrustumSlope;
  38143. /**
  38144. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38145. */
  38146. private _clearAnimationLocks;
  38147. /**
  38148. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38149. */
  38150. private _applyUserInteraction;
  38151. /**
  38152. * Stops and removes all animations that have been applied to the camera
  38153. */
  38154. stopAllAnimations(): void;
  38155. /**
  38156. * Gets a value indicating if the user is moving the camera
  38157. */
  38158. get isUserIsMoving(): boolean;
  38159. /**
  38160. * The camera can move all the way towards the mesh.
  38161. */
  38162. static IgnoreBoundsSizeMode: number;
  38163. /**
  38164. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38165. */
  38166. static FitFrustumSidesMode: number;
  38167. }
  38168. }
  38169. declare module BABYLON {
  38170. /**
  38171. * Base class for Camera Pointer Inputs.
  38172. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38173. * for example usage.
  38174. */
  38175. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38176. /**
  38177. * Defines the camera the input is attached to.
  38178. */
  38179. abstract camera: Camera;
  38180. /**
  38181. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38182. */
  38183. protected _altKey: boolean;
  38184. protected _ctrlKey: boolean;
  38185. protected _metaKey: boolean;
  38186. protected _shiftKey: boolean;
  38187. /**
  38188. * Which mouse buttons were pressed at time of last mouse event.
  38189. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38190. */
  38191. protected _buttonsPressed: number;
  38192. /**
  38193. * Defines the buttons associated with the input to handle camera move.
  38194. */
  38195. buttons: number[];
  38196. /**
  38197. * Attach the input controls to a specific dom element to get the input from.
  38198. * @param element Defines the element the controls should be listened from
  38199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38200. */
  38201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38202. /**
  38203. * Detach the current controls from the specified dom element.
  38204. * @param element Defines the element to stop listening the inputs from
  38205. */
  38206. detachControl(element: Nullable<HTMLElement>): void;
  38207. /**
  38208. * Gets the class name of the current input.
  38209. * @returns the class name
  38210. */
  38211. getClassName(): string;
  38212. /**
  38213. * Get the friendly name associated with the input class.
  38214. * @returns the input friendly name
  38215. */
  38216. getSimpleName(): string;
  38217. /**
  38218. * Called on pointer POINTERDOUBLETAP event.
  38219. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38220. */
  38221. protected onDoubleTap(type: string): void;
  38222. /**
  38223. * Called on pointer POINTERMOVE event if only a single touch is active.
  38224. * Override this method to provide functionality.
  38225. */
  38226. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38227. /**
  38228. * Called on pointer POINTERMOVE event if multiple touches are active.
  38229. * Override this method to provide functionality.
  38230. */
  38231. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38232. /**
  38233. * Called on JS contextmenu event.
  38234. * Override this method to provide functionality.
  38235. */
  38236. protected onContextMenu(evt: PointerEvent): void;
  38237. /**
  38238. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38239. * press.
  38240. * Override this method to provide functionality.
  38241. */
  38242. protected onButtonDown(evt: PointerEvent): void;
  38243. /**
  38244. * Called each time a new POINTERUP event occurs. Ie, for each button
  38245. * release.
  38246. * Override this method to provide functionality.
  38247. */
  38248. protected onButtonUp(evt: PointerEvent): void;
  38249. /**
  38250. * Called when window becomes inactive.
  38251. * Override this method to provide functionality.
  38252. */
  38253. protected onLostFocus(): void;
  38254. private _pointerInput;
  38255. private _observer;
  38256. private _onLostFocus;
  38257. private pointA;
  38258. private pointB;
  38259. }
  38260. }
  38261. declare module BABYLON {
  38262. /**
  38263. * Manage the pointers inputs to control an arc rotate camera.
  38264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38265. */
  38266. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38267. /**
  38268. * Defines the camera the input is attached to.
  38269. */
  38270. camera: ArcRotateCamera;
  38271. /**
  38272. * Gets the class name of the current input.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. /**
  38277. * Defines the buttons associated with the input to handle camera move.
  38278. */
  38279. buttons: number[];
  38280. /**
  38281. * Defines the pointer angular sensibility along the X axis or how fast is
  38282. * the camera rotating.
  38283. */
  38284. angularSensibilityX: number;
  38285. /**
  38286. * Defines the pointer angular sensibility along the Y axis or how fast is
  38287. * the camera rotating.
  38288. */
  38289. angularSensibilityY: number;
  38290. /**
  38291. * Defines the pointer pinch precision or how fast is the camera zooming.
  38292. */
  38293. pinchPrecision: number;
  38294. /**
  38295. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38296. * from 0.
  38297. * It defines the percentage of current camera.radius to use as delta when
  38298. * pinch zoom is used.
  38299. */
  38300. pinchDeltaPercentage: number;
  38301. /**
  38302. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38303. * that any object in the plane at the camera's target point will scale
  38304. * perfectly with finger motion.
  38305. * Overrides pinchDeltaPercentage and pinchPrecision.
  38306. */
  38307. useNaturalPinchZoom: boolean;
  38308. /**
  38309. * Defines the pointer panning sensibility or how fast is the camera moving.
  38310. */
  38311. panningSensibility: number;
  38312. /**
  38313. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38314. */
  38315. multiTouchPanning: boolean;
  38316. /**
  38317. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38318. * zoom (pinch) through multitouch.
  38319. */
  38320. multiTouchPanAndZoom: boolean;
  38321. /**
  38322. * Revers pinch action direction.
  38323. */
  38324. pinchInwards: boolean;
  38325. private _isPanClick;
  38326. private _twoFingerActivityCount;
  38327. private _isPinching;
  38328. /**
  38329. * Called on pointer POINTERMOVE event if only a single touch is active.
  38330. */
  38331. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38332. /**
  38333. * Called on pointer POINTERDOUBLETAP event.
  38334. */
  38335. protected onDoubleTap(type: string): void;
  38336. /**
  38337. * Called on pointer POINTERMOVE event if multiple touches are active.
  38338. */
  38339. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38340. /**
  38341. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38342. * press.
  38343. */
  38344. protected onButtonDown(evt: PointerEvent): void;
  38345. /**
  38346. * Called each time a new POINTERUP event occurs. Ie, for each button
  38347. * release.
  38348. */
  38349. protected onButtonUp(evt: PointerEvent): void;
  38350. /**
  38351. * Called when window becomes inactive.
  38352. */
  38353. protected onLostFocus(): void;
  38354. }
  38355. }
  38356. declare module BABYLON {
  38357. /**
  38358. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38360. */
  38361. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38362. /**
  38363. * Defines the camera the input is attached to.
  38364. */
  38365. camera: ArcRotateCamera;
  38366. /**
  38367. * Defines the list of key codes associated with the up action (increase alpha)
  38368. */
  38369. keysUp: number[];
  38370. /**
  38371. * Defines the list of key codes associated with the down action (decrease alpha)
  38372. */
  38373. keysDown: number[];
  38374. /**
  38375. * Defines the list of key codes associated with the left action (increase beta)
  38376. */
  38377. keysLeft: number[];
  38378. /**
  38379. * Defines the list of key codes associated with the right action (decrease beta)
  38380. */
  38381. keysRight: number[];
  38382. /**
  38383. * Defines the list of key codes associated with the reset action.
  38384. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38385. */
  38386. keysReset: number[];
  38387. /**
  38388. * Defines the panning sensibility of the inputs.
  38389. * (How fast is the camera panning)
  38390. */
  38391. panningSensibility: number;
  38392. /**
  38393. * Defines the zooming sensibility of the inputs.
  38394. * (How fast is the camera zooming)
  38395. */
  38396. zoomingSensibility: number;
  38397. /**
  38398. * Defines whether maintaining the alt key down switch the movement mode from
  38399. * orientation to zoom.
  38400. */
  38401. useAltToZoom: boolean;
  38402. /**
  38403. * Rotation speed of the camera
  38404. */
  38405. angularSpeed: number;
  38406. private _keys;
  38407. private _ctrlPressed;
  38408. private _altPressed;
  38409. private _onCanvasBlurObserver;
  38410. private _onKeyboardObserver;
  38411. private _engine;
  38412. private _scene;
  38413. /**
  38414. * Attach the input controls to a specific dom element to get the input from.
  38415. * @param element Defines the element the controls should be listened from
  38416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38417. */
  38418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38419. /**
  38420. * Detach the current controls from the specified dom element.
  38421. * @param element Defines the element to stop listening the inputs from
  38422. */
  38423. detachControl(element: Nullable<HTMLElement>): void;
  38424. /**
  38425. * Update the current camera state depending on the inputs that have been used this frame.
  38426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38427. */
  38428. checkInputs(): void;
  38429. /**
  38430. * Gets the class name of the current intput.
  38431. * @returns the class name
  38432. */
  38433. getClassName(): string;
  38434. /**
  38435. * Get the friendly name associated with the input class.
  38436. * @returns the input friendly name
  38437. */
  38438. getSimpleName(): string;
  38439. }
  38440. }
  38441. declare module BABYLON {
  38442. /**
  38443. * Manage the mouse wheel inputs to control an arc rotate camera.
  38444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38445. */
  38446. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38447. /**
  38448. * Defines the camera the input is attached to.
  38449. */
  38450. camera: ArcRotateCamera;
  38451. /**
  38452. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38453. */
  38454. wheelPrecision: number;
  38455. /**
  38456. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38457. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38458. */
  38459. wheelDeltaPercentage: number;
  38460. private _wheel;
  38461. private _observer;
  38462. private computeDeltaFromMouseWheelLegacyEvent;
  38463. /**
  38464. * Attach the input controls to a specific dom element to get the input from.
  38465. * @param element Defines the element the controls should be listened from
  38466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38467. */
  38468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38469. /**
  38470. * Detach the current controls from the specified dom element.
  38471. * @param element Defines the element to stop listening the inputs from
  38472. */
  38473. detachControl(element: Nullable<HTMLElement>): void;
  38474. /**
  38475. * Gets the class name of the current intput.
  38476. * @returns the class name
  38477. */
  38478. getClassName(): string;
  38479. /**
  38480. * Get the friendly name associated with the input class.
  38481. * @returns the input friendly name
  38482. */
  38483. getSimpleName(): string;
  38484. }
  38485. }
  38486. declare module BABYLON {
  38487. /**
  38488. * Default Inputs manager for the ArcRotateCamera.
  38489. * It groups all the default supported inputs for ease of use.
  38490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38491. */
  38492. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38493. /**
  38494. * Instantiates a new ArcRotateCameraInputsManager.
  38495. * @param camera Defines the camera the inputs belong to
  38496. */
  38497. constructor(camera: ArcRotateCamera);
  38498. /**
  38499. * Add mouse wheel input support to the input manager.
  38500. * @returns the current input manager
  38501. */
  38502. addMouseWheel(): ArcRotateCameraInputsManager;
  38503. /**
  38504. * Add pointers input support to the input manager.
  38505. * @returns the current input manager
  38506. */
  38507. addPointers(): ArcRotateCameraInputsManager;
  38508. /**
  38509. * Add keyboard input support to the input manager.
  38510. * @returns the current input manager
  38511. */
  38512. addKeyboard(): ArcRotateCameraInputsManager;
  38513. }
  38514. }
  38515. declare module BABYLON {
  38516. /**
  38517. * This represents an orbital type of camera.
  38518. *
  38519. * 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.
  38520. * 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.
  38521. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38522. */
  38523. export class ArcRotateCamera extends TargetCamera {
  38524. /**
  38525. * Defines the rotation angle of the camera along the longitudinal axis.
  38526. */
  38527. alpha: number;
  38528. /**
  38529. * Defines the rotation angle of the camera along the latitudinal axis.
  38530. */
  38531. beta: number;
  38532. /**
  38533. * Defines the radius of the camera from it s target point.
  38534. */
  38535. radius: number;
  38536. protected _target: Vector3;
  38537. protected _targetHost: Nullable<AbstractMesh>;
  38538. /**
  38539. * Defines the target point of the camera.
  38540. * The camera looks towards it form the radius distance.
  38541. */
  38542. get target(): Vector3;
  38543. set target(value: Vector3);
  38544. /**
  38545. * Define the current local position of the camera in the scene
  38546. */
  38547. get position(): Vector3;
  38548. set position(newPosition: Vector3);
  38549. protected _upVector: Vector3;
  38550. protected _upToYMatrix: Matrix;
  38551. protected _YToUpMatrix: Matrix;
  38552. /**
  38553. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38554. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38555. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38556. */
  38557. set upVector(vec: Vector3);
  38558. get upVector(): Vector3;
  38559. /**
  38560. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38561. */
  38562. setMatUp(): void;
  38563. /**
  38564. * Current inertia value on the longitudinal axis.
  38565. * The bigger this number the longer it will take for the camera to stop.
  38566. */
  38567. inertialAlphaOffset: number;
  38568. /**
  38569. * Current inertia value on the latitudinal axis.
  38570. * The bigger this number the longer it will take for the camera to stop.
  38571. */
  38572. inertialBetaOffset: number;
  38573. /**
  38574. * Current inertia value on the radius axis.
  38575. * The bigger this number the longer it will take for the camera to stop.
  38576. */
  38577. inertialRadiusOffset: number;
  38578. /**
  38579. * Minimum allowed angle on the longitudinal axis.
  38580. * This can help limiting how the Camera is able to move in the scene.
  38581. */
  38582. lowerAlphaLimit: Nullable<number>;
  38583. /**
  38584. * Maximum allowed angle on the longitudinal axis.
  38585. * This can help limiting how the Camera is able to move in the scene.
  38586. */
  38587. upperAlphaLimit: Nullable<number>;
  38588. /**
  38589. * Minimum allowed angle on the latitudinal axis.
  38590. * This can help limiting how the Camera is able to move in the scene.
  38591. */
  38592. lowerBetaLimit: number;
  38593. /**
  38594. * Maximum allowed angle on the latitudinal axis.
  38595. * This can help limiting how the Camera is able to move in the scene.
  38596. */
  38597. upperBetaLimit: number;
  38598. /**
  38599. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38600. * This can help limiting how the Camera is able to move in the scene.
  38601. */
  38602. lowerRadiusLimit: Nullable<number>;
  38603. /**
  38604. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38605. * This can help limiting how the Camera is able to move in the scene.
  38606. */
  38607. upperRadiusLimit: Nullable<number>;
  38608. /**
  38609. * Defines the current inertia value used during panning of the camera along the X axis.
  38610. */
  38611. inertialPanningX: number;
  38612. /**
  38613. * Defines the current inertia value used during panning of the camera along the Y axis.
  38614. */
  38615. inertialPanningY: number;
  38616. /**
  38617. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38618. * Basically if your fingers moves away from more than this distance you will be considered
  38619. * in pinch mode.
  38620. */
  38621. pinchToPanMaxDistance: number;
  38622. /**
  38623. * Defines the maximum distance the camera can pan.
  38624. * This could help keeping the cammera always in your scene.
  38625. */
  38626. panningDistanceLimit: Nullable<number>;
  38627. /**
  38628. * Defines the target of the camera before paning.
  38629. */
  38630. panningOriginTarget: Vector3;
  38631. /**
  38632. * Defines the value of the inertia used during panning.
  38633. * 0 would mean stop inertia and one would mean no decelleration at all.
  38634. */
  38635. panningInertia: number;
  38636. /**
  38637. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38638. */
  38639. get angularSensibilityX(): number;
  38640. set angularSensibilityX(value: number);
  38641. /**
  38642. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38643. */
  38644. get angularSensibilityY(): number;
  38645. set angularSensibilityY(value: number);
  38646. /**
  38647. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38648. */
  38649. get pinchPrecision(): number;
  38650. set pinchPrecision(value: number);
  38651. /**
  38652. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38653. * It will be used instead of pinchDeltaPrecision if different from 0.
  38654. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38655. */
  38656. get pinchDeltaPercentage(): number;
  38657. set pinchDeltaPercentage(value: number);
  38658. /**
  38659. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38660. * and pinch delta percentage.
  38661. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38662. * that any object in the plane at the camera's target point will scale
  38663. * perfectly with finger motion.
  38664. */
  38665. get useNaturalPinchZoom(): boolean;
  38666. set useNaturalPinchZoom(value: boolean);
  38667. /**
  38668. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38669. */
  38670. get panningSensibility(): number;
  38671. set panningSensibility(value: number);
  38672. /**
  38673. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38674. */
  38675. get keysUp(): number[];
  38676. set keysUp(value: number[]);
  38677. /**
  38678. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38679. */
  38680. get keysDown(): number[];
  38681. set keysDown(value: number[]);
  38682. /**
  38683. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38684. */
  38685. get keysLeft(): number[];
  38686. set keysLeft(value: number[]);
  38687. /**
  38688. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38689. */
  38690. get keysRight(): number[];
  38691. set keysRight(value: number[]);
  38692. /**
  38693. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38694. */
  38695. get wheelPrecision(): number;
  38696. set wheelPrecision(value: number);
  38697. /**
  38698. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38699. * It will be used instead of pinchDeltaPrecision if different from 0.
  38700. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38701. */
  38702. get wheelDeltaPercentage(): number;
  38703. set wheelDeltaPercentage(value: number);
  38704. /**
  38705. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38706. */
  38707. zoomOnFactor: number;
  38708. /**
  38709. * Defines a screen offset for the camera position.
  38710. */
  38711. targetScreenOffset: Vector2;
  38712. /**
  38713. * Allows the camera to be completely reversed.
  38714. * If false the camera can not arrive upside down.
  38715. */
  38716. allowUpsideDown: boolean;
  38717. /**
  38718. * Define if double tap/click is used to restore the previously saved state of the camera.
  38719. */
  38720. useInputToRestoreState: boolean;
  38721. /** @hidden */
  38722. _viewMatrix: Matrix;
  38723. /** @hidden */
  38724. _useCtrlForPanning: boolean;
  38725. /** @hidden */
  38726. _panningMouseButton: number;
  38727. /**
  38728. * Defines the input associated to the camera.
  38729. */
  38730. inputs: ArcRotateCameraInputsManager;
  38731. /** @hidden */
  38732. _reset: () => void;
  38733. /**
  38734. * Defines the allowed panning axis.
  38735. */
  38736. panningAxis: Vector3;
  38737. protected _localDirection: Vector3;
  38738. protected _transformedDirection: Vector3;
  38739. private _bouncingBehavior;
  38740. /**
  38741. * Gets the bouncing behavior of the camera if it has been enabled.
  38742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38743. */
  38744. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38745. /**
  38746. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38748. */
  38749. get useBouncingBehavior(): boolean;
  38750. set useBouncingBehavior(value: boolean);
  38751. private _framingBehavior;
  38752. /**
  38753. * Gets the framing behavior of the camera if it has been enabled.
  38754. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38755. */
  38756. get framingBehavior(): Nullable<FramingBehavior>;
  38757. /**
  38758. * Defines if the framing behavior of the camera is enabled on the camera.
  38759. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38760. */
  38761. get useFramingBehavior(): boolean;
  38762. set useFramingBehavior(value: boolean);
  38763. private _autoRotationBehavior;
  38764. /**
  38765. * Gets the auto rotation behavior of the camera if it has been enabled.
  38766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38767. */
  38768. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38769. /**
  38770. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38771. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38772. */
  38773. get useAutoRotationBehavior(): boolean;
  38774. set useAutoRotationBehavior(value: boolean);
  38775. /**
  38776. * Observable triggered when the mesh target has been changed on the camera.
  38777. */
  38778. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38779. /**
  38780. * Event raised when the camera is colliding with a mesh.
  38781. */
  38782. onCollide: (collidedMesh: AbstractMesh) => void;
  38783. /**
  38784. * Defines whether the camera should check collision with the objects oh the scene.
  38785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38786. */
  38787. checkCollisions: boolean;
  38788. /**
  38789. * Defines the collision radius of the camera.
  38790. * This simulates a sphere around the camera.
  38791. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38792. */
  38793. collisionRadius: Vector3;
  38794. protected _collider: Collider;
  38795. protected _previousPosition: Vector3;
  38796. protected _collisionVelocity: Vector3;
  38797. protected _newPosition: Vector3;
  38798. protected _previousAlpha: number;
  38799. protected _previousBeta: number;
  38800. protected _previousRadius: number;
  38801. protected _collisionTriggered: boolean;
  38802. protected _targetBoundingCenter: Nullable<Vector3>;
  38803. private _computationVector;
  38804. /**
  38805. * Instantiates a new ArcRotateCamera in a given scene
  38806. * @param name Defines the name of the camera
  38807. * @param alpha Defines the camera rotation along the logitudinal axis
  38808. * @param beta Defines the camera rotation along the latitudinal axis
  38809. * @param radius Defines the camera distance from its target
  38810. * @param target Defines the camera target
  38811. * @param scene Defines the scene the camera belongs to
  38812. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38813. */
  38814. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38815. /** @hidden */
  38816. _initCache(): void;
  38817. /** @hidden */
  38818. _updateCache(ignoreParentClass?: boolean): void;
  38819. protected _getTargetPosition(): Vector3;
  38820. private _storedAlpha;
  38821. private _storedBeta;
  38822. private _storedRadius;
  38823. private _storedTarget;
  38824. private _storedTargetScreenOffset;
  38825. /**
  38826. * Stores the current state of the camera (alpha, beta, radius and target)
  38827. * @returns the camera itself
  38828. */
  38829. storeState(): Camera;
  38830. /**
  38831. * @hidden
  38832. * Restored camera state. You must call storeState() first
  38833. */
  38834. _restoreStateValues(): boolean;
  38835. /** @hidden */
  38836. _isSynchronizedViewMatrix(): boolean;
  38837. /**
  38838. * Attached controls to the current camera.
  38839. * @param element Defines the element the controls should be listened from
  38840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38841. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38842. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38843. */
  38844. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38845. /**
  38846. * Detach the current controls from the camera.
  38847. * The camera will stop reacting to inputs.
  38848. * @param element Defines the element to stop listening the inputs from
  38849. */
  38850. detachControl(element: HTMLElement): void;
  38851. /** @hidden */
  38852. _checkInputs(): void;
  38853. protected _checkLimits(): void;
  38854. /**
  38855. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38856. */
  38857. rebuildAnglesAndRadius(): void;
  38858. /**
  38859. * Use a position to define the current camera related information like alpha, beta and radius
  38860. * @param position Defines the position to set the camera at
  38861. */
  38862. setPosition(position: Vector3): void;
  38863. /**
  38864. * Defines the target the camera should look at.
  38865. * This will automatically adapt alpha beta and radius to fit within the new target.
  38866. * @param target Defines the new target as a Vector or a mesh
  38867. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38868. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38869. */
  38870. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38871. /** @hidden */
  38872. _getViewMatrix(): Matrix;
  38873. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38874. /**
  38875. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38876. * @param meshes Defines the mesh to zoom on
  38877. * @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)
  38878. */
  38879. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38880. /**
  38881. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38882. * The target will be changed but the radius
  38883. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38884. * @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)
  38885. */
  38886. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38887. min: Vector3;
  38888. max: Vector3;
  38889. distance: number;
  38890. }, doNotUpdateMaxZ?: boolean): void;
  38891. /**
  38892. * @override
  38893. * Override Camera.createRigCamera
  38894. */
  38895. createRigCamera(name: string, cameraIndex: number): Camera;
  38896. /**
  38897. * @hidden
  38898. * @override
  38899. * Override Camera._updateRigCameras
  38900. */
  38901. _updateRigCameras(): void;
  38902. /**
  38903. * Destroy the camera and release the current resources hold by it.
  38904. */
  38905. dispose(): void;
  38906. /**
  38907. * Gets the current object class name.
  38908. * @return the class name
  38909. */
  38910. getClassName(): string;
  38911. }
  38912. }
  38913. declare module BABYLON {
  38914. /**
  38915. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38917. */
  38918. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38919. /**
  38920. * Gets the name of the behavior.
  38921. */
  38922. get name(): string;
  38923. private _zoomStopsAnimation;
  38924. private _idleRotationSpeed;
  38925. private _idleRotationWaitTime;
  38926. private _idleRotationSpinupTime;
  38927. /**
  38928. * Sets the flag that indicates if user zooming should stop animation.
  38929. */
  38930. set zoomStopsAnimation(flag: boolean);
  38931. /**
  38932. * Gets the flag that indicates if user zooming should stop animation.
  38933. */
  38934. get zoomStopsAnimation(): boolean;
  38935. /**
  38936. * Sets the default speed at which the camera rotates around the model.
  38937. */
  38938. set idleRotationSpeed(speed: number);
  38939. /**
  38940. * Gets the default speed at which the camera rotates around the model.
  38941. */
  38942. get idleRotationSpeed(): number;
  38943. /**
  38944. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38945. */
  38946. set idleRotationWaitTime(time: number);
  38947. /**
  38948. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38949. */
  38950. get idleRotationWaitTime(): number;
  38951. /**
  38952. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38953. */
  38954. set idleRotationSpinupTime(time: number);
  38955. /**
  38956. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38957. */
  38958. get idleRotationSpinupTime(): number;
  38959. /**
  38960. * Gets a value indicating if the camera is currently rotating because of this behavior
  38961. */
  38962. get rotationInProgress(): boolean;
  38963. private _onPrePointerObservableObserver;
  38964. private _onAfterCheckInputsObserver;
  38965. private _attachedCamera;
  38966. private _isPointerDown;
  38967. private _lastFrameTime;
  38968. private _lastInteractionTime;
  38969. private _cameraRotationSpeed;
  38970. /**
  38971. * Initializes the behavior.
  38972. */
  38973. init(): void;
  38974. /**
  38975. * Attaches the behavior to its arc rotate camera.
  38976. * @param camera Defines the camera to attach the behavior to
  38977. */
  38978. attach(camera: ArcRotateCamera): void;
  38979. /**
  38980. * Detaches the behavior from its current arc rotate camera.
  38981. */
  38982. detach(): void;
  38983. /**
  38984. * Returns true if user is scrolling.
  38985. * @return true if user is scrolling.
  38986. */
  38987. private _userIsZooming;
  38988. private _lastFrameRadius;
  38989. private _shouldAnimationStopForInteraction;
  38990. /**
  38991. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38992. */
  38993. private _applyUserInteraction;
  38994. private _userIsMoving;
  38995. }
  38996. }
  38997. declare module BABYLON {
  38998. /**
  38999. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39000. */
  39001. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39002. private ui;
  39003. /**
  39004. * The name of the behavior
  39005. */
  39006. name: string;
  39007. /**
  39008. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39009. */
  39010. distanceAwayFromFace: number;
  39011. /**
  39012. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39013. */
  39014. distanceAwayFromBottomOfFace: number;
  39015. private _faceVectors;
  39016. private _target;
  39017. private _scene;
  39018. private _onRenderObserver;
  39019. private _tmpMatrix;
  39020. private _tmpVector;
  39021. /**
  39022. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39023. * @param ui The transform node that should be attched to the mesh
  39024. */
  39025. constructor(ui: TransformNode);
  39026. /**
  39027. * Initializes the behavior
  39028. */
  39029. init(): void;
  39030. private _closestFace;
  39031. private _zeroVector;
  39032. private _lookAtTmpMatrix;
  39033. private _lookAtToRef;
  39034. /**
  39035. * Attaches the AttachToBoxBehavior to the passed in mesh
  39036. * @param target The mesh that the specified node will be attached to
  39037. */
  39038. attach(target: Mesh): void;
  39039. /**
  39040. * Detaches the behavior from the mesh
  39041. */
  39042. detach(): void;
  39043. }
  39044. }
  39045. declare module BABYLON {
  39046. /**
  39047. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39048. */
  39049. export class FadeInOutBehavior implements Behavior<Mesh> {
  39050. /**
  39051. * Time in milliseconds to delay before fading in (Default: 0)
  39052. */
  39053. delay: number;
  39054. /**
  39055. * Time in milliseconds for the mesh to fade in (Default: 300)
  39056. */
  39057. fadeInTime: number;
  39058. private _millisecondsPerFrame;
  39059. private _hovered;
  39060. private _hoverValue;
  39061. private _ownerNode;
  39062. /**
  39063. * Instatiates the FadeInOutBehavior
  39064. */
  39065. constructor();
  39066. /**
  39067. * The name of the behavior
  39068. */
  39069. get name(): string;
  39070. /**
  39071. * Initializes the behavior
  39072. */
  39073. init(): void;
  39074. /**
  39075. * Attaches the fade behavior on the passed in mesh
  39076. * @param ownerNode The mesh that will be faded in/out once attached
  39077. */
  39078. attach(ownerNode: Mesh): void;
  39079. /**
  39080. * Detaches the behavior from the mesh
  39081. */
  39082. detach(): void;
  39083. /**
  39084. * Triggers the mesh to begin fading in or out
  39085. * @param value if the object should fade in or out (true to fade in)
  39086. */
  39087. fadeIn(value: boolean): void;
  39088. private _update;
  39089. private _setAllVisibility;
  39090. }
  39091. }
  39092. declare module BABYLON {
  39093. /**
  39094. * Class containing a set of static utilities functions for managing Pivots
  39095. * @hidden
  39096. */
  39097. export class PivotTools {
  39098. private static _PivotCached;
  39099. private static _OldPivotPoint;
  39100. private static _PivotTranslation;
  39101. private static _PivotTmpVector;
  39102. /** @hidden */
  39103. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39104. /** @hidden */
  39105. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39106. }
  39107. }
  39108. declare module BABYLON {
  39109. /**
  39110. * Class containing static functions to help procedurally build meshes
  39111. */
  39112. export class PlaneBuilder {
  39113. /**
  39114. * Creates a plane mesh
  39115. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39116. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39117. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39119. * * 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
  39120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39121. * @param name defines the name of the mesh
  39122. * @param options defines the options used to create the mesh
  39123. * @param scene defines the hosting scene
  39124. * @returns the plane mesh
  39125. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39126. */
  39127. static CreatePlane(name: string, options: {
  39128. size?: number;
  39129. width?: number;
  39130. height?: number;
  39131. sideOrientation?: number;
  39132. frontUVs?: Vector4;
  39133. backUVs?: Vector4;
  39134. updatable?: boolean;
  39135. sourcePlane?: Plane;
  39136. }, scene?: Nullable<Scene>): Mesh;
  39137. }
  39138. }
  39139. declare module BABYLON {
  39140. /**
  39141. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39142. */
  39143. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39144. private static _AnyMouseID;
  39145. /**
  39146. * Abstract mesh the behavior is set on
  39147. */
  39148. attachedNode: AbstractMesh;
  39149. private _dragPlane;
  39150. private _scene;
  39151. private _pointerObserver;
  39152. private _beforeRenderObserver;
  39153. private static _planeScene;
  39154. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39155. /**
  39156. * 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)
  39157. */
  39158. maxDragAngle: number;
  39159. /**
  39160. * @hidden
  39161. */
  39162. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39163. /**
  39164. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39165. */
  39166. currentDraggingPointerID: number;
  39167. /**
  39168. * The last position where the pointer hit the drag plane in world space
  39169. */
  39170. lastDragPosition: Vector3;
  39171. /**
  39172. * If the behavior is currently in a dragging state
  39173. */
  39174. dragging: boolean;
  39175. /**
  39176. * 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)
  39177. */
  39178. dragDeltaRatio: number;
  39179. /**
  39180. * If the drag plane orientation should be updated during the dragging (Default: true)
  39181. */
  39182. updateDragPlane: boolean;
  39183. private _debugMode;
  39184. private _moving;
  39185. /**
  39186. * Fires each time the attached mesh is dragged with the pointer
  39187. * * delta between last drag position and current drag position in world space
  39188. * * dragDistance along the drag axis
  39189. * * dragPlaneNormal normal of the current drag plane used during the drag
  39190. * * dragPlanePoint in world space where the drag intersects the drag plane
  39191. */
  39192. onDragObservable: Observable<{
  39193. delta: Vector3;
  39194. dragPlanePoint: Vector3;
  39195. dragPlaneNormal: Vector3;
  39196. dragDistance: number;
  39197. pointerId: number;
  39198. }>;
  39199. /**
  39200. * Fires each time a drag begins (eg. mouse down on mesh)
  39201. */
  39202. onDragStartObservable: Observable<{
  39203. dragPlanePoint: Vector3;
  39204. pointerId: number;
  39205. }>;
  39206. /**
  39207. * Fires each time a drag ends (eg. mouse release after drag)
  39208. */
  39209. onDragEndObservable: Observable<{
  39210. dragPlanePoint: Vector3;
  39211. pointerId: number;
  39212. }>;
  39213. /**
  39214. * If the attached mesh should be moved when dragged
  39215. */
  39216. moveAttached: boolean;
  39217. /**
  39218. * If the drag behavior will react to drag events (Default: true)
  39219. */
  39220. enabled: boolean;
  39221. /**
  39222. * If pointer events should start and release the drag (Default: true)
  39223. */
  39224. startAndReleaseDragOnPointerEvents: boolean;
  39225. /**
  39226. * If camera controls should be detached during the drag
  39227. */
  39228. detachCameraControls: boolean;
  39229. /**
  39230. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39231. */
  39232. useObjectOrientationForDragging: boolean;
  39233. private _options;
  39234. /**
  39235. * Gets the options used by the behavior
  39236. */
  39237. get options(): {
  39238. dragAxis?: Vector3;
  39239. dragPlaneNormal?: Vector3;
  39240. };
  39241. /**
  39242. * Sets the options used by the behavior
  39243. */
  39244. set options(options: {
  39245. dragAxis?: Vector3;
  39246. dragPlaneNormal?: Vector3;
  39247. });
  39248. /**
  39249. * Creates a pointer drag behavior that can be attached to a mesh
  39250. * @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)
  39251. */
  39252. constructor(options?: {
  39253. dragAxis?: Vector3;
  39254. dragPlaneNormal?: Vector3;
  39255. });
  39256. /**
  39257. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39258. */
  39259. validateDrag: (targetPosition: Vector3) => boolean;
  39260. /**
  39261. * The name of the behavior
  39262. */
  39263. get name(): string;
  39264. /**
  39265. * Initializes the behavior
  39266. */
  39267. init(): void;
  39268. private _tmpVector;
  39269. private _alternatePickedPoint;
  39270. private _worldDragAxis;
  39271. private _targetPosition;
  39272. private _attachedElement;
  39273. /**
  39274. * Attaches the drag behavior the passed in mesh
  39275. * @param ownerNode The mesh that will be dragged around once attached
  39276. * @param predicate Predicate to use for pick filtering
  39277. */
  39278. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39279. /**
  39280. * Force relase the drag action by code.
  39281. */
  39282. releaseDrag(): void;
  39283. private _startDragRay;
  39284. private _lastPointerRay;
  39285. /**
  39286. * Simulates the start of a pointer drag event on the behavior
  39287. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39288. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39289. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39290. */
  39291. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39292. private _startDrag;
  39293. private _dragDelta;
  39294. private _moveDrag;
  39295. private _pickWithRayOnDragPlane;
  39296. private _pointA;
  39297. private _pointB;
  39298. private _pointC;
  39299. private _lineA;
  39300. private _lineB;
  39301. private _localAxis;
  39302. private _lookAt;
  39303. private _updateDragPlanePosition;
  39304. /**
  39305. * Detaches the behavior from the mesh
  39306. */
  39307. detach(): void;
  39308. }
  39309. }
  39310. declare module BABYLON {
  39311. /**
  39312. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39313. */
  39314. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39315. private _dragBehaviorA;
  39316. private _dragBehaviorB;
  39317. private _startDistance;
  39318. private _initialScale;
  39319. private _targetScale;
  39320. private _ownerNode;
  39321. private _sceneRenderObserver;
  39322. /**
  39323. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39324. */
  39325. constructor();
  39326. /**
  39327. * The name of the behavior
  39328. */
  39329. get name(): string;
  39330. /**
  39331. * Initializes the behavior
  39332. */
  39333. init(): void;
  39334. private _getCurrentDistance;
  39335. /**
  39336. * Attaches the scale behavior the passed in mesh
  39337. * @param ownerNode The mesh that will be scaled around once attached
  39338. */
  39339. attach(ownerNode: Mesh): void;
  39340. /**
  39341. * Detaches the behavior from the mesh
  39342. */
  39343. detach(): void;
  39344. }
  39345. }
  39346. declare module BABYLON {
  39347. /**
  39348. * 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
  39349. */
  39350. export class SixDofDragBehavior implements Behavior<Mesh> {
  39351. private static _virtualScene;
  39352. private _ownerNode;
  39353. private _sceneRenderObserver;
  39354. private _scene;
  39355. private _targetPosition;
  39356. private _virtualOriginMesh;
  39357. private _virtualDragMesh;
  39358. private _pointerObserver;
  39359. private _moving;
  39360. private _startingOrientation;
  39361. /**
  39362. * 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)
  39363. */
  39364. private zDragFactor;
  39365. /**
  39366. * If the object should rotate to face the drag origin
  39367. */
  39368. rotateDraggedObject: boolean;
  39369. /**
  39370. * If the behavior is currently in a dragging state
  39371. */
  39372. dragging: boolean;
  39373. /**
  39374. * 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)
  39375. */
  39376. dragDeltaRatio: number;
  39377. /**
  39378. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39379. */
  39380. currentDraggingPointerID: number;
  39381. /**
  39382. * If camera controls should be detached during the drag
  39383. */
  39384. detachCameraControls: boolean;
  39385. /**
  39386. * Fires each time a drag starts
  39387. */
  39388. onDragStartObservable: Observable<{}>;
  39389. /**
  39390. * Fires each time a drag ends (eg. mouse release after drag)
  39391. */
  39392. onDragEndObservable: Observable<{}>;
  39393. /**
  39394. * 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
  39395. */
  39396. constructor();
  39397. /**
  39398. * The name of the behavior
  39399. */
  39400. get name(): string;
  39401. /**
  39402. * Initializes the behavior
  39403. */
  39404. init(): void;
  39405. /**
  39406. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39407. */
  39408. private get _pointerCamera();
  39409. /**
  39410. * Attaches the scale behavior the passed in mesh
  39411. * @param ownerNode The mesh that will be scaled around once attached
  39412. */
  39413. attach(ownerNode: Mesh): void;
  39414. /**
  39415. * Detaches the behavior from the mesh
  39416. */
  39417. detach(): void;
  39418. }
  39419. }
  39420. declare module BABYLON {
  39421. /**
  39422. * Class used to apply inverse kinematics to bones
  39423. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39424. */
  39425. export class BoneIKController {
  39426. private static _tmpVecs;
  39427. private static _tmpQuat;
  39428. private static _tmpMats;
  39429. /**
  39430. * Gets or sets the target mesh
  39431. */
  39432. targetMesh: AbstractMesh;
  39433. /** Gets or sets the mesh used as pole */
  39434. poleTargetMesh: AbstractMesh;
  39435. /**
  39436. * Gets or sets the bone used as pole
  39437. */
  39438. poleTargetBone: Nullable<Bone>;
  39439. /**
  39440. * Gets or sets the target position
  39441. */
  39442. targetPosition: Vector3;
  39443. /**
  39444. * Gets or sets the pole target position
  39445. */
  39446. poleTargetPosition: Vector3;
  39447. /**
  39448. * Gets or sets the pole target local offset
  39449. */
  39450. poleTargetLocalOffset: Vector3;
  39451. /**
  39452. * Gets or sets the pole angle
  39453. */
  39454. poleAngle: number;
  39455. /**
  39456. * Gets or sets the mesh associated with the controller
  39457. */
  39458. mesh: AbstractMesh;
  39459. /**
  39460. * 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)
  39461. */
  39462. slerpAmount: number;
  39463. private _bone1Quat;
  39464. private _bone1Mat;
  39465. private _bone2Ang;
  39466. private _bone1;
  39467. private _bone2;
  39468. private _bone1Length;
  39469. private _bone2Length;
  39470. private _maxAngle;
  39471. private _maxReach;
  39472. private _rightHandedSystem;
  39473. private _bendAxis;
  39474. private _slerping;
  39475. private _adjustRoll;
  39476. /**
  39477. * Gets or sets maximum allowed angle
  39478. */
  39479. get maxAngle(): number;
  39480. set maxAngle(value: number);
  39481. /**
  39482. * Creates a new BoneIKController
  39483. * @param mesh defines the mesh to control
  39484. * @param bone defines the bone to control
  39485. * @param options defines options to set up the controller
  39486. */
  39487. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39488. targetMesh?: AbstractMesh;
  39489. poleTargetMesh?: AbstractMesh;
  39490. poleTargetBone?: Bone;
  39491. poleTargetLocalOffset?: Vector3;
  39492. poleAngle?: number;
  39493. bendAxis?: Vector3;
  39494. maxAngle?: number;
  39495. slerpAmount?: number;
  39496. });
  39497. private _setMaxAngle;
  39498. /**
  39499. * Force the controller to update the bones
  39500. */
  39501. update(): void;
  39502. }
  39503. }
  39504. declare module BABYLON {
  39505. /**
  39506. * Class used to make a bone look toward a point in space
  39507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39508. */
  39509. export class BoneLookController {
  39510. private static _tmpVecs;
  39511. private static _tmpQuat;
  39512. private static _tmpMats;
  39513. /**
  39514. * The target Vector3 that the bone will look at
  39515. */
  39516. target: Vector3;
  39517. /**
  39518. * The mesh that the bone is attached to
  39519. */
  39520. mesh: AbstractMesh;
  39521. /**
  39522. * The bone that will be looking to the target
  39523. */
  39524. bone: Bone;
  39525. /**
  39526. * The up axis of the coordinate system that is used when the bone is rotated
  39527. */
  39528. upAxis: Vector3;
  39529. /**
  39530. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39531. */
  39532. upAxisSpace: Space;
  39533. /**
  39534. * Used to make an adjustment to the yaw of the bone
  39535. */
  39536. adjustYaw: number;
  39537. /**
  39538. * Used to make an adjustment to the pitch of the bone
  39539. */
  39540. adjustPitch: number;
  39541. /**
  39542. * Used to make an adjustment to the roll of the bone
  39543. */
  39544. adjustRoll: number;
  39545. /**
  39546. * 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)
  39547. */
  39548. slerpAmount: number;
  39549. private _minYaw;
  39550. private _maxYaw;
  39551. private _minPitch;
  39552. private _maxPitch;
  39553. private _minYawSin;
  39554. private _minYawCos;
  39555. private _maxYawSin;
  39556. private _maxYawCos;
  39557. private _midYawConstraint;
  39558. private _minPitchTan;
  39559. private _maxPitchTan;
  39560. private _boneQuat;
  39561. private _slerping;
  39562. private _transformYawPitch;
  39563. private _transformYawPitchInv;
  39564. private _firstFrameSkipped;
  39565. private _yawRange;
  39566. private _fowardAxis;
  39567. /**
  39568. * Gets or sets the minimum yaw angle that the bone can look to
  39569. */
  39570. get minYaw(): number;
  39571. set minYaw(value: number);
  39572. /**
  39573. * Gets or sets the maximum yaw angle that the bone can look to
  39574. */
  39575. get maxYaw(): number;
  39576. set maxYaw(value: number);
  39577. /**
  39578. * Gets or sets the minimum pitch angle that the bone can look to
  39579. */
  39580. get minPitch(): number;
  39581. set minPitch(value: number);
  39582. /**
  39583. * Gets or sets the maximum pitch angle that the bone can look to
  39584. */
  39585. get maxPitch(): number;
  39586. set maxPitch(value: number);
  39587. /**
  39588. * Create a BoneLookController
  39589. * @param mesh the mesh that the bone belongs to
  39590. * @param bone the bone that will be looking to the target
  39591. * @param target the target Vector3 to look at
  39592. * @param options optional settings:
  39593. * * maxYaw: the maximum angle the bone will yaw to
  39594. * * minYaw: the minimum angle the bone will yaw to
  39595. * * maxPitch: the maximum angle the bone will pitch to
  39596. * * minPitch: the minimum angle the bone will yaw to
  39597. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39598. * * upAxis: the up axis of the coordinate system
  39599. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39600. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39601. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39602. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39603. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39604. * * adjustRoll: used to make an adjustment to the roll of the bone
  39605. **/
  39606. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39607. maxYaw?: number;
  39608. minYaw?: number;
  39609. maxPitch?: number;
  39610. minPitch?: number;
  39611. slerpAmount?: number;
  39612. upAxis?: Vector3;
  39613. upAxisSpace?: Space;
  39614. yawAxis?: Vector3;
  39615. pitchAxis?: Vector3;
  39616. adjustYaw?: number;
  39617. adjustPitch?: number;
  39618. adjustRoll?: number;
  39619. });
  39620. /**
  39621. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39622. */
  39623. update(): void;
  39624. private _getAngleDiff;
  39625. private _getAngleBetween;
  39626. private _isAngleBetween;
  39627. }
  39628. }
  39629. declare module BABYLON {
  39630. /**
  39631. * Manage the gamepad inputs to control an arc rotate camera.
  39632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39633. */
  39634. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39635. /**
  39636. * Defines the camera the input is attached to.
  39637. */
  39638. camera: ArcRotateCamera;
  39639. /**
  39640. * Defines the gamepad the input is gathering event from.
  39641. */
  39642. gamepad: Nullable<Gamepad>;
  39643. /**
  39644. * Defines the gamepad rotation sensiblity.
  39645. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39646. */
  39647. gamepadRotationSensibility: number;
  39648. /**
  39649. * Defines the gamepad move sensiblity.
  39650. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39651. */
  39652. gamepadMoveSensibility: number;
  39653. private _yAxisScale;
  39654. /**
  39655. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39656. */
  39657. get invertYAxis(): boolean;
  39658. set invertYAxis(value: boolean);
  39659. private _onGamepadConnectedObserver;
  39660. private _onGamepadDisconnectedObserver;
  39661. /**
  39662. * Attach the input controls to a specific dom element to get the input from.
  39663. * @param element Defines the element the controls should be listened from
  39664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39665. */
  39666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39667. /**
  39668. * Detach the current controls from the specified dom element.
  39669. * @param element Defines the element to stop listening the inputs from
  39670. */
  39671. detachControl(element: Nullable<HTMLElement>): void;
  39672. /**
  39673. * Update the current camera state depending on the inputs that have been used this frame.
  39674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39675. */
  39676. checkInputs(): void;
  39677. /**
  39678. * Gets the class name of the current intput.
  39679. * @returns the class name
  39680. */
  39681. getClassName(): string;
  39682. /**
  39683. * Get the friendly name associated with the input class.
  39684. * @returns the input friendly name
  39685. */
  39686. getSimpleName(): string;
  39687. }
  39688. }
  39689. declare module BABYLON {
  39690. interface ArcRotateCameraInputsManager {
  39691. /**
  39692. * Add orientation input support to the input manager.
  39693. * @returns the current input manager
  39694. */
  39695. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39696. }
  39697. /**
  39698. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39700. */
  39701. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39702. /**
  39703. * Defines the camera the input is attached to.
  39704. */
  39705. camera: ArcRotateCamera;
  39706. /**
  39707. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39708. */
  39709. alphaCorrection: number;
  39710. /**
  39711. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39712. */
  39713. gammaCorrection: number;
  39714. private _alpha;
  39715. private _gamma;
  39716. private _dirty;
  39717. private _deviceOrientationHandler;
  39718. /**
  39719. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39720. */
  39721. constructor();
  39722. /**
  39723. * Attach the input controls to a specific dom element to get the input from.
  39724. * @param element Defines the element the controls should be listened from
  39725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39726. */
  39727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39728. /** @hidden */
  39729. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39730. /**
  39731. * Update the current camera state depending on the inputs that have been used this frame.
  39732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39733. */
  39734. checkInputs(): void;
  39735. /**
  39736. * Detach the current controls from the specified dom element.
  39737. * @param element Defines the element to stop listening the inputs from
  39738. */
  39739. detachControl(element: Nullable<HTMLElement>): void;
  39740. /**
  39741. * Gets the class name of the current intput.
  39742. * @returns the class name
  39743. */
  39744. getClassName(): string;
  39745. /**
  39746. * Get the friendly name associated with the input class.
  39747. * @returns the input friendly name
  39748. */
  39749. getSimpleName(): string;
  39750. }
  39751. }
  39752. declare module BABYLON {
  39753. /**
  39754. * Listen to mouse events to control the camera.
  39755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39756. */
  39757. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39758. /**
  39759. * Defines the camera the input is attached to.
  39760. */
  39761. camera: FlyCamera;
  39762. /**
  39763. * Defines if touch is enabled. (Default is true.)
  39764. */
  39765. touchEnabled: boolean;
  39766. /**
  39767. * Defines the buttons associated with the input to handle camera rotation.
  39768. */
  39769. buttons: number[];
  39770. /**
  39771. * Assign buttons for Yaw control.
  39772. */
  39773. buttonsYaw: number[];
  39774. /**
  39775. * Assign buttons for Pitch control.
  39776. */
  39777. buttonsPitch: number[];
  39778. /**
  39779. * Assign buttons for Roll control.
  39780. */
  39781. buttonsRoll: number[];
  39782. /**
  39783. * Detect if any button is being pressed while mouse is moved.
  39784. * -1 = Mouse locked.
  39785. * 0 = Left button.
  39786. * 1 = Middle Button.
  39787. * 2 = Right Button.
  39788. */
  39789. activeButton: number;
  39790. /**
  39791. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39792. * Higher values reduce its sensitivity.
  39793. */
  39794. angularSensibility: number;
  39795. private _mousemoveCallback;
  39796. private _observer;
  39797. private _rollObserver;
  39798. private previousPosition;
  39799. private noPreventDefault;
  39800. private element;
  39801. /**
  39802. * Listen to mouse events to control the camera.
  39803. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39805. */
  39806. constructor(touchEnabled?: boolean);
  39807. /**
  39808. * Attach the mouse control to the HTML DOM element.
  39809. * @param element Defines the element that listens to the input events.
  39810. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39811. */
  39812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39813. /**
  39814. * Detach the current controls from the specified dom element.
  39815. * @param element Defines the element to stop listening the inputs from
  39816. */
  39817. detachControl(element: Nullable<HTMLElement>): void;
  39818. /**
  39819. * Gets the class name of the current input.
  39820. * @returns the class name.
  39821. */
  39822. getClassName(): string;
  39823. /**
  39824. * Get the friendly name associated with the input class.
  39825. * @returns the input's friendly name.
  39826. */
  39827. getSimpleName(): string;
  39828. private _pointerInput;
  39829. private _onMouseMove;
  39830. /**
  39831. * Rotate camera by mouse offset.
  39832. */
  39833. private rotateCamera;
  39834. }
  39835. }
  39836. declare module BABYLON {
  39837. /**
  39838. * Default Inputs manager for the FlyCamera.
  39839. * It groups all the default supported inputs for ease of use.
  39840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39841. */
  39842. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39843. /**
  39844. * Instantiates a new FlyCameraInputsManager.
  39845. * @param camera Defines the camera the inputs belong to.
  39846. */
  39847. constructor(camera: FlyCamera);
  39848. /**
  39849. * Add keyboard input support to the input manager.
  39850. * @returns the new FlyCameraKeyboardMoveInput().
  39851. */
  39852. addKeyboard(): FlyCameraInputsManager;
  39853. /**
  39854. * Add mouse input support to the input manager.
  39855. * @param touchEnabled Enable touch screen support.
  39856. * @returns the new FlyCameraMouseInput().
  39857. */
  39858. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39859. }
  39860. }
  39861. declare module BABYLON {
  39862. /**
  39863. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39864. * such as in a 3D Space Shooter or a Flight Simulator.
  39865. */
  39866. export class FlyCamera extends TargetCamera {
  39867. /**
  39868. * Define the collision ellipsoid of the camera.
  39869. * This is helpful for simulating a camera body, like a player's body.
  39870. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39871. */
  39872. ellipsoid: Vector3;
  39873. /**
  39874. * Define an offset for the position of the ellipsoid around the camera.
  39875. * This can be helpful if the camera is attached away from the player's body center,
  39876. * such as at its head.
  39877. */
  39878. ellipsoidOffset: Vector3;
  39879. /**
  39880. * Enable or disable collisions of the camera with the rest of the scene objects.
  39881. */
  39882. checkCollisions: boolean;
  39883. /**
  39884. * Enable or disable gravity on the camera.
  39885. */
  39886. applyGravity: boolean;
  39887. /**
  39888. * Define the current direction the camera is moving to.
  39889. */
  39890. cameraDirection: Vector3;
  39891. /**
  39892. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39893. * This overrides and empties cameraRotation.
  39894. */
  39895. rotationQuaternion: Quaternion;
  39896. /**
  39897. * Track Roll to maintain the wanted Rolling when looking around.
  39898. */
  39899. _trackRoll: number;
  39900. /**
  39901. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39902. */
  39903. rollCorrect: number;
  39904. /**
  39905. * Mimic a banked turn, Rolling the camera when Yawing.
  39906. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39907. */
  39908. bankedTurn: boolean;
  39909. /**
  39910. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39911. */
  39912. bankedTurnLimit: number;
  39913. /**
  39914. * Value of 0 disables the banked Roll.
  39915. * Value of 1 is equal to the Yaw angle in radians.
  39916. */
  39917. bankedTurnMultiplier: number;
  39918. /**
  39919. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39920. */
  39921. inputs: FlyCameraInputsManager;
  39922. /**
  39923. * Gets the input sensibility for mouse input.
  39924. * Higher values reduce sensitivity.
  39925. */
  39926. get angularSensibility(): number;
  39927. /**
  39928. * Sets the input sensibility for a mouse input.
  39929. * Higher values reduce sensitivity.
  39930. */
  39931. set angularSensibility(value: number);
  39932. /**
  39933. * Get the keys for camera movement forward.
  39934. */
  39935. get keysForward(): number[];
  39936. /**
  39937. * Set the keys for camera movement forward.
  39938. */
  39939. set keysForward(value: number[]);
  39940. /**
  39941. * Get the keys for camera movement backward.
  39942. */
  39943. get keysBackward(): number[];
  39944. set keysBackward(value: number[]);
  39945. /**
  39946. * Get the keys for camera movement up.
  39947. */
  39948. get keysUp(): number[];
  39949. /**
  39950. * Set the keys for camera movement up.
  39951. */
  39952. set keysUp(value: number[]);
  39953. /**
  39954. * Get the keys for camera movement down.
  39955. */
  39956. get keysDown(): number[];
  39957. /**
  39958. * Set the keys for camera movement down.
  39959. */
  39960. set keysDown(value: number[]);
  39961. /**
  39962. * Get the keys for camera movement left.
  39963. */
  39964. get keysLeft(): number[];
  39965. /**
  39966. * Set the keys for camera movement left.
  39967. */
  39968. set keysLeft(value: number[]);
  39969. /**
  39970. * Set the keys for camera movement right.
  39971. */
  39972. get keysRight(): number[];
  39973. /**
  39974. * Set the keys for camera movement right.
  39975. */
  39976. set keysRight(value: number[]);
  39977. /**
  39978. * Event raised when the camera collides with a mesh in the scene.
  39979. */
  39980. onCollide: (collidedMesh: AbstractMesh) => void;
  39981. private _collider;
  39982. private _needMoveForGravity;
  39983. private _oldPosition;
  39984. private _diffPosition;
  39985. private _newPosition;
  39986. /** @hidden */
  39987. _localDirection: Vector3;
  39988. /** @hidden */
  39989. _transformedDirection: Vector3;
  39990. /**
  39991. * Instantiates a FlyCamera.
  39992. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39993. * such as in a 3D Space Shooter or a Flight Simulator.
  39994. * @param name Define the name of the camera in the scene.
  39995. * @param position Define the starting position of the camera in the scene.
  39996. * @param scene Define the scene the camera belongs to.
  39997. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39998. */
  39999. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40000. /**
  40001. * Attach a control to the HTML DOM element.
  40002. * @param element Defines the element that listens to the input events.
  40003. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40004. */
  40005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40006. /**
  40007. * Detach a control from the HTML DOM element.
  40008. * The camera will stop reacting to that input.
  40009. * @param element Defines the element that listens to the input events.
  40010. */
  40011. detachControl(element: HTMLElement): void;
  40012. private _collisionMask;
  40013. /**
  40014. * Get the mask that the camera ignores in collision events.
  40015. */
  40016. get collisionMask(): number;
  40017. /**
  40018. * Set the mask that the camera ignores in collision events.
  40019. */
  40020. set collisionMask(mask: number);
  40021. /** @hidden */
  40022. _collideWithWorld(displacement: Vector3): void;
  40023. /** @hidden */
  40024. private _onCollisionPositionChange;
  40025. /** @hidden */
  40026. _checkInputs(): void;
  40027. /** @hidden */
  40028. _decideIfNeedsToMove(): boolean;
  40029. /** @hidden */
  40030. _updatePosition(): void;
  40031. /**
  40032. * Restore the Roll to its target value at the rate specified.
  40033. * @param rate - Higher means slower restoring.
  40034. * @hidden
  40035. */
  40036. restoreRoll(rate: number): void;
  40037. /**
  40038. * Destroy the camera and release the current resources held by it.
  40039. */
  40040. dispose(): void;
  40041. /**
  40042. * Get the current object class name.
  40043. * @returns the class name.
  40044. */
  40045. getClassName(): string;
  40046. }
  40047. }
  40048. declare module BABYLON {
  40049. /**
  40050. * Listen to keyboard events to control the camera.
  40051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40052. */
  40053. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40054. /**
  40055. * Defines the camera the input is attached to.
  40056. */
  40057. camera: FlyCamera;
  40058. /**
  40059. * The list of keyboard keys used to control the forward move of the camera.
  40060. */
  40061. keysForward: number[];
  40062. /**
  40063. * The list of keyboard keys used to control the backward move of the camera.
  40064. */
  40065. keysBackward: number[];
  40066. /**
  40067. * The list of keyboard keys used to control the forward move of the camera.
  40068. */
  40069. keysUp: number[];
  40070. /**
  40071. * The list of keyboard keys used to control the backward move of the camera.
  40072. */
  40073. keysDown: number[];
  40074. /**
  40075. * The list of keyboard keys used to control the right strafe move of the camera.
  40076. */
  40077. keysRight: number[];
  40078. /**
  40079. * The list of keyboard keys used to control the left strafe move of the camera.
  40080. */
  40081. keysLeft: number[];
  40082. private _keys;
  40083. private _onCanvasBlurObserver;
  40084. private _onKeyboardObserver;
  40085. private _engine;
  40086. private _scene;
  40087. /**
  40088. * Attach the input controls to a specific dom element to get the input from.
  40089. * @param element Defines the element the controls should be listened from
  40090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40091. */
  40092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40093. /**
  40094. * Detach the current controls from the specified dom element.
  40095. * @param element Defines the element to stop listening the inputs from
  40096. */
  40097. detachControl(element: Nullable<HTMLElement>): void;
  40098. /**
  40099. * Gets the class name of the current intput.
  40100. * @returns the class name
  40101. */
  40102. getClassName(): string;
  40103. /** @hidden */
  40104. _onLostFocus(e: FocusEvent): void;
  40105. /**
  40106. * Get the friendly name associated with the input class.
  40107. * @returns the input friendly name
  40108. */
  40109. getSimpleName(): string;
  40110. /**
  40111. * Update the current camera state depending on the inputs that have been used this frame.
  40112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40113. */
  40114. checkInputs(): void;
  40115. }
  40116. }
  40117. declare module BABYLON {
  40118. /**
  40119. * Manage the mouse wheel inputs to control a follow camera.
  40120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40121. */
  40122. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40123. /**
  40124. * Defines the camera the input is attached to.
  40125. */
  40126. camera: FollowCamera;
  40127. /**
  40128. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40129. */
  40130. axisControlRadius: boolean;
  40131. /**
  40132. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40133. */
  40134. axisControlHeight: boolean;
  40135. /**
  40136. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40137. */
  40138. axisControlRotation: boolean;
  40139. /**
  40140. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40141. * relation to mouseWheel events.
  40142. */
  40143. wheelPrecision: number;
  40144. /**
  40145. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40146. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40147. */
  40148. wheelDeltaPercentage: number;
  40149. private _wheel;
  40150. private _observer;
  40151. /**
  40152. * Attach the input controls to a specific dom element to get the input from.
  40153. * @param element Defines the element the controls should be listened from
  40154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40155. */
  40156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40157. /**
  40158. * Detach the current controls from the specified dom element.
  40159. * @param element Defines the element to stop listening the inputs from
  40160. */
  40161. detachControl(element: Nullable<HTMLElement>): void;
  40162. /**
  40163. * Gets the class name of the current intput.
  40164. * @returns the class name
  40165. */
  40166. getClassName(): string;
  40167. /**
  40168. * Get the friendly name associated with the input class.
  40169. * @returns the input friendly name
  40170. */
  40171. getSimpleName(): string;
  40172. }
  40173. }
  40174. declare module BABYLON {
  40175. /**
  40176. * Manage the pointers inputs to control an follow camera.
  40177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40178. */
  40179. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40180. /**
  40181. * Defines the camera the input is attached to.
  40182. */
  40183. camera: FollowCamera;
  40184. /**
  40185. * Gets the class name of the current input.
  40186. * @returns the class name
  40187. */
  40188. getClassName(): string;
  40189. /**
  40190. * Defines the pointer angular sensibility along the X axis or how fast is
  40191. * the camera rotating.
  40192. * A negative number will reverse the axis direction.
  40193. */
  40194. angularSensibilityX: number;
  40195. /**
  40196. * Defines the pointer angular sensibility along the Y axis or how fast is
  40197. * the camera rotating.
  40198. * A negative number will reverse the axis direction.
  40199. */
  40200. angularSensibilityY: number;
  40201. /**
  40202. * Defines the pointer pinch precision or how fast is the camera zooming.
  40203. * A negative number will reverse the axis direction.
  40204. */
  40205. pinchPrecision: number;
  40206. /**
  40207. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40208. * from 0.
  40209. * It defines the percentage of current camera.radius to use as delta when
  40210. * pinch zoom is used.
  40211. */
  40212. pinchDeltaPercentage: number;
  40213. /**
  40214. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40215. */
  40216. axisXControlRadius: boolean;
  40217. /**
  40218. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40219. */
  40220. axisXControlHeight: boolean;
  40221. /**
  40222. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40223. */
  40224. axisXControlRotation: boolean;
  40225. /**
  40226. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40227. */
  40228. axisYControlRadius: boolean;
  40229. /**
  40230. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40231. */
  40232. axisYControlHeight: boolean;
  40233. /**
  40234. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40235. */
  40236. axisYControlRotation: boolean;
  40237. /**
  40238. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40239. */
  40240. axisPinchControlRadius: boolean;
  40241. /**
  40242. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40243. */
  40244. axisPinchControlHeight: boolean;
  40245. /**
  40246. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40247. */
  40248. axisPinchControlRotation: boolean;
  40249. /**
  40250. * Log error messages if basic misconfiguration has occurred.
  40251. */
  40252. warningEnable: boolean;
  40253. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40254. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40255. private _warningCounter;
  40256. private _warning;
  40257. }
  40258. }
  40259. declare module BABYLON {
  40260. /**
  40261. * Default Inputs manager for the FollowCamera.
  40262. * It groups all the default supported inputs for ease of use.
  40263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40264. */
  40265. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40266. /**
  40267. * Instantiates a new FollowCameraInputsManager.
  40268. * @param camera Defines the camera the inputs belong to
  40269. */
  40270. constructor(camera: FollowCamera);
  40271. /**
  40272. * Add keyboard input support to the input manager.
  40273. * @returns the current input manager
  40274. */
  40275. addKeyboard(): FollowCameraInputsManager;
  40276. /**
  40277. * Add mouse wheel input support to the input manager.
  40278. * @returns the current input manager
  40279. */
  40280. addMouseWheel(): FollowCameraInputsManager;
  40281. /**
  40282. * Add pointers input support to the input manager.
  40283. * @returns the current input manager
  40284. */
  40285. addPointers(): FollowCameraInputsManager;
  40286. /**
  40287. * Add orientation input support to the input manager.
  40288. * @returns the current input manager
  40289. */
  40290. addVRDeviceOrientation(): FollowCameraInputsManager;
  40291. }
  40292. }
  40293. declare module BABYLON {
  40294. /**
  40295. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40296. * an arc rotate version arcFollowCamera are available.
  40297. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40298. */
  40299. export class FollowCamera extends TargetCamera {
  40300. /**
  40301. * Distance the follow camera should follow an object at
  40302. */
  40303. radius: number;
  40304. /**
  40305. * Minimum allowed distance of the camera to the axis of rotation
  40306. * (The camera can not get closer).
  40307. * This can help limiting how the Camera is able to move in the scene.
  40308. */
  40309. lowerRadiusLimit: Nullable<number>;
  40310. /**
  40311. * Maximum allowed distance of the camera to the axis of rotation
  40312. * (The camera can not get further).
  40313. * This can help limiting how the Camera is able to move in the scene.
  40314. */
  40315. upperRadiusLimit: Nullable<number>;
  40316. /**
  40317. * Define a rotation offset between the camera and the object it follows
  40318. */
  40319. rotationOffset: number;
  40320. /**
  40321. * Minimum allowed angle to camera position relative to target object.
  40322. * This can help limiting how the Camera is able to move in the scene.
  40323. */
  40324. lowerRotationOffsetLimit: Nullable<number>;
  40325. /**
  40326. * Maximum allowed angle to camera position relative to target object.
  40327. * This can help limiting how the Camera is able to move in the scene.
  40328. */
  40329. upperRotationOffsetLimit: Nullable<number>;
  40330. /**
  40331. * Define a height offset between the camera and the object it follows.
  40332. * It can help following an object from the top (like a car chaing a plane)
  40333. */
  40334. heightOffset: number;
  40335. /**
  40336. * Minimum allowed height of camera position relative to target object.
  40337. * This can help limiting how the Camera is able to move in the scene.
  40338. */
  40339. lowerHeightOffsetLimit: Nullable<number>;
  40340. /**
  40341. * Maximum allowed height of camera position relative to target object.
  40342. * This can help limiting how the Camera is able to move in the scene.
  40343. */
  40344. upperHeightOffsetLimit: Nullable<number>;
  40345. /**
  40346. * Define how fast the camera can accelerate to follow it s target.
  40347. */
  40348. cameraAcceleration: number;
  40349. /**
  40350. * Define the speed limit of the camera following an object.
  40351. */
  40352. maxCameraSpeed: number;
  40353. /**
  40354. * Define the target of the camera.
  40355. */
  40356. lockedTarget: Nullable<AbstractMesh>;
  40357. /**
  40358. * Defines the input associated with the camera.
  40359. */
  40360. inputs: FollowCameraInputsManager;
  40361. /**
  40362. * Instantiates the follow camera.
  40363. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40364. * @param name Define the name of the camera in the scene
  40365. * @param position Define the position of the camera
  40366. * @param scene Define the scene the camera belong to
  40367. * @param lockedTarget Define the target of the camera
  40368. */
  40369. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40370. private _follow;
  40371. /**
  40372. * Attached controls to the current camera.
  40373. * @param element Defines the element the controls should be listened from
  40374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40375. */
  40376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40377. /**
  40378. * Detach the current controls from the camera.
  40379. * The camera will stop reacting to inputs.
  40380. * @param element Defines the element to stop listening the inputs from
  40381. */
  40382. detachControl(element: HTMLElement): void;
  40383. /** @hidden */
  40384. _checkInputs(): void;
  40385. private _checkLimits;
  40386. /**
  40387. * Gets the camera class name.
  40388. * @returns the class name
  40389. */
  40390. getClassName(): string;
  40391. }
  40392. /**
  40393. * Arc Rotate version of the follow camera.
  40394. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40395. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40396. */
  40397. export class ArcFollowCamera extends TargetCamera {
  40398. /** The longitudinal angle of the camera */
  40399. alpha: number;
  40400. /** The latitudinal angle of the camera */
  40401. beta: number;
  40402. /** The radius of the camera from its target */
  40403. radius: number;
  40404. /** Define the camera target (the messh it should follow) */
  40405. target: Nullable<AbstractMesh>;
  40406. private _cartesianCoordinates;
  40407. /**
  40408. * Instantiates a new ArcFollowCamera
  40409. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40410. * @param name Define the name of the camera
  40411. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40412. * @param beta Define the rotation angle of the camera around the elevation axis
  40413. * @param radius Define the radius of the camera from its target point
  40414. * @param target Define the target of the camera
  40415. * @param scene Define the scene the camera belongs to
  40416. */
  40417. constructor(name: string,
  40418. /** The longitudinal angle of the camera */
  40419. alpha: number,
  40420. /** The latitudinal angle of the camera */
  40421. beta: number,
  40422. /** The radius of the camera from its target */
  40423. radius: number,
  40424. /** Define the camera target (the messh it should follow) */
  40425. target: Nullable<AbstractMesh>, scene: Scene);
  40426. private _follow;
  40427. /** @hidden */
  40428. _checkInputs(): void;
  40429. /**
  40430. * Returns the class name of the object.
  40431. * It is mostly used internally for serialization purposes.
  40432. */
  40433. getClassName(): string;
  40434. }
  40435. }
  40436. declare module BABYLON {
  40437. /**
  40438. * Manage the keyboard inputs to control the movement of a follow camera.
  40439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40440. */
  40441. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40442. /**
  40443. * Defines the camera the input is attached to.
  40444. */
  40445. camera: FollowCamera;
  40446. /**
  40447. * Defines the list of key codes associated with the up action (increase heightOffset)
  40448. */
  40449. keysHeightOffsetIncr: number[];
  40450. /**
  40451. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40452. */
  40453. keysHeightOffsetDecr: number[];
  40454. /**
  40455. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40456. */
  40457. keysHeightOffsetModifierAlt: boolean;
  40458. /**
  40459. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40460. */
  40461. keysHeightOffsetModifierCtrl: boolean;
  40462. /**
  40463. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40464. */
  40465. keysHeightOffsetModifierShift: boolean;
  40466. /**
  40467. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40468. */
  40469. keysRotationOffsetIncr: number[];
  40470. /**
  40471. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40472. */
  40473. keysRotationOffsetDecr: number[];
  40474. /**
  40475. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40476. */
  40477. keysRotationOffsetModifierAlt: boolean;
  40478. /**
  40479. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40480. */
  40481. keysRotationOffsetModifierCtrl: boolean;
  40482. /**
  40483. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40484. */
  40485. keysRotationOffsetModifierShift: boolean;
  40486. /**
  40487. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40488. */
  40489. keysRadiusIncr: number[];
  40490. /**
  40491. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40492. */
  40493. keysRadiusDecr: number[];
  40494. /**
  40495. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40496. */
  40497. keysRadiusModifierAlt: boolean;
  40498. /**
  40499. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40500. */
  40501. keysRadiusModifierCtrl: boolean;
  40502. /**
  40503. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40504. */
  40505. keysRadiusModifierShift: boolean;
  40506. /**
  40507. * Defines the rate of change of heightOffset.
  40508. */
  40509. heightSensibility: number;
  40510. /**
  40511. * Defines the rate of change of rotationOffset.
  40512. */
  40513. rotationSensibility: number;
  40514. /**
  40515. * Defines the rate of change of radius.
  40516. */
  40517. radiusSensibility: number;
  40518. private _keys;
  40519. private _ctrlPressed;
  40520. private _altPressed;
  40521. private _shiftPressed;
  40522. private _onCanvasBlurObserver;
  40523. private _onKeyboardObserver;
  40524. private _engine;
  40525. private _scene;
  40526. /**
  40527. * Attach the input controls to a specific dom element to get the input from.
  40528. * @param element Defines the element the controls should be listened from
  40529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40530. */
  40531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40532. /**
  40533. * Detach the current controls from the specified dom element.
  40534. * @param element Defines the element to stop listening the inputs from
  40535. */
  40536. detachControl(element: Nullable<HTMLElement>): void;
  40537. /**
  40538. * Update the current camera state depending on the inputs that have been used this frame.
  40539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40540. */
  40541. checkInputs(): void;
  40542. /**
  40543. * Gets the class name of the current input.
  40544. * @returns the class name
  40545. */
  40546. getClassName(): string;
  40547. /**
  40548. * Get the friendly name associated with the input class.
  40549. * @returns the input friendly name
  40550. */
  40551. getSimpleName(): string;
  40552. /**
  40553. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40554. * allow modification of the heightOffset value.
  40555. */
  40556. private _modifierHeightOffset;
  40557. /**
  40558. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40559. * allow modification of the rotationOffset value.
  40560. */
  40561. private _modifierRotationOffset;
  40562. /**
  40563. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40564. * allow modification of the radius value.
  40565. */
  40566. private _modifierRadius;
  40567. }
  40568. }
  40569. declare module BABYLON {
  40570. interface FreeCameraInputsManager {
  40571. /**
  40572. * @hidden
  40573. */
  40574. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40575. /**
  40576. * Add orientation input support to the input manager.
  40577. * @returns the current input manager
  40578. */
  40579. addDeviceOrientation(): FreeCameraInputsManager;
  40580. }
  40581. /**
  40582. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40583. * Screen rotation is taken into account.
  40584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40585. */
  40586. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40587. private _camera;
  40588. private _screenOrientationAngle;
  40589. private _constantTranform;
  40590. private _screenQuaternion;
  40591. private _alpha;
  40592. private _beta;
  40593. private _gamma;
  40594. /**
  40595. * Can be used to detect if a device orientation sensor is available on a device
  40596. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40597. * @returns a promise that will resolve on orientation change
  40598. */
  40599. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40600. /**
  40601. * @hidden
  40602. */
  40603. _onDeviceOrientationChangedObservable: Observable<void>;
  40604. /**
  40605. * Instantiates a new input
  40606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40607. */
  40608. constructor();
  40609. /**
  40610. * Define the camera controlled by the input.
  40611. */
  40612. get camera(): FreeCamera;
  40613. set camera(camera: FreeCamera);
  40614. /**
  40615. * Attach the input controls to a specific dom element to get the input from.
  40616. * @param element Defines the element the controls should be listened from
  40617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40618. */
  40619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40620. private _orientationChanged;
  40621. private _deviceOrientation;
  40622. /**
  40623. * Detach the current controls from the specified dom element.
  40624. * @param element Defines the element to stop listening the inputs from
  40625. */
  40626. detachControl(element: Nullable<HTMLElement>): void;
  40627. /**
  40628. * Update the current camera state depending on the inputs that have been used this frame.
  40629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40630. */
  40631. checkInputs(): void;
  40632. /**
  40633. * Gets the class name of the current intput.
  40634. * @returns the class name
  40635. */
  40636. getClassName(): string;
  40637. /**
  40638. * Get the friendly name associated with the input class.
  40639. * @returns the input friendly name
  40640. */
  40641. getSimpleName(): string;
  40642. }
  40643. }
  40644. declare module BABYLON {
  40645. /**
  40646. * Manage the gamepad inputs to control a free camera.
  40647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40648. */
  40649. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40650. /**
  40651. * Define the camera the input is attached to.
  40652. */
  40653. camera: FreeCamera;
  40654. /**
  40655. * Define the Gamepad controlling the input
  40656. */
  40657. gamepad: Nullable<Gamepad>;
  40658. /**
  40659. * Defines the gamepad rotation sensiblity.
  40660. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40661. */
  40662. gamepadAngularSensibility: number;
  40663. /**
  40664. * Defines the gamepad move sensiblity.
  40665. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40666. */
  40667. gamepadMoveSensibility: number;
  40668. private _yAxisScale;
  40669. /**
  40670. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40671. */
  40672. get invertYAxis(): boolean;
  40673. set invertYAxis(value: boolean);
  40674. private _onGamepadConnectedObserver;
  40675. private _onGamepadDisconnectedObserver;
  40676. private _cameraTransform;
  40677. private _deltaTransform;
  40678. private _vector3;
  40679. private _vector2;
  40680. /**
  40681. * Attach the input controls to a specific dom element to get the input from.
  40682. * @param element Defines the element the controls should be listened from
  40683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40684. */
  40685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40686. /**
  40687. * Detach the current controls from the specified dom element.
  40688. * @param element Defines the element to stop listening the inputs from
  40689. */
  40690. detachControl(element: Nullable<HTMLElement>): void;
  40691. /**
  40692. * Update the current camera state depending on the inputs that have been used this frame.
  40693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40694. */
  40695. checkInputs(): void;
  40696. /**
  40697. * Gets the class name of the current intput.
  40698. * @returns the class name
  40699. */
  40700. getClassName(): string;
  40701. /**
  40702. * Get the friendly name associated with the input class.
  40703. * @returns the input friendly name
  40704. */
  40705. getSimpleName(): string;
  40706. }
  40707. }
  40708. declare module BABYLON {
  40709. /**
  40710. * Defines the potential axis of a Joystick
  40711. */
  40712. export enum JoystickAxis {
  40713. /** X axis */
  40714. X = 0,
  40715. /** Y axis */
  40716. Y = 1,
  40717. /** Z axis */
  40718. Z = 2
  40719. }
  40720. /**
  40721. * Class used to define virtual joystick (used in touch mode)
  40722. */
  40723. export class VirtualJoystick {
  40724. /**
  40725. * Gets or sets a boolean indicating that left and right values must be inverted
  40726. */
  40727. reverseLeftRight: boolean;
  40728. /**
  40729. * Gets or sets a boolean indicating that up and down values must be inverted
  40730. */
  40731. reverseUpDown: boolean;
  40732. /**
  40733. * Gets the offset value for the position (ie. the change of the position value)
  40734. */
  40735. deltaPosition: Vector3;
  40736. /**
  40737. * Gets a boolean indicating if the virtual joystick was pressed
  40738. */
  40739. pressed: boolean;
  40740. /**
  40741. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40742. */
  40743. static Canvas: Nullable<HTMLCanvasElement>;
  40744. private static _globalJoystickIndex;
  40745. private static vjCanvasContext;
  40746. private static vjCanvasWidth;
  40747. private static vjCanvasHeight;
  40748. private static halfWidth;
  40749. private _action;
  40750. private _axisTargetedByLeftAndRight;
  40751. private _axisTargetedByUpAndDown;
  40752. private _joystickSensibility;
  40753. private _inversedSensibility;
  40754. private _joystickPointerID;
  40755. private _joystickColor;
  40756. private _joystickPointerPos;
  40757. private _joystickPreviousPointerPos;
  40758. private _joystickPointerStartPos;
  40759. private _deltaJoystickVector;
  40760. private _leftJoystick;
  40761. private _touches;
  40762. private _onPointerDownHandlerRef;
  40763. private _onPointerMoveHandlerRef;
  40764. private _onPointerUpHandlerRef;
  40765. private _onResize;
  40766. /**
  40767. * Creates a new virtual joystick
  40768. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40769. */
  40770. constructor(leftJoystick?: boolean);
  40771. /**
  40772. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40773. * @param newJoystickSensibility defines the new sensibility
  40774. */
  40775. setJoystickSensibility(newJoystickSensibility: number): void;
  40776. private _onPointerDown;
  40777. private _onPointerMove;
  40778. private _onPointerUp;
  40779. /**
  40780. * Change the color of the virtual joystick
  40781. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40782. */
  40783. setJoystickColor(newColor: string): void;
  40784. /**
  40785. * Defines a callback to call when the joystick is touched
  40786. * @param action defines the callback
  40787. */
  40788. setActionOnTouch(action: () => any): void;
  40789. /**
  40790. * Defines which axis you'd like to control for left & right
  40791. * @param axis defines the axis to use
  40792. */
  40793. setAxisForLeftRight(axis: JoystickAxis): void;
  40794. /**
  40795. * Defines which axis you'd like to control for up & down
  40796. * @param axis defines the axis to use
  40797. */
  40798. setAxisForUpDown(axis: JoystickAxis): void;
  40799. private _drawVirtualJoystick;
  40800. /**
  40801. * Release internal HTML canvas
  40802. */
  40803. releaseCanvas(): void;
  40804. }
  40805. }
  40806. declare module BABYLON {
  40807. interface FreeCameraInputsManager {
  40808. /**
  40809. * Add virtual joystick input support to the input manager.
  40810. * @returns the current input manager
  40811. */
  40812. addVirtualJoystick(): FreeCameraInputsManager;
  40813. }
  40814. /**
  40815. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40817. */
  40818. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40819. /**
  40820. * Defines the camera the input is attached to.
  40821. */
  40822. camera: FreeCamera;
  40823. private _leftjoystick;
  40824. private _rightjoystick;
  40825. /**
  40826. * Gets the left stick of the virtual joystick.
  40827. * @returns The virtual Joystick
  40828. */
  40829. getLeftJoystick(): VirtualJoystick;
  40830. /**
  40831. * Gets the right stick of the virtual joystick.
  40832. * @returns The virtual Joystick
  40833. */
  40834. getRightJoystick(): VirtualJoystick;
  40835. /**
  40836. * Update the current camera state depending on the inputs that have been used this frame.
  40837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40838. */
  40839. checkInputs(): void;
  40840. /**
  40841. * Attach the input controls to a specific dom element to get the input from.
  40842. * @param element Defines the element the controls should be listened from
  40843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40844. */
  40845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40846. /**
  40847. * Detach the current controls from the specified dom element.
  40848. * @param element Defines the element to stop listening the inputs from
  40849. */
  40850. detachControl(element: Nullable<HTMLElement>): void;
  40851. /**
  40852. * Gets the class name of the current intput.
  40853. * @returns the class name
  40854. */
  40855. getClassName(): string;
  40856. /**
  40857. * Get the friendly name associated with the input class.
  40858. * @returns the input friendly name
  40859. */
  40860. getSimpleName(): string;
  40861. }
  40862. }
  40863. declare module BABYLON {
  40864. /**
  40865. * This represents a FPS type of camera controlled by touch.
  40866. * This is like a universal camera minus the Gamepad controls.
  40867. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40868. */
  40869. export class TouchCamera extends FreeCamera {
  40870. /**
  40871. * Defines the touch sensibility for rotation.
  40872. * The higher the faster.
  40873. */
  40874. get touchAngularSensibility(): number;
  40875. set touchAngularSensibility(value: number);
  40876. /**
  40877. * Defines the touch sensibility for move.
  40878. * The higher the faster.
  40879. */
  40880. get touchMoveSensibility(): number;
  40881. set touchMoveSensibility(value: number);
  40882. /**
  40883. * Instantiates a new touch camera.
  40884. * This represents a FPS type of camera controlled by touch.
  40885. * This is like a universal camera minus the Gamepad controls.
  40886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40887. * @param name Define the name of the camera in the scene
  40888. * @param position Define the start position of the camera in the scene
  40889. * @param scene Define the scene the camera belongs to
  40890. */
  40891. constructor(name: string, position: Vector3, scene: Scene);
  40892. /**
  40893. * Gets the current object class name.
  40894. * @return the class name
  40895. */
  40896. getClassName(): string;
  40897. /** @hidden */
  40898. _setupInputs(): void;
  40899. }
  40900. }
  40901. declare module BABYLON {
  40902. /**
  40903. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40904. * being tilted forward or back and left or right.
  40905. */
  40906. export class DeviceOrientationCamera extends FreeCamera {
  40907. private _initialQuaternion;
  40908. private _quaternionCache;
  40909. private _tmpDragQuaternion;
  40910. private _disablePointerInputWhenUsingDeviceOrientation;
  40911. /**
  40912. * Creates a new device orientation camera
  40913. * @param name The name of the camera
  40914. * @param position The start position camera
  40915. * @param scene The scene the camera belongs to
  40916. */
  40917. constructor(name: string, position: Vector3, scene: Scene);
  40918. /**
  40919. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40920. */
  40921. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40922. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40923. private _dragFactor;
  40924. /**
  40925. * Enabled turning on the y axis when the orientation sensor is active
  40926. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40927. */
  40928. enableHorizontalDragging(dragFactor?: number): void;
  40929. /**
  40930. * Gets the current instance class name ("DeviceOrientationCamera").
  40931. * This helps avoiding instanceof at run time.
  40932. * @returns the class name
  40933. */
  40934. getClassName(): string;
  40935. /**
  40936. * @hidden
  40937. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40938. */
  40939. _checkInputs(): void;
  40940. /**
  40941. * Reset the camera to its default orientation on the specified axis only.
  40942. * @param axis The axis to reset
  40943. */
  40944. resetToCurrentRotation(axis?: Axis): void;
  40945. }
  40946. }
  40947. declare module BABYLON {
  40948. /**
  40949. * Defines supported buttons for XBox360 compatible gamepads
  40950. */
  40951. export enum Xbox360Button {
  40952. /** A */
  40953. A = 0,
  40954. /** B */
  40955. B = 1,
  40956. /** X */
  40957. X = 2,
  40958. /** Y */
  40959. Y = 3,
  40960. /** Start */
  40961. Start = 4,
  40962. /** Back */
  40963. Back = 5,
  40964. /** Left button */
  40965. LB = 6,
  40966. /** Right button */
  40967. RB = 7,
  40968. /** Left stick */
  40969. LeftStick = 8,
  40970. /** Right stick */
  40971. RightStick = 9
  40972. }
  40973. /** Defines values for XBox360 DPad */
  40974. export enum Xbox360Dpad {
  40975. /** Up */
  40976. Up = 0,
  40977. /** Down */
  40978. Down = 1,
  40979. /** Left */
  40980. Left = 2,
  40981. /** Right */
  40982. Right = 3
  40983. }
  40984. /**
  40985. * Defines a XBox360 gamepad
  40986. */
  40987. export class Xbox360Pad extends Gamepad {
  40988. private _leftTrigger;
  40989. private _rightTrigger;
  40990. private _onlefttriggerchanged;
  40991. private _onrighttriggerchanged;
  40992. private _onbuttondown;
  40993. private _onbuttonup;
  40994. private _ondpaddown;
  40995. private _ondpadup;
  40996. /** Observable raised when a button is pressed */
  40997. onButtonDownObservable: Observable<Xbox360Button>;
  40998. /** Observable raised when a button is released */
  40999. onButtonUpObservable: Observable<Xbox360Button>;
  41000. /** Observable raised when a pad is pressed */
  41001. onPadDownObservable: Observable<Xbox360Dpad>;
  41002. /** Observable raised when a pad is released */
  41003. onPadUpObservable: Observable<Xbox360Dpad>;
  41004. private _buttonA;
  41005. private _buttonB;
  41006. private _buttonX;
  41007. private _buttonY;
  41008. private _buttonBack;
  41009. private _buttonStart;
  41010. private _buttonLB;
  41011. private _buttonRB;
  41012. private _buttonLeftStick;
  41013. private _buttonRightStick;
  41014. private _dPadUp;
  41015. private _dPadDown;
  41016. private _dPadLeft;
  41017. private _dPadRight;
  41018. private _isXboxOnePad;
  41019. /**
  41020. * Creates a new XBox360 gamepad object
  41021. * @param id defines the id of this gamepad
  41022. * @param index defines its index
  41023. * @param gamepad defines the internal HTML gamepad object
  41024. * @param xboxOne defines if it is a XBox One gamepad
  41025. */
  41026. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41027. /**
  41028. * Defines the callback to call when left trigger is pressed
  41029. * @param callback defines the callback to use
  41030. */
  41031. onlefttriggerchanged(callback: (value: number) => void): void;
  41032. /**
  41033. * Defines the callback to call when right trigger is pressed
  41034. * @param callback defines the callback to use
  41035. */
  41036. onrighttriggerchanged(callback: (value: number) => void): void;
  41037. /**
  41038. * Gets the left trigger value
  41039. */
  41040. get leftTrigger(): number;
  41041. /**
  41042. * Sets the left trigger value
  41043. */
  41044. set leftTrigger(newValue: number);
  41045. /**
  41046. * Gets the right trigger value
  41047. */
  41048. get rightTrigger(): number;
  41049. /**
  41050. * Sets the right trigger value
  41051. */
  41052. set rightTrigger(newValue: number);
  41053. /**
  41054. * Defines the callback to call when a button is pressed
  41055. * @param callback defines the callback to use
  41056. */
  41057. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41058. /**
  41059. * Defines the callback to call when a button is released
  41060. * @param callback defines the callback to use
  41061. */
  41062. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41063. /**
  41064. * Defines the callback to call when a pad is pressed
  41065. * @param callback defines the callback to use
  41066. */
  41067. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41068. /**
  41069. * Defines the callback to call when a pad is released
  41070. * @param callback defines the callback to use
  41071. */
  41072. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41073. private _setButtonValue;
  41074. private _setDPadValue;
  41075. /**
  41076. * Gets the value of the `A` button
  41077. */
  41078. get buttonA(): number;
  41079. /**
  41080. * Sets the value of the `A` button
  41081. */
  41082. set buttonA(value: number);
  41083. /**
  41084. * Gets the value of the `B` button
  41085. */
  41086. get buttonB(): number;
  41087. /**
  41088. * Sets the value of the `B` button
  41089. */
  41090. set buttonB(value: number);
  41091. /**
  41092. * Gets the value of the `X` button
  41093. */
  41094. get buttonX(): number;
  41095. /**
  41096. * Sets the value of the `X` button
  41097. */
  41098. set buttonX(value: number);
  41099. /**
  41100. * Gets the value of the `Y` button
  41101. */
  41102. get buttonY(): number;
  41103. /**
  41104. * Sets the value of the `Y` button
  41105. */
  41106. set buttonY(value: number);
  41107. /**
  41108. * Gets the value of the `Start` button
  41109. */
  41110. get buttonStart(): number;
  41111. /**
  41112. * Sets the value of the `Start` button
  41113. */
  41114. set buttonStart(value: number);
  41115. /**
  41116. * Gets the value of the `Back` button
  41117. */
  41118. get buttonBack(): number;
  41119. /**
  41120. * Sets the value of the `Back` button
  41121. */
  41122. set buttonBack(value: number);
  41123. /**
  41124. * Gets the value of the `Left` button
  41125. */
  41126. get buttonLB(): number;
  41127. /**
  41128. * Sets the value of the `Left` button
  41129. */
  41130. set buttonLB(value: number);
  41131. /**
  41132. * Gets the value of the `Right` button
  41133. */
  41134. get buttonRB(): number;
  41135. /**
  41136. * Sets the value of the `Right` button
  41137. */
  41138. set buttonRB(value: number);
  41139. /**
  41140. * Gets the value of the Left joystick
  41141. */
  41142. get buttonLeftStick(): number;
  41143. /**
  41144. * Sets the value of the Left joystick
  41145. */
  41146. set buttonLeftStick(value: number);
  41147. /**
  41148. * Gets the value of the Right joystick
  41149. */
  41150. get buttonRightStick(): number;
  41151. /**
  41152. * Sets the value of the Right joystick
  41153. */
  41154. set buttonRightStick(value: number);
  41155. /**
  41156. * Gets the value of D-pad up
  41157. */
  41158. get dPadUp(): number;
  41159. /**
  41160. * Sets the value of D-pad up
  41161. */
  41162. set dPadUp(value: number);
  41163. /**
  41164. * Gets the value of D-pad down
  41165. */
  41166. get dPadDown(): number;
  41167. /**
  41168. * Sets the value of D-pad down
  41169. */
  41170. set dPadDown(value: number);
  41171. /**
  41172. * Gets the value of D-pad left
  41173. */
  41174. get dPadLeft(): number;
  41175. /**
  41176. * Sets the value of D-pad left
  41177. */
  41178. set dPadLeft(value: number);
  41179. /**
  41180. * Gets the value of D-pad right
  41181. */
  41182. get dPadRight(): number;
  41183. /**
  41184. * Sets the value of D-pad right
  41185. */
  41186. set dPadRight(value: number);
  41187. /**
  41188. * Force the gamepad to synchronize with device values
  41189. */
  41190. update(): void;
  41191. /**
  41192. * Disposes the gamepad
  41193. */
  41194. dispose(): void;
  41195. }
  41196. }
  41197. declare module BABYLON {
  41198. /**
  41199. * Defines supported buttons for DualShock compatible gamepads
  41200. */
  41201. export enum DualShockButton {
  41202. /** Cross */
  41203. Cross = 0,
  41204. /** Circle */
  41205. Circle = 1,
  41206. /** Square */
  41207. Square = 2,
  41208. /** Triangle */
  41209. Triangle = 3,
  41210. /** Options */
  41211. Options = 4,
  41212. /** Share */
  41213. Share = 5,
  41214. /** L1 */
  41215. L1 = 6,
  41216. /** R1 */
  41217. R1 = 7,
  41218. /** Left stick */
  41219. LeftStick = 8,
  41220. /** Right stick */
  41221. RightStick = 9
  41222. }
  41223. /** Defines values for DualShock DPad */
  41224. export enum DualShockDpad {
  41225. /** Up */
  41226. Up = 0,
  41227. /** Down */
  41228. Down = 1,
  41229. /** Left */
  41230. Left = 2,
  41231. /** Right */
  41232. Right = 3
  41233. }
  41234. /**
  41235. * Defines a DualShock gamepad
  41236. */
  41237. export class DualShockPad extends Gamepad {
  41238. private _leftTrigger;
  41239. private _rightTrigger;
  41240. private _onlefttriggerchanged;
  41241. private _onrighttriggerchanged;
  41242. private _onbuttondown;
  41243. private _onbuttonup;
  41244. private _ondpaddown;
  41245. private _ondpadup;
  41246. /** Observable raised when a button is pressed */
  41247. onButtonDownObservable: Observable<DualShockButton>;
  41248. /** Observable raised when a button is released */
  41249. onButtonUpObservable: Observable<DualShockButton>;
  41250. /** Observable raised when a pad is pressed */
  41251. onPadDownObservable: Observable<DualShockDpad>;
  41252. /** Observable raised when a pad is released */
  41253. onPadUpObservable: Observable<DualShockDpad>;
  41254. private _buttonCross;
  41255. private _buttonCircle;
  41256. private _buttonSquare;
  41257. private _buttonTriangle;
  41258. private _buttonShare;
  41259. private _buttonOptions;
  41260. private _buttonL1;
  41261. private _buttonR1;
  41262. private _buttonLeftStick;
  41263. private _buttonRightStick;
  41264. private _dPadUp;
  41265. private _dPadDown;
  41266. private _dPadLeft;
  41267. private _dPadRight;
  41268. /**
  41269. * Creates a new DualShock gamepad object
  41270. * @param id defines the id of this gamepad
  41271. * @param index defines its index
  41272. * @param gamepad defines the internal HTML gamepad object
  41273. */
  41274. constructor(id: string, index: number, gamepad: any);
  41275. /**
  41276. * Defines the callback to call when left trigger is pressed
  41277. * @param callback defines the callback to use
  41278. */
  41279. onlefttriggerchanged(callback: (value: number) => void): void;
  41280. /**
  41281. * Defines the callback to call when right trigger is pressed
  41282. * @param callback defines the callback to use
  41283. */
  41284. onrighttriggerchanged(callback: (value: number) => void): void;
  41285. /**
  41286. * Gets the left trigger value
  41287. */
  41288. get leftTrigger(): number;
  41289. /**
  41290. * Sets the left trigger value
  41291. */
  41292. set leftTrigger(newValue: number);
  41293. /**
  41294. * Gets the right trigger value
  41295. */
  41296. get rightTrigger(): number;
  41297. /**
  41298. * Sets the right trigger value
  41299. */
  41300. set rightTrigger(newValue: number);
  41301. /**
  41302. * Defines the callback to call when a button is pressed
  41303. * @param callback defines the callback to use
  41304. */
  41305. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41306. /**
  41307. * Defines the callback to call when a button is released
  41308. * @param callback defines the callback to use
  41309. */
  41310. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41311. /**
  41312. * Defines the callback to call when a pad is pressed
  41313. * @param callback defines the callback to use
  41314. */
  41315. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41316. /**
  41317. * Defines the callback to call when a pad is released
  41318. * @param callback defines the callback to use
  41319. */
  41320. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41321. private _setButtonValue;
  41322. private _setDPadValue;
  41323. /**
  41324. * Gets the value of the `Cross` button
  41325. */
  41326. get buttonCross(): number;
  41327. /**
  41328. * Sets the value of the `Cross` button
  41329. */
  41330. set buttonCross(value: number);
  41331. /**
  41332. * Gets the value of the `Circle` button
  41333. */
  41334. get buttonCircle(): number;
  41335. /**
  41336. * Sets the value of the `Circle` button
  41337. */
  41338. set buttonCircle(value: number);
  41339. /**
  41340. * Gets the value of the `Square` button
  41341. */
  41342. get buttonSquare(): number;
  41343. /**
  41344. * Sets the value of the `Square` button
  41345. */
  41346. set buttonSquare(value: number);
  41347. /**
  41348. * Gets the value of the `Triangle` button
  41349. */
  41350. get buttonTriangle(): number;
  41351. /**
  41352. * Sets the value of the `Triangle` button
  41353. */
  41354. set buttonTriangle(value: number);
  41355. /**
  41356. * Gets the value of the `Options` button
  41357. */
  41358. get buttonOptions(): number;
  41359. /**
  41360. * Sets the value of the `Options` button
  41361. */
  41362. set buttonOptions(value: number);
  41363. /**
  41364. * Gets the value of the `Share` button
  41365. */
  41366. get buttonShare(): number;
  41367. /**
  41368. * Sets the value of the `Share` button
  41369. */
  41370. set buttonShare(value: number);
  41371. /**
  41372. * Gets the value of the `L1` button
  41373. */
  41374. get buttonL1(): number;
  41375. /**
  41376. * Sets the value of the `L1` button
  41377. */
  41378. set buttonL1(value: number);
  41379. /**
  41380. * Gets the value of the `R1` button
  41381. */
  41382. get buttonR1(): number;
  41383. /**
  41384. * Sets the value of the `R1` button
  41385. */
  41386. set buttonR1(value: number);
  41387. /**
  41388. * Gets the value of the Left joystick
  41389. */
  41390. get buttonLeftStick(): number;
  41391. /**
  41392. * Sets the value of the Left joystick
  41393. */
  41394. set buttonLeftStick(value: number);
  41395. /**
  41396. * Gets the value of the Right joystick
  41397. */
  41398. get buttonRightStick(): number;
  41399. /**
  41400. * Sets the value of the Right joystick
  41401. */
  41402. set buttonRightStick(value: number);
  41403. /**
  41404. * Gets the value of D-pad up
  41405. */
  41406. get dPadUp(): number;
  41407. /**
  41408. * Sets the value of D-pad up
  41409. */
  41410. set dPadUp(value: number);
  41411. /**
  41412. * Gets the value of D-pad down
  41413. */
  41414. get dPadDown(): number;
  41415. /**
  41416. * Sets the value of D-pad down
  41417. */
  41418. set dPadDown(value: number);
  41419. /**
  41420. * Gets the value of D-pad left
  41421. */
  41422. get dPadLeft(): number;
  41423. /**
  41424. * Sets the value of D-pad left
  41425. */
  41426. set dPadLeft(value: number);
  41427. /**
  41428. * Gets the value of D-pad right
  41429. */
  41430. get dPadRight(): number;
  41431. /**
  41432. * Sets the value of D-pad right
  41433. */
  41434. set dPadRight(value: number);
  41435. /**
  41436. * Force the gamepad to synchronize with device values
  41437. */
  41438. update(): void;
  41439. /**
  41440. * Disposes the gamepad
  41441. */
  41442. dispose(): void;
  41443. }
  41444. }
  41445. declare module BABYLON {
  41446. /**
  41447. * Manager for handling gamepads
  41448. */
  41449. export class GamepadManager {
  41450. private _scene?;
  41451. private _babylonGamepads;
  41452. private _oneGamepadConnected;
  41453. /** @hidden */
  41454. _isMonitoring: boolean;
  41455. private _gamepadEventSupported;
  41456. private _gamepadSupport?;
  41457. /**
  41458. * observable to be triggered when the gamepad controller has been connected
  41459. */
  41460. onGamepadConnectedObservable: Observable<Gamepad>;
  41461. /**
  41462. * observable to be triggered when the gamepad controller has been disconnected
  41463. */
  41464. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41465. private _onGamepadConnectedEvent;
  41466. private _onGamepadDisconnectedEvent;
  41467. /**
  41468. * Initializes the gamepad manager
  41469. * @param _scene BabylonJS scene
  41470. */
  41471. constructor(_scene?: Scene | undefined);
  41472. /**
  41473. * The gamepads in the game pad manager
  41474. */
  41475. get gamepads(): Gamepad[];
  41476. /**
  41477. * Get the gamepad controllers based on type
  41478. * @param type The type of gamepad controller
  41479. * @returns Nullable gamepad
  41480. */
  41481. getGamepadByType(type?: number): Nullable<Gamepad>;
  41482. /**
  41483. * Disposes the gamepad manager
  41484. */
  41485. dispose(): void;
  41486. private _addNewGamepad;
  41487. private _startMonitoringGamepads;
  41488. private _stopMonitoringGamepads;
  41489. /** @hidden */
  41490. _checkGamepadsStatus(): void;
  41491. private _updateGamepadObjects;
  41492. }
  41493. }
  41494. declare module BABYLON {
  41495. interface Scene {
  41496. /** @hidden */
  41497. _gamepadManager: Nullable<GamepadManager>;
  41498. /**
  41499. * Gets the gamepad manager associated with the scene
  41500. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41501. */
  41502. gamepadManager: GamepadManager;
  41503. }
  41504. /**
  41505. * Interface representing a free camera inputs manager
  41506. */
  41507. interface FreeCameraInputsManager {
  41508. /**
  41509. * Adds gamepad input support to the FreeCameraInputsManager.
  41510. * @returns the FreeCameraInputsManager
  41511. */
  41512. addGamepad(): FreeCameraInputsManager;
  41513. }
  41514. /**
  41515. * Interface representing an arc rotate camera inputs manager
  41516. */
  41517. interface ArcRotateCameraInputsManager {
  41518. /**
  41519. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41520. * @returns the camera inputs manager
  41521. */
  41522. addGamepad(): ArcRotateCameraInputsManager;
  41523. }
  41524. /**
  41525. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41526. */
  41527. export class GamepadSystemSceneComponent implements ISceneComponent {
  41528. /**
  41529. * The component name helpfull to identify the component in the list of scene components.
  41530. */
  41531. readonly name: string;
  41532. /**
  41533. * The scene the component belongs to.
  41534. */
  41535. scene: Scene;
  41536. /**
  41537. * Creates a new instance of the component for the given scene
  41538. * @param scene Defines the scene to register the component in
  41539. */
  41540. constructor(scene: Scene);
  41541. /**
  41542. * Registers the component in a given scene
  41543. */
  41544. register(): void;
  41545. /**
  41546. * Rebuilds the elements related to this component in case of
  41547. * context lost for instance.
  41548. */
  41549. rebuild(): void;
  41550. /**
  41551. * Disposes the component and the associated ressources
  41552. */
  41553. dispose(): void;
  41554. private _beforeCameraUpdate;
  41555. }
  41556. }
  41557. declare module BABYLON {
  41558. /**
  41559. * 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,
  41560. * which still works and will still be found in many Playgrounds.
  41561. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41562. */
  41563. export class UniversalCamera extends TouchCamera {
  41564. /**
  41565. * Defines the gamepad rotation sensiblity.
  41566. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41567. */
  41568. get gamepadAngularSensibility(): number;
  41569. set gamepadAngularSensibility(value: number);
  41570. /**
  41571. * Defines the gamepad move sensiblity.
  41572. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41573. */
  41574. get gamepadMoveSensibility(): number;
  41575. set gamepadMoveSensibility(value: number);
  41576. /**
  41577. * 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,
  41578. * which still works and will still be found in many Playgrounds.
  41579. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41580. * @param name Define the name of the camera in the scene
  41581. * @param position Define the start position of the camera in the scene
  41582. * @param scene Define the scene the camera belongs to
  41583. */
  41584. constructor(name: string, position: Vector3, scene: Scene);
  41585. /**
  41586. * Gets the current object class name.
  41587. * @return the class name
  41588. */
  41589. getClassName(): string;
  41590. }
  41591. }
  41592. declare module BABYLON {
  41593. /**
  41594. * This represents a FPS type of camera. This is only here for back compat purpose.
  41595. * Please use the UniversalCamera instead as both are identical.
  41596. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41597. */
  41598. export class GamepadCamera extends UniversalCamera {
  41599. /**
  41600. * Instantiates a new Gamepad Camera
  41601. * This represents a FPS type of camera. This is only here for back compat purpose.
  41602. * Please use the UniversalCamera instead as both are identical.
  41603. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41604. * @param name Define the name of the camera in the scene
  41605. * @param position Define the start position of the camera in the scene
  41606. * @param scene Define the scene the camera belongs to
  41607. */
  41608. constructor(name: string, position: Vector3, scene: Scene);
  41609. /**
  41610. * Gets the current object class name.
  41611. * @return the class name
  41612. */
  41613. getClassName(): string;
  41614. }
  41615. }
  41616. declare module BABYLON {
  41617. /** @hidden */
  41618. export var passPixelShader: {
  41619. name: string;
  41620. shader: string;
  41621. };
  41622. }
  41623. declare module BABYLON {
  41624. /** @hidden */
  41625. export var passCubePixelShader: {
  41626. name: string;
  41627. shader: string;
  41628. };
  41629. }
  41630. declare module BABYLON {
  41631. /**
  41632. * PassPostProcess which produces an output the same as it's input
  41633. */
  41634. export class PassPostProcess extends PostProcess {
  41635. /**
  41636. * Creates the PassPostProcess
  41637. * @param name The name of the effect.
  41638. * @param options The required width/height ratio to downsize to before computing the render pass.
  41639. * @param camera The camera to apply the render pass to.
  41640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41641. * @param engine The engine which the post process will be applied. (default: current engine)
  41642. * @param reusable If the post process can be reused on the same frame. (default: false)
  41643. * @param textureType The type of texture to be used when performing the post processing.
  41644. * @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)
  41645. */
  41646. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41647. }
  41648. /**
  41649. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41650. */
  41651. export class PassCubePostProcess extends PostProcess {
  41652. private _face;
  41653. /**
  41654. * Gets or sets the cube face to display.
  41655. * * 0 is +X
  41656. * * 1 is -X
  41657. * * 2 is +Y
  41658. * * 3 is -Y
  41659. * * 4 is +Z
  41660. * * 5 is -Z
  41661. */
  41662. get face(): number;
  41663. set face(value: number);
  41664. /**
  41665. * Creates the PassCubePostProcess
  41666. * @param name The name of the effect.
  41667. * @param options The required width/height ratio to downsize to before computing the render pass.
  41668. * @param camera The camera to apply the render pass to.
  41669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41670. * @param engine The engine which the post process will be applied. (default: current engine)
  41671. * @param reusable If the post process can be reused on the same frame. (default: false)
  41672. * @param textureType The type of texture to be used when performing the post processing.
  41673. * @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)
  41674. */
  41675. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41676. }
  41677. }
  41678. declare module BABYLON {
  41679. /** @hidden */
  41680. export var anaglyphPixelShader: {
  41681. name: string;
  41682. shader: string;
  41683. };
  41684. }
  41685. declare module BABYLON {
  41686. /**
  41687. * Postprocess used to generate anaglyphic rendering
  41688. */
  41689. export class AnaglyphPostProcess extends PostProcess {
  41690. private _passedProcess;
  41691. /**
  41692. * Creates a new AnaglyphPostProcess
  41693. * @param name defines postprocess name
  41694. * @param options defines creation options or target ratio scale
  41695. * @param rigCameras defines cameras using this postprocess
  41696. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41697. * @param engine defines hosting engine
  41698. * @param reusable defines if the postprocess will be reused multiple times per frame
  41699. */
  41700. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41706. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41707. */
  41708. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41709. /**
  41710. * Creates a new AnaglyphArcRotateCamera
  41711. * @param name defines camera name
  41712. * @param alpha defines alpha angle (in radians)
  41713. * @param beta defines beta angle (in radians)
  41714. * @param radius defines radius
  41715. * @param target defines camera target
  41716. * @param interaxialDistance defines distance between each color axis
  41717. * @param scene defines the hosting scene
  41718. */
  41719. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41720. /**
  41721. * Gets camera class name
  41722. * @returns AnaglyphArcRotateCamera
  41723. */
  41724. getClassName(): string;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41730. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41731. */
  41732. export class AnaglyphFreeCamera extends FreeCamera {
  41733. /**
  41734. * Creates a new AnaglyphFreeCamera
  41735. * @param name defines camera name
  41736. * @param position defines initial position
  41737. * @param interaxialDistance defines distance between each color axis
  41738. * @param scene defines the hosting scene
  41739. */
  41740. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41741. /**
  41742. * Gets camera class name
  41743. * @returns AnaglyphFreeCamera
  41744. */
  41745. getClassName(): string;
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. /**
  41750. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41751. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41752. */
  41753. export class AnaglyphGamepadCamera extends GamepadCamera {
  41754. /**
  41755. * Creates a new AnaglyphGamepadCamera
  41756. * @param name defines camera name
  41757. * @param position defines initial position
  41758. * @param interaxialDistance defines distance between each color axis
  41759. * @param scene defines the hosting scene
  41760. */
  41761. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41762. /**
  41763. * Gets camera class name
  41764. * @returns AnaglyphGamepadCamera
  41765. */
  41766. getClassName(): string;
  41767. }
  41768. }
  41769. declare module BABYLON {
  41770. /**
  41771. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41772. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41773. */
  41774. export class AnaglyphUniversalCamera extends UniversalCamera {
  41775. /**
  41776. * Creates a new AnaglyphUniversalCamera
  41777. * @param name defines camera name
  41778. * @param position defines initial position
  41779. * @param interaxialDistance defines distance between each color axis
  41780. * @param scene defines the hosting scene
  41781. */
  41782. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41783. /**
  41784. * Gets camera class name
  41785. * @returns AnaglyphUniversalCamera
  41786. */
  41787. getClassName(): string;
  41788. }
  41789. }
  41790. declare module BABYLON {
  41791. /** @hidden */
  41792. export var stereoscopicInterlacePixelShader: {
  41793. name: string;
  41794. shader: string;
  41795. };
  41796. }
  41797. declare module BABYLON {
  41798. /**
  41799. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41800. */
  41801. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41802. private _stepSize;
  41803. private _passedProcess;
  41804. /**
  41805. * Initializes a StereoscopicInterlacePostProcessI
  41806. * @param name The name of the effect.
  41807. * @param rigCameras The rig cameras to be appled to the post process
  41808. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41809. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41811. * @param engine The engine which the post process will be applied. (default: current engine)
  41812. * @param reusable If the post process can be reused on the same frame. (default: false)
  41813. */
  41814. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41815. }
  41816. /**
  41817. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41818. */
  41819. export class StereoscopicInterlacePostProcess extends PostProcess {
  41820. private _stepSize;
  41821. private _passedProcess;
  41822. /**
  41823. * Initializes a StereoscopicInterlacePostProcess
  41824. * @param name The name of the effect.
  41825. * @param rigCameras The rig cameras to be appled to the post process
  41826. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41828. * @param engine The engine which the post process will be applied. (default: current engine)
  41829. * @param reusable If the post process can be reused on the same frame. (default: false)
  41830. */
  41831. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41832. }
  41833. }
  41834. declare module BABYLON {
  41835. /**
  41836. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41837. * @see http://doc.babylonjs.com/features/cameras
  41838. */
  41839. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41840. /**
  41841. * Creates a new StereoscopicArcRotateCamera
  41842. * @param name defines camera name
  41843. * @param alpha defines alpha angle (in radians)
  41844. * @param beta defines beta angle (in radians)
  41845. * @param radius defines radius
  41846. * @param target defines camera target
  41847. * @param interaxialDistance defines distance between each color axis
  41848. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41849. * @param scene defines the hosting scene
  41850. */
  41851. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41852. /**
  41853. * Gets camera class name
  41854. * @returns StereoscopicArcRotateCamera
  41855. */
  41856. getClassName(): string;
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41862. * @see http://doc.babylonjs.com/features/cameras
  41863. */
  41864. export class StereoscopicFreeCamera extends FreeCamera {
  41865. /**
  41866. * Creates a new StereoscopicFreeCamera
  41867. * @param name defines camera name
  41868. * @param position defines initial position
  41869. * @param interaxialDistance defines distance between each color axis
  41870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41871. * @param scene defines the hosting scene
  41872. */
  41873. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41874. /**
  41875. * Gets camera class name
  41876. * @returns StereoscopicFreeCamera
  41877. */
  41878. getClassName(): string;
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41884. * @see http://doc.babylonjs.com/features/cameras
  41885. */
  41886. export class StereoscopicGamepadCamera extends GamepadCamera {
  41887. /**
  41888. * Creates a new StereoscopicGamepadCamera
  41889. * @param name defines camera name
  41890. * @param position defines initial position
  41891. * @param interaxialDistance defines distance between each color axis
  41892. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41893. * @param scene defines the hosting scene
  41894. */
  41895. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41896. /**
  41897. * Gets camera class name
  41898. * @returns StereoscopicGamepadCamera
  41899. */
  41900. getClassName(): string;
  41901. }
  41902. }
  41903. declare module BABYLON {
  41904. /**
  41905. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41906. * @see http://doc.babylonjs.com/features/cameras
  41907. */
  41908. export class StereoscopicUniversalCamera extends UniversalCamera {
  41909. /**
  41910. * Creates a new StereoscopicUniversalCamera
  41911. * @param name defines camera name
  41912. * @param position defines initial position
  41913. * @param interaxialDistance defines distance between each color axis
  41914. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41915. * @param scene defines the hosting scene
  41916. */
  41917. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41918. /**
  41919. * Gets camera class name
  41920. * @returns StereoscopicUniversalCamera
  41921. */
  41922. getClassName(): string;
  41923. }
  41924. }
  41925. declare module BABYLON {
  41926. /**
  41927. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41928. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41929. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41930. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41931. */
  41932. export class VirtualJoysticksCamera extends FreeCamera {
  41933. /**
  41934. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41935. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41936. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41937. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41938. * @param name Define the name of the camera in the scene
  41939. * @param position Define the start position of the camera in the scene
  41940. * @param scene Define the scene the camera belongs to
  41941. */
  41942. constructor(name: string, position: Vector3, scene: Scene);
  41943. /**
  41944. * Gets the current object class name.
  41945. * @return the class name
  41946. */
  41947. getClassName(): string;
  41948. }
  41949. }
  41950. declare module BABYLON {
  41951. /**
  41952. * This represents all the required metrics to create a VR camera.
  41953. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41954. */
  41955. export class VRCameraMetrics {
  41956. /**
  41957. * Define the horizontal resolution off the screen.
  41958. */
  41959. hResolution: number;
  41960. /**
  41961. * Define the vertical resolution off the screen.
  41962. */
  41963. vResolution: number;
  41964. /**
  41965. * Define the horizontal screen size.
  41966. */
  41967. hScreenSize: number;
  41968. /**
  41969. * Define the vertical screen size.
  41970. */
  41971. vScreenSize: number;
  41972. /**
  41973. * Define the vertical screen center position.
  41974. */
  41975. vScreenCenter: number;
  41976. /**
  41977. * Define the distance of the eyes to the screen.
  41978. */
  41979. eyeToScreenDistance: number;
  41980. /**
  41981. * Define the distance between both lenses
  41982. */
  41983. lensSeparationDistance: number;
  41984. /**
  41985. * Define the distance between both viewer's eyes.
  41986. */
  41987. interpupillaryDistance: number;
  41988. /**
  41989. * Define the distortion factor of the VR postprocess.
  41990. * Please, touch with care.
  41991. */
  41992. distortionK: number[];
  41993. /**
  41994. * Define the chromatic aberration correction factors for the VR post process.
  41995. */
  41996. chromaAbCorrection: number[];
  41997. /**
  41998. * Define the scale factor of the post process.
  41999. * The smaller the better but the slower.
  42000. */
  42001. postProcessScaleFactor: number;
  42002. /**
  42003. * Define an offset for the lens center.
  42004. */
  42005. lensCenterOffset: number;
  42006. /**
  42007. * Define if the current vr camera should compensate the distortion of the lense or not.
  42008. */
  42009. compensateDistortion: boolean;
  42010. /**
  42011. * Defines if multiview should be enabled when rendering (Default: false)
  42012. */
  42013. multiviewEnabled: boolean;
  42014. /**
  42015. * Gets the rendering aspect ratio based on the provided resolutions.
  42016. */
  42017. get aspectRatio(): number;
  42018. /**
  42019. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42020. */
  42021. get aspectRatioFov(): number;
  42022. /**
  42023. * @hidden
  42024. */
  42025. get leftHMatrix(): Matrix;
  42026. /**
  42027. * @hidden
  42028. */
  42029. get rightHMatrix(): Matrix;
  42030. /**
  42031. * @hidden
  42032. */
  42033. get leftPreViewMatrix(): Matrix;
  42034. /**
  42035. * @hidden
  42036. */
  42037. get rightPreViewMatrix(): Matrix;
  42038. /**
  42039. * Get the default VRMetrics based on the most generic setup.
  42040. * @returns the default vr metrics
  42041. */
  42042. static GetDefault(): VRCameraMetrics;
  42043. }
  42044. }
  42045. declare module BABYLON {
  42046. /** @hidden */
  42047. export var vrDistortionCorrectionPixelShader: {
  42048. name: string;
  42049. shader: string;
  42050. };
  42051. }
  42052. declare module BABYLON {
  42053. /**
  42054. * VRDistortionCorrectionPostProcess used for mobile VR
  42055. */
  42056. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42057. private _isRightEye;
  42058. private _distortionFactors;
  42059. private _postProcessScaleFactor;
  42060. private _lensCenterOffset;
  42061. private _scaleIn;
  42062. private _scaleFactor;
  42063. private _lensCenter;
  42064. /**
  42065. * Initializes the VRDistortionCorrectionPostProcess
  42066. * @param name The name of the effect.
  42067. * @param camera The camera to apply the render pass to.
  42068. * @param isRightEye If this is for the right eye distortion
  42069. * @param vrMetrics All the required metrics for the VR camera
  42070. */
  42071. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42072. }
  42073. }
  42074. declare module BABYLON {
  42075. /**
  42076. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42077. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42078. */
  42079. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42080. /**
  42081. * Creates a new VRDeviceOrientationArcRotateCamera
  42082. * @param name defines camera name
  42083. * @param alpha defines the camera rotation along the logitudinal axis
  42084. * @param beta defines the camera rotation along the latitudinal axis
  42085. * @param radius defines the camera distance from its target
  42086. * @param target defines the camera target
  42087. * @param scene defines the scene the camera belongs to
  42088. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42089. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42090. */
  42091. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42092. /**
  42093. * Gets camera class name
  42094. * @returns VRDeviceOrientationArcRotateCamera
  42095. */
  42096. getClassName(): string;
  42097. }
  42098. }
  42099. declare module BABYLON {
  42100. /**
  42101. * Camera used to simulate VR rendering (based on FreeCamera)
  42102. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42103. */
  42104. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42105. /**
  42106. * Creates a new VRDeviceOrientationFreeCamera
  42107. * @param name defines camera name
  42108. * @param position defines the start position of the camera
  42109. * @param scene defines the scene the camera belongs to
  42110. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42111. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42112. */
  42113. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42114. /**
  42115. * Gets camera class name
  42116. * @returns VRDeviceOrientationFreeCamera
  42117. */
  42118. getClassName(): string;
  42119. }
  42120. }
  42121. declare module BABYLON {
  42122. /**
  42123. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42124. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42125. */
  42126. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42127. /**
  42128. * Creates a new VRDeviceOrientationGamepadCamera
  42129. * @param name defines camera name
  42130. * @param position defines the start position of the camera
  42131. * @param scene defines the scene the camera belongs to
  42132. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42133. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42134. */
  42135. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42136. /**
  42137. * Gets camera class name
  42138. * @returns VRDeviceOrientationGamepadCamera
  42139. */
  42140. getClassName(): string;
  42141. }
  42142. }
  42143. declare module BABYLON {
  42144. /** @hidden */
  42145. export var imageProcessingPixelShader: {
  42146. name: string;
  42147. shader: string;
  42148. };
  42149. }
  42150. declare module BABYLON {
  42151. /**
  42152. * ImageProcessingPostProcess
  42153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42154. */
  42155. export class ImageProcessingPostProcess extends PostProcess {
  42156. /**
  42157. * Default configuration related to image processing available in the PBR Material.
  42158. */
  42159. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42160. /**
  42161. * Gets the image processing configuration used either in this material.
  42162. */
  42163. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42164. /**
  42165. * Sets the Default image processing configuration used either in the this material.
  42166. *
  42167. * If sets to null, the scene one is in use.
  42168. */
  42169. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42170. /**
  42171. * Keep track of the image processing observer to allow dispose and replace.
  42172. */
  42173. private _imageProcessingObserver;
  42174. /**
  42175. * Attaches a new image processing configuration to the PBR Material.
  42176. * @param configuration
  42177. */
  42178. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42179. /**
  42180. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42181. */
  42182. get colorCurves(): Nullable<ColorCurves>;
  42183. /**
  42184. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42185. */
  42186. set colorCurves(value: Nullable<ColorCurves>);
  42187. /**
  42188. * Gets wether the color curves effect is enabled.
  42189. */
  42190. get colorCurvesEnabled(): boolean;
  42191. /**
  42192. * Sets wether the color curves effect is enabled.
  42193. */
  42194. set colorCurvesEnabled(value: boolean);
  42195. /**
  42196. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42197. */
  42198. get colorGradingTexture(): Nullable<BaseTexture>;
  42199. /**
  42200. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42201. */
  42202. set colorGradingTexture(value: Nullable<BaseTexture>);
  42203. /**
  42204. * Gets wether the color grading effect is enabled.
  42205. */
  42206. get colorGradingEnabled(): boolean;
  42207. /**
  42208. * Gets wether the color grading effect is enabled.
  42209. */
  42210. set colorGradingEnabled(value: boolean);
  42211. /**
  42212. * Gets exposure used in the effect.
  42213. */
  42214. get exposure(): number;
  42215. /**
  42216. * Sets exposure used in the effect.
  42217. */
  42218. set exposure(value: number);
  42219. /**
  42220. * Gets wether tonemapping is enabled or not.
  42221. */
  42222. get toneMappingEnabled(): boolean;
  42223. /**
  42224. * Sets wether tonemapping is enabled or not
  42225. */
  42226. set toneMappingEnabled(value: boolean);
  42227. /**
  42228. * Gets the type of tone mapping effect.
  42229. */
  42230. get toneMappingType(): number;
  42231. /**
  42232. * Sets the type of tone mapping effect.
  42233. */
  42234. set toneMappingType(value: number);
  42235. /**
  42236. * Gets contrast used in the effect.
  42237. */
  42238. get contrast(): number;
  42239. /**
  42240. * Sets contrast used in the effect.
  42241. */
  42242. set contrast(value: number);
  42243. /**
  42244. * Gets Vignette stretch size.
  42245. */
  42246. get vignetteStretch(): number;
  42247. /**
  42248. * Sets Vignette stretch size.
  42249. */
  42250. set vignetteStretch(value: number);
  42251. /**
  42252. * Gets Vignette centre X Offset.
  42253. */
  42254. get vignetteCentreX(): number;
  42255. /**
  42256. * Sets Vignette centre X Offset.
  42257. */
  42258. set vignetteCentreX(value: number);
  42259. /**
  42260. * Gets Vignette centre Y Offset.
  42261. */
  42262. get vignetteCentreY(): number;
  42263. /**
  42264. * Sets Vignette centre Y Offset.
  42265. */
  42266. set vignetteCentreY(value: number);
  42267. /**
  42268. * Gets Vignette weight or intensity of the vignette effect.
  42269. */
  42270. get vignetteWeight(): number;
  42271. /**
  42272. * Sets Vignette weight or intensity of the vignette effect.
  42273. */
  42274. set vignetteWeight(value: number);
  42275. /**
  42276. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42277. * if vignetteEnabled is set to true.
  42278. */
  42279. get vignetteColor(): Color4;
  42280. /**
  42281. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42282. * if vignetteEnabled is set to true.
  42283. */
  42284. set vignetteColor(value: Color4);
  42285. /**
  42286. * Gets Camera field of view used by the Vignette effect.
  42287. */
  42288. get vignetteCameraFov(): number;
  42289. /**
  42290. * Sets Camera field of view used by the Vignette effect.
  42291. */
  42292. set vignetteCameraFov(value: number);
  42293. /**
  42294. * Gets the vignette blend mode allowing different kind of effect.
  42295. */
  42296. get vignetteBlendMode(): number;
  42297. /**
  42298. * Sets the vignette blend mode allowing different kind of effect.
  42299. */
  42300. set vignetteBlendMode(value: number);
  42301. /**
  42302. * Gets wether the vignette effect is enabled.
  42303. */
  42304. get vignetteEnabled(): boolean;
  42305. /**
  42306. * Sets wether the vignette effect is enabled.
  42307. */
  42308. set vignetteEnabled(value: boolean);
  42309. private _fromLinearSpace;
  42310. /**
  42311. * Gets wether the input of the processing is in Gamma or Linear Space.
  42312. */
  42313. get fromLinearSpace(): boolean;
  42314. /**
  42315. * Sets wether the input of the processing is in Gamma or Linear Space.
  42316. */
  42317. set fromLinearSpace(value: boolean);
  42318. /**
  42319. * Defines cache preventing GC.
  42320. */
  42321. private _defines;
  42322. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42323. /**
  42324. * "ImageProcessingPostProcess"
  42325. * @returns "ImageProcessingPostProcess"
  42326. */
  42327. getClassName(): string;
  42328. protected _updateParameters(): void;
  42329. dispose(camera?: Camera): void;
  42330. }
  42331. }
  42332. declare module BABYLON {
  42333. /**
  42334. * Class containing static functions to help procedurally build meshes
  42335. */
  42336. export class GroundBuilder {
  42337. /**
  42338. * Creates a ground mesh
  42339. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42340. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42342. * @param name defines the name of the mesh
  42343. * @param options defines the options used to create the mesh
  42344. * @param scene defines the hosting scene
  42345. * @returns the ground mesh
  42346. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42347. */
  42348. static CreateGround(name: string, options: {
  42349. width?: number;
  42350. height?: number;
  42351. subdivisions?: number;
  42352. subdivisionsX?: number;
  42353. subdivisionsY?: number;
  42354. updatable?: boolean;
  42355. }, scene: any): Mesh;
  42356. /**
  42357. * Creates a tiled ground mesh
  42358. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42359. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42360. * * 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
  42361. * * 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
  42362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42363. * @param name defines the name of the mesh
  42364. * @param options defines the options used to create the mesh
  42365. * @param scene defines the hosting scene
  42366. * @returns the tiled ground mesh
  42367. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42368. */
  42369. static CreateTiledGround(name: string, options: {
  42370. xmin: number;
  42371. zmin: number;
  42372. xmax: number;
  42373. zmax: number;
  42374. subdivisions?: {
  42375. w: number;
  42376. h: number;
  42377. };
  42378. precision?: {
  42379. w: number;
  42380. h: number;
  42381. };
  42382. updatable?: boolean;
  42383. }, scene?: Nullable<Scene>): Mesh;
  42384. /**
  42385. * Creates a ground mesh from a height map
  42386. * * The parameter `url` sets the URL of the height map image resource.
  42387. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42388. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42389. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42390. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42391. * * 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.
  42392. * * 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).
  42393. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42395. * @param name defines the name of the mesh
  42396. * @param url defines the url to the height map
  42397. * @param options defines the options used to create the mesh
  42398. * @param scene defines the hosting scene
  42399. * @returns the ground mesh
  42400. * @see https://doc.babylonjs.com/babylon101/height_map
  42401. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42402. */
  42403. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42404. width?: number;
  42405. height?: number;
  42406. subdivisions?: number;
  42407. minHeight?: number;
  42408. maxHeight?: number;
  42409. colorFilter?: Color3;
  42410. alphaFilter?: number;
  42411. updatable?: boolean;
  42412. onReady?: (mesh: GroundMesh) => void;
  42413. }, scene?: Nullable<Scene>): GroundMesh;
  42414. }
  42415. }
  42416. declare module BABYLON {
  42417. /**
  42418. * Class containing static functions to help procedurally build meshes
  42419. */
  42420. export class TorusBuilder {
  42421. /**
  42422. * Creates a torus mesh
  42423. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42424. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42425. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42427. * * 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
  42428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42429. * @param name defines the name of the mesh
  42430. * @param options defines the options used to create the mesh
  42431. * @param scene defines the hosting scene
  42432. * @returns the torus mesh
  42433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42434. */
  42435. static CreateTorus(name: string, options: {
  42436. diameter?: number;
  42437. thickness?: number;
  42438. tessellation?: number;
  42439. updatable?: boolean;
  42440. sideOrientation?: number;
  42441. frontUVs?: Vector4;
  42442. backUVs?: Vector4;
  42443. }, scene: any): Mesh;
  42444. }
  42445. }
  42446. declare module BABYLON {
  42447. /**
  42448. * Class containing static functions to help procedurally build meshes
  42449. */
  42450. export class CylinderBuilder {
  42451. /**
  42452. * Creates a cylinder or a cone mesh
  42453. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42454. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42455. * * 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.
  42456. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42457. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42458. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42459. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42460. * * 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).
  42461. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42462. * * 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).
  42463. * * 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
  42464. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42465. * * 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
  42466. * * 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.
  42467. * * If `enclose` is false, a ring surface is one element.
  42468. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42469. * * 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
  42470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42471. * * 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
  42472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42473. * @param name defines the name of the mesh
  42474. * @param options defines the options used to create the mesh
  42475. * @param scene defines the hosting scene
  42476. * @returns the cylinder mesh
  42477. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42478. */
  42479. static CreateCylinder(name: string, options: {
  42480. height?: number;
  42481. diameterTop?: number;
  42482. diameterBottom?: number;
  42483. diameter?: number;
  42484. tessellation?: number;
  42485. subdivisions?: number;
  42486. arc?: number;
  42487. faceColors?: Color4[];
  42488. faceUV?: Vector4[];
  42489. updatable?: boolean;
  42490. hasRings?: boolean;
  42491. enclose?: boolean;
  42492. cap?: number;
  42493. sideOrientation?: number;
  42494. frontUVs?: Vector4;
  42495. backUVs?: Vector4;
  42496. }, scene: any): Mesh;
  42497. }
  42498. }
  42499. declare module BABYLON {
  42500. /**
  42501. * States of the webXR experience
  42502. */
  42503. export enum WebXRState {
  42504. /**
  42505. * Transitioning to being in XR mode
  42506. */
  42507. ENTERING_XR = 0,
  42508. /**
  42509. * Transitioning to non XR mode
  42510. */
  42511. EXITING_XR = 1,
  42512. /**
  42513. * In XR mode and presenting
  42514. */
  42515. IN_XR = 2,
  42516. /**
  42517. * Not entered XR mode
  42518. */
  42519. NOT_IN_XR = 3
  42520. }
  42521. /**
  42522. * Abstraction of the XR render target
  42523. */
  42524. export interface WebXRRenderTarget extends IDisposable {
  42525. /**
  42526. * xrpresent context of the canvas which can be used to display/mirror xr content
  42527. */
  42528. canvasContext: WebGLRenderingContext;
  42529. /**
  42530. * xr layer for the canvas
  42531. */
  42532. xrLayer: Nullable<XRWebGLLayer>;
  42533. /**
  42534. * Initializes the xr layer for the session
  42535. * @param xrSession xr session
  42536. * @returns a promise that will resolve once the XR Layer has been created
  42537. */
  42538. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42539. }
  42540. }
  42541. declare module BABYLON {
  42542. /**
  42543. * COnfiguration object for WebXR output canvas
  42544. */
  42545. export class WebXRManagedOutputCanvasOptions {
  42546. /**
  42547. * Options for this XR Layer output
  42548. */
  42549. canvasOptions?: XRWebGLLayerOptions;
  42550. /**
  42551. * CSS styling for a newly created canvas (if not provided)
  42552. */
  42553. newCanvasCssStyle?: string;
  42554. /**
  42555. * An optional canvas in case you wish to create it yourself and provide it here.
  42556. * If not provided, a new canvas will be created
  42557. */
  42558. canvasElement?: HTMLCanvasElement;
  42559. /**
  42560. * Get the default values of the configuration object
  42561. * @returns default values of this configuration object
  42562. */
  42563. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42564. }
  42565. /**
  42566. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42567. */
  42568. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42569. private _options;
  42570. private _engine;
  42571. private _canvas;
  42572. /**
  42573. * Rendering context of the canvas which can be used to display/mirror xr content
  42574. */
  42575. canvasContext: WebGLRenderingContext;
  42576. /**
  42577. * xr layer for the canvas
  42578. */
  42579. xrLayer: Nullable<XRWebGLLayer>;
  42580. /**
  42581. * Initializes the xr layer for the session
  42582. * @param xrSession xr session
  42583. * @returns a promise that will resolve once the XR Layer has been created
  42584. */
  42585. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42586. /**
  42587. * Initializes the canvas to be added/removed upon entering/exiting xr
  42588. * @param _xrSessionManager The XR Session manager
  42589. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42590. */
  42591. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42592. /**
  42593. * Disposes of the object
  42594. */
  42595. dispose(): void;
  42596. private _setManagedOutputCanvas;
  42597. private _addCanvas;
  42598. private _removeCanvas;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Manages an XRSession to work with Babylon's engine
  42604. * @see https://doc.babylonjs.com/how_to/webxr
  42605. */
  42606. export class WebXRSessionManager implements IDisposable {
  42607. /** The scene which the session should be created for */
  42608. scene: Scene;
  42609. /**
  42610. * Fires every time a new xrFrame arrives which can be used to update the camera
  42611. */
  42612. onXRFrameObservable: Observable<XRFrame>;
  42613. /**
  42614. * Fires when the xr session is ended either by the device or manually done
  42615. */
  42616. onXRSessionEnded: Observable<any>;
  42617. /**
  42618. * Fires when the xr session is ended either by the device or manually done
  42619. */
  42620. onXRSessionInit: Observable<XRSession>;
  42621. /**
  42622. * Fires when the reference space changed
  42623. */
  42624. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42625. /**
  42626. * Underlying xr session
  42627. */
  42628. session: XRSession;
  42629. /**
  42630. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42631. * or get the offset the player is currently at.
  42632. */
  42633. viewerReferenceSpace: XRReferenceSpace;
  42634. private _referenceSpace;
  42635. /**
  42636. * The current reference space used in this session. This reference space can constantly change!
  42637. * It is mainly used to offset the camera's position.
  42638. */
  42639. get referenceSpace(): XRReferenceSpace;
  42640. /**
  42641. * Set a new reference space and triggers the observable
  42642. */
  42643. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42644. /**
  42645. * The base reference space from which the session started. good if you want to reset your
  42646. * reference space
  42647. */
  42648. baseReferenceSpace: XRReferenceSpace;
  42649. /**
  42650. * Used just in case of a failure to initialize an immersive session.
  42651. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42652. */
  42653. defaultHeightCompensation: number;
  42654. /**
  42655. * Current XR frame
  42656. */
  42657. currentFrame: Nullable<XRFrame>;
  42658. /** WebXR timestamp updated every frame */
  42659. currentTimestamp: number;
  42660. private _xrNavigator;
  42661. private baseLayer;
  42662. private _rttProvider;
  42663. private _sessionEnded;
  42664. /**
  42665. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42666. * @param scene The scene which the session should be created for
  42667. */
  42668. constructor(
  42669. /** The scene which the session should be created for */
  42670. scene: Scene);
  42671. /**
  42672. * Initializes the manager
  42673. * After initialization enterXR can be called to start an XR session
  42674. * @returns Promise which resolves after it is initialized
  42675. */
  42676. initializeAsync(): Promise<void>;
  42677. /**
  42678. * Initializes an xr session
  42679. * @param xrSessionMode mode to initialize
  42680. * @param xrSessionInit defines optional and required values to pass to the session builder
  42681. * @returns a promise which will resolve once the session has been initialized
  42682. */
  42683. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42684. /**
  42685. * Sets the reference space on the xr session
  42686. * @param referenceSpaceType space to set
  42687. * @returns a promise that will resolve once the reference space has been set
  42688. */
  42689. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42690. /**
  42691. * Resets the reference space to the one started the session
  42692. */
  42693. resetReferenceSpace(): void;
  42694. /**
  42695. * Updates the render state of the session
  42696. * @param state state to set
  42697. * @returns a promise that resolves once the render state has been updated
  42698. */
  42699. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42700. /**
  42701. * Starts rendering to the xr layer
  42702. */
  42703. runXRRenderLoop(): void;
  42704. /**
  42705. * Gets the correct render target texture to be rendered this frame for this eye
  42706. * @param eye the eye for which to get the render target
  42707. * @returns the render target for the specified eye
  42708. */
  42709. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42710. /**
  42711. * Stops the xrSession and restores the renderloop
  42712. * @returns Promise which resolves after it exits XR
  42713. */
  42714. exitXRAsync(): Promise<void>;
  42715. /**
  42716. * Checks if a session would be supported for the creation options specified
  42717. * @param sessionMode session mode to check if supported eg. immersive-vr
  42718. * @returns A Promise that resolves to true if supported and false if not
  42719. */
  42720. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42721. /**
  42722. * Creates a WebXRRenderTarget object for the XR session
  42723. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42724. * @param options optional options to provide when creating a new render target
  42725. * @returns a WebXR render target to which the session can render
  42726. */
  42727. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42728. /**
  42729. * @hidden
  42730. * Converts the render layer of xrSession to a render target
  42731. * @param session session to create render target for
  42732. * @param scene scene the new render target should be created for
  42733. * @param baseLayer the webgl layer to create the render target for
  42734. */
  42735. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42736. /**
  42737. * Disposes of the session manager
  42738. */
  42739. dispose(): void;
  42740. /**
  42741. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42742. * @param sessionMode defines the session to test
  42743. * @returns a promise with boolean as final value
  42744. */
  42745. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42746. }
  42747. }
  42748. declare module BABYLON {
  42749. /**
  42750. * WebXR Camera which holds the views for the xrSession
  42751. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42752. */
  42753. export class WebXRCamera extends FreeCamera {
  42754. private _xrSessionManager;
  42755. private _firstFrame;
  42756. private _referenceQuaternion;
  42757. private _referencedPosition;
  42758. private _xrInvPositionCache;
  42759. private _xrInvQuaternionCache;
  42760. /**
  42761. * Should position compensation execute on first frame.
  42762. * This is used when copying the position from a native (non XR) camera
  42763. */
  42764. compensateOnFirstFrame: boolean;
  42765. /**
  42766. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42767. * @param name the name of the camera
  42768. * @param scene the scene to add the camera to
  42769. * @param _xrSessionManager a constructed xr session manager
  42770. */
  42771. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42772. /**
  42773. * Return the user's height, unrelated to the current ground.
  42774. * This will be the y position of this camera, when ground level is 0.
  42775. */
  42776. get realWorldHeight(): number;
  42777. /** @hidden */
  42778. _updateForDualEyeDebugging(): void;
  42779. /**
  42780. * Sets this camera's transformation based on a non-vr camera
  42781. * @param otherCamera the non-vr camera to copy the transformation from
  42782. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42783. */
  42784. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42785. private _updateFromXRSession;
  42786. private _updateNumberOfRigCameras;
  42787. private _updateReferenceSpace;
  42788. private _updateReferenceSpaceOffset;
  42789. }
  42790. }
  42791. declare module BABYLON {
  42792. /**
  42793. * Defining the interface required for a (webxr) feature
  42794. */
  42795. export interface IWebXRFeature extends IDisposable {
  42796. /**
  42797. * Is this feature attached
  42798. */
  42799. attached: boolean;
  42800. /**
  42801. * Should auto-attach be disabled?
  42802. */
  42803. disableAutoAttach: boolean;
  42804. /**
  42805. * Attach the feature to the session
  42806. * Will usually be called by the features manager
  42807. *
  42808. * @param force should attachment be forced (even when already attached)
  42809. * @returns true if successful.
  42810. */
  42811. attach(force?: boolean): boolean;
  42812. /**
  42813. * Detach the feature from the session
  42814. * Will usually be called by the features manager
  42815. *
  42816. * @returns true if successful.
  42817. */
  42818. detach(): boolean;
  42819. }
  42820. /**
  42821. * A list of the currently available features without referencing them
  42822. */
  42823. export class WebXRFeatureName {
  42824. /**
  42825. * The name of the hit test feature
  42826. */
  42827. static HIT_TEST: string;
  42828. /**
  42829. * The name of the anchor system feature
  42830. */
  42831. static ANCHOR_SYSTEM: string;
  42832. /**
  42833. * The name of the background remover feature
  42834. */
  42835. static BACKGROUND_REMOVER: string;
  42836. /**
  42837. * The name of the pointer selection feature
  42838. */
  42839. static POINTER_SELECTION: string;
  42840. /**
  42841. * The name of the teleportation feature
  42842. */
  42843. static TELEPORTATION: string;
  42844. /**
  42845. * The name of the plane detection feature
  42846. */
  42847. static PLANE_DETECTION: string;
  42848. /**
  42849. * physics impostors for xr controllers feature
  42850. */
  42851. static PHYSICS_CONTROLLERS: string;
  42852. }
  42853. /**
  42854. * Defining the constructor of a feature. Used to register the modules.
  42855. */
  42856. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42857. /**
  42858. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42859. * It is mainly used in AR sessions.
  42860. *
  42861. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42862. */
  42863. export class WebXRFeaturesManager implements IDisposable {
  42864. private _xrSessionManager;
  42865. private static readonly _AvailableFeatures;
  42866. /**
  42867. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42868. * Mainly used internally.
  42869. *
  42870. * @param featureName the name of the feature to register
  42871. * @param constructorFunction the function used to construct the module
  42872. * @param version the (babylon) version of the module
  42873. * @param stable is that a stable version of this module
  42874. */
  42875. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42876. /**
  42877. * Returns a constructor of a specific feature.
  42878. *
  42879. * @param featureName the name of the feature to construct
  42880. * @param version the version of the feature to load
  42881. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42882. * @param options optional options provided to the module.
  42883. * @returns a function that, when called, will return a new instance of this feature
  42884. */
  42885. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42886. /**
  42887. * Return the latest unstable version of this feature
  42888. * @param featureName the name of the feature to search
  42889. * @returns the version number. if not found will return -1
  42890. */
  42891. static GetLatestVersionOfFeature(featureName: string): number;
  42892. /**
  42893. * Return the latest stable version of this feature
  42894. * @param featureName the name of the feature to search
  42895. * @returns the version number. if not found will return -1
  42896. */
  42897. static GetStableVersionOfFeature(featureName: string): number;
  42898. /**
  42899. * Can be used to return the list of features currently registered
  42900. *
  42901. * @returns an Array of available features
  42902. */
  42903. static GetAvailableFeatures(): string[];
  42904. /**
  42905. * Gets the versions available for a specific feature
  42906. * @param featureName the name of the feature
  42907. * @returns an array with the available versions
  42908. */
  42909. static GetAvailableVersions(featureName: string): string[];
  42910. private _features;
  42911. /**
  42912. * constructs a new features manages.
  42913. *
  42914. * @param _xrSessionManager an instance of WebXRSessionManager
  42915. */
  42916. constructor(_xrSessionManager: WebXRSessionManager);
  42917. /**
  42918. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  42919. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  42920. *
  42921. * @param featureName the name of the feature to load or the class of the feature
  42922. * @param version optional version to load. if not provided the latest version will be enabled
  42923. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42924. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42925. * @returns a new constructed feature or throws an error if feature not found.
  42926. */
  42927. enableFeature(featureName: string | {
  42928. Name: string;
  42929. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42930. /**
  42931. * Used to disable an already-enabled feature
  42932. * The feature will be disposed and will be recreated once enabled.
  42933. * @param featureName the feature to disable
  42934. * @returns true if disable was successful
  42935. */
  42936. disableFeature(featureName: string | {
  42937. Name: string;
  42938. }): boolean;
  42939. /**
  42940. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42941. * Can be used during a session to start a feature
  42942. * @param featureName the name of feature to attach
  42943. */
  42944. attachFeature(featureName: string): void;
  42945. /**
  42946. * Can be used inside a session or when the session ends to detach a specific feature
  42947. * @param featureName the name of the feature to detach
  42948. */
  42949. detachFeature(featureName: string): void;
  42950. /**
  42951. * Get the list of enabled features
  42952. * @returns an array of enabled features
  42953. */
  42954. getEnabledFeatures(): string[];
  42955. /**
  42956. * get the implementation of an enabled feature.
  42957. * @param featureName the name of the feature to load
  42958. * @returns the feature class, if found
  42959. */
  42960. getEnabledFeature(featureName: string): IWebXRFeature;
  42961. /**
  42962. * dispose this features manager
  42963. */
  42964. dispose(): void;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42970. * @see https://doc.babylonjs.com/how_to/webxr
  42971. */
  42972. export class WebXRExperienceHelper implements IDisposable {
  42973. private scene;
  42974. /**
  42975. * Camera used to render xr content
  42976. */
  42977. camera: WebXRCamera;
  42978. /**
  42979. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42980. */
  42981. state: WebXRState;
  42982. private _setState;
  42983. /**
  42984. * Fires when the state of the experience helper has changed
  42985. */
  42986. onStateChangedObservable: Observable<WebXRState>;
  42987. /**
  42988. * Observers registered here will be triggered after the camera's initial transformation is set
  42989. * This can be used to set a different ground level or an extra rotation.
  42990. *
  42991. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42992. * to the position set after this observable is done executing.
  42993. */
  42994. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42995. /** Session manager used to keep track of xr session */
  42996. sessionManager: WebXRSessionManager;
  42997. /** A features manager for this xr session */
  42998. featuresManager: WebXRFeaturesManager;
  42999. private _nonVRCamera;
  43000. private _originalSceneAutoClear;
  43001. private _supported;
  43002. /**
  43003. * Creates the experience helper
  43004. * @param scene the scene to attach the experience helper to
  43005. * @returns a promise for the experience helper
  43006. */
  43007. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43008. /**
  43009. * Creates a WebXRExperienceHelper
  43010. * @param scene The scene the helper should be created in
  43011. */
  43012. private constructor();
  43013. /**
  43014. * Exits XR mode and returns the scene to its original state
  43015. * @returns promise that resolves after xr mode has exited
  43016. */
  43017. exitXRAsync(): Promise<void>;
  43018. /**
  43019. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43020. * @param sessionMode options for the XR session
  43021. * @param referenceSpaceType frame of reference of the XR session
  43022. * @param renderTarget the output canvas that will be used to enter XR mode
  43023. * @returns promise that resolves after xr mode has entered
  43024. */
  43025. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43026. /**
  43027. * Disposes of the experience helper
  43028. */
  43029. dispose(): void;
  43030. private _nonXRToXRCamera;
  43031. }
  43032. }
  43033. declare module BABYLON {
  43034. /**
  43035. * X-Y values for axes in WebXR
  43036. */
  43037. export interface IWebXRMotionControllerAxesValue {
  43038. /**
  43039. * The value of the x axis
  43040. */
  43041. x: number;
  43042. /**
  43043. * The value of the y-axis
  43044. */
  43045. y: number;
  43046. }
  43047. /**
  43048. * changed / previous values for the values of this component
  43049. */
  43050. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43051. /**
  43052. * current (this frame) value
  43053. */
  43054. current: T;
  43055. /**
  43056. * previous (last change) value
  43057. */
  43058. previous: T;
  43059. }
  43060. /**
  43061. * Represents changes in the component between current frame and last values recorded
  43062. */
  43063. export interface IWebXRMotionControllerComponentChanges {
  43064. /**
  43065. * will be populated with previous and current values if touched changed
  43066. */
  43067. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43068. /**
  43069. * will be populated with previous and current values if pressed changed
  43070. */
  43071. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43072. /**
  43073. * will be populated with previous and current values if value changed
  43074. */
  43075. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43076. /**
  43077. * will be populated with previous and current values if axes changed
  43078. */
  43079. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43080. }
  43081. /**
  43082. * This class represents a single component (for example button or thumbstick) of a motion controller
  43083. */
  43084. export class WebXRControllerComponent implements IDisposable {
  43085. /**
  43086. * the id of this component
  43087. */
  43088. id: string;
  43089. /**
  43090. * the type of the component
  43091. */
  43092. type: MotionControllerComponentType;
  43093. private _buttonIndex;
  43094. private _axesIndices;
  43095. /**
  43096. * Thumbstick component type
  43097. */
  43098. static THUMBSTICK: MotionControllerComponentType;
  43099. /**
  43100. * Touchpad component type
  43101. */
  43102. static TOUCHPAD: MotionControllerComponentType;
  43103. /**
  43104. * trigger component type
  43105. */
  43106. static TRIGGER: MotionControllerComponentType;
  43107. /**
  43108. * squeeze component type
  43109. */
  43110. static SQUEEZE: MotionControllerComponentType;
  43111. /**
  43112. * button component type
  43113. */
  43114. static BUTTON: MotionControllerComponentType;
  43115. /**
  43116. * Observers registered here will be triggered when the state of a button changes
  43117. * State change is either pressed / touched / value
  43118. */
  43119. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43120. /**
  43121. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43122. * the axes data changes
  43123. */
  43124. onAxisValueChangedObservable: Observable<{
  43125. x: number;
  43126. y: number;
  43127. }>;
  43128. private _currentValue;
  43129. private _touched;
  43130. private _pressed;
  43131. private _axes;
  43132. private _changes;
  43133. private _hasChanges;
  43134. /**
  43135. * Return whether or not the component changed the last frame
  43136. */
  43137. get hasChanges(): boolean;
  43138. /**
  43139. * Creates a new component for a motion controller.
  43140. * It is created by the motion controller itself
  43141. *
  43142. * @param id the id of this component
  43143. * @param type the type of the component
  43144. * @param _buttonIndex index in the buttons array of the gamepad
  43145. * @param _axesIndices indices of the values in the axes array of the gamepad
  43146. */
  43147. constructor(
  43148. /**
  43149. * the id of this component
  43150. */
  43151. id: string,
  43152. /**
  43153. * the type of the component
  43154. */
  43155. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43156. /**
  43157. * Get the current value of this component
  43158. */
  43159. get value(): number;
  43160. /**
  43161. * is the button currently pressed
  43162. */
  43163. get pressed(): boolean;
  43164. /**
  43165. * is the button currently touched
  43166. */
  43167. get touched(): boolean;
  43168. /**
  43169. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43170. */
  43171. get axes(): IWebXRMotionControllerAxesValue;
  43172. /**
  43173. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43174. */
  43175. get changes(): IWebXRMotionControllerComponentChanges;
  43176. /**
  43177. * Is this component a button (hence - pressable)
  43178. * @returns true if can be pressed
  43179. */
  43180. isButton(): boolean;
  43181. /**
  43182. * Are there axes correlating to this component
  43183. * @return true is axes data is available
  43184. */
  43185. isAxes(): boolean;
  43186. /**
  43187. * update this component using the gamepad object it is in. Called on every frame
  43188. * @param nativeController the native gamepad controller object
  43189. */
  43190. update(nativeController: IMinimalMotionControllerObject): void;
  43191. /**
  43192. * Dispose this component
  43193. */
  43194. dispose(): void;
  43195. }
  43196. }
  43197. declare module BABYLON {
  43198. /**
  43199. * Class used to represent data loading progression
  43200. */
  43201. export class SceneLoaderProgressEvent {
  43202. /** defines if data length to load can be evaluated */
  43203. readonly lengthComputable: boolean;
  43204. /** defines the loaded data length */
  43205. readonly loaded: number;
  43206. /** defines the data length to load */
  43207. readonly total: number;
  43208. /**
  43209. * Create a new progress event
  43210. * @param lengthComputable defines if data length to load can be evaluated
  43211. * @param loaded defines the loaded data length
  43212. * @param total defines the data length to load
  43213. */
  43214. constructor(
  43215. /** defines if data length to load can be evaluated */
  43216. lengthComputable: boolean,
  43217. /** defines the loaded data length */
  43218. loaded: number,
  43219. /** defines the data length to load */
  43220. total: number);
  43221. /**
  43222. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43223. * @param event defines the source event
  43224. * @returns a new SceneLoaderProgressEvent
  43225. */
  43226. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43227. }
  43228. /**
  43229. * Interface used by SceneLoader plugins to define supported file extensions
  43230. */
  43231. export interface ISceneLoaderPluginExtensions {
  43232. /**
  43233. * Defines the list of supported extensions
  43234. */
  43235. [extension: string]: {
  43236. isBinary: boolean;
  43237. };
  43238. }
  43239. /**
  43240. * Interface used by SceneLoader plugin factory
  43241. */
  43242. export interface ISceneLoaderPluginFactory {
  43243. /**
  43244. * Defines the name of the factory
  43245. */
  43246. name: string;
  43247. /**
  43248. * Function called to create a new plugin
  43249. * @return the new plugin
  43250. */
  43251. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43252. /**
  43253. * The callback that returns true if the data can be directly loaded.
  43254. * @param data string containing the file data
  43255. * @returns if the data can be loaded directly
  43256. */
  43257. canDirectLoad?(data: string): boolean;
  43258. }
  43259. /**
  43260. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43261. */
  43262. export interface ISceneLoaderPluginBase {
  43263. /**
  43264. * The friendly name of this plugin.
  43265. */
  43266. name: string;
  43267. /**
  43268. * The file extensions supported by this plugin.
  43269. */
  43270. extensions: string | ISceneLoaderPluginExtensions;
  43271. /**
  43272. * The callback called when loading from a url.
  43273. * @param scene scene loading this url
  43274. * @param url url to load
  43275. * @param onSuccess callback called when the file successfully loads
  43276. * @param onProgress callback called while file is loading (if the server supports this mode)
  43277. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43278. * @param onError callback called when the file fails to load
  43279. * @returns a file request object
  43280. */
  43281. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43282. /**
  43283. * The callback called when loading from a file object.
  43284. * @param scene scene loading this file
  43285. * @param file defines the file to load
  43286. * @param onSuccess defines the callback to call when data is loaded
  43287. * @param onProgress defines the callback to call during loading process
  43288. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43289. * @param onError defines the callback to call when an error occurs
  43290. * @returns a file request object
  43291. */
  43292. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43293. /**
  43294. * The callback that returns true if the data can be directly loaded.
  43295. * @param data string containing the file data
  43296. * @returns if the data can be loaded directly
  43297. */
  43298. canDirectLoad?(data: string): boolean;
  43299. /**
  43300. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43301. * @param scene scene loading this data
  43302. * @param data string containing the data
  43303. * @returns data to pass to the plugin
  43304. */
  43305. directLoad?(scene: Scene, data: string): any;
  43306. /**
  43307. * The callback that allows custom handling of the root url based on the response url.
  43308. * @param rootUrl the original root url
  43309. * @param responseURL the response url if available
  43310. * @returns the new root url
  43311. */
  43312. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43313. }
  43314. /**
  43315. * Interface used to define a SceneLoader plugin
  43316. */
  43317. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43318. /**
  43319. * Import meshes into a scene.
  43320. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43321. * @param scene The scene to import into
  43322. * @param data The data to import
  43323. * @param rootUrl The root url for scene and resources
  43324. * @param meshes The meshes array to import into
  43325. * @param particleSystems The particle systems array to import into
  43326. * @param skeletons The skeletons array to import into
  43327. * @param onError The callback when import fails
  43328. * @returns True if successful or false otherwise
  43329. */
  43330. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43331. /**
  43332. * Load into a scene.
  43333. * @param scene The scene to load into
  43334. * @param data The data to import
  43335. * @param rootUrl The root url for scene and resources
  43336. * @param onError The callback when import fails
  43337. * @returns True if successful or false otherwise
  43338. */
  43339. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43340. /**
  43341. * Load into an asset container.
  43342. * @param scene The scene to load into
  43343. * @param data The data to import
  43344. * @param rootUrl The root url for scene and resources
  43345. * @param onError The callback when import fails
  43346. * @returns The loaded asset container
  43347. */
  43348. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43349. }
  43350. /**
  43351. * Interface used to define an async SceneLoader plugin
  43352. */
  43353. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43354. /**
  43355. * Import meshes into a scene.
  43356. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43357. * @param scene The scene to import into
  43358. * @param data The data to import
  43359. * @param rootUrl The root url for scene and resources
  43360. * @param onProgress The callback when the load progresses
  43361. * @param fileName Defines the name of the file to load
  43362. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43363. */
  43364. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43365. meshes: AbstractMesh[];
  43366. particleSystems: IParticleSystem[];
  43367. skeletons: Skeleton[];
  43368. animationGroups: AnimationGroup[];
  43369. }>;
  43370. /**
  43371. * Load into a scene.
  43372. * @param scene The scene to load into
  43373. * @param data The data to import
  43374. * @param rootUrl The root url for scene and resources
  43375. * @param onProgress The callback when the load progresses
  43376. * @param fileName Defines the name of the file to load
  43377. * @returns Nothing
  43378. */
  43379. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43380. /**
  43381. * Load into an asset container.
  43382. * @param scene The scene to load into
  43383. * @param data The data to import
  43384. * @param rootUrl The root url for scene and resources
  43385. * @param onProgress The callback when the load progresses
  43386. * @param fileName Defines the name of the file to load
  43387. * @returns The loaded asset container
  43388. */
  43389. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43390. }
  43391. /**
  43392. * Mode that determines how to handle old animation groups before loading new ones.
  43393. */
  43394. export enum SceneLoaderAnimationGroupLoadingMode {
  43395. /**
  43396. * Reset all old animations to initial state then dispose them.
  43397. */
  43398. Clean = 0,
  43399. /**
  43400. * Stop all old animations.
  43401. */
  43402. Stop = 1,
  43403. /**
  43404. * Restart old animations from first frame.
  43405. */
  43406. Sync = 2,
  43407. /**
  43408. * Old animations remains untouched.
  43409. */
  43410. NoSync = 3
  43411. }
  43412. /**
  43413. * Class used to load scene from various file formats using registered plugins
  43414. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43415. */
  43416. export class SceneLoader {
  43417. /**
  43418. * No logging while loading
  43419. */
  43420. static readonly NO_LOGGING: number;
  43421. /**
  43422. * Minimal logging while loading
  43423. */
  43424. static readonly MINIMAL_LOGGING: number;
  43425. /**
  43426. * Summary logging while loading
  43427. */
  43428. static readonly SUMMARY_LOGGING: number;
  43429. /**
  43430. * Detailled logging while loading
  43431. */
  43432. static readonly DETAILED_LOGGING: number;
  43433. /**
  43434. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43435. */
  43436. static get ForceFullSceneLoadingForIncremental(): boolean;
  43437. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43438. /**
  43439. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43440. */
  43441. static get ShowLoadingScreen(): boolean;
  43442. static set ShowLoadingScreen(value: boolean);
  43443. /**
  43444. * Defines the current logging level (while loading the scene)
  43445. * @ignorenaming
  43446. */
  43447. static get loggingLevel(): number;
  43448. static set loggingLevel(value: number);
  43449. /**
  43450. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43451. */
  43452. static get CleanBoneMatrixWeights(): boolean;
  43453. static set CleanBoneMatrixWeights(value: boolean);
  43454. /**
  43455. * Event raised when a plugin is used to load a scene
  43456. */
  43457. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43458. private static _registeredPlugins;
  43459. private static _getDefaultPlugin;
  43460. private static _getPluginForExtension;
  43461. private static _getPluginForDirectLoad;
  43462. private static _getPluginForFilename;
  43463. private static _getDirectLoad;
  43464. private static _loadData;
  43465. private static _getFileInfo;
  43466. /**
  43467. * Gets a plugin that can load the given extension
  43468. * @param extension defines the extension to load
  43469. * @returns a plugin or null if none works
  43470. */
  43471. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43472. /**
  43473. * Gets a boolean indicating that the given extension can be loaded
  43474. * @param extension defines the extension to load
  43475. * @returns true if the extension is supported
  43476. */
  43477. static IsPluginForExtensionAvailable(extension: string): boolean;
  43478. /**
  43479. * Adds a new plugin to the list of registered plugins
  43480. * @param plugin defines the plugin to add
  43481. */
  43482. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43483. /**
  43484. * Import meshes into a scene
  43485. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43486. * @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)
  43487. * @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)
  43488. * @param scene the instance of BABYLON.Scene to append to
  43489. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43490. * @param onProgress a callback with a progress event for each file being loaded
  43491. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43492. * @param pluginExtension the extension used to determine the plugin
  43493. * @returns The loaded plugin
  43494. */
  43495. 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>;
  43496. /**
  43497. * Import meshes into a scene
  43498. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43499. * @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)
  43500. * @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)
  43501. * @param scene the instance of BABYLON.Scene to append to
  43502. * @param onProgress a callback with a progress event for each file being loaded
  43503. * @param pluginExtension the extension used to determine the plugin
  43504. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43505. */
  43506. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43507. meshes: AbstractMesh[];
  43508. particleSystems: IParticleSystem[];
  43509. skeletons: Skeleton[];
  43510. animationGroups: AnimationGroup[];
  43511. }>;
  43512. /**
  43513. * Load a scene
  43514. * @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)
  43515. * @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)
  43516. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43517. * @param onSuccess a callback with the scene when import succeeds
  43518. * @param onProgress a callback with a progress event for each file being loaded
  43519. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43520. * @param pluginExtension the extension used to determine the plugin
  43521. * @returns The loaded plugin
  43522. */
  43523. 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>;
  43524. /**
  43525. * Load a scene
  43526. * @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)
  43527. * @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)
  43528. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43529. * @param onProgress a callback with a progress event for each file being loaded
  43530. * @param pluginExtension the extension used to determine the plugin
  43531. * @returns The loaded scene
  43532. */
  43533. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43534. /**
  43535. * Append a scene
  43536. * @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)
  43537. * @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)
  43538. * @param scene is the instance of BABYLON.Scene to append to
  43539. * @param onSuccess a callback with the scene when import succeeds
  43540. * @param onProgress a callback with a progress event for each file being loaded
  43541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43542. * @param pluginExtension the extension used to determine the plugin
  43543. * @returns The loaded plugin
  43544. */
  43545. 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>;
  43546. /**
  43547. * Append a scene
  43548. * @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)
  43549. * @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)
  43550. * @param scene is the instance of BABYLON.Scene to append to
  43551. * @param onProgress a callback with a progress event for each file being loaded
  43552. * @param pluginExtension the extension used to determine the plugin
  43553. * @returns The given scene
  43554. */
  43555. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43556. /**
  43557. * Load a scene into an asset container
  43558. * @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)
  43559. * @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)
  43560. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43561. * @param onSuccess a callback with the scene when import succeeds
  43562. * @param onProgress a callback with a progress event for each file being loaded
  43563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43564. * @param pluginExtension the extension used to determine the plugin
  43565. * @returns The loaded plugin
  43566. */
  43567. 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>;
  43568. /**
  43569. * Load a scene into an asset container
  43570. * @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)
  43571. * @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)
  43572. * @param scene is the instance of Scene to append to
  43573. * @param onProgress a callback with a progress event for each file being loaded
  43574. * @param pluginExtension the extension used to determine the plugin
  43575. * @returns The loaded asset container
  43576. */
  43577. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43578. /**
  43579. * Import animations from a file into a scene
  43580. * @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)
  43581. * @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)
  43582. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43583. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43584. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43585. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43586. * @param onSuccess a callback with the scene when import succeeds
  43587. * @param onProgress a callback with a progress event for each file being loaded
  43588. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43589. */
  43590. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43591. /**
  43592. * Import animations from a file into a scene
  43593. * @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)
  43594. * @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)
  43595. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43596. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43597. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43598. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43599. * @param onSuccess a callback with the scene when import succeeds
  43600. * @param onProgress a callback with a progress event for each file being loaded
  43601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43602. * @returns the updated scene with imported animations
  43603. */
  43604. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43605. }
  43606. }
  43607. declare module BABYLON {
  43608. /**
  43609. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43610. */
  43611. export type MotionControllerHandness = "none" | "left" | "right";
  43612. /**
  43613. * The type of components available in motion controllers.
  43614. * This is not the name of the component.
  43615. */
  43616. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43617. /**
  43618. * The state of a controller component
  43619. */
  43620. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43621. /**
  43622. * The schema of motion controller layout.
  43623. * No object will be initialized using this interface
  43624. * This is used just to define the profile.
  43625. */
  43626. export interface IMotionControllerLayout {
  43627. /**
  43628. * Defines the main button component id
  43629. */
  43630. selectComponentId: string;
  43631. /**
  43632. * Available components (unsorted)
  43633. */
  43634. components: {
  43635. /**
  43636. * A map of component Ids
  43637. */
  43638. [componentId: string]: {
  43639. /**
  43640. * The type of input the component outputs
  43641. */
  43642. type: MotionControllerComponentType;
  43643. /**
  43644. * The indices of this component in the gamepad object
  43645. */
  43646. gamepadIndices: {
  43647. /**
  43648. * Index of button
  43649. */
  43650. button?: number;
  43651. /**
  43652. * If available, index of x-axis
  43653. */
  43654. xAxis?: number;
  43655. /**
  43656. * If available, index of y-axis
  43657. */
  43658. yAxis?: number;
  43659. };
  43660. /**
  43661. * The mesh's root node name
  43662. */
  43663. rootNodeName: string;
  43664. /**
  43665. * Animation definitions for this model
  43666. */
  43667. visualResponses: {
  43668. [stateKey: string]: {
  43669. /**
  43670. * What property will be animated
  43671. */
  43672. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43673. /**
  43674. * What states influence this visual reponse
  43675. */
  43676. states: MotionControllerComponentStateType[];
  43677. /**
  43678. * Type of animation - movement or visibility
  43679. */
  43680. valueNodeProperty: "transform" | "visibility";
  43681. /**
  43682. * Base node name to move. Its position will be calculated according to the min and max nodes
  43683. */
  43684. valueNodeName?: string;
  43685. /**
  43686. * Minimum movement node
  43687. */
  43688. minNodeName?: string;
  43689. /**
  43690. * Max movement node
  43691. */
  43692. maxNodeName?: string;
  43693. };
  43694. };
  43695. /**
  43696. * If touch enabled, what is the name of node to display user feedback
  43697. */
  43698. touchPointNodeName?: string;
  43699. };
  43700. };
  43701. /**
  43702. * Is it xr standard mapping or not
  43703. */
  43704. gamepadMapping: "" | "xr-standard";
  43705. /**
  43706. * Base root node of this entire model
  43707. */
  43708. rootNodeName: string;
  43709. /**
  43710. * Path to load the assets. Usually relative to the base path
  43711. */
  43712. assetPath: string;
  43713. }
  43714. /**
  43715. * A definition for the layout map in the input profile
  43716. */
  43717. export interface IMotionControllerLayoutMap {
  43718. /**
  43719. * Layouts with handness type as a key
  43720. */
  43721. [handness: string]: IMotionControllerLayout;
  43722. }
  43723. /**
  43724. * The XR Input profile schema
  43725. * Profiles can be found here:
  43726. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43727. */
  43728. export interface IMotionControllerProfile {
  43729. /**
  43730. * The id of this profile
  43731. * correlates to the profile(s) in the xrInput.profiles array
  43732. */
  43733. profileId: string;
  43734. /**
  43735. * fallback profiles for this profileId
  43736. */
  43737. fallbackProfileIds: string[];
  43738. /**
  43739. * The layout map, with handness as key
  43740. */
  43741. layouts: IMotionControllerLayoutMap;
  43742. }
  43743. /**
  43744. * A helper-interface for the 3 meshes needed for controller button animation
  43745. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43746. */
  43747. export interface IMotionControllerButtonMeshMap {
  43748. /**
  43749. * The mesh that will be changed when value changes
  43750. */
  43751. valueMesh: AbstractMesh;
  43752. /**
  43753. * the mesh that defines the pressed value mesh position.
  43754. * This is used to find the max-position of this button
  43755. */
  43756. pressedMesh: AbstractMesh;
  43757. /**
  43758. * the mesh that defines the unpressed value mesh position.
  43759. * This is used to find the min (or initial) position of this button
  43760. */
  43761. unpressedMesh: AbstractMesh;
  43762. }
  43763. /**
  43764. * A helper-interface for the 3 meshes needed for controller axis animation.
  43765. * This will be expanded when touchpad animations are fully supported
  43766. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43767. */
  43768. export interface IMotionControllerMeshMap {
  43769. /**
  43770. * The mesh that will be changed when axis value changes
  43771. */
  43772. valueMesh: AbstractMesh;
  43773. /**
  43774. * the mesh that defines the minimum value mesh position.
  43775. */
  43776. minMesh?: AbstractMesh;
  43777. /**
  43778. * the mesh that defines the maximum value mesh position.
  43779. */
  43780. maxMesh?: AbstractMesh;
  43781. }
  43782. /**
  43783. * The elements needed for change-detection of the gamepad objects in motion controllers
  43784. */
  43785. export interface IMinimalMotionControllerObject {
  43786. /**
  43787. * An array of available buttons
  43788. */
  43789. buttons: Array<{
  43790. /**
  43791. * Value of the button/trigger
  43792. */
  43793. value: number;
  43794. /**
  43795. * If the button/trigger is currently touched
  43796. */
  43797. touched: boolean;
  43798. /**
  43799. * If the button/trigger is currently pressed
  43800. */
  43801. pressed: boolean;
  43802. }>;
  43803. /**
  43804. * Available axes of this controller
  43805. */
  43806. axes: number[];
  43807. }
  43808. /**
  43809. * An Abstract Motion controller
  43810. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43811. * Each component has an observable to check for changes in value and state
  43812. */
  43813. export abstract class WebXRAbstractMotionController implements IDisposable {
  43814. protected scene: Scene;
  43815. protected layout: IMotionControllerLayout;
  43816. /**
  43817. * The gamepad object correlating to this controller
  43818. */
  43819. gamepadObject: IMinimalMotionControllerObject;
  43820. /**
  43821. * handness (left/right/none) of this controller
  43822. */
  43823. handness: MotionControllerHandness;
  43824. /**
  43825. * The profile id of this motion controller
  43826. */
  43827. abstract profileId: string;
  43828. /**
  43829. * A map of components (WebXRControllerComponent) in this motion controller
  43830. * Components have a ComponentType and can also have both button and axis definitions
  43831. */
  43832. readonly components: {
  43833. [id: string]: WebXRControllerComponent;
  43834. };
  43835. /**
  43836. * Observers registered here will be triggered when the model of this controller is done loading
  43837. */
  43838. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43839. /**
  43840. * The root mesh of the model. It is null if the model was not yet initialized
  43841. */
  43842. rootMesh: Nullable<AbstractMesh>;
  43843. /**
  43844. * Disable the model's animation. Can be set at any time.
  43845. */
  43846. disableAnimation: boolean;
  43847. private _modelReady;
  43848. /**
  43849. * constructs a new abstract motion controller
  43850. * @param scene the scene to which the model of the controller will be added
  43851. * @param layout The profile layout to load
  43852. * @param gamepadObject The gamepad object correlating to this controller
  43853. * @param handness handness (left/right/none) of this controller
  43854. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43855. */
  43856. constructor(scene: Scene, layout: IMotionControllerLayout,
  43857. /**
  43858. * The gamepad object correlating to this controller
  43859. */
  43860. gamepadObject: IMinimalMotionControllerObject,
  43861. /**
  43862. * handness (left/right/none) of this controller
  43863. */
  43864. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43865. private _initComponent;
  43866. /**
  43867. * Update this model using the current XRFrame
  43868. * @param xrFrame the current xr frame to use and update the model
  43869. */
  43870. updateFromXRFrame(xrFrame: XRFrame): void;
  43871. /**
  43872. * Get the list of components available in this motion controller
  43873. * @returns an array of strings correlating to available components
  43874. */
  43875. getComponentIds(): string[];
  43876. /**
  43877. * Get the main (Select) component of this controller as defined in the layout
  43878. * @returns the main component of this controller
  43879. */
  43880. getMainComponent(): WebXRControllerComponent;
  43881. /**
  43882. * get a component based an its component id as defined in layout.components
  43883. * @param id the id of the component
  43884. * @returns the component correlates to the id or undefined if not found
  43885. */
  43886. getComponent(id: string): WebXRControllerComponent;
  43887. /**
  43888. * Get the first component of specific type
  43889. * @param type type of component to find
  43890. * @return a controller component or null if not found
  43891. */
  43892. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43893. /**
  43894. * Returns all components of specific type
  43895. * @param type the type to search for
  43896. * @return an array of components with this type
  43897. */
  43898. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43899. /**
  43900. * Loads the model correlating to this controller
  43901. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43902. * @returns A promise fulfilled with the result of the model loading
  43903. */
  43904. loadModel(): Promise<boolean>;
  43905. /**
  43906. * Update the model itself with the current frame data
  43907. * @param xrFrame the frame to use for updating the model mesh
  43908. */
  43909. protected updateModel(xrFrame: XRFrame): void;
  43910. /**
  43911. * Moves the axis on the controller mesh based on its current state
  43912. * @param axis the index of the axis
  43913. * @param axisValue the value of the axis which determines the meshes new position
  43914. * @hidden
  43915. */
  43916. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43917. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43918. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43919. private _getGenericFilenameAndPath;
  43920. private _getGenericParentMesh;
  43921. /**
  43922. * Get the filename and path for this controller's model
  43923. * @returns a map of filename and path
  43924. */
  43925. protected abstract _getFilenameAndPath(): {
  43926. filename: string;
  43927. path: string;
  43928. };
  43929. /**
  43930. * This function will be called after the model was successfully loaded and can be used
  43931. * for mesh transformations before it is available for the user
  43932. * @param meshes the loaded meshes
  43933. */
  43934. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43935. /**
  43936. * Set the root mesh for this controller. Important for the WebXR controller class
  43937. * @param meshes the loaded meshes
  43938. */
  43939. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43940. /**
  43941. * A function executed each frame that updates the mesh (if needed)
  43942. * @param xrFrame the current xrFrame
  43943. */
  43944. protected abstract _updateModel(xrFrame: XRFrame): void;
  43945. /**
  43946. * This function is called before the mesh is loaded. It checks for loading constraints.
  43947. * For example, this function can check if the GLB loader is available
  43948. * If this function returns false, the generic controller will be loaded instead
  43949. * @returns Is the client ready to load the mesh
  43950. */
  43951. protected abstract _getModelLoadingConstraints(): boolean;
  43952. /**
  43953. * Dispose this controller, the model mesh and all its components
  43954. */
  43955. dispose(): void;
  43956. }
  43957. }
  43958. declare module BABYLON {
  43959. /**
  43960. * A generic trigger-only motion controller for WebXR
  43961. */
  43962. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43963. /**
  43964. * Static version of the profile id of this controller
  43965. */
  43966. static ProfileId: string;
  43967. profileId: string;
  43968. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43969. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43970. protected _updateModel(): void;
  43971. protected _getFilenameAndPath(): {
  43972. filename: string;
  43973. path: string;
  43974. };
  43975. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43976. protected _getModelLoadingConstraints(): boolean;
  43977. }
  43978. }
  43979. declare module BABYLON {
  43980. /**
  43981. * Class containing static functions to help procedurally build meshes
  43982. */
  43983. export class SphereBuilder {
  43984. /**
  43985. * Creates a sphere mesh
  43986. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43987. * * 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`)
  43988. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43989. * * 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
  43990. * * 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)
  43991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43992. * * 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
  43993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43994. * @param name defines the name of the mesh
  43995. * @param options defines the options used to create the mesh
  43996. * @param scene defines the hosting scene
  43997. * @returns the sphere mesh
  43998. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43999. */
  44000. static CreateSphere(name: string, options: {
  44001. segments?: number;
  44002. diameter?: number;
  44003. diameterX?: number;
  44004. diameterY?: number;
  44005. diameterZ?: number;
  44006. arc?: number;
  44007. slice?: number;
  44008. sideOrientation?: number;
  44009. frontUVs?: Vector4;
  44010. backUVs?: Vector4;
  44011. updatable?: boolean;
  44012. }, scene?: Nullable<Scene>): Mesh;
  44013. }
  44014. }
  44015. declare module BABYLON {
  44016. /**
  44017. * A profiled motion controller has its profile loaded from an online repository.
  44018. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44019. */
  44020. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44021. private _repositoryUrl;
  44022. /**
  44023. * The profile ID of this controller. Will be populated when the controller initializes.
  44024. */
  44025. profileId: string;
  44026. private _buttonMeshMapping;
  44027. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44028. protected _getFilenameAndPath(): {
  44029. filename: string;
  44030. path: string;
  44031. };
  44032. private _touchDots;
  44033. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44034. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44035. protected _updateModel(_xrFrame: XRFrame): void;
  44036. protected _getModelLoadingConstraints(): boolean;
  44037. dispose(): void;
  44038. }
  44039. }
  44040. declare module BABYLON {
  44041. /**
  44042. * A construction function type to create a new controller based on an xrInput object
  44043. */
  44044. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44045. /**
  44046. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44047. *
  44048. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44049. * it should be replaced with auto-loaded controllers.
  44050. *
  44051. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44052. */
  44053. export class WebXRMotionControllerManager {
  44054. /**
  44055. * The base URL of the online controller repository. Can be changed at any time.
  44056. */
  44057. static BaseRepositoryUrl: string;
  44058. /**
  44059. * Use the online repository, or use only locally-defined controllers
  44060. */
  44061. static UseOnlineRepository: boolean;
  44062. /**
  44063. * Which repository gets priority - local or online
  44064. */
  44065. static PrioritizeOnlineRepository: boolean;
  44066. private static _AvailableControllers;
  44067. private static _Fallbacks;
  44068. /**
  44069. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44070. *
  44071. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44072. *
  44073. * @param type the profile type to register
  44074. * @param constructFunction the function to be called when loading this profile
  44075. */
  44076. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44077. /**
  44078. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44079. * The order of search:
  44080. *
  44081. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44082. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44083. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44084. * 4) return the generic trigger controller if none were found
  44085. *
  44086. * @param xrInput the xrInput to which a new controller is initialized
  44087. * @param scene the scene to which the model will be added
  44088. * @param forceProfile force a certain profile for this controller
  44089. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44090. */
  44091. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44092. private static _LoadProfilesFromAvailableControllers;
  44093. private static _ProfilesList;
  44094. private static _ProfileLoadingPromises;
  44095. private static _LoadProfileFromRepository;
  44096. /**
  44097. * Clear the cache used for profile loading and reload when requested again
  44098. */
  44099. static ClearProfilesCache(): void;
  44100. /**
  44101. * Will update the list of profiles available in the repository
  44102. * @return a promise that resolves to a map of profiles available online
  44103. */
  44104. static UpdateProfilesList(): Promise<{
  44105. [profile: string]: string;
  44106. }>;
  44107. /**
  44108. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44109. * @param profileId the profile to which a fallback needs to be found
  44110. * @return an array with corresponding fallback profiles
  44111. */
  44112. static FindFallbackWithProfileId(profileId: string): string[];
  44113. /**
  44114. * Register a fallback to a specific profile.
  44115. * @param profileId the profileId that will receive the fallbacks
  44116. * @param fallbacks A list of fallback profiles
  44117. */
  44118. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44119. /**
  44120. * Register the default fallbacks.
  44121. * This function is called automatically when this file is imported.
  44122. */
  44123. static DefaultFallbacks(): void;
  44124. }
  44125. }
  44126. declare module BABYLON {
  44127. /**
  44128. * Configuration options for the WebXR controller creation
  44129. */
  44130. export interface IWebXRControllerOptions {
  44131. /**
  44132. * Force a specific controller type for this controller.
  44133. * This can be used when creating your own profile or when testing different controllers
  44134. */
  44135. forceControllerProfile?: string;
  44136. /**
  44137. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44138. */
  44139. doNotLoadControllerMesh?: boolean;
  44140. /**
  44141. * Should the controller mesh be animated when a user interacts with it
  44142. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44143. */
  44144. disableMotionControllerAnimation?: boolean;
  44145. }
  44146. /**
  44147. * Represents an XR controller
  44148. */
  44149. export class WebXRInputSource {
  44150. private _scene;
  44151. /** The underlying input source for the controller */
  44152. inputSource: XRInputSource;
  44153. private _options;
  44154. /**
  44155. * 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
  44156. */
  44157. grip?: AbstractMesh;
  44158. /**
  44159. * Pointer which can be used to select objects or attach a visible laser to
  44160. */
  44161. pointer: AbstractMesh;
  44162. /**
  44163. * If available, this is the gamepad object related to this controller.
  44164. * Using this object it is possible to get click events and trackpad changes of the
  44165. * webxr controller that is currently being used.
  44166. */
  44167. motionController?: WebXRAbstractMotionController;
  44168. /**
  44169. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44170. */
  44171. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44172. /**
  44173. * Will be triggered when the mesh associated with the motion controller is done loading.
  44174. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44175. * A shortened version of controller -> motion controller -> on mesh loaded.
  44176. */
  44177. onMeshLoadedObservable: Observable<AbstractMesh>;
  44178. /**
  44179. * Event that fires when the controller is removed/disposed.
  44180. * The object provided as event data is this controller, after associated assets were disposed.
  44181. * uniqueId is still available.
  44182. */
  44183. onDisposeObservable: Observable<WebXRInputSource>;
  44184. private _tmpQuaternion;
  44185. private _tmpVector;
  44186. private _uniqueId;
  44187. /**
  44188. * Creates the controller
  44189. * @see https://doc.babylonjs.com/how_to/webxr
  44190. * @param _scene the scene which the controller should be associated to
  44191. * @param inputSource the underlying input source for the controller
  44192. * @param _options options for this controller creation
  44193. */
  44194. constructor(_scene: Scene,
  44195. /** The underlying input source for the controller */
  44196. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44197. /**
  44198. * Get this controllers unique id
  44199. */
  44200. get uniqueId(): string;
  44201. /**
  44202. * Updates the controller pose based on the given XRFrame
  44203. * @param xrFrame xr frame to update the pose with
  44204. * @param referenceSpace reference space to use
  44205. */
  44206. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44207. /**
  44208. * Gets a world space ray coming from the pointer or grip
  44209. * @param result the resulting ray
  44210. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44211. */
  44212. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44213. /**
  44214. * Disposes of the object
  44215. */
  44216. dispose(): void;
  44217. }
  44218. }
  44219. declare module BABYLON {
  44220. /**
  44221. * The schema for initialization options of the XR Input class
  44222. */
  44223. export interface IWebXRInputOptions {
  44224. /**
  44225. * If set to true no model will be automatically loaded
  44226. */
  44227. doNotLoadControllerMeshes?: boolean;
  44228. /**
  44229. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44230. * If not found, the xr input profile data will be used.
  44231. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44232. */
  44233. forceInputProfile?: string;
  44234. /**
  44235. * Do not send a request to the controlle repository to load the profile.
  44236. *
  44237. * Instead, use the controllers available in babylon itself.
  44238. */
  44239. disableOnlineControllerRepository?: boolean;
  44240. /**
  44241. * A custom URL for the controllers repository
  44242. */
  44243. customControllersRepositoryURL?: string;
  44244. /**
  44245. * Should the controller model's components not move according to the user input
  44246. */
  44247. disableControllerAnimation?: boolean;
  44248. }
  44249. /**
  44250. * XR input used to track XR inputs such as controllers/rays
  44251. */
  44252. export class WebXRInput implements IDisposable {
  44253. /**
  44254. * the xr session manager for this session
  44255. */
  44256. xrSessionManager: WebXRSessionManager;
  44257. /**
  44258. * the WebXR camera for this session. Mainly used for teleportation
  44259. */
  44260. xrCamera: WebXRCamera;
  44261. private readonly options;
  44262. /**
  44263. * XR controllers being tracked
  44264. */
  44265. controllers: Array<WebXRInputSource>;
  44266. private _frameObserver;
  44267. private _sessionEndedObserver;
  44268. private _sessionInitObserver;
  44269. /**
  44270. * Event when a controller has been connected/added
  44271. */
  44272. onControllerAddedObservable: Observable<WebXRInputSource>;
  44273. /**
  44274. * Event when a controller has been removed/disconnected
  44275. */
  44276. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44277. /**
  44278. * Initializes the WebXRInput
  44279. * @param xrSessionManager the xr session manager for this session
  44280. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44281. * @param options = initialization options for this xr input
  44282. */
  44283. constructor(
  44284. /**
  44285. * the xr session manager for this session
  44286. */
  44287. xrSessionManager: WebXRSessionManager,
  44288. /**
  44289. * the WebXR camera for this session. Mainly used for teleportation
  44290. */
  44291. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44292. private _onInputSourcesChange;
  44293. private _addAndRemoveControllers;
  44294. /**
  44295. * Disposes of the object
  44296. */
  44297. dispose(): void;
  44298. }
  44299. }
  44300. declare module BABYLON {
  44301. /**
  44302. * This is the base class for all WebXR features.
  44303. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44304. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44305. */
  44306. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44307. protected _xrSessionManager: WebXRSessionManager;
  44308. /**
  44309. * Construct a new (abstract) webxr feature
  44310. * @param _xrSessionManager the xr session manager for this feature
  44311. */
  44312. constructor(_xrSessionManager: WebXRSessionManager);
  44313. private _attached;
  44314. private _removeOnDetach;
  44315. /**
  44316. * Is this feature attached
  44317. */
  44318. get attached(): boolean;
  44319. /**
  44320. * Should auto-attach be disabled?
  44321. */
  44322. disableAutoAttach: boolean;
  44323. /**
  44324. * attach this feature
  44325. *
  44326. * @param force should attachment be forced (even when already attached)
  44327. * @returns true if successful, false is failed or already attached
  44328. */
  44329. attach(force?: boolean): boolean;
  44330. /**
  44331. * detach this feature.
  44332. *
  44333. * @returns true if successful, false if failed or already detached
  44334. */
  44335. detach(): boolean;
  44336. /**
  44337. * Dispose this feature and all of the resources attached
  44338. */
  44339. dispose(): void;
  44340. /**
  44341. * Code in this function will be executed on each xrFrame received from the browser.
  44342. * This function will not execute after the feature is detached.
  44343. * @param _xrFrame the current frame
  44344. */
  44345. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44346. /**
  44347. * This is used to register callbacks that will automatically be removed when detach is called.
  44348. * @param observable the observable to which the observer will be attached
  44349. * @param callback the callback to register
  44350. */
  44351. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44352. }
  44353. }
  44354. declare module BABYLON {
  44355. /**
  44356. * Options interface for the pointer selection module
  44357. */
  44358. export interface IWebXRControllerPointerSelectionOptions {
  44359. /**
  44360. * the xr input to use with this pointer selection
  44361. */
  44362. xrInput: WebXRInput;
  44363. /**
  44364. * Different button type to use instead of the main component
  44365. */
  44366. overrideButtonId?: string;
  44367. /**
  44368. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44369. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44370. * 3000 means 3 seconds between pointing at something and selecting it
  44371. */
  44372. timeToSelect?: number;
  44373. /**
  44374. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44375. * If not disabled, the last picked point will be used to execute a pointer up event
  44376. * If disabled, pointer up event will be triggered right after the pointer down event.
  44377. * Used in screen and gaze target ray mode only
  44378. */
  44379. disablePointerUpOnTouchOut: boolean;
  44380. /**
  44381. * For gaze mode (time to select instead of press)
  44382. */
  44383. forceGazeMode: boolean;
  44384. /**
  44385. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44386. * to start a new countdown to the pointer down event.
  44387. * Defaults to 1.
  44388. */
  44389. gazeModePointerMovedFactor?: number;
  44390. }
  44391. /**
  44392. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44393. */
  44394. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44395. private readonly _options;
  44396. /**
  44397. * The module's name
  44398. */
  44399. static readonly Name: string;
  44400. /**
  44401. * The (Babylon) version of this module.
  44402. * This is an integer representing the implementation version.
  44403. * This number does not correspond to the webxr specs version
  44404. */
  44405. static readonly Version: number;
  44406. /**
  44407. * This color will be set to the laser pointer when selection is triggered
  44408. */
  44409. laserPointerPickedColor: Color3;
  44410. /**
  44411. * This color will be applied to the selection ring when selection is triggered
  44412. */
  44413. selectionMeshPickedColor: Color3;
  44414. /**
  44415. * default color of the selection ring
  44416. */
  44417. selectionMeshDefaultColor: Color3;
  44418. /**
  44419. * Default color of the laser pointer
  44420. */
  44421. lasterPointerDefaultColor: Color3;
  44422. /**
  44423. * Should the laser pointer be displayed
  44424. */
  44425. displayLaserPointer: boolean;
  44426. /**
  44427. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44428. */
  44429. displaySelectionMesh: boolean;
  44430. /**
  44431. * Disable lighting on the laser pointer (so it will always be visible)
  44432. */
  44433. disablePointerLighting: boolean;
  44434. /**
  44435. * Disable lighting on the selection mesh (so it will always be visible)
  44436. */
  44437. disableSelectionMeshLighting: boolean;
  44438. private static _idCounter;
  44439. private _tmpRay;
  44440. private _controllers;
  44441. private _scene;
  44442. /**
  44443. * constructs a new background remover module
  44444. * @param _xrSessionManager the session manager for this module
  44445. * @param _options read-only options to be used in this module
  44446. */
  44447. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44448. /**
  44449. * attach this feature
  44450. * Will usually be called by the features manager
  44451. *
  44452. * @returns true if successful.
  44453. */
  44454. attach(): boolean;
  44455. /**
  44456. * detach this feature.
  44457. * Will usually be called by the features manager
  44458. *
  44459. * @returns true if successful.
  44460. */
  44461. detach(): boolean;
  44462. /**
  44463. * Get the xr controller that correlates to the pointer id in the pointer event
  44464. *
  44465. * @param id the pointer id to search for
  44466. * @returns the controller that correlates to this id or null if not found
  44467. */
  44468. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44469. protected _onXRFrame(_xrFrame: XRFrame): void;
  44470. private _attachController;
  44471. private _attachScreenRayMode;
  44472. private _attachGazeMode;
  44473. private _tmpVectorForPickCompare;
  44474. private _pickingMoved;
  44475. private _attachTrackedPointerRayMode;
  44476. private _detachController;
  44477. private _generateNewMeshPair;
  44478. private _convertNormalToDirectionOfRay;
  44479. private _updatePointerDistance;
  44480. }
  44481. }
  44482. declare module BABYLON {
  44483. /**
  44484. * Button which can be used to enter a different mode of XR
  44485. */
  44486. export class WebXREnterExitUIButton {
  44487. /** button element */
  44488. element: HTMLElement;
  44489. /** XR initialization options for the button */
  44490. sessionMode: XRSessionMode;
  44491. /** Reference space type */
  44492. referenceSpaceType: XRReferenceSpaceType;
  44493. /**
  44494. * Creates a WebXREnterExitUIButton
  44495. * @param element button element
  44496. * @param sessionMode XR initialization session mode
  44497. * @param referenceSpaceType the type of reference space to be used
  44498. */
  44499. constructor(
  44500. /** button element */
  44501. element: HTMLElement,
  44502. /** XR initialization options for the button */
  44503. sessionMode: XRSessionMode,
  44504. /** Reference space type */
  44505. referenceSpaceType: XRReferenceSpaceType);
  44506. /**
  44507. * Overwritable function which can be used to update the button's visuals when the state changes
  44508. * @param activeButton the current active button in the UI
  44509. */
  44510. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44511. }
  44512. /**
  44513. * Options to create the webXR UI
  44514. */
  44515. export class WebXREnterExitUIOptions {
  44516. /**
  44517. * Context to enter xr with
  44518. */
  44519. renderTarget?: Nullable<WebXRRenderTarget>;
  44520. /**
  44521. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44522. */
  44523. customButtons?: Array<WebXREnterExitUIButton>;
  44524. /**
  44525. * A session mode to use when creating the default button.
  44526. * Default is immersive-vr
  44527. */
  44528. sessionMode?: XRSessionMode;
  44529. /**
  44530. * A reference space type to use when creating the default button.
  44531. * Default is local-floor
  44532. */
  44533. referenceSpaceType?: XRReferenceSpaceType;
  44534. }
  44535. /**
  44536. * UI to allow the user to enter/exit XR mode
  44537. */
  44538. export class WebXREnterExitUI implements IDisposable {
  44539. private scene;
  44540. /** version of the options passed to this UI */
  44541. options: WebXREnterExitUIOptions;
  44542. private _overlay;
  44543. private _buttons;
  44544. private _activeButton;
  44545. /**
  44546. * Fired every time the active button is changed.
  44547. *
  44548. * When xr is entered via a button that launches xr that button will be the callback parameter
  44549. *
  44550. * When exiting xr the callback parameter will be null)
  44551. */
  44552. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44553. /**
  44554. * Creates UI to allow the user to enter/exit XR mode
  44555. * @param scene the scene to add the ui to
  44556. * @param helper the xr experience helper to enter/exit xr with
  44557. * @param options options to configure the UI
  44558. * @returns the created ui
  44559. */
  44560. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44561. /**
  44562. *
  44563. * @param scene babylon scene object to use
  44564. * @param options (read-only) version of the options passed to this UI
  44565. */
  44566. private constructor();
  44567. private _updateButtons;
  44568. /**
  44569. * Disposes of the object
  44570. */
  44571. dispose(): void;
  44572. }
  44573. }
  44574. declare module BABYLON {
  44575. /**
  44576. * Class containing static functions to help procedurally build meshes
  44577. */
  44578. export class LinesBuilder {
  44579. /**
  44580. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44581. * * 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
  44582. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44583. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44584. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44585. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44586. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44587. * * 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
  44588. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44591. * @param name defines the name of the new line system
  44592. * @param options defines the options used to create the line system
  44593. * @param scene defines the hosting scene
  44594. * @returns a new line system mesh
  44595. */
  44596. static CreateLineSystem(name: string, options: {
  44597. lines: Vector3[][];
  44598. updatable?: boolean;
  44599. instance?: Nullable<LinesMesh>;
  44600. colors?: Nullable<Color4[][]>;
  44601. useVertexAlpha?: boolean;
  44602. }, scene: Nullable<Scene>): LinesMesh;
  44603. /**
  44604. * Creates a line mesh
  44605. * 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
  44606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44607. * * The parameter `points` is an array successive Vector3
  44608. * * 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
  44609. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44611. * * When updating an instance, remember that only point positions can change, not the number of points
  44612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44614. * @param name defines the name of the new line system
  44615. * @param options defines the options used to create the line system
  44616. * @param scene defines the hosting scene
  44617. * @returns a new line mesh
  44618. */
  44619. static CreateLines(name: string, options: {
  44620. points: Vector3[];
  44621. updatable?: boolean;
  44622. instance?: Nullable<LinesMesh>;
  44623. colors?: Color4[];
  44624. useVertexAlpha?: boolean;
  44625. }, scene?: Nullable<Scene>): LinesMesh;
  44626. /**
  44627. * Creates a dashed line mesh
  44628. * * 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
  44629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44630. * * The parameter `points` is an array successive Vector3
  44631. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44632. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44633. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44634. * * 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
  44635. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44636. * * When updating an instance, remember that only point positions can change, not the number of points
  44637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44638. * @param name defines the name of the mesh
  44639. * @param options defines the options used to create the mesh
  44640. * @param scene defines the hosting scene
  44641. * @returns the dashed line mesh
  44642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44643. */
  44644. static CreateDashedLines(name: string, options: {
  44645. points: Vector3[];
  44646. dashSize?: number;
  44647. gapSize?: number;
  44648. dashNb?: number;
  44649. updatable?: boolean;
  44650. instance?: LinesMesh;
  44651. useVertexAlpha?: boolean;
  44652. }, scene?: Nullable<Scene>): LinesMesh;
  44653. }
  44654. }
  44655. declare module BABYLON {
  44656. /**
  44657. * The options container for the teleportation module
  44658. */
  44659. export interface IWebXRTeleportationOptions {
  44660. /**
  44661. * Babylon XR Input class for controller
  44662. */
  44663. xrInput: WebXRInput;
  44664. /**
  44665. * A list of meshes to use as floor meshes.
  44666. * Meshes can be added and removed after initializing the feature using the
  44667. * addFloorMesh and removeFloorMesh functions
  44668. * If empty, rotation will still work
  44669. */
  44670. floorMeshes?: AbstractMesh[];
  44671. /**
  44672. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44673. * If you want to support rotation, make sure your mesh has a direction indicator.
  44674. *
  44675. * When left untouched, the default mesh will be initialized.
  44676. */
  44677. teleportationTargetMesh?: AbstractMesh;
  44678. /**
  44679. * Values to configure the default target mesh
  44680. */
  44681. defaultTargetMeshOptions?: {
  44682. /**
  44683. * Fill color of the teleportation area
  44684. */
  44685. teleportationFillColor?: string;
  44686. /**
  44687. * Border color for the teleportation area
  44688. */
  44689. teleportationBorderColor?: string;
  44690. /**
  44691. * Disable the mesh's animation sequence
  44692. */
  44693. disableAnimation?: boolean;
  44694. /**
  44695. * Disable lighting on the material or the ring and arrow
  44696. */
  44697. disableLighting?: boolean;
  44698. /**
  44699. * Override the default material of the torus and arrow
  44700. */
  44701. torusArrowMaterial?: Material;
  44702. };
  44703. /**
  44704. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44705. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44706. */
  44707. useMainComponentOnly?: boolean;
  44708. /**
  44709. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44710. */
  44711. timeToTeleport?: number;
  44712. }
  44713. /**
  44714. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44715. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44716. * the input of the attached controllers.
  44717. */
  44718. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44719. private _options;
  44720. /**
  44721. * The module's name
  44722. */
  44723. static readonly Name: string;
  44724. /**
  44725. * The (Babylon) version of this module.
  44726. * This is an integer representing the implementation version.
  44727. * This number does not correspond to the webxr specs version
  44728. */
  44729. static readonly Version: number;
  44730. /**
  44731. * Is rotation enabled when moving forward?
  44732. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44733. */
  44734. rotationEnabled: boolean;
  44735. /**
  44736. * Should the module support parabolic ray on top of direct ray
  44737. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44738. * Very helpful when moving between floors / different heights
  44739. */
  44740. parabolicRayEnabled: boolean;
  44741. /**
  44742. * The distance from the user to the inspection point in the direction of the controller
  44743. * A higher number will allow the user to move further
  44744. * defaults to 5 (meters, in xr units)
  44745. */
  44746. parabolicCheckRadius: number;
  44747. /**
  44748. * How much rotation should be applied when rotating right and left
  44749. */
  44750. rotationAngle: number;
  44751. /**
  44752. * Is movement backwards enabled
  44753. */
  44754. backwardsMovementEnabled: boolean;
  44755. /**
  44756. * Distance to travel when moving backwards
  44757. */
  44758. backwardsTeleportationDistance: number;
  44759. /**
  44760. * Add a new mesh to the floor meshes array
  44761. * @param mesh the mesh to use as floor mesh
  44762. */
  44763. addFloorMesh(mesh: AbstractMesh): void;
  44764. /**
  44765. * Remove a mesh from the floor meshes array
  44766. * @param mesh the mesh to remove
  44767. */
  44768. removeFloorMesh(mesh: AbstractMesh): void;
  44769. /**
  44770. * Remove a mesh from the floor meshes array using its name
  44771. * @param name the mesh name to remove
  44772. */
  44773. removeFloorMeshByName(name: string): void;
  44774. private _tmpRay;
  44775. private _tmpVector;
  44776. private _floorMeshes;
  44777. private _controllers;
  44778. /**
  44779. * constructs a new anchor system
  44780. * @param _xrSessionManager an instance of WebXRSessionManager
  44781. * @param _options configuration object for this feature
  44782. */
  44783. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44784. private _selectionFeature;
  44785. /**
  44786. * This function sets a selection feature that will be disabled when
  44787. * the forward ray is shown and will be reattached when hidden.
  44788. * This is used to remove the selection rays when moving.
  44789. * @param selectionFeature the feature to disable when forward movement is enabled
  44790. */
  44791. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44792. attach(): boolean;
  44793. detach(): boolean;
  44794. dispose(): void;
  44795. protected _onXRFrame(_xrFrame: XRFrame): void;
  44796. private _currentTeleportationControllerId;
  44797. private _attachController;
  44798. private _teleportForward;
  44799. private _detachController;
  44800. private createDefaultTargetMesh;
  44801. private setTargetMeshVisibility;
  44802. private setTargetMeshPosition;
  44803. private _quadraticBezierCurve;
  44804. private _showParabolicPath;
  44805. }
  44806. }
  44807. declare module BABYLON {
  44808. /**
  44809. * Options for the default xr helper
  44810. */
  44811. export class WebXRDefaultExperienceOptions {
  44812. /**
  44813. * Floor meshes that will be used for teleporting
  44814. */
  44815. floorMeshes?: Array<AbstractMesh>;
  44816. /**
  44817. * Enable or disable default UI to enter XR
  44818. */
  44819. disableDefaultUI?: boolean;
  44820. /**
  44821. * optional configuration for the output canvas
  44822. */
  44823. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44824. /**
  44825. * optional UI options. This can be used among other to change session mode and reference space type
  44826. */
  44827. uiOptions?: WebXREnterExitUIOptions;
  44828. /**
  44829. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44830. */
  44831. inputOptions?: IWebXRInputOptions;
  44832. /**
  44833. * Should teleportation not initialize. defaults to false.
  44834. */
  44835. disableTeleportation?: boolean;
  44836. /**
  44837. * If set to true, the first frame will not be used to reset position
  44838. * The first frame is mainly used when copying transformation from the old camera
  44839. * Mainly used in AR
  44840. */
  44841. ignoreNativeCameraTransformation?: boolean;
  44842. /**
  44843. * When loading teleportation and pointer select, use stable versions instead of latest.
  44844. */
  44845. useStablePlugins?: boolean;
  44846. }
  44847. /**
  44848. * Default experience which provides a similar setup to the previous webVRExperience
  44849. */
  44850. export class WebXRDefaultExperience {
  44851. /**
  44852. * Base experience
  44853. */
  44854. baseExperience: WebXRExperienceHelper;
  44855. /**
  44856. * Input experience extension
  44857. */
  44858. input: WebXRInput;
  44859. /**
  44860. * Enables laser pointer and selection
  44861. */
  44862. pointerSelection: WebXRControllerPointerSelection;
  44863. /**
  44864. * Enables teleportation
  44865. */
  44866. teleportation: WebXRMotionControllerTeleportation;
  44867. /**
  44868. * Enables ui for entering/exiting xr
  44869. */
  44870. enterExitUI: WebXREnterExitUI;
  44871. /**
  44872. * Default target xr should render to
  44873. */
  44874. renderTarget: WebXRRenderTarget;
  44875. /**
  44876. * Creates the default xr experience
  44877. * @param scene scene
  44878. * @param options options for basic configuration
  44879. * @returns resulting WebXRDefaultExperience
  44880. */
  44881. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44882. private constructor();
  44883. /**
  44884. * DIsposes of the experience helper
  44885. */
  44886. dispose(): void;
  44887. }
  44888. }
  44889. declare module BABYLON {
  44890. /**
  44891. * Options to modify the vr teleportation behavior.
  44892. */
  44893. export interface VRTeleportationOptions {
  44894. /**
  44895. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44896. */
  44897. floorMeshName?: string;
  44898. /**
  44899. * A list of meshes to be used as the teleportation floor. (default: empty)
  44900. */
  44901. floorMeshes?: Mesh[];
  44902. /**
  44903. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44904. */
  44905. teleportationMode?: number;
  44906. /**
  44907. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44908. */
  44909. teleportationTime?: number;
  44910. /**
  44911. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44912. */
  44913. teleportationSpeed?: number;
  44914. /**
  44915. * The easing function used in the animation or null for Linear. (default CircleEase)
  44916. */
  44917. easingFunction?: EasingFunction;
  44918. }
  44919. /**
  44920. * Options to modify the vr experience helper's behavior.
  44921. */
  44922. export interface VRExperienceHelperOptions extends WebVROptions {
  44923. /**
  44924. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44925. */
  44926. createDeviceOrientationCamera?: boolean;
  44927. /**
  44928. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44929. */
  44930. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44931. /**
  44932. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44933. */
  44934. laserToggle?: boolean;
  44935. /**
  44936. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44937. */
  44938. floorMeshes?: Mesh[];
  44939. /**
  44940. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44941. */
  44942. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44943. /**
  44944. * Defines if WebXR should be used instead of WebVR (if available)
  44945. */
  44946. useXR?: boolean;
  44947. }
  44948. /**
  44949. * Event containing information after VR has been entered
  44950. */
  44951. export class OnAfterEnteringVRObservableEvent {
  44952. /**
  44953. * If entering vr was successful
  44954. */
  44955. success: boolean;
  44956. }
  44957. /**
  44958. * Helps to quickly add VR support to an existing scene.
  44959. * See http://doc.babylonjs.com/how_to/webvr_helper
  44960. */
  44961. export class VRExperienceHelper {
  44962. /** Options to modify the vr experience helper's behavior. */
  44963. webVROptions: VRExperienceHelperOptions;
  44964. private _scene;
  44965. private _position;
  44966. private _btnVR;
  44967. private _btnVRDisplayed;
  44968. private _webVRsupported;
  44969. private _webVRready;
  44970. private _webVRrequesting;
  44971. private _webVRpresenting;
  44972. private _hasEnteredVR;
  44973. private _fullscreenVRpresenting;
  44974. private _inputElement;
  44975. private _webVRCamera;
  44976. private _vrDeviceOrientationCamera;
  44977. private _deviceOrientationCamera;
  44978. private _existingCamera;
  44979. private _onKeyDown;
  44980. private _onVrDisplayPresentChange;
  44981. private _onVRDisplayChanged;
  44982. private _onVRRequestPresentStart;
  44983. private _onVRRequestPresentComplete;
  44984. /**
  44985. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  44986. */
  44987. enableGazeEvenWhenNoPointerLock: boolean;
  44988. /**
  44989. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44990. */
  44991. exitVROnDoubleTap: boolean;
  44992. /**
  44993. * Observable raised right before entering VR.
  44994. */
  44995. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44996. /**
  44997. * Observable raised when entering VR has completed.
  44998. */
  44999. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45000. /**
  45001. * Observable raised when exiting VR.
  45002. */
  45003. onExitingVRObservable: Observable<VRExperienceHelper>;
  45004. /**
  45005. * Observable raised when controller mesh is loaded.
  45006. */
  45007. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45008. /** Return this.onEnteringVRObservable
  45009. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45010. */
  45011. get onEnteringVR(): Observable<VRExperienceHelper>;
  45012. /** Return this.onExitingVRObservable
  45013. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45014. */
  45015. get onExitingVR(): Observable<VRExperienceHelper>;
  45016. /** Return this.onControllerMeshLoadedObservable
  45017. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45018. */
  45019. get onControllerMeshLoaded(): Observable<WebVRController>;
  45020. private _rayLength;
  45021. private _useCustomVRButton;
  45022. private _teleportationRequested;
  45023. private _teleportActive;
  45024. private _floorMeshName;
  45025. private _floorMeshesCollection;
  45026. private _teleportationMode;
  45027. private _teleportationTime;
  45028. private _teleportationSpeed;
  45029. private _teleportationEasing;
  45030. private _rotationAllowed;
  45031. private _teleportBackwardsVector;
  45032. private _teleportationTarget;
  45033. private _isDefaultTeleportationTarget;
  45034. private _postProcessMove;
  45035. private _teleportationFillColor;
  45036. private _teleportationBorderColor;
  45037. private _rotationAngle;
  45038. private _haloCenter;
  45039. private _cameraGazer;
  45040. private _padSensibilityUp;
  45041. private _padSensibilityDown;
  45042. private _leftController;
  45043. private _rightController;
  45044. private _gazeColor;
  45045. private _laserColor;
  45046. private _pickedLaserColor;
  45047. private _pickedGazeColor;
  45048. /**
  45049. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45050. */
  45051. onNewMeshSelected: Observable<AbstractMesh>;
  45052. /**
  45053. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45054. * This observable will provide the mesh and the controller used to select the mesh
  45055. */
  45056. onMeshSelectedWithController: Observable<{
  45057. mesh: AbstractMesh;
  45058. controller: WebVRController;
  45059. }>;
  45060. /**
  45061. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45062. */
  45063. onNewMeshPicked: Observable<PickingInfo>;
  45064. private _circleEase;
  45065. /**
  45066. * Observable raised before camera teleportation
  45067. */
  45068. onBeforeCameraTeleport: Observable<Vector3>;
  45069. /**
  45070. * Observable raised after camera teleportation
  45071. */
  45072. onAfterCameraTeleport: Observable<Vector3>;
  45073. /**
  45074. * Observable raised when current selected mesh gets unselected
  45075. */
  45076. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45077. private _raySelectionPredicate;
  45078. /**
  45079. * To be optionaly changed by user to define custom ray selection
  45080. */
  45081. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45082. /**
  45083. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45084. */
  45085. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45086. /**
  45087. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45088. */
  45089. teleportationEnabled: boolean;
  45090. private _defaultHeight;
  45091. private _teleportationInitialized;
  45092. private _interactionsEnabled;
  45093. private _interactionsRequested;
  45094. private _displayGaze;
  45095. private _displayLaserPointer;
  45096. /**
  45097. * The mesh used to display where the user is going to teleport.
  45098. */
  45099. get teleportationTarget(): Mesh;
  45100. /**
  45101. * Sets the mesh to be used to display where the user is going to teleport.
  45102. */
  45103. set teleportationTarget(value: Mesh);
  45104. /**
  45105. * 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
  45106. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45107. * See http://doc.babylonjs.com/resources/baking_transformations
  45108. */
  45109. get gazeTrackerMesh(): Mesh;
  45110. set gazeTrackerMesh(value: Mesh);
  45111. /**
  45112. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45113. */
  45114. updateGazeTrackerScale: boolean;
  45115. /**
  45116. * If the gaze trackers color should be updated when selecting meshes
  45117. */
  45118. updateGazeTrackerColor: boolean;
  45119. /**
  45120. * If the controller laser color should be updated when selecting meshes
  45121. */
  45122. updateControllerLaserColor: boolean;
  45123. /**
  45124. * The gaze tracking mesh corresponding to the left controller
  45125. */
  45126. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45127. /**
  45128. * The gaze tracking mesh corresponding to the right controller
  45129. */
  45130. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45131. /**
  45132. * If the ray of the gaze should be displayed.
  45133. */
  45134. get displayGaze(): boolean;
  45135. /**
  45136. * Sets if the ray of the gaze should be displayed.
  45137. */
  45138. set displayGaze(value: boolean);
  45139. /**
  45140. * If the ray of the LaserPointer should be displayed.
  45141. */
  45142. get displayLaserPointer(): boolean;
  45143. /**
  45144. * Sets if the ray of the LaserPointer should be displayed.
  45145. */
  45146. set displayLaserPointer(value: boolean);
  45147. /**
  45148. * The deviceOrientationCamera used as the camera when not in VR.
  45149. */
  45150. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45151. /**
  45152. * Based on the current WebVR support, returns the current VR camera used.
  45153. */
  45154. get currentVRCamera(): Nullable<Camera>;
  45155. /**
  45156. * The webVRCamera which is used when in VR.
  45157. */
  45158. get webVRCamera(): WebVRFreeCamera;
  45159. /**
  45160. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45161. */
  45162. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45163. /**
  45164. * The html button that is used to trigger entering into VR.
  45165. */
  45166. get vrButton(): Nullable<HTMLButtonElement>;
  45167. private get _teleportationRequestInitiated();
  45168. /**
  45169. * Defines whether or not Pointer lock should be requested when switching to
  45170. * full screen.
  45171. */
  45172. requestPointerLockOnFullScreen: boolean;
  45173. /**
  45174. * If asking to force XR, this will be populated with the default xr experience
  45175. */
  45176. xr: WebXRDefaultExperience;
  45177. /**
  45178. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45179. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45180. */
  45181. xrTestDone: boolean;
  45182. /**
  45183. * Instantiates a VRExperienceHelper.
  45184. * Helps to quickly add VR support to an existing scene.
  45185. * @param scene The scene the VRExperienceHelper belongs to.
  45186. * @param webVROptions Options to modify the vr experience helper's behavior.
  45187. */
  45188. constructor(scene: Scene,
  45189. /** Options to modify the vr experience helper's behavior. */
  45190. webVROptions?: VRExperienceHelperOptions);
  45191. private completeVRInit;
  45192. private _onDefaultMeshLoaded;
  45193. private _onResize;
  45194. private _onFullscreenChange;
  45195. /**
  45196. * Gets a value indicating if we are currently in VR mode.
  45197. */
  45198. get isInVRMode(): boolean;
  45199. private onVrDisplayPresentChange;
  45200. private onVRDisplayChanged;
  45201. private moveButtonToBottomRight;
  45202. private displayVRButton;
  45203. private updateButtonVisibility;
  45204. private _cachedAngularSensibility;
  45205. /**
  45206. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45207. * Otherwise, will use the fullscreen API.
  45208. */
  45209. enterVR(): void;
  45210. /**
  45211. * Attempt to exit VR, or fullscreen.
  45212. */
  45213. exitVR(): void;
  45214. /**
  45215. * The position of the vr experience helper.
  45216. */
  45217. get position(): Vector3;
  45218. /**
  45219. * Sets the position of the vr experience helper.
  45220. */
  45221. set position(value: Vector3);
  45222. /**
  45223. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45224. */
  45225. enableInteractions(): void;
  45226. private get _noControllerIsActive();
  45227. private beforeRender;
  45228. private _isTeleportationFloor;
  45229. /**
  45230. * Adds a floor mesh to be used for teleportation.
  45231. * @param floorMesh the mesh to be used for teleportation.
  45232. */
  45233. addFloorMesh(floorMesh: Mesh): void;
  45234. /**
  45235. * Removes a floor mesh from being used for teleportation.
  45236. * @param floorMesh the mesh to be removed.
  45237. */
  45238. removeFloorMesh(floorMesh: Mesh): void;
  45239. /**
  45240. * Enables interactions and teleportation using the VR controllers and gaze.
  45241. * @param vrTeleportationOptions options to modify teleportation behavior.
  45242. */
  45243. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45244. private _onNewGamepadConnected;
  45245. private _tryEnableInteractionOnController;
  45246. private _onNewGamepadDisconnected;
  45247. private _enableInteractionOnController;
  45248. private _checkTeleportWithRay;
  45249. private _checkRotate;
  45250. private _checkTeleportBackwards;
  45251. private _enableTeleportationOnController;
  45252. private _createTeleportationCircles;
  45253. private _displayTeleportationTarget;
  45254. private _hideTeleportationTarget;
  45255. private _rotateCamera;
  45256. private _moveTeleportationSelectorTo;
  45257. private _workingVector;
  45258. private _workingQuaternion;
  45259. private _workingMatrix;
  45260. /**
  45261. * Time Constant Teleportation Mode
  45262. */
  45263. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45264. /**
  45265. * Speed Constant Teleportation Mode
  45266. */
  45267. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45268. /**
  45269. * Teleports the users feet to the desired location
  45270. * @param location The location where the user's feet should be placed
  45271. */
  45272. teleportCamera(location: Vector3): void;
  45273. private _convertNormalToDirectionOfRay;
  45274. private _castRayAndSelectObject;
  45275. private _notifySelectedMeshUnselected;
  45276. /**
  45277. * Permanently set new colors for the laser pointer
  45278. * @param color the new laser color
  45279. * @param pickedColor the new laser color when picked mesh detected
  45280. */
  45281. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45282. /**
  45283. * Set lighting enabled / disabled on the laser pointer of both controllers
  45284. * @param enabled should the lighting be enabled on the laser pointer
  45285. */
  45286. setLaserLightingState(enabled?: boolean): void;
  45287. /**
  45288. * Permanently set new colors for the gaze pointer
  45289. * @param color the new gaze color
  45290. * @param pickedColor the new gaze color when picked mesh detected
  45291. */
  45292. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45293. /**
  45294. * Sets the color of the laser ray from the vr controllers.
  45295. * @param color new color for the ray.
  45296. */
  45297. changeLaserColor(color: Color3): void;
  45298. /**
  45299. * Sets the color of the ray from the vr headsets gaze.
  45300. * @param color new color for the ray.
  45301. */
  45302. changeGazeColor(color: Color3): void;
  45303. /**
  45304. * Exits VR and disposes of the vr experience helper
  45305. */
  45306. dispose(): void;
  45307. /**
  45308. * Gets the name of the VRExperienceHelper class
  45309. * @returns "VRExperienceHelper"
  45310. */
  45311. getClassName(): string;
  45312. }
  45313. }
  45314. declare module BABYLON {
  45315. /**
  45316. * Contains an array of blocks representing the octree
  45317. */
  45318. export interface IOctreeContainer<T> {
  45319. /**
  45320. * Blocks within the octree
  45321. */
  45322. blocks: Array<OctreeBlock<T>>;
  45323. }
  45324. /**
  45325. * Class used to store a cell in an octree
  45326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45327. */
  45328. export class OctreeBlock<T> {
  45329. /**
  45330. * Gets the content of the current block
  45331. */
  45332. entries: T[];
  45333. /**
  45334. * Gets the list of block children
  45335. */
  45336. blocks: Array<OctreeBlock<T>>;
  45337. private _depth;
  45338. private _maxDepth;
  45339. private _capacity;
  45340. private _minPoint;
  45341. private _maxPoint;
  45342. private _boundingVectors;
  45343. private _creationFunc;
  45344. /**
  45345. * Creates a new block
  45346. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45347. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45348. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45349. * @param depth defines the current depth of this block in the octree
  45350. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45351. * @param creationFunc defines a callback to call when an element is added to the block
  45352. */
  45353. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45354. /**
  45355. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45356. */
  45357. get capacity(): number;
  45358. /**
  45359. * Gets the minimum vector (in world space) of the block's bounding box
  45360. */
  45361. get minPoint(): Vector3;
  45362. /**
  45363. * Gets the maximum vector (in world space) of the block's bounding box
  45364. */
  45365. get maxPoint(): Vector3;
  45366. /**
  45367. * Add a new element to this block
  45368. * @param entry defines the element to add
  45369. */
  45370. addEntry(entry: T): void;
  45371. /**
  45372. * Remove an element from this block
  45373. * @param entry defines the element to remove
  45374. */
  45375. removeEntry(entry: T): void;
  45376. /**
  45377. * Add an array of elements to this block
  45378. * @param entries defines the array of elements to add
  45379. */
  45380. addEntries(entries: T[]): void;
  45381. /**
  45382. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45383. * @param frustumPlanes defines the frustum planes to test
  45384. * @param selection defines the array to store current content if selection is positive
  45385. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45386. */
  45387. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45388. /**
  45389. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45390. * @param sphereCenter defines the bounding sphere center
  45391. * @param sphereRadius defines the bounding sphere radius
  45392. * @param selection defines the array to store current content if selection is positive
  45393. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45394. */
  45395. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45396. /**
  45397. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45398. * @param ray defines the ray to test with
  45399. * @param selection defines the array to store current content if selection is positive
  45400. */
  45401. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45402. /**
  45403. * Subdivide the content into child blocks (this block will then be empty)
  45404. */
  45405. createInnerBlocks(): void;
  45406. /**
  45407. * @hidden
  45408. */
  45409. 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;
  45410. }
  45411. }
  45412. declare module BABYLON {
  45413. /**
  45414. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45416. */
  45417. export class Octree<T> {
  45418. /** 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.) */
  45419. maxDepth: number;
  45420. /**
  45421. * Blocks within the octree containing objects
  45422. */
  45423. blocks: Array<OctreeBlock<T>>;
  45424. /**
  45425. * Content stored in the octree
  45426. */
  45427. dynamicContent: T[];
  45428. private _maxBlockCapacity;
  45429. private _selectionContent;
  45430. private _creationFunc;
  45431. /**
  45432. * Creates a octree
  45433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45434. * @param creationFunc function to be used to instatiate the octree
  45435. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45436. * @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.)
  45437. */
  45438. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45439. /** 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.) */
  45440. maxDepth?: number);
  45441. /**
  45442. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45443. * @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);
  45444. * @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);
  45445. * @param entries meshes to be added to the octree blocks
  45446. */
  45447. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45448. /**
  45449. * Adds a mesh to the octree
  45450. * @param entry Mesh to add to the octree
  45451. */
  45452. addMesh(entry: T): void;
  45453. /**
  45454. * Remove an element from the octree
  45455. * @param entry defines the element to remove
  45456. */
  45457. removeMesh(entry: T): void;
  45458. /**
  45459. * Selects an array of meshes within the frustum
  45460. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45461. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45462. * @returns array of meshes within the frustum
  45463. */
  45464. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45465. /**
  45466. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45467. * @param sphereCenter defines the bounding sphere center
  45468. * @param sphereRadius defines the bounding sphere radius
  45469. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45470. * @returns an array of objects that intersect the sphere
  45471. */
  45472. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45473. /**
  45474. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45475. * @param ray defines the ray to test with
  45476. * @returns array of intersected objects
  45477. */
  45478. intersectsRay(ray: Ray): SmartArray<T>;
  45479. /**
  45480. * Adds a mesh into the octree block if it intersects the block
  45481. */
  45482. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45483. /**
  45484. * Adds a submesh into the octree block if it intersects the block
  45485. */
  45486. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45487. }
  45488. }
  45489. declare module BABYLON {
  45490. interface Scene {
  45491. /**
  45492. * @hidden
  45493. * Backing Filed
  45494. */
  45495. _selectionOctree: Octree<AbstractMesh>;
  45496. /**
  45497. * Gets the octree used to boost mesh selection (picking)
  45498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45499. */
  45500. selectionOctree: Octree<AbstractMesh>;
  45501. /**
  45502. * Creates or updates the octree used to boost selection (picking)
  45503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45504. * @param maxCapacity defines the maximum capacity per leaf
  45505. * @param maxDepth defines the maximum depth of the octree
  45506. * @returns an octree of AbstractMesh
  45507. */
  45508. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45509. }
  45510. interface AbstractMesh {
  45511. /**
  45512. * @hidden
  45513. * Backing Field
  45514. */
  45515. _submeshesOctree: Octree<SubMesh>;
  45516. /**
  45517. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45518. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45519. * @param maxCapacity defines the maximum size of each block (64 by default)
  45520. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45521. * @returns the new octree
  45522. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45524. */
  45525. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45526. }
  45527. /**
  45528. * Defines the octree scene component responsible to manage any octrees
  45529. * in a given scene.
  45530. */
  45531. export class OctreeSceneComponent {
  45532. /**
  45533. * The component name help to identify the component in the list of scene components.
  45534. */
  45535. readonly name: string;
  45536. /**
  45537. * The scene the component belongs to.
  45538. */
  45539. scene: Scene;
  45540. /**
  45541. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45542. */
  45543. readonly checksIsEnabled: boolean;
  45544. /**
  45545. * Creates a new instance of the component for the given scene
  45546. * @param scene Defines the scene to register the component in
  45547. */
  45548. constructor(scene: Scene);
  45549. /**
  45550. * Registers the component in a given scene
  45551. */
  45552. register(): void;
  45553. /**
  45554. * Return the list of active meshes
  45555. * @returns the list of active meshes
  45556. */
  45557. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45558. /**
  45559. * Return the list of active sub meshes
  45560. * @param mesh The mesh to get the candidates sub meshes from
  45561. * @returns the list of active sub meshes
  45562. */
  45563. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45564. private _tempRay;
  45565. /**
  45566. * Return the list of sub meshes intersecting with a given local ray
  45567. * @param mesh defines the mesh to find the submesh for
  45568. * @param localRay defines the ray in local space
  45569. * @returns the list of intersecting sub meshes
  45570. */
  45571. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45572. /**
  45573. * Return the list of sub meshes colliding with a collider
  45574. * @param mesh defines the mesh to find the submesh for
  45575. * @param collider defines the collider to evaluate the collision against
  45576. * @returns the list of colliding sub meshes
  45577. */
  45578. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45579. /**
  45580. * Rebuilds the elements related to this component in case of
  45581. * context lost for instance.
  45582. */
  45583. rebuild(): void;
  45584. /**
  45585. * Disposes the component and the associated ressources.
  45586. */
  45587. dispose(): void;
  45588. }
  45589. }
  45590. declare module BABYLON {
  45591. /**
  45592. * Renders a layer on top of an existing scene
  45593. */
  45594. export class UtilityLayerRenderer implements IDisposable {
  45595. /** the original scene that will be rendered on top of */
  45596. originalScene: Scene;
  45597. private _pointerCaptures;
  45598. private _lastPointerEvents;
  45599. private static _DefaultUtilityLayer;
  45600. private static _DefaultKeepDepthUtilityLayer;
  45601. private _sharedGizmoLight;
  45602. private _renderCamera;
  45603. /**
  45604. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45605. * @returns the camera that is used when rendering the utility layer
  45606. */
  45607. getRenderCamera(): Camera;
  45608. /**
  45609. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45610. * @param cam the camera that should be used when rendering the utility layer
  45611. */
  45612. setRenderCamera(cam: Nullable<Camera>): void;
  45613. /**
  45614. * @hidden
  45615. * Light which used by gizmos to get light shading
  45616. */
  45617. _getSharedGizmoLight(): HemisphericLight;
  45618. /**
  45619. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45620. */
  45621. pickUtilitySceneFirst: boolean;
  45622. /**
  45623. * 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)
  45624. */
  45625. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45626. /**
  45627. * 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)
  45628. */
  45629. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45630. /**
  45631. * The scene that is rendered on top of the original scene
  45632. */
  45633. utilityLayerScene: Scene;
  45634. /**
  45635. * If the utility layer should automatically be rendered on top of existing scene
  45636. */
  45637. shouldRender: boolean;
  45638. /**
  45639. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45640. */
  45641. onlyCheckPointerDownEvents: boolean;
  45642. /**
  45643. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45644. */
  45645. processAllEvents: boolean;
  45646. /**
  45647. * Observable raised when the pointer move from the utility layer scene to the main scene
  45648. */
  45649. onPointerOutObservable: Observable<number>;
  45650. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45651. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45652. private _afterRenderObserver;
  45653. private _sceneDisposeObserver;
  45654. private _originalPointerObserver;
  45655. /**
  45656. * Instantiates a UtilityLayerRenderer
  45657. * @param originalScene the original scene that will be rendered on top of
  45658. * @param handleEvents boolean indicating if the utility layer should handle events
  45659. */
  45660. constructor(
  45661. /** the original scene that will be rendered on top of */
  45662. originalScene: Scene, handleEvents?: boolean);
  45663. private _notifyObservers;
  45664. /**
  45665. * Renders the utility layers scene on top of the original scene
  45666. */
  45667. render(): void;
  45668. /**
  45669. * Disposes of the renderer
  45670. */
  45671. dispose(): void;
  45672. private _updateCamera;
  45673. }
  45674. }
  45675. declare module BABYLON {
  45676. /**
  45677. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45678. */
  45679. export class Gizmo implements IDisposable {
  45680. /** The utility layer the gizmo will be added to */
  45681. gizmoLayer: UtilityLayerRenderer;
  45682. /**
  45683. * The root mesh of the gizmo
  45684. */
  45685. _rootMesh: Mesh;
  45686. private _attachedMesh;
  45687. /**
  45688. * Ratio for the scale of the gizmo (Default: 1)
  45689. */
  45690. scaleRatio: number;
  45691. /**
  45692. * If a custom mesh has been set (Default: false)
  45693. */
  45694. protected _customMeshSet: boolean;
  45695. /**
  45696. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45697. * * When set, interactions will be enabled
  45698. */
  45699. get attachedMesh(): Nullable<AbstractMesh>;
  45700. set attachedMesh(value: Nullable<AbstractMesh>);
  45701. /**
  45702. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45703. * @param mesh The mesh to replace the default mesh of the gizmo
  45704. */
  45705. setCustomMesh(mesh: Mesh): void;
  45706. /**
  45707. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45708. */
  45709. updateGizmoRotationToMatchAttachedMesh: boolean;
  45710. /**
  45711. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45712. */
  45713. updateGizmoPositionToMatchAttachedMesh: boolean;
  45714. /**
  45715. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45716. */
  45717. updateScale: boolean;
  45718. protected _interactionsEnabled: boolean;
  45719. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45720. private _beforeRenderObserver;
  45721. private _tempVector;
  45722. /**
  45723. * Creates a gizmo
  45724. * @param gizmoLayer The utility layer the gizmo will be added to
  45725. */
  45726. constructor(
  45727. /** The utility layer the gizmo will be added to */
  45728. gizmoLayer?: UtilityLayerRenderer);
  45729. /**
  45730. * Updates the gizmo to match the attached mesh's position/rotation
  45731. */
  45732. protected _update(): void;
  45733. /**
  45734. * Disposes of the gizmo
  45735. */
  45736. dispose(): void;
  45737. }
  45738. }
  45739. declare module BABYLON {
  45740. /**
  45741. * Single plane drag gizmo
  45742. */
  45743. export class PlaneDragGizmo extends Gizmo {
  45744. /**
  45745. * Drag behavior responsible for the gizmos dragging interactions
  45746. */
  45747. dragBehavior: PointerDragBehavior;
  45748. private _pointerObserver;
  45749. /**
  45750. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45751. */
  45752. snapDistance: number;
  45753. /**
  45754. * Event that fires each time the gizmo snaps to a new location.
  45755. * * snapDistance is the the change in distance
  45756. */
  45757. onSnapObservable: Observable<{
  45758. snapDistance: number;
  45759. }>;
  45760. private _plane;
  45761. private _coloredMaterial;
  45762. private _hoverMaterial;
  45763. private _isEnabled;
  45764. private _parent;
  45765. /** @hidden */
  45766. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45767. /** @hidden */
  45768. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45769. /**
  45770. * Creates a PlaneDragGizmo
  45771. * @param gizmoLayer The utility layer the gizmo will be added to
  45772. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45773. * @param color The color of the gizmo
  45774. */
  45775. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45776. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45777. /**
  45778. * If the gizmo is enabled
  45779. */
  45780. set isEnabled(value: boolean);
  45781. get isEnabled(): boolean;
  45782. /**
  45783. * Disposes of the gizmo
  45784. */
  45785. dispose(): void;
  45786. }
  45787. }
  45788. declare module BABYLON {
  45789. /**
  45790. * Gizmo that enables dragging a mesh along 3 axis
  45791. */
  45792. export class PositionGizmo extends Gizmo {
  45793. /**
  45794. * Internal gizmo used for interactions on the x axis
  45795. */
  45796. xGizmo: AxisDragGizmo;
  45797. /**
  45798. * Internal gizmo used for interactions on the y axis
  45799. */
  45800. yGizmo: AxisDragGizmo;
  45801. /**
  45802. * Internal gizmo used for interactions on the z axis
  45803. */
  45804. zGizmo: AxisDragGizmo;
  45805. /**
  45806. * Internal gizmo used for interactions on the yz plane
  45807. */
  45808. xPlaneGizmo: PlaneDragGizmo;
  45809. /**
  45810. * Internal gizmo used for interactions on the xz plane
  45811. */
  45812. yPlaneGizmo: PlaneDragGizmo;
  45813. /**
  45814. * Internal gizmo used for interactions on the xy plane
  45815. */
  45816. zPlaneGizmo: PlaneDragGizmo;
  45817. /**
  45818. * private variables
  45819. */
  45820. private _meshAttached;
  45821. private _updateGizmoRotationToMatchAttachedMesh;
  45822. private _snapDistance;
  45823. private _scaleRatio;
  45824. /** Fires an event when any of it's sub gizmos are dragged */
  45825. onDragStartObservable: Observable<unknown>;
  45826. /** Fires an event when any of it's sub gizmos are released from dragging */
  45827. onDragEndObservable: Observable<unknown>;
  45828. /**
  45829. * If set to true, planar drag is enabled
  45830. */
  45831. private _planarGizmoEnabled;
  45832. get attachedMesh(): Nullable<AbstractMesh>;
  45833. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45834. /**
  45835. * Creates a PositionGizmo
  45836. * @param gizmoLayer The utility layer the gizmo will be added to
  45837. */
  45838. constructor(gizmoLayer?: UtilityLayerRenderer);
  45839. /**
  45840. * If the planar drag gizmo is enabled
  45841. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45842. */
  45843. set planarGizmoEnabled(value: boolean);
  45844. get planarGizmoEnabled(): boolean;
  45845. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45846. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45847. /**
  45848. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45849. */
  45850. set snapDistance(value: number);
  45851. get snapDistance(): number;
  45852. /**
  45853. * Ratio for the scale of the gizmo (Default: 1)
  45854. */
  45855. set scaleRatio(value: number);
  45856. get scaleRatio(): number;
  45857. /**
  45858. * Disposes of the gizmo
  45859. */
  45860. dispose(): void;
  45861. /**
  45862. * CustomMeshes are not supported by this gizmo
  45863. * @param mesh The mesh to replace the default mesh of the gizmo
  45864. */
  45865. setCustomMesh(mesh: Mesh): void;
  45866. }
  45867. }
  45868. declare module BABYLON {
  45869. /**
  45870. * Single axis drag gizmo
  45871. */
  45872. export class AxisDragGizmo extends Gizmo {
  45873. /**
  45874. * Drag behavior responsible for the gizmos dragging interactions
  45875. */
  45876. dragBehavior: PointerDragBehavior;
  45877. private _pointerObserver;
  45878. /**
  45879. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45880. */
  45881. snapDistance: number;
  45882. /**
  45883. * Event that fires each time the gizmo snaps to a new location.
  45884. * * snapDistance is the the change in distance
  45885. */
  45886. onSnapObservable: Observable<{
  45887. snapDistance: number;
  45888. }>;
  45889. private _isEnabled;
  45890. private _parent;
  45891. private _arrow;
  45892. private _coloredMaterial;
  45893. private _hoverMaterial;
  45894. /** @hidden */
  45895. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45896. /** @hidden */
  45897. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45898. /**
  45899. * Creates an AxisDragGizmo
  45900. * @param gizmoLayer The utility layer the gizmo will be added to
  45901. * @param dragAxis The axis which the gizmo will be able to drag on
  45902. * @param color The color of the gizmo
  45903. */
  45904. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45905. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45906. /**
  45907. * If the gizmo is enabled
  45908. */
  45909. set isEnabled(value: boolean);
  45910. get isEnabled(): boolean;
  45911. /**
  45912. * Disposes of the gizmo
  45913. */
  45914. dispose(): void;
  45915. }
  45916. }
  45917. declare module BABYLON.Debug {
  45918. /**
  45919. * The Axes viewer will show 3 axes in a specific point in space
  45920. */
  45921. export class AxesViewer {
  45922. private _xAxis;
  45923. private _yAxis;
  45924. private _zAxis;
  45925. private _scaleLinesFactor;
  45926. private _instanced;
  45927. /**
  45928. * Gets the hosting scene
  45929. */
  45930. scene: Scene;
  45931. /**
  45932. * Gets or sets a number used to scale line length
  45933. */
  45934. scaleLines: number;
  45935. /** Gets the node hierarchy used to render x-axis */
  45936. get xAxis(): TransformNode;
  45937. /** Gets the node hierarchy used to render y-axis */
  45938. get yAxis(): TransformNode;
  45939. /** Gets the node hierarchy used to render z-axis */
  45940. get zAxis(): TransformNode;
  45941. /**
  45942. * Creates a new AxesViewer
  45943. * @param scene defines the hosting scene
  45944. * @param scaleLines defines a number used to scale line length (1 by default)
  45945. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45946. * @param xAxis defines the node hierarchy used to render the x-axis
  45947. * @param yAxis defines the node hierarchy used to render the y-axis
  45948. * @param zAxis defines the node hierarchy used to render the z-axis
  45949. */
  45950. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45951. /**
  45952. * Force the viewer to update
  45953. * @param position defines the position of the viewer
  45954. * @param xaxis defines the x axis of the viewer
  45955. * @param yaxis defines the y axis of the viewer
  45956. * @param zaxis defines the z axis of the viewer
  45957. */
  45958. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45959. /**
  45960. * Creates an instance of this axes viewer.
  45961. * @returns a new axes viewer with instanced meshes
  45962. */
  45963. createInstance(): AxesViewer;
  45964. /** Releases resources */
  45965. dispose(): void;
  45966. private static _SetRenderingGroupId;
  45967. }
  45968. }
  45969. declare module BABYLON.Debug {
  45970. /**
  45971. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45972. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45973. */
  45974. export class BoneAxesViewer extends AxesViewer {
  45975. /**
  45976. * Gets or sets the target mesh where to display the axes viewer
  45977. */
  45978. mesh: Nullable<Mesh>;
  45979. /**
  45980. * Gets or sets the target bone where to display the axes viewer
  45981. */
  45982. bone: Nullable<Bone>;
  45983. /** Gets current position */
  45984. pos: Vector3;
  45985. /** Gets direction of X axis */
  45986. xaxis: Vector3;
  45987. /** Gets direction of Y axis */
  45988. yaxis: Vector3;
  45989. /** Gets direction of Z axis */
  45990. zaxis: Vector3;
  45991. /**
  45992. * Creates a new BoneAxesViewer
  45993. * @param scene defines the hosting scene
  45994. * @param bone defines the target bone
  45995. * @param mesh defines the target mesh
  45996. * @param scaleLines defines a scaling factor for line length (1 by default)
  45997. */
  45998. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45999. /**
  46000. * Force the viewer to update
  46001. */
  46002. update(): void;
  46003. /** Releases resources */
  46004. dispose(): void;
  46005. }
  46006. }
  46007. declare module BABYLON {
  46008. /**
  46009. * Interface used to define scene explorer extensibility option
  46010. */
  46011. export interface IExplorerExtensibilityOption {
  46012. /**
  46013. * Define the option label
  46014. */
  46015. label: string;
  46016. /**
  46017. * Defines the action to execute on click
  46018. */
  46019. action: (entity: any) => void;
  46020. }
  46021. /**
  46022. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46023. */
  46024. export interface IExplorerExtensibilityGroup {
  46025. /**
  46026. * Defines a predicate to test if a given type mut be extended
  46027. */
  46028. predicate: (entity: any) => boolean;
  46029. /**
  46030. * Gets the list of options added to a type
  46031. */
  46032. entries: IExplorerExtensibilityOption[];
  46033. }
  46034. /**
  46035. * Interface used to define the options to use to create the Inspector
  46036. */
  46037. export interface IInspectorOptions {
  46038. /**
  46039. * Display in overlay mode (default: false)
  46040. */
  46041. overlay?: boolean;
  46042. /**
  46043. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46044. */
  46045. globalRoot?: HTMLElement;
  46046. /**
  46047. * Display the Scene explorer
  46048. */
  46049. showExplorer?: boolean;
  46050. /**
  46051. * Display the property inspector
  46052. */
  46053. showInspector?: boolean;
  46054. /**
  46055. * Display in embed mode (both panes on the right)
  46056. */
  46057. embedMode?: boolean;
  46058. /**
  46059. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46060. */
  46061. handleResize?: boolean;
  46062. /**
  46063. * Allow the panes to popup (default: true)
  46064. */
  46065. enablePopup?: boolean;
  46066. /**
  46067. * Allow the panes to be closed by users (default: true)
  46068. */
  46069. enableClose?: boolean;
  46070. /**
  46071. * Optional list of extensibility entries
  46072. */
  46073. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46074. /**
  46075. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46076. */
  46077. inspectorURL?: string;
  46078. /**
  46079. * Optional initial tab (default to DebugLayerTab.Properties)
  46080. */
  46081. initialTab?: DebugLayerTab;
  46082. }
  46083. interface Scene {
  46084. /**
  46085. * @hidden
  46086. * Backing field
  46087. */
  46088. _debugLayer: DebugLayer;
  46089. /**
  46090. * Gets the debug layer (aka Inspector) associated with the scene
  46091. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46092. */
  46093. debugLayer: DebugLayer;
  46094. }
  46095. /**
  46096. * Enum of inspector action tab
  46097. */
  46098. export enum DebugLayerTab {
  46099. /**
  46100. * Properties tag (default)
  46101. */
  46102. Properties = 0,
  46103. /**
  46104. * Debug tab
  46105. */
  46106. Debug = 1,
  46107. /**
  46108. * Statistics tab
  46109. */
  46110. Statistics = 2,
  46111. /**
  46112. * Tools tab
  46113. */
  46114. Tools = 3,
  46115. /**
  46116. * Settings tab
  46117. */
  46118. Settings = 4
  46119. }
  46120. /**
  46121. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46122. * what is happening in your scene
  46123. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46124. */
  46125. export class DebugLayer {
  46126. /**
  46127. * Define the url to get the inspector script from.
  46128. * By default it uses the babylonjs CDN.
  46129. * @ignoreNaming
  46130. */
  46131. static InspectorURL: string;
  46132. private _scene;
  46133. private BJSINSPECTOR;
  46134. private _onPropertyChangedObservable?;
  46135. /**
  46136. * Observable triggered when a property is changed through the inspector.
  46137. */
  46138. get onPropertyChangedObservable(): any;
  46139. /**
  46140. * Instantiates a new debug layer.
  46141. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46142. * what is happening in your scene
  46143. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46144. * @param scene Defines the scene to inspect
  46145. */
  46146. constructor(scene: Scene);
  46147. /** Creates the inspector window. */
  46148. private _createInspector;
  46149. /**
  46150. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46151. * @param entity defines the entity to select
  46152. * @param lineContainerTitle defines the specific block to highlight
  46153. */
  46154. select(entity: any, lineContainerTitle?: string): void;
  46155. /** Get the inspector from bundle or global */
  46156. private _getGlobalInspector;
  46157. /**
  46158. * Get if the inspector is visible or not.
  46159. * @returns true if visible otherwise, false
  46160. */
  46161. isVisible(): boolean;
  46162. /**
  46163. * Hide the inspector and close its window.
  46164. */
  46165. hide(): void;
  46166. /**
  46167. * Launch the debugLayer.
  46168. * @param config Define the configuration of the inspector
  46169. * @return a promise fulfilled when the debug layer is visible
  46170. */
  46171. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46172. }
  46173. }
  46174. declare module BABYLON {
  46175. /**
  46176. * Class containing static functions to help procedurally build meshes
  46177. */
  46178. export class BoxBuilder {
  46179. /**
  46180. * Creates a box mesh
  46181. * * The parameter `size` sets the size (float) of each box side (default 1)
  46182. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46183. * * 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)
  46184. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46186. * * 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
  46187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46188. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46189. * @param name defines the name of the mesh
  46190. * @param options defines the options used to create the mesh
  46191. * @param scene defines the hosting scene
  46192. * @returns the box mesh
  46193. */
  46194. static CreateBox(name: string, options: {
  46195. size?: number;
  46196. width?: number;
  46197. height?: number;
  46198. depth?: number;
  46199. faceUV?: Vector4[];
  46200. faceColors?: Color4[];
  46201. sideOrientation?: number;
  46202. frontUVs?: Vector4;
  46203. backUVs?: Vector4;
  46204. wrap?: boolean;
  46205. topBaseAt?: number;
  46206. bottomBaseAt?: number;
  46207. updatable?: boolean;
  46208. }, scene?: Nullable<Scene>): Mesh;
  46209. }
  46210. }
  46211. declare module BABYLON.Debug {
  46212. /**
  46213. * Used to show the physics impostor around the specific mesh
  46214. */
  46215. export class PhysicsViewer {
  46216. /** @hidden */
  46217. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46218. /** @hidden */
  46219. protected _meshes: Array<Nullable<AbstractMesh>>;
  46220. /** @hidden */
  46221. protected _scene: Nullable<Scene>;
  46222. /** @hidden */
  46223. protected _numMeshes: number;
  46224. /** @hidden */
  46225. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46226. private _renderFunction;
  46227. private _utilityLayer;
  46228. private _debugBoxMesh;
  46229. private _debugSphereMesh;
  46230. private _debugCylinderMesh;
  46231. private _debugMaterial;
  46232. private _debugMeshMeshes;
  46233. /**
  46234. * Creates a new PhysicsViewer
  46235. * @param scene defines the hosting scene
  46236. */
  46237. constructor(scene: Scene);
  46238. /** @hidden */
  46239. protected _updateDebugMeshes(): void;
  46240. /**
  46241. * Renders a specified physic impostor
  46242. * @param impostor defines the impostor to render
  46243. * @param targetMesh defines the mesh represented by the impostor
  46244. * @returns the new debug mesh used to render the impostor
  46245. */
  46246. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46247. /**
  46248. * Hides a specified physic impostor
  46249. * @param impostor defines the impostor to hide
  46250. */
  46251. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46252. private _getDebugMaterial;
  46253. private _getDebugBoxMesh;
  46254. private _getDebugSphereMesh;
  46255. private _getDebugCylinderMesh;
  46256. private _getDebugMeshMesh;
  46257. private _getDebugMesh;
  46258. /** Releases all resources */
  46259. dispose(): void;
  46260. }
  46261. }
  46262. declare module BABYLON {
  46263. /**
  46264. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46265. * in order to better appreciate the issue one might have.
  46266. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46267. */
  46268. export class RayHelper {
  46269. /**
  46270. * Defines the ray we are currently tryin to visualize.
  46271. */
  46272. ray: Nullable<Ray>;
  46273. private _renderPoints;
  46274. private _renderLine;
  46275. private _renderFunction;
  46276. private _scene;
  46277. private _updateToMeshFunction;
  46278. private _attachedToMesh;
  46279. private _meshSpaceDirection;
  46280. private _meshSpaceOrigin;
  46281. /**
  46282. * Helper function to create a colored helper in a scene in one line.
  46283. * @param ray Defines the ray we are currently tryin to visualize
  46284. * @param scene Defines the scene the ray is used in
  46285. * @param color Defines the color we want to see the ray in
  46286. * @returns The newly created ray helper.
  46287. */
  46288. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46289. /**
  46290. * Instantiate a new ray helper.
  46291. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46292. * in order to better appreciate the issue one might have.
  46293. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46294. * @param ray Defines the ray we are currently tryin to visualize
  46295. */
  46296. constructor(ray: Ray);
  46297. /**
  46298. * Shows the ray we are willing to debug.
  46299. * @param scene Defines the scene the ray needs to be rendered in
  46300. * @param color Defines the color the ray needs to be rendered in
  46301. */
  46302. show(scene: Scene, color?: Color3): void;
  46303. /**
  46304. * Hides the ray we are debugging.
  46305. */
  46306. hide(): void;
  46307. private _render;
  46308. /**
  46309. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46310. * @param mesh Defines the mesh we want the helper attached to
  46311. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46312. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46313. * @param length Defines the length of the ray
  46314. */
  46315. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46316. /**
  46317. * Detach the ray helper from the mesh it has previously been attached to.
  46318. */
  46319. detachFromMesh(): void;
  46320. private _updateToMesh;
  46321. /**
  46322. * Dispose the helper and release its associated resources.
  46323. */
  46324. dispose(): void;
  46325. }
  46326. }
  46327. declare module BABYLON.Debug {
  46328. /**
  46329. * Class used to render a debug view of a given skeleton
  46330. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46331. */
  46332. export class SkeletonViewer {
  46333. /** defines the skeleton to render */
  46334. skeleton: Skeleton;
  46335. /** defines the mesh attached to the skeleton */
  46336. mesh: AbstractMesh;
  46337. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46338. autoUpdateBonesMatrices: boolean;
  46339. /** defines the rendering group id to use with the viewer */
  46340. renderingGroupId: number;
  46341. /** Gets or sets the color used to render the skeleton */
  46342. color: Color3;
  46343. private _scene;
  46344. private _debugLines;
  46345. private _debugMesh;
  46346. private _isEnabled;
  46347. private _renderFunction;
  46348. private _utilityLayer;
  46349. /**
  46350. * Returns the mesh used to render the bones
  46351. */
  46352. get debugMesh(): Nullable<LinesMesh>;
  46353. /**
  46354. * Creates a new SkeletonViewer
  46355. * @param skeleton defines the skeleton to render
  46356. * @param mesh defines the mesh attached to the skeleton
  46357. * @param scene defines the hosting scene
  46358. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46359. * @param renderingGroupId defines the rendering group id to use with the viewer
  46360. */
  46361. constructor(
  46362. /** defines the skeleton to render */
  46363. skeleton: Skeleton,
  46364. /** defines the mesh attached to the skeleton */
  46365. mesh: AbstractMesh, scene: Scene,
  46366. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46367. autoUpdateBonesMatrices?: boolean,
  46368. /** defines the rendering group id to use with the viewer */
  46369. renderingGroupId?: number);
  46370. /** Gets or sets a boolean indicating if the viewer is enabled */
  46371. set isEnabled(value: boolean);
  46372. get isEnabled(): boolean;
  46373. private _getBonePosition;
  46374. private _getLinesForBonesWithLength;
  46375. private _getLinesForBonesNoLength;
  46376. /** Update the viewer to sync with current skeleton state */
  46377. update(): void;
  46378. /** Release associated resources */
  46379. dispose(): void;
  46380. }
  46381. }
  46382. declare module BABYLON {
  46383. /**
  46384. * Options to create the null engine
  46385. */
  46386. export class NullEngineOptions {
  46387. /**
  46388. * Render width (Default: 512)
  46389. */
  46390. renderWidth: number;
  46391. /**
  46392. * Render height (Default: 256)
  46393. */
  46394. renderHeight: number;
  46395. /**
  46396. * Texture size (Default: 512)
  46397. */
  46398. textureSize: number;
  46399. /**
  46400. * If delta time between frames should be constant
  46401. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46402. */
  46403. deterministicLockstep: boolean;
  46404. /**
  46405. * Maximum about of steps between frames (Default: 4)
  46406. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46407. */
  46408. lockstepMaxSteps: number;
  46409. }
  46410. /**
  46411. * The null engine class provides support for headless version of babylon.js.
  46412. * This can be used in server side scenario or for testing purposes
  46413. */
  46414. export class NullEngine extends Engine {
  46415. private _options;
  46416. /**
  46417. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46419. * @returns true if engine is in deterministic lock step mode
  46420. */
  46421. isDeterministicLockStep(): boolean;
  46422. /**
  46423. * Gets the max steps when engine is running in deterministic lock step
  46424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46425. * @returns the max steps
  46426. */
  46427. getLockstepMaxSteps(): number;
  46428. /**
  46429. * Gets the current hardware scaling level.
  46430. * By default the hardware scaling level is computed from the window device ratio.
  46431. * 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.
  46432. * @returns a number indicating the current hardware scaling level
  46433. */
  46434. getHardwareScalingLevel(): number;
  46435. constructor(options?: NullEngineOptions);
  46436. /**
  46437. * Creates a vertex buffer
  46438. * @param vertices the data for the vertex buffer
  46439. * @returns the new WebGL static buffer
  46440. */
  46441. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46442. /**
  46443. * Creates a new index buffer
  46444. * @param indices defines the content of the index buffer
  46445. * @param updatable defines if the index buffer must be updatable
  46446. * @returns a new webGL buffer
  46447. */
  46448. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46449. /**
  46450. * Clear the current render buffer or the current render target (if any is set up)
  46451. * @param color defines the color to use
  46452. * @param backBuffer defines if the back buffer must be cleared
  46453. * @param depth defines if the depth buffer must be cleared
  46454. * @param stencil defines if the stencil buffer must be cleared
  46455. */
  46456. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46457. /**
  46458. * Gets the current render width
  46459. * @param useScreen defines if screen size must be used (or the current render target if any)
  46460. * @returns a number defining the current render width
  46461. */
  46462. getRenderWidth(useScreen?: boolean): number;
  46463. /**
  46464. * Gets the current render height
  46465. * @param useScreen defines if screen size must be used (or the current render target if any)
  46466. * @returns a number defining the current render height
  46467. */
  46468. getRenderHeight(useScreen?: boolean): number;
  46469. /**
  46470. * Set the WebGL's viewport
  46471. * @param viewport defines the viewport element to be used
  46472. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46473. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46474. */
  46475. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46476. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46477. /**
  46478. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46479. * @param pipelineContext defines the pipeline context to use
  46480. * @param uniformsNames defines the list of uniform names
  46481. * @returns an array of webGL uniform locations
  46482. */
  46483. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46484. /**
  46485. * Gets the lsit of active attributes for a given webGL program
  46486. * @param pipelineContext defines the pipeline context to use
  46487. * @param attributesNames defines the list of attribute names to get
  46488. * @returns an array of indices indicating the offset of each attribute
  46489. */
  46490. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46491. /**
  46492. * Binds an effect to the webGL context
  46493. * @param effect defines the effect to bind
  46494. */
  46495. bindSamplers(effect: Effect): void;
  46496. /**
  46497. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46498. * @param effect defines the effect to activate
  46499. */
  46500. enableEffect(effect: Effect): void;
  46501. /**
  46502. * Set various states to the webGL context
  46503. * @param culling defines backface culling state
  46504. * @param zOffset defines the value to apply to zOffset (0 by default)
  46505. * @param force defines if states must be applied even if cache is up to date
  46506. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46507. */
  46508. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46509. /**
  46510. * Set the value of an uniform to an array of int32
  46511. * @param uniform defines the webGL uniform location where to store the value
  46512. * @param array defines the array of int32 to store
  46513. */
  46514. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46515. /**
  46516. * Set the value of an uniform to an array of int32 (stored as vec2)
  46517. * @param uniform defines the webGL uniform location where to store the value
  46518. * @param array defines the array of int32 to store
  46519. */
  46520. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46521. /**
  46522. * Set the value of an uniform to an array of int32 (stored as vec3)
  46523. * @param uniform defines the webGL uniform location where to store the value
  46524. * @param array defines the array of int32 to store
  46525. */
  46526. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46527. /**
  46528. * Set the value of an uniform to an array of int32 (stored as vec4)
  46529. * @param uniform defines the webGL uniform location where to store the value
  46530. * @param array defines the array of int32 to store
  46531. */
  46532. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46533. /**
  46534. * Set the value of an uniform to an array of float32
  46535. * @param uniform defines the webGL uniform location where to store the value
  46536. * @param array defines the array of float32 to store
  46537. */
  46538. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46539. /**
  46540. * Set the value of an uniform to an array of float32 (stored as vec2)
  46541. * @param uniform defines the webGL uniform location where to store the value
  46542. * @param array defines the array of float32 to store
  46543. */
  46544. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46545. /**
  46546. * Set the value of an uniform to an array of float32 (stored as vec3)
  46547. * @param uniform defines the webGL uniform location where to store the value
  46548. * @param array defines the array of float32 to store
  46549. */
  46550. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46551. /**
  46552. * Set the value of an uniform to an array of float32 (stored as vec4)
  46553. * @param uniform defines the webGL uniform location where to store the value
  46554. * @param array defines the array of float32 to store
  46555. */
  46556. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46557. /**
  46558. * Set the value of an uniform to an array of number
  46559. * @param uniform defines the webGL uniform location where to store the value
  46560. * @param array defines the array of number to store
  46561. */
  46562. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46563. /**
  46564. * Set the value of an uniform to an array of number (stored as vec2)
  46565. * @param uniform defines the webGL uniform location where to store the value
  46566. * @param array defines the array of number to store
  46567. */
  46568. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46569. /**
  46570. * Set the value of an uniform to an array of number (stored as vec3)
  46571. * @param uniform defines the webGL uniform location where to store the value
  46572. * @param array defines the array of number to store
  46573. */
  46574. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46575. /**
  46576. * Set the value of an uniform to an array of number (stored as vec4)
  46577. * @param uniform defines the webGL uniform location where to store the value
  46578. * @param array defines the array of number to store
  46579. */
  46580. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46581. /**
  46582. * Set the value of an uniform to an array of float32 (stored as matrices)
  46583. * @param uniform defines the webGL uniform location where to store the value
  46584. * @param matrices defines the array of float32 to store
  46585. */
  46586. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46587. /**
  46588. * Set the value of an uniform to a matrix (3x3)
  46589. * @param uniform defines the webGL uniform location where to store the value
  46590. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46591. */
  46592. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46593. /**
  46594. * Set the value of an uniform to a matrix (2x2)
  46595. * @param uniform defines the webGL uniform location where to store the value
  46596. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46597. */
  46598. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46599. /**
  46600. * Set the value of an uniform to a number (float)
  46601. * @param uniform defines the webGL uniform location where to store the value
  46602. * @param value defines the float number to store
  46603. */
  46604. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46605. /**
  46606. * Set the value of an uniform to a vec2
  46607. * @param uniform defines the webGL uniform location where to store the value
  46608. * @param x defines the 1st component of the value
  46609. * @param y defines the 2nd component of the value
  46610. */
  46611. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46612. /**
  46613. * Set the value of an uniform to a vec3
  46614. * @param uniform defines the webGL uniform location where to store the value
  46615. * @param x defines the 1st component of the value
  46616. * @param y defines the 2nd component of the value
  46617. * @param z defines the 3rd component of the value
  46618. */
  46619. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46620. /**
  46621. * Set the value of an uniform to a boolean
  46622. * @param uniform defines the webGL uniform location where to store the value
  46623. * @param bool defines the boolean to store
  46624. */
  46625. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46626. /**
  46627. * Set the value of an uniform to a vec4
  46628. * @param uniform defines the webGL uniform location where to store the value
  46629. * @param x defines the 1st component of the value
  46630. * @param y defines the 2nd component of the value
  46631. * @param z defines the 3rd component of the value
  46632. * @param w defines the 4th component of the value
  46633. */
  46634. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46635. /**
  46636. * Sets the current alpha mode
  46637. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46638. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46639. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46640. */
  46641. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46642. /**
  46643. * Bind webGl buffers directly to the webGL context
  46644. * @param vertexBuffers defines the vertex buffer to bind
  46645. * @param indexBuffer defines the index buffer to bind
  46646. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46647. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46648. * @param effect defines the effect associated with the vertex buffer
  46649. */
  46650. bindBuffers(vertexBuffers: {
  46651. [key: string]: VertexBuffer;
  46652. }, indexBuffer: DataBuffer, effect: Effect): void;
  46653. /**
  46654. * Force the entire cache to be cleared
  46655. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46656. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46657. */
  46658. wipeCaches(bruteForce?: boolean): void;
  46659. /**
  46660. * Send a draw order
  46661. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46662. * @param indexStart defines the starting index
  46663. * @param indexCount defines the number of index to draw
  46664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46665. */
  46666. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46667. /**
  46668. * Draw a list of indexed primitives
  46669. * @param fillMode defines the primitive to use
  46670. * @param indexStart defines the starting index
  46671. * @param indexCount defines the number of index to draw
  46672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46673. */
  46674. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46675. /**
  46676. * Draw a list of unindexed primitives
  46677. * @param fillMode defines the primitive to use
  46678. * @param verticesStart defines the index of first vertex to draw
  46679. * @param verticesCount defines the count of vertices to draw
  46680. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46681. */
  46682. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46683. /** @hidden */
  46684. _createTexture(): WebGLTexture;
  46685. /** @hidden */
  46686. _releaseTexture(texture: InternalTexture): void;
  46687. /**
  46688. * Usually called from Texture.ts.
  46689. * Passed information to create a WebGLTexture
  46690. * @param urlArg defines a value which contains one of the following:
  46691. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46692. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46693. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46695. * @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)
  46696. * @param scene needed for loading to the correct scene
  46697. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46698. * @param onLoad optional callback to be called upon successful completion
  46699. * @param onError optional callback to be called upon failure
  46700. * @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
  46701. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46702. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46703. * @param forcedExtension defines the extension to use to pick the right loader
  46704. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46705. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46706. */
  46707. 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;
  46708. /**
  46709. * Creates a new render target texture
  46710. * @param size defines the size of the texture
  46711. * @param options defines the options used to create the texture
  46712. * @returns a new render target texture stored in an InternalTexture
  46713. */
  46714. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46715. /**
  46716. * Update the sampling mode of a given texture
  46717. * @param samplingMode defines the required sampling mode
  46718. * @param texture defines the texture to update
  46719. */
  46720. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46721. /**
  46722. * Binds the frame buffer to the specified texture.
  46723. * @param texture The texture to render to or null for the default canvas
  46724. * @param faceIndex The face of the texture to render to in case of cube texture
  46725. * @param requiredWidth The width of the target to render to
  46726. * @param requiredHeight The height of the target to render to
  46727. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46728. * @param lodLevel defines le lod level to bind to the frame buffer
  46729. */
  46730. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46731. /**
  46732. * Unbind the current render target texture from the webGL context
  46733. * @param texture defines the render target texture to unbind
  46734. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46735. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46736. */
  46737. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46738. /**
  46739. * Creates a dynamic vertex buffer
  46740. * @param vertices the data for the dynamic vertex buffer
  46741. * @returns the new WebGL dynamic buffer
  46742. */
  46743. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46744. /**
  46745. * Update the content of a dynamic texture
  46746. * @param texture defines the texture to update
  46747. * @param canvas defines the canvas containing the source
  46748. * @param invertY defines if data must be stored with Y axis inverted
  46749. * @param premulAlpha defines if alpha is stored as premultiplied
  46750. * @param format defines the format of the data
  46751. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46752. */
  46753. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46754. /**
  46755. * Gets a boolean indicating if all created effects are ready
  46756. * @returns true if all effects are ready
  46757. */
  46758. areAllEffectsReady(): boolean;
  46759. /**
  46760. * @hidden
  46761. * Get the current error code of the webGL context
  46762. * @returns the error code
  46763. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46764. */
  46765. getError(): number;
  46766. /** @hidden */
  46767. _getUnpackAlignement(): number;
  46768. /** @hidden */
  46769. _unpackFlipY(value: boolean): void;
  46770. /**
  46771. * Update a dynamic index buffer
  46772. * @param indexBuffer defines the target index buffer
  46773. * @param indices defines the data to update
  46774. * @param offset defines the offset in the target index buffer where update should start
  46775. */
  46776. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46777. /**
  46778. * Updates a dynamic vertex buffer.
  46779. * @param vertexBuffer the vertex buffer to update
  46780. * @param vertices the data used to update the vertex buffer
  46781. * @param byteOffset the byte offset of the data (optional)
  46782. * @param byteLength the byte length of the data (optional)
  46783. */
  46784. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46785. /** @hidden */
  46786. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46787. /** @hidden */
  46788. _bindTexture(channel: number, texture: InternalTexture): void;
  46789. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46790. /**
  46791. * 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
  46792. */
  46793. releaseEffects(): void;
  46794. displayLoadingUI(): void;
  46795. hideLoadingUI(): void;
  46796. /** @hidden */
  46797. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46798. /** @hidden */
  46799. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46800. /** @hidden */
  46801. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46802. /** @hidden */
  46803. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46804. }
  46805. }
  46806. declare module BABYLON {
  46807. /** @hidden */
  46808. export class _OcclusionDataStorage {
  46809. /** @hidden */
  46810. occlusionInternalRetryCounter: number;
  46811. /** @hidden */
  46812. isOcclusionQueryInProgress: boolean;
  46813. /** @hidden */
  46814. isOccluded: boolean;
  46815. /** @hidden */
  46816. occlusionRetryCount: number;
  46817. /** @hidden */
  46818. occlusionType: number;
  46819. /** @hidden */
  46820. occlusionQueryAlgorithmType: number;
  46821. }
  46822. interface Engine {
  46823. /**
  46824. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46825. * @return the new query
  46826. */
  46827. createQuery(): WebGLQuery;
  46828. /**
  46829. * Delete and release a webGL query
  46830. * @param query defines the query to delete
  46831. * @return the current engine
  46832. */
  46833. deleteQuery(query: WebGLQuery): Engine;
  46834. /**
  46835. * Check if a given query has resolved and got its value
  46836. * @param query defines the query to check
  46837. * @returns true if the query got its value
  46838. */
  46839. isQueryResultAvailable(query: WebGLQuery): boolean;
  46840. /**
  46841. * Gets the value of a given query
  46842. * @param query defines the query to check
  46843. * @returns the value of the query
  46844. */
  46845. getQueryResult(query: WebGLQuery): number;
  46846. /**
  46847. * Initiates an occlusion query
  46848. * @param algorithmType defines the algorithm to use
  46849. * @param query defines the query to use
  46850. * @returns the current engine
  46851. * @see http://doc.babylonjs.com/features/occlusionquery
  46852. */
  46853. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46854. /**
  46855. * Ends an occlusion query
  46856. * @see http://doc.babylonjs.com/features/occlusionquery
  46857. * @param algorithmType defines the algorithm to use
  46858. * @returns the current engine
  46859. */
  46860. endOcclusionQuery(algorithmType: number): Engine;
  46861. /**
  46862. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46863. * Please note that only one query can be issued at a time
  46864. * @returns a time token used to track the time span
  46865. */
  46866. startTimeQuery(): Nullable<_TimeToken>;
  46867. /**
  46868. * Ends a time query
  46869. * @param token defines the token used to measure the time span
  46870. * @returns the time spent (in ns)
  46871. */
  46872. endTimeQuery(token: _TimeToken): int;
  46873. /** @hidden */
  46874. _currentNonTimestampToken: Nullable<_TimeToken>;
  46875. /** @hidden */
  46876. _createTimeQuery(): WebGLQuery;
  46877. /** @hidden */
  46878. _deleteTimeQuery(query: WebGLQuery): void;
  46879. /** @hidden */
  46880. _getGlAlgorithmType(algorithmType: number): number;
  46881. /** @hidden */
  46882. _getTimeQueryResult(query: WebGLQuery): any;
  46883. /** @hidden */
  46884. _getTimeQueryAvailability(query: WebGLQuery): any;
  46885. }
  46886. interface AbstractMesh {
  46887. /**
  46888. * Backing filed
  46889. * @hidden
  46890. */
  46891. __occlusionDataStorage: _OcclusionDataStorage;
  46892. /**
  46893. * Access property
  46894. * @hidden
  46895. */
  46896. _occlusionDataStorage: _OcclusionDataStorage;
  46897. /**
  46898. * 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.
  46899. * The default value is -1 which means don't break the query and wait till the result
  46900. * @see http://doc.babylonjs.com/features/occlusionquery
  46901. */
  46902. occlusionRetryCount: number;
  46903. /**
  46904. * 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:
  46905. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46906. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46907. * * 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.
  46908. * @see http://doc.babylonjs.com/features/occlusionquery
  46909. */
  46910. occlusionType: number;
  46911. /**
  46912. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46913. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46914. * * 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.
  46915. * @see http://doc.babylonjs.com/features/occlusionquery
  46916. */
  46917. occlusionQueryAlgorithmType: number;
  46918. /**
  46919. * 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
  46920. * @see http://doc.babylonjs.com/features/occlusionquery
  46921. */
  46922. isOccluded: boolean;
  46923. /**
  46924. * Flag to check the progress status of the query
  46925. * @see http://doc.babylonjs.com/features/occlusionquery
  46926. */
  46927. isOcclusionQueryInProgress: boolean;
  46928. }
  46929. }
  46930. declare module BABYLON {
  46931. /** @hidden */
  46932. export var _forceTransformFeedbackToBundle: boolean;
  46933. interface Engine {
  46934. /**
  46935. * Creates a webGL transform feedback object
  46936. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46937. * @returns the webGL transform feedback object
  46938. */
  46939. createTransformFeedback(): WebGLTransformFeedback;
  46940. /**
  46941. * Delete a webGL transform feedback object
  46942. * @param value defines the webGL transform feedback object to delete
  46943. */
  46944. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46945. /**
  46946. * Bind a webGL transform feedback object to the webgl context
  46947. * @param value defines the webGL transform feedback object to bind
  46948. */
  46949. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46950. /**
  46951. * Begins a transform feedback operation
  46952. * @param usePoints defines if points or triangles must be used
  46953. */
  46954. beginTransformFeedback(usePoints: boolean): void;
  46955. /**
  46956. * Ends a transform feedback operation
  46957. */
  46958. endTransformFeedback(): void;
  46959. /**
  46960. * Specify the varyings to use with transform feedback
  46961. * @param program defines the associated webGL program
  46962. * @param value defines the list of strings representing the varying names
  46963. */
  46964. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46965. /**
  46966. * Bind a webGL buffer for a transform feedback operation
  46967. * @param value defines the webGL buffer to bind
  46968. */
  46969. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46970. }
  46971. }
  46972. declare module BABYLON {
  46973. /**
  46974. * Creation options of the multi render target texture.
  46975. */
  46976. export interface IMultiRenderTargetOptions {
  46977. /**
  46978. * Define if the texture needs to create mip maps after render.
  46979. */
  46980. generateMipMaps?: boolean;
  46981. /**
  46982. * Define the types of all the draw buffers we want to create
  46983. */
  46984. types?: number[];
  46985. /**
  46986. * Define the sampling modes of all the draw buffers we want to create
  46987. */
  46988. samplingModes?: number[];
  46989. /**
  46990. * Define if a depth buffer is required
  46991. */
  46992. generateDepthBuffer?: boolean;
  46993. /**
  46994. * Define if a stencil buffer is required
  46995. */
  46996. generateStencilBuffer?: boolean;
  46997. /**
  46998. * Define if a depth texture is required instead of a depth buffer
  46999. */
  47000. generateDepthTexture?: boolean;
  47001. /**
  47002. * Define the number of desired draw buffers
  47003. */
  47004. textureCount?: number;
  47005. /**
  47006. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47007. */
  47008. doNotChangeAspectRatio?: boolean;
  47009. /**
  47010. * Define the default type of the buffers we are creating
  47011. */
  47012. defaultType?: number;
  47013. }
  47014. /**
  47015. * A multi render target, like a render target provides the ability to render to a texture.
  47016. * Unlike the render target, it can render to several draw buffers in one draw.
  47017. * This is specially interesting in deferred rendering or for any effects requiring more than
  47018. * just one color from a single pass.
  47019. */
  47020. export class MultiRenderTarget extends RenderTargetTexture {
  47021. private _internalTextures;
  47022. private _textures;
  47023. private _multiRenderTargetOptions;
  47024. /**
  47025. * Get if draw buffers are currently supported by the used hardware and browser.
  47026. */
  47027. get isSupported(): boolean;
  47028. /**
  47029. * Get the list of textures generated by the multi render target.
  47030. */
  47031. get textures(): Texture[];
  47032. /**
  47033. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47034. */
  47035. get depthTexture(): Texture;
  47036. /**
  47037. * Set the wrapping mode on U of all the textures we are rendering to.
  47038. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47039. */
  47040. set wrapU(wrap: number);
  47041. /**
  47042. * Set the wrapping mode on V of all the textures we are rendering to.
  47043. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47044. */
  47045. set wrapV(wrap: number);
  47046. /**
  47047. * Instantiate a new multi render target texture.
  47048. * A multi render target, like a render target provides the ability to render to a texture.
  47049. * Unlike the render target, it can render to several draw buffers in one draw.
  47050. * This is specially interesting in deferred rendering or for any effects requiring more than
  47051. * just one color from a single pass.
  47052. * @param name Define the name of the texture
  47053. * @param size Define the size of the buffers to render to
  47054. * @param count Define the number of target we are rendering into
  47055. * @param scene Define the scene the texture belongs to
  47056. * @param options Define the options used to create the multi render target
  47057. */
  47058. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47059. /** @hidden */
  47060. _rebuild(): void;
  47061. private _createInternalTextures;
  47062. private _createTextures;
  47063. /**
  47064. * Define the number of samples used if MSAA is enabled.
  47065. */
  47066. get samples(): number;
  47067. set samples(value: number);
  47068. /**
  47069. * Resize all the textures in the multi render target.
  47070. * Be carrefull as it will recreate all the data in the new texture.
  47071. * @param size Define the new size
  47072. */
  47073. resize(size: any): void;
  47074. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47075. /**
  47076. * Dispose the render targets and their associated resources
  47077. */
  47078. dispose(): void;
  47079. /**
  47080. * Release all the underlying texture used as draw buffers.
  47081. */
  47082. releaseInternalTextures(): void;
  47083. }
  47084. }
  47085. declare module BABYLON {
  47086. interface ThinEngine {
  47087. /**
  47088. * Unbind a list of render target textures from the webGL context
  47089. * This is used only when drawBuffer extension or webGL2 are active
  47090. * @param textures defines the render target textures to unbind
  47091. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47092. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47093. */
  47094. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47095. /**
  47096. * Create a multi render target texture
  47097. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47098. * @param size defines the size of the texture
  47099. * @param options defines the creation options
  47100. * @returns the cube texture as an InternalTexture
  47101. */
  47102. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47103. /**
  47104. * Update the sample count for a given multiple render target texture
  47105. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47106. * @param textures defines the textures to update
  47107. * @param samples defines the sample count to set
  47108. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47109. */
  47110. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47111. }
  47112. }
  47113. declare module BABYLON {
  47114. /**
  47115. * Class used to define an additional view for the engine
  47116. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47117. */
  47118. export class EngineView {
  47119. /** Defines the canvas where to render the view */
  47120. target: HTMLCanvasElement;
  47121. /** Defines an optional camera used to render the view (will use active camera else) */
  47122. camera?: Camera;
  47123. }
  47124. interface Engine {
  47125. /**
  47126. * Gets or sets the HTML element to use for attaching events
  47127. */
  47128. inputElement: Nullable<HTMLElement>;
  47129. /**
  47130. * Gets the current engine view
  47131. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47132. */
  47133. activeView: Nullable<EngineView>;
  47134. /** Gets or sets the list of views */
  47135. views: EngineView[];
  47136. /**
  47137. * Register a new child canvas
  47138. * @param canvas defines the canvas to register
  47139. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47140. * @returns the associated view
  47141. */
  47142. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47143. /**
  47144. * Remove a registered child canvas
  47145. * @param canvas defines the canvas to remove
  47146. * @returns the current engine
  47147. */
  47148. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47149. }
  47150. }
  47151. declare module BABYLON {
  47152. /**
  47153. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47154. */
  47155. export interface CubeMapInfo {
  47156. /**
  47157. * The pixel array for the front face.
  47158. * This is stored in format, left to right, up to down format.
  47159. */
  47160. front: Nullable<ArrayBufferView>;
  47161. /**
  47162. * The pixel array for the back face.
  47163. * This is stored in format, left to right, up to down format.
  47164. */
  47165. back: Nullable<ArrayBufferView>;
  47166. /**
  47167. * The pixel array for the left face.
  47168. * This is stored in format, left to right, up to down format.
  47169. */
  47170. left: Nullable<ArrayBufferView>;
  47171. /**
  47172. * The pixel array for the right face.
  47173. * This is stored in format, left to right, up to down format.
  47174. */
  47175. right: Nullable<ArrayBufferView>;
  47176. /**
  47177. * The pixel array for the up face.
  47178. * This is stored in format, left to right, up to down format.
  47179. */
  47180. up: Nullable<ArrayBufferView>;
  47181. /**
  47182. * The pixel array for the down face.
  47183. * This is stored in format, left to right, up to down format.
  47184. */
  47185. down: Nullable<ArrayBufferView>;
  47186. /**
  47187. * The size of the cubemap stored.
  47188. *
  47189. * Each faces will be size * size pixels.
  47190. */
  47191. size: number;
  47192. /**
  47193. * The format of the texture.
  47194. *
  47195. * RGBA, RGB.
  47196. */
  47197. format: number;
  47198. /**
  47199. * The type of the texture data.
  47200. *
  47201. * UNSIGNED_INT, FLOAT.
  47202. */
  47203. type: number;
  47204. /**
  47205. * Specifies whether the texture is in gamma space.
  47206. */
  47207. gammaSpace: boolean;
  47208. }
  47209. /**
  47210. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47211. */
  47212. export class PanoramaToCubeMapTools {
  47213. private static FACE_FRONT;
  47214. private static FACE_BACK;
  47215. private static FACE_RIGHT;
  47216. private static FACE_LEFT;
  47217. private static FACE_DOWN;
  47218. private static FACE_UP;
  47219. /**
  47220. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47221. *
  47222. * @param float32Array The source data.
  47223. * @param inputWidth The width of the input panorama.
  47224. * @param inputHeight The height of the input panorama.
  47225. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47226. * @return The cubemap data
  47227. */
  47228. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47229. private static CreateCubemapTexture;
  47230. private static CalcProjectionSpherical;
  47231. }
  47232. }
  47233. declare module BABYLON {
  47234. /**
  47235. * Helper class dealing with the extraction of spherical polynomial dataArray
  47236. * from a cube map.
  47237. */
  47238. export class CubeMapToSphericalPolynomialTools {
  47239. private static FileFaces;
  47240. /**
  47241. * Converts a texture to the according Spherical Polynomial data.
  47242. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47243. *
  47244. * @param texture The texture to extract the information from.
  47245. * @return The Spherical Polynomial data.
  47246. */
  47247. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47248. /**
  47249. * Converts a cubemap to the according Spherical Polynomial data.
  47250. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47251. *
  47252. * @param cubeInfo The Cube map to extract the information from.
  47253. * @return The Spherical Polynomial data.
  47254. */
  47255. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47256. }
  47257. }
  47258. declare module BABYLON {
  47259. interface BaseTexture {
  47260. /**
  47261. * Get the polynomial representation of the texture data.
  47262. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47263. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47264. */
  47265. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47266. }
  47267. }
  47268. declare module BABYLON {
  47269. /** @hidden */
  47270. export var rgbdEncodePixelShader: {
  47271. name: string;
  47272. shader: string;
  47273. };
  47274. }
  47275. declare module BABYLON {
  47276. /** @hidden */
  47277. export var rgbdDecodePixelShader: {
  47278. name: string;
  47279. shader: string;
  47280. };
  47281. }
  47282. declare module BABYLON {
  47283. /**
  47284. * Raw texture data and descriptor sufficient for WebGL texture upload
  47285. */
  47286. export interface EnvironmentTextureInfo {
  47287. /**
  47288. * Version of the environment map
  47289. */
  47290. version: number;
  47291. /**
  47292. * Width of image
  47293. */
  47294. width: number;
  47295. /**
  47296. * Irradiance information stored in the file.
  47297. */
  47298. irradiance: any;
  47299. /**
  47300. * Specular information stored in the file.
  47301. */
  47302. specular: any;
  47303. }
  47304. /**
  47305. * Defines One Image in the file. It requires only the position in the file
  47306. * as well as the length.
  47307. */
  47308. interface BufferImageData {
  47309. /**
  47310. * Length of the image data.
  47311. */
  47312. length: number;
  47313. /**
  47314. * Position of the data from the null terminator delimiting the end of the JSON.
  47315. */
  47316. position: number;
  47317. }
  47318. /**
  47319. * Defines the specular data enclosed in the file.
  47320. * This corresponds to the version 1 of the data.
  47321. */
  47322. export interface EnvironmentTextureSpecularInfoV1 {
  47323. /**
  47324. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47325. */
  47326. specularDataPosition?: number;
  47327. /**
  47328. * This contains all the images data needed to reconstruct the cubemap.
  47329. */
  47330. mipmaps: Array<BufferImageData>;
  47331. /**
  47332. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47333. */
  47334. lodGenerationScale: number;
  47335. }
  47336. /**
  47337. * Sets of helpers addressing the serialization and deserialization of environment texture
  47338. * stored in a BabylonJS env file.
  47339. * Those files are usually stored as .env files.
  47340. */
  47341. export class EnvironmentTextureTools {
  47342. /**
  47343. * Magic number identifying the env file.
  47344. */
  47345. private static _MagicBytes;
  47346. /**
  47347. * Gets the environment info from an env file.
  47348. * @param data The array buffer containing the .env bytes.
  47349. * @returns the environment file info (the json header) if successfully parsed.
  47350. */
  47351. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47352. /**
  47353. * Creates an environment texture from a loaded cube texture.
  47354. * @param texture defines the cube texture to convert in env file
  47355. * @return a promise containing the environment data if succesfull.
  47356. */
  47357. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47358. /**
  47359. * Creates a JSON representation of the spherical data.
  47360. * @param texture defines the texture containing the polynomials
  47361. * @return the JSON representation of the spherical info
  47362. */
  47363. private static _CreateEnvTextureIrradiance;
  47364. /**
  47365. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47366. * @param data the image data
  47367. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47368. * @return the views described by info providing access to the underlying buffer
  47369. */
  47370. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47371. /**
  47372. * Uploads the texture info contained in the env file to the GPU.
  47373. * @param texture defines the internal texture to upload to
  47374. * @param data defines the data to load
  47375. * @param info defines the texture info retrieved through the GetEnvInfo method
  47376. * @returns a promise
  47377. */
  47378. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47379. private static _OnImageReadyAsync;
  47380. /**
  47381. * Uploads the levels of image data to the GPU.
  47382. * @param texture defines the internal texture to upload to
  47383. * @param imageData defines the array buffer views of image data [mipmap][face]
  47384. * @returns a promise
  47385. */
  47386. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47387. /**
  47388. * Uploads spherical polynomials information to the texture.
  47389. * @param texture defines the texture we are trying to upload the information to
  47390. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47391. */
  47392. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47393. /** @hidden */
  47394. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47395. }
  47396. }
  47397. declare module BABYLON {
  47398. /**
  47399. * Contains position and normal vectors for a vertex
  47400. */
  47401. export class PositionNormalVertex {
  47402. /** the position of the vertex (defaut: 0,0,0) */
  47403. position: Vector3;
  47404. /** the normal of the vertex (defaut: 0,1,0) */
  47405. normal: Vector3;
  47406. /**
  47407. * Creates a PositionNormalVertex
  47408. * @param position the position of the vertex (defaut: 0,0,0)
  47409. * @param normal the normal of the vertex (defaut: 0,1,0)
  47410. */
  47411. constructor(
  47412. /** the position of the vertex (defaut: 0,0,0) */
  47413. position?: Vector3,
  47414. /** the normal of the vertex (defaut: 0,1,0) */
  47415. normal?: Vector3);
  47416. /**
  47417. * Clones the PositionNormalVertex
  47418. * @returns the cloned PositionNormalVertex
  47419. */
  47420. clone(): PositionNormalVertex;
  47421. }
  47422. /**
  47423. * Contains position, normal and uv vectors for a vertex
  47424. */
  47425. export class PositionNormalTextureVertex {
  47426. /** the position of the vertex (defaut: 0,0,0) */
  47427. position: Vector3;
  47428. /** the normal of the vertex (defaut: 0,1,0) */
  47429. normal: Vector3;
  47430. /** the uv of the vertex (default: 0,0) */
  47431. uv: Vector2;
  47432. /**
  47433. * Creates a PositionNormalTextureVertex
  47434. * @param position the position of the vertex (defaut: 0,0,0)
  47435. * @param normal the normal of the vertex (defaut: 0,1,0)
  47436. * @param uv the uv of the vertex (default: 0,0)
  47437. */
  47438. constructor(
  47439. /** the position of the vertex (defaut: 0,0,0) */
  47440. position?: Vector3,
  47441. /** the normal of the vertex (defaut: 0,1,0) */
  47442. normal?: Vector3,
  47443. /** the uv of the vertex (default: 0,0) */
  47444. uv?: Vector2);
  47445. /**
  47446. * Clones the PositionNormalTextureVertex
  47447. * @returns the cloned PositionNormalTextureVertex
  47448. */
  47449. clone(): PositionNormalTextureVertex;
  47450. }
  47451. }
  47452. declare module BABYLON {
  47453. /** @hidden */
  47454. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47455. private _genericAttributeLocation;
  47456. private _varyingLocationCount;
  47457. private _varyingLocationMap;
  47458. private _replacements;
  47459. private _textureCount;
  47460. private _uniforms;
  47461. lineProcessor(line: string): string;
  47462. attributeProcessor(attribute: string): string;
  47463. varyingProcessor(varying: string, isFragment: boolean): string;
  47464. uniformProcessor(uniform: string): string;
  47465. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47466. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47467. }
  47468. }
  47469. declare module BABYLON {
  47470. /**
  47471. * Container for accessors for natively-stored mesh data buffers.
  47472. */
  47473. class NativeDataBuffer extends DataBuffer {
  47474. /**
  47475. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47476. */
  47477. nativeIndexBuffer?: any;
  47478. /**
  47479. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47480. */
  47481. nativeVertexBuffer?: any;
  47482. }
  47483. /** @hidden */
  47484. class NativeTexture extends InternalTexture {
  47485. getInternalTexture(): InternalTexture;
  47486. getViewCount(): number;
  47487. }
  47488. /** @hidden */
  47489. export class NativeEngine extends Engine {
  47490. private readonly _native;
  47491. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47492. private readonly INVALID_HANDLE;
  47493. getHardwareScalingLevel(): number;
  47494. constructor();
  47495. /**
  47496. * Can be used to override the current requestAnimationFrame requester.
  47497. * @hidden
  47498. */
  47499. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47500. /**
  47501. * Override default engine behavior.
  47502. * @param color
  47503. * @param backBuffer
  47504. * @param depth
  47505. * @param stencil
  47506. */
  47507. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47508. /**
  47509. * Gets host document
  47510. * @returns the host document object
  47511. */
  47512. getHostDocument(): Nullable<Document>;
  47513. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47514. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47515. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47516. recordVertexArrayObject(vertexBuffers: {
  47517. [key: string]: VertexBuffer;
  47518. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47519. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47520. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47521. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47522. /**
  47523. * Draw a list of indexed primitives
  47524. * @param fillMode defines the primitive to use
  47525. * @param indexStart defines the starting index
  47526. * @param indexCount defines the number of index to draw
  47527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47528. */
  47529. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47530. /**
  47531. * Draw a list of unindexed primitives
  47532. * @param fillMode defines the primitive to use
  47533. * @param verticesStart defines the index of first vertex to draw
  47534. * @param verticesCount defines the count of vertices to draw
  47535. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47536. */
  47537. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47538. createPipelineContext(): IPipelineContext;
  47539. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47540. /** @hidden */
  47541. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47542. /** @hidden */
  47543. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47544. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47545. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47546. protected _setProgram(program: WebGLProgram): void;
  47547. _releaseEffect(effect: Effect): void;
  47548. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47549. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47550. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47551. bindSamplers(effect: Effect): void;
  47552. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47553. getRenderWidth(useScreen?: boolean): number;
  47554. getRenderHeight(useScreen?: boolean): number;
  47555. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47556. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47557. /**
  47558. * Set the z offset to apply to current rendering
  47559. * @param value defines the offset to apply
  47560. */
  47561. setZOffset(value: number): void;
  47562. /**
  47563. * Gets the current value of the zOffset
  47564. * @returns the current zOffset state
  47565. */
  47566. getZOffset(): number;
  47567. /**
  47568. * Enable or disable depth buffering
  47569. * @param enable defines the state to set
  47570. */
  47571. setDepthBuffer(enable: boolean): void;
  47572. /**
  47573. * Gets a boolean indicating if depth writing is enabled
  47574. * @returns the current depth writing state
  47575. */
  47576. getDepthWrite(): boolean;
  47577. /**
  47578. * Enable or disable depth writing
  47579. * @param enable defines the state to set
  47580. */
  47581. setDepthWrite(enable: boolean): void;
  47582. /**
  47583. * Enable or disable color writing
  47584. * @param enable defines the state to set
  47585. */
  47586. setColorWrite(enable: boolean): void;
  47587. /**
  47588. * Gets a boolean indicating if color writing is enabled
  47589. * @returns the current color writing state
  47590. */
  47591. getColorWrite(): boolean;
  47592. /**
  47593. * Sets alpha constants used by some alpha blending modes
  47594. * @param r defines the red component
  47595. * @param g defines the green component
  47596. * @param b defines the blue component
  47597. * @param a defines the alpha component
  47598. */
  47599. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47600. /**
  47601. * Sets the current alpha mode
  47602. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47603. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47604. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47605. */
  47606. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47607. /**
  47608. * Gets the current alpha mode
  47609. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47610. * @returns the current alpha mode
  47611. */
  47612. getAlphaMode(): number;
  47613. setInt(uniform: WebGLUniformLocation, int: number): void;
  47614. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47615. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47616. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47617. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47618. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47619. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47620. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47621. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47622. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47623. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47624. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47625. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47626. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47627. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47628. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47629. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47630. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47631. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47632. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47633. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47634. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47635. wipeCaches(bruteForce?: boolean): void;
  47636. _createTexture(): WebGLTexture;
  47637. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47638. /**
  47639. * Usually called from BABYLON.Texture.ts.
  47640. * Passed information to create a WebGLTexture
  47641. * @param urlArg defines a value which contains one of the following:
  47642. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47643. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47644. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47646. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47647. * @param scene needed for loading to the correct scene
  47648. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47649. * @param onLoad optional callback to be called upon successful completion
  47650. * @param onError optional callback to be called upon failure
  47651. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47652. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47653. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47654. * @param forcedExtension defines the extension to use to pick the right loader
  47655. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47656. */
  47657. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47658. /**
  47659. * Creates a cube texture
  47660. * @param rootUrl defines the url where the files to load is located
  47661. * @param scene defines the current scene
  47662. * @param files defines the list of files to load (1 per face)
  47663. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47664. * @param onLoad defines an optional callback raised when the texture is loaded
  47665. * @param onError defines an optional callback raised if there is an issue to load the texture
  47666. * @param format defines the format of the data
  47667. * @param forcedExtension defines the extension to use to pick the right loader
  47668. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47669. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47670. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47671. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47672. * @returns the cube texture as an InternalTexture
  47673. */
  47674. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47675. private _getSamplingFilter;
  47676. private static _GetNativeTextureFormat;
  47677. createRenderTargetTexture(size: number | {
  47678. width: number;
  47679. height: number;
  47680. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47681. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47682. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47683. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47684. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47685. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47686. /**
  47687. * Updates a dynamic vertex buffer.
  47688. * @param vertexBuffer the vertex buffer to update
  47689. * @param data the data used to update the vertex buffer
  47690. * @param byteOffset the byte offset of the data (optional)
  47691. * @param byteLength the byte length of the data (optional)
  47692. */
  47693. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47694. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47695. private _updateAnisotropicLevel;
  47696. private _getAddressMode;
  47697. /** @hidden */
  47698. _bindTexture(channel: number, texture: InternalTexture): void;
  47699. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47700. releaseEffects(): void;
  47701. /** @hidden */
  47702. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47703. /** @hidden */
  47704. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47705. /** @hidden */
  47706. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47707. /** @hidden */
  47708. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47709. }
  47710. }
  47711. declare module BABYLON {
  47712. /**
  47713. * Gather the list of clipboard event types as constants.
  47714. */
  47715. export class ClipboardEventTypes {
  47716. /**
  47717. * The clipboard event is fired when a copy command is active (pressed).
  47718. */
  47719. static readonly COPY: number;
  47720. /**
  47721. * The clipboard event is fired when a cut command is active (pressed).
  47722. */
  47723. static readonly CUT: number;
  47724. /**
  47725. * The clipboard event is fired when a paste command is active (pressed).
  47726. */
  47727. static readonly PASTE: number;
  47728. }
  47729. /**
  47730. * This class is used to store clipboard related info for the onClipboardObservable event.
  47731. */
  47732. export class ClipboardInfo {
  47733. /**
  47734. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47735. */
  47736. type: number;
  47737. /**
  47738. * Defines the related dom event
  47739. */
  47740. event: ClipboardEvent;
  47741. /**
  47742. *Creates an instance of ClipboardInfo.
  47743. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47744. * @param event Defines the related dom event
  47745. */
  47746. constructor(
  47747. /**
  47748. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47749. */
  47750. type: number,
  47751. /**
  47752. * Defines the related dom event
  47753. */
  47754. event: ClipboardEvent);
  47755. /**
  47756. * Get the clipboard event's type from the keycode.
  47757. * @param keyCode Defines the keyCode for the current keyboard event.
  47758. * @return {number}
  47759. */
  47760. static GetTypeFromCharacter(keyCode: number): number;
  47761. }
  47762. }
  47763. declare module BABYLON {
  47764. /**
  47765. * Google Daydream controller
  47766. */
  47767. export class DaydreamController extends WebVRController {
  47768. /**
  47769. * Base Url for the controller model.
  47770. */
  47771. static MODEL_BASE_URL: string;
  47772. /**
  47773. * File name for the controller model.
  47774. */
  47775. static MODEL_FILENAME: string;
  47776. /**
  47777. * Gamepad Id prefix used to identify Daydream Controller.
  47778. */
  47779. static readonly GAMEPAD_ID_PREFIX: string;
  47780. /**
  47781. * Creates a new DaydreamController from a gamepad
  47782. * @param vrGamepad the gamepad that the controller should be created from
  47783. */
  47784. constructor(vrGamepad: any);
  47785. /**
  47786. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47787. * @param scene scene in which to add meshes
  47788. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47789. */
  47790. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47791. /**
  47792. * Called once for each button that changed state since the last frame
  47793. * @param buttonIdx Which button index changed
  47794. * @param state New state of the button
  47795. * @param changes Which properties on the state changed since last frame
  47796. */
  47797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47798. }
  47799. }
  47800. declare module BABYLON {
  47801. /**
  47802. * Gear VR Controller
  47803. */
  47804. export class GearVRController extends WebVRController {
  47805. /**
  47806. * Base Url for the controller model.
  47807. */
  47808. static MODEL_BASE_URL: string;
  47809. /**
  47810. * File name for the controller model.
  47811. */
  47812. static MODEL_FILENAME: string;
  47813. /**
  47814. * Gamepad Id prefix used to identify this controller.
  47815. */
  47816. static readonly GAMEPAD_ID_PREFIX: string;
  47817. private readonly _buttonIndexToObservableNameMap;
  47818. /**
  47819. * Creates a new GearVRController from a gamepad
  47820. * @param vrGamepad the gamepad that the controller should be created from
  47821. */
  47822. constructor(vrGamepad: any);
  47823. /**
  47824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47825. * @param scene scene in which to add meshes
  47826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47827. */
  47828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47829. /**
  47830. * Called once for each button that changed state since the last frame
  47831. * @param buttonIdx Which button index changed
  47832. * @param state New state of the button
  47833. * @param changes Which properties on the state changed since last frame
  47834. */
  47835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47836. }
  47837. }
  47838. declare module BABYLON {
  47839. /**
  47840. * Generic Controller
  47841. */
  47842. export class GenericController extends WebVRController {
  47843. /**
  47844. * Base Url for the controller model.
  47845. */
  47846. static readonly MODEL_BASE_URL: string;
  47847. /**
  47848. * File name for the controller model.
  47849. */
  47850. static readonly MODEL_FILENAME: string;
  47851. /**
  47852. * Creates a new GenericController from a gamepad
  47853. * @param vrGamepad the gamepad that the controller should be created from
  47854. */
  47855. constructor(vrGamepad: any);
  47856. /**
  47857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47858. * @param scene scene in which to add meshes
  47859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47860. */
  47861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47862. /**
  47863. * Called once for each button that changed state since the last frame
  47864. * @param buttonIdx Which button index changed
  47865. * @param state New state of the button
  47866. * @param changes Which properties on the state changed since last frame
  47867. */
  47868. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47869. }
  47870. }
  47871. declare module BABYLON {
  47872. /**
  47873. * Oculus Touch Controller
  47874. */
  47875. export class OculusTouchController extends WebVRController {
  47876. /**
  47877. * Base Url for the controller model.
  47878. */
  47879. static MODEL_BASE_URL: string;
  47880. /**
  47881. * File name for the left controller model.
  47882. */
  47883. static MODEL_LEFT_FILENAME: string;
  47884. /**
  47885. * File name for the right controller model.
  47886. */
  47887. static MODEL_RIGHT_FILENAME: string;
  47888. /**
  47889. * Base Url for the Quest controller model.
  47890. */
  47891. static QUEST_MODEL_BASE_URL: string;
  47892. /**
  47893. * @hidden
  47894. * If the controllers are running on a device that needs the updated Quest controller models
  47895. */
  47896. static _IsQuest: boolean;
  47897. /**
  47898. * Fired when the secondary trigger on this controller is modified
  47899. */
  47900. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47901. /**
  47902. * Fired when the thumb rest on this controller is modified
  47903. */
  47904. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47905. /**
  47906. * Creates a new OculusTouchController from a gamepad
  47907. * @param vrGamepad the gamepad that the controller should be created from
  47908. */
  47909. constructor(vrGamepad: any);
  47910. /**
  47911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47912. * @param scene scene in which to add meshes
  47913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47914. */
  47915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47916. /**
  47917. * Fired when the A button on this controller is modified
  47918. */
  47919. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47920. /**
  47921. * Fired when the B button on this controller is modified
  47922. */
  47923. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47924. /**
  47925. * Fired when the X button on this controller is modified
  47926. */
  47927. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47928. /**
  47929. * Fired when the Y button on this controller is modified
  47930. */
  47931. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47932. /**
  47933. * Called once for each button that changed state since the last frame
  47934. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  47935. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  47936. * 2) secondary trigger (same)
  47937. * 3) A (right) X (left), touch, pressed = value
  47938. * 4) B / Y
  47939. * 5) thumb rest
  47940. * @param buttonIdx Which button index changed
  47941. * @param state New state of the button
  47942. * @param changes Which properties on the state changed since last frame
  47943. */
  47944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47945. }
  47946. }
  47947. declare module BABYLON {
  47948. /**
  47949. * Vive Controller
  47950. */
  47951. export class ViveController extends WebVRController {
  47952. /**
  47953. * Base Url for the controller model.
  47954. */
  47955. static MODEL_BASE_URL: string;
  47956. /**
  47957. * File name for the controller model.
  47958. */
  47959. static MODEL_FILENAME: string;
  47960. /**
  47961. * Creates a new ViveController from a gamepad
  47962. * @param vrGamepad the gamepad that the controller should be created from
  47963. */
  47964. constructor(vrGamepad: any);
  47965. /**
  47966. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47967. * @param scene scene in which to add meshes
  47968. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47969. */
  47970. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47971. /**
  47972. * Fired when the left button on this controller is modified
  47973. */
  47974. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47975. /**
  47976. * Fired when the right button on this controller is modified
  47977. */
  47978. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47979. /**
  47980. * Fired when the menu button on this controller is modified
  47981. */
  47982. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47983. /**
  47984. * Called once for each button that changed state since the last frame
  47985. * Vive mapping:
  47986. * 0: touchpad
  47987. * 1: trigger
  47988. * 2: left AND right buttons
  47989. * 3: menu button
  47990. * @param buttonIdx Which button index changed
  47991. * @param state New state of the button
  47992. * @param changes Which properties on the state changed since last frame
  47993. */
  47994. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47995. }
  47996. }
  47997. declare module BABYLON {
  47998. /**
  47999. * Defines the WindowsMotionController object that the state of the windows motion controller
  48000. */
  48001. export class WindowsMotionController extends WebVRController {
  48002. /**
  48003. * The base url used to load the left and right controller models
  48004. */
  48005. static MODEL_BASE_URL: string;
  48006. /**
  48007. * The name of the left controller model file
  48008. */
  48009. static MODEL_LEFT_FILENAME: string;
  48010. /**
  48011. * The name of the right controller model file
  48012. */
  48013. static MODEL_RIGHT_FILENAME: string;
  48014. /**
  48015. * The controller name prefix for this controller type
  48016. */
  48017. static readonly GAMEPAD_ID_PREFIX: string;
  48018. /**
  48019. * The controller id pattern for this controller type
  48020. */
  48021. private static readonly GAMEPAD_ID_PATTERN;
  48022. private _loadedMeshInfo;
  48023. protected readonly _mapping: {
  48024. buttons: string[];
  48025. buttonMeshNames: {
  48026. 'trigger': string;
  48027. 'menu': string;
  48028. 'grip': string;
  48029. 'thumbstick': string;
  48030. 'trackpad': string;
  48031. };
  48032. buttonObservableNames: {
  48033. 'trigger': string;
  48034. 'menu': string;
  48035. 'grip': string;
  48036. 'thumbstick': string;
  48037. 'trackpad': string;
  48038. };
  48039. axisMeshNames: string[];
  48040. pointingPoseMeshName: string;
  48041. };
  48042. /**
  48043. * Fired when the trackpad on this controller is clicked
  48044. */
  48045. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48046. /**
  48047. * Fired when the trackpad on this controller is modified
  48048. */
  48049. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48050. /**
  48051. * The current x and y values of this controller's trackpad
  48052. */
  48053. trackpad: StickValues;
  48054. /**
  48055. * Creates a new WindowsMotionController from a gamepad
  48056. * @param vrGamepad the gamepad that the controller should be created from
  48057. */
  48058. constructor(vrGamepad: any);
  48059. /**
  48060. * Fired when the trigger on this controller is modified
  48061. */
  48062. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48063. /**
  48064. * Fired when the menu button on this controller is modified
  48065. */
  48066. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48067. /**
  48068. * Fired when the grip button on this controller is modified
  48069. */
  48070. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48071. /**
  48072. * Fired when the thumbstick button on this controller is modified
  48073. */
  48074. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48075. /**
  48076. * Fired when the touchpad button on this controller is modified
  48077. */
  48078. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48079. /**
  48080. * Fired when the touchpad values on this controller are modified
  48081. */
  48082. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48083. protected _updateTrackpad(): void;
  48084. /**
  48085. * Called once per frame by the engine.
  48086. */
  48087. update(): void;
  48088. /**
  48089. * Called once for each button that changed state since the last frame
  48090. * @param buttonIdx Which button index changed
  48091. * @param state New state of the button
  48092. * @param changes Which properties on the state changed since last frame
  48093. */
  48094. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48095. /**
  48096. * Moves the buttons on the controller mesh based on their current state
  48097. * @param buttonName the name of the button to move
  48098. * @param buttonValue the value of the button which determines the buttons new position
  48099. */
  48100. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48101. /**
  48102. * Moves the axis on the controller mesh based on its current state
  48103. * @param axis the index of the axis
  48104. * @param axisValue the value of the axis which determines the meshes new position
  48105. * @hidden
  48106. */
  48107. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48108. /**
  48109. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48110. * @param scene scene in which to add meshes
  48111. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48112. */
  48113. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48114. /**
  48115. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48116. * can be transformed by button presses and axes values, based on this._mapping.
  48117. *
  48118. * @param scene scene in which the meshes exist
  48119. * @param meshes list of meshes that make up the controller model to process
  48120. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48121. */
  48122. private processModel;
  48123. private createMeshInfo;
  48124. /**
  48125. * Gets the ray of the controller in the direction the controller is pointing
  48126. * @param length the length the resulting ray should be
  48127. * @returns a ray in the direction the controller is pointing
  48128. */
  48129. getForwardRay(length?: number): Ray;
  48130. /**
  48131. * Disposes of the controller
  48132. */
  48133. dispose(): void;
  48134. }
  48135. /**
  48136. * This class represents a new windows motion controller in XR.
  48137. */
  48138. export class XRWindowsMotionController extends WindowsMotionController {
  48139. /**
  48140. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48141. */
  48142. protected readonly _mapping: {
  48143. buttons: string[];
  48144. buttonMeshNames: {
  48145. 'trigger': string;
  48146. 'menu': string;
  48147. 'grip': string;
  48148. 'thumbstick': string;
  48149. 'trackpad': string;
  48150. };
  48151. buttonObservableNames: {
  48152. 'trigger': string;
  48153. 'menu': string;
  48154. 'grip': string;
  48155. 'thumbstick': string;
  48156. 'trackpad': string;
  48157. };
  48158. axisMeshNames: string[];
  48159. pointingPoseMeshName: string;
  48160. };
  48161. /**
  48162. * Construct a new XR-Based windows motion controller
  48163. *
  48164. * @param gamepadInfo the gamepad object from the browser
  48165. */
  48166. constructor(gamepadInfo: any);
  48167. /**
  48168. * holds the thumbstick values (X,Y)
  48169. */
  48170. thumbstickValues: StickValues;
  48171. /**
  48172. * Fired when the thumbstick on this controller is clicked
  48173. */
  48174. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48175. /**
  48176. * Fired when the thumbstick on this controller is modified
  48177. */
  48178. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48179. /**
  48180. * Fired when the touchpad button on this controller is modified
  48181. */
  48182. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48183. /**
  48184. * Fired when the touchpad values on this controller are modified
  48185. */
  48186. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48187. /**
  48188. * Fired when the thumbstick button on this controller is modified
  48189. * here to prevent breaking changes
  48190. */
  48191. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48192. /**
  48193. * updating the thumbstick(!) and not the trackpad.
  48194. * This is named this way due to the difference between WebVR and XR and to avoid
  48195. * changing the parent class.
  48196. */
  48197. protected _updateTrackpad(): void;
  48198. /**
  48199. * Disposes the class with joy
  48200. */
  48201. dispose(): void;
  48202. }
  48203. }
  48204. declare module BABYLON {
  48205. /**
  48206. * Class containing static functions to help procedurally build meshes
  48207. */
  48208. export class PolyhedronBuilder {
  48209. /**
  48210. * Creates a polyhedron mesh
  48211. * * 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
  48212. * * The parameter `size` (positive float, default 1) sets the polygon size
  48213. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48214. * * 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`
  48215. * * 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
  48216. * * 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)`)
  48217. * * 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
  48218. * * 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
  48219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48220. * * 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
  48221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48222. * @param name defines the name of the mesh
  48223. * @param options defines the options used to create the mesh
  48224. * @param scene defines the hosting scene
  48225. * @returns the polyhedron mesh
  48226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48227. */
  48228. static CreatePolyhedron(name: string, options: {
  48229. type?: number;
  48230. size?: number;
  48231. sizeX?: number;
  48232. sizeY?: number;
  48233. sizeZ?: number;
  48234. custom?: any;
  48235. faceUV?: Vector4[];
  48236. faceColors?: Color4[];
  48237. flat?: boolean;
  48238. updatable?: boolean;
  48239. sideOrientation?: number;
  48240. frontUVs?: Vector4;
  48241. backUVs?: Vector4;
  48242. }, scene?: Nullable<Scene>): Mesh;
  48243. }
  48244. }
  48245. declare module BABYLON {
  48246. /**
  48247. * Gizmo that enables scaling a mesh along 3 axis
  48248. */
  48249. export class ScaleGizmo extends Gizmo {
  48250. /**
  48251. * Internal gizmo used for interactions on the x axis
  48252. */
  48253. xGizmo: AxisScaleGizmo;
  48254. /**
  48255. * Internal gizmo used for interactions on the y axis
  48256. */
  48257. yGizmo: AxisScaleGizmo;
  48258. /**
  48259. * Internal gizmo used for interactions on the z axis
  48260. */
  48261. zGizmo: AxisScaleGizmo;
  48262. /**
  48263. * Internal gizmo used to scale all axis equally
  48264. */
  48265. uniformScaleGizmo: AxisScaleGizmo;
  48266. private _meshAttached;
  48267. private _updateGizmoRotationToMatchAttachedMesh;
  48268. private _snapDistance;
  48269. private _scaleRatio;
  48270. private _uniformScalingMesh;
  48271. private _octahedron;
  48272. private _sensitivity;
  48273. /** Fires an event when any of it's sub gizmos are dragged */
  48274. onDragStartObservable: Observable<unknown>;
  48275. /** Fires an event when any of it's sub gizmos are released from dragging */
  48276. onDragEndObservable: Observable<unknown>;
  48277. get attachedMesh(): Nullable<AbstractMesh>;
  48278. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48279. /**
  48280. * Creates a ScaleGizmo
  48281. * @param gizmoLayer The utility layer the gizmo will be added to
  48282. */
  48283. constructor(gizmoLayer?: UtilityLayerRenderer);
  48284. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48285. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48286. /**
  48287. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48288. */
  48289. set snapDistance(value: number);
  48290. get snapDistance(): number;
  48291. /**
  48292. * Ratio for the scale of the gizmo (Default: 1)
  48293. */
  48294. set scaleRatio(value: number);
  48295. get scaleRatio(): number;
  48296. /**
  48297. * Sensitivity factor for dragging (Default: 1)
  48298. */
  48299. set sensitivity(value: number);
  48300. get sensitivity(): number;
  48301. /**
  48302. * Disposes of the gizmo
  48303. */
  48304. dispose(): void;
  48305. }
  48306. }
  48307. declare module BABYLON {
  48308. /**
  48309. * Single axis scale gizmo
  48310. */
  48311. export class AxisScaleGizmo extends Gizmo {
  48312. /**
  48313. * Drag behavior responsible for the gizmos dragging interactions
  48314. */
  48315. dragBehavior: PointerDragBehavior;
  48316. private _pointerObserver;
  48317. /**
  48318. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48319. */
  48320. snapDistance: number;
  48321. /**
  48322. * Event that fires each time the gizmo snaps to a new location.
  48323. * * snapDistance is the the change in distance
  48324. */
  48325. onSnapObservable: Observable<{
  48326. snapDistance: number;
  48327. }>;
  48328. /**
  48329. * If the scaling operation should be done on all axis (default: false)
  48330. */
  48331. uniformScaling: boolean;
  48332. /**
  48333. * Custom sensitivity value for the drag strength
  48334. */
  48335. sensitivity: number;
  48336. private _isEnabled;
  48337. private _parent;
  48338. private _arrow;
  48339. private _coloredMaterial;
  48340. private _hoverMaterial;
  48341. /**
  48342. * Creates an AxisScaleGizmo
  48343. * @param gizmoLayer The utility layer the gizmo will be added to
  48344. * @param dragAxis The axis which the gizmo will be able to scale on
  48345. * @param color The color of the gizmo
  48346. */
  48347. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48348. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48349. /**
  48350. * If the gizmo is enabled
  48351. */
  48352. set isEnabled(value: boolean);
  48353. get isEnabled(): boolean;
  48354. /**
  48355. * Disposes of the gizmo
  48356. */
  48357. dispose(): void;
  48358. /**
  48359. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48360. * @param mesh The mesh to replace the default mesh of the gizmo
  48361. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48362. */
  48363. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48364. }
  48365. }
  48366. declare module BABYLON {
  48367. /**
  48368. * Bounding box gizmo
  48369. */
  48370. export class BoundingBoxGizmo extends Gizmo {
  48371. private _lineBoundingBox;
  48372. private _rotateSpheresParent;
  48373. private _scaleBoxesParent;
  48374. private _boundingDimensions;
  48375. private _renderObserver;
  48376. private _pointerObserver;
  48377. private _scaleDragSpeed;
  48378. private _tmpQuaternion;
  48379. private _tmpVector;
  48380. private _tmpRotationMatrix;
  48381. /**
  48382. * 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)
  48383. */
  48384. ignoreChildren: boolean;
  48385. /**
  48386. * 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)
  48387. */
  48388. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48389. /**
  48390. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48391. */
  48392. rotationSphereSize: number;
  48393. /**
  48394. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48395. */
  48396. scaleBoxSize: number;
  48397. /**
  48398. * 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)
  48399. */
  48400. fixedDragMeshScreenSize: boolean;
  48401. /**
  48402. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48403. */
  48404. fixedDragMeshScreenSizeDistanceFactor: number;
  48405. /**
  48406. * Fired when a rotation sphere or scale box is dragged
  48407. */
  48408. onDragStartObservable: Observable<{}>;
  48409. /**
  48410. * Fired when a scale box is dragged
  48411. */
  48412. onScaleBoxDragObservable: Observable<{}>;
  48413. /**
  48414. * Fired when a scale box drag is ended
  48415. */
  48416. onScaleBoxDragEndObservable: Observable<{}>;
  48417. /**
  48418. * Fired when a rotation sphere is dragged
  48419. */
  48420. onRotationSphereDragObservable: Observable<{}>;
  48421. /**
  48422. * Fired when a rotation sphere drag is ended
  48423. */
  48424. onRotationSphereDragEndObservable: Observable<{}>;
  48425. /**
  48426. * 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)
  48427. */
  48428. scalePivot: Nullable<Vector3>;
  48429. /**
  48430. * Mesh used as a pivot to rotate the attached mesh
  48431. */
  48432. private _anchorMesh;
  48433. private _existingMeshScale;
  48434. private _dragMesh;
  48435. private pointerDragBehavior;
  48436. private coloredMaterial;
  48437. private hoverColoredMaterial;
  48438. /**
  48439. * Sets the color of the bounding box gizmo
  48440. * @param color the color to set
  48441. */
  48442. setColor(color: Color3): void;
  48443. /**
  48444. * Creates an BoundingBoxGizmo
  48445. * @param gizmoLayer The utility layer the gizmo will be added to
  48446. * @param color The color of the gizmo
  48447. */
  48448. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48449. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48450. private _selectNode;
  48451. /**
  48452. * Updates the bounding box information for the Gizmo
  48453. */
  48454. updateBoundingBox(): void;
  48455. private _updateRotationSpheres;
  48456. private _updateScaleBoxes;
  48457. /**
  48458. * Enables rotation on the specified axis and disables rotation on the others
  48459. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48460. */
  48461. setEnabledRotationAxis(axis: string): void;
  48462. /**
  48463. * Enables/disables scaling
  48464. * @param enable if scaling should be enabled
  48465. */
  48466. setEnabledScaling(enable: boolean): void;
  48467. private _updateDummy;
  48468. /**
  48469. * Enables a pointer drag behavior on the bounding box of the gizmo
  48470. */
  48471. enableDragBehavior(): void;
  48472. /**
  48473. * Disposes of the gizmo
  48474. */
  48475. dispose(): void;
  48476. /**
  48477. * 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)
  48478. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48479. * @returns the bounding box mesh with the passed in mesh as a child
  48480. */
  48481. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48482. /**
  48483. * CustomMeshes are not supported by this gizmo
  48484. * @param mesh The mesh to replace the default mesh of the gizmo
  48485. */
  48486. setCustomMesh(mesh: Mesh): void;
  48487. }
  48488. }
  48489. declare module BABYLON {
  48490. /**
  48491. * Single plane rotation gizmo
  48492. */
  48493. export class PlaneRotationGizmo extends Gizmo {
  48494. /**
  48495. * Drag behavior responsible for the gizmos dragging interactions
  48496. */
  48497. dragBehavior: PointerDragBehavior;
  48498. private _pointerObserver;
  48499. /**
  48500. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48501. */
  48502. snapDistance: number;
  48503. /**
  48504. * Event that fires each time the gizmo snaps to a new location.
  48505. * * snapDistance is the the change in distance
  48506. */
  48507. onSnapObservable: Observable<{
  48508. snapDistance: number;
  48509. }>;
  48510. private _isEnabled;
  48511. private _parent;
  48512. /**
  48513. * Creates a PlaneRotationGizmo
  48514. * @param gizmoLayer The utility layer the gizmo will be added to
  48515. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48516. * @param color The color of the gizmo
  48517. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48518. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48519. */
  48520. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48521. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48522. /**
  48523. * If the gizmo is enabled
  48524. */
  48525. set isEnabled(value: boolean);
  48526. get isEnabled(): boolean;
  48527. /**
  48528. * Disposes of the gizmo
  48529. */
  48530. dispose(): void;
  48531. }
  48532. }
  48533. declare module BABYLON {
  48534. /**
  48535. * Gizmo that enables rotating a mesh along 3 axis
  48536. */
  48537. export class RotationGizmo extends Gizmo {
  48538. /**
  48539. * Internal gizmo used for interactions on the x axis
  48540. */
  48541. xGizmo: PlaneRotationGizmo;
  48542. /**
  48543. * Internal gizmo used for interactions on the y axis
  48544. */
  48545. yGizmo: PlaneRotationGizmo;
  48546. /**
  48547. * Internal gizmo used for interactions on the z axis
  48548. */
  48549. zGizmo: PlaneRotationGizmo;
  48550. /** Fires an event when any of it's sub gizmos are dragged */
  48551. onDragStartObservable: Observable<unknown>;
  48552. /** Fires an event when any of it's sub gizmos are released from dragging */
  48553. onDragEndObservable: Observable<unknown>;
  48554. private _meshAttached;
  48555. get attachedMesh(): Nullable<AbstractMesh>;
  48556. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48557. /**
  48558. * Creates a RotationGizmo
  48559. * @param gizmoLayer The utility layer the gizmo will be added to
  48560. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48561. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48562. */
  48563. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48564. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48565. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48566. /**
  48567. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48568. */
  48569. set snapDistance(value: number);
  48570. get snapDistance(): number;
  48571. /**
  48572. * Ratio for the scale of the gizmo (Default: 1)
  48573. */
  48574. set scaleRatio(value: number);
  48575. get scaleRatio(): number;
  48576. /**
  48577. * Disposes of the gizmo
  48578. */
  48579. dispose(): void;
  48580. /**
  48581. * CustomMeshes are not supported by this gizmo
  48582. * @param mesh The mesh to replace the default mesh of the gizmo
  48583. */
  48584. setCustomMesh(mesh: Mesh): void;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48590. */
  48591. export class GizmoManager implements IDisposable {
  48592. private scene;
  48593. /**
  48594. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48595. */
  48596. gizmos: {
  48597. positionGizmo: Nullable<PositionGizmo>;
  48598. rotationGizmo: Nullable<RotationGizmo>;
  48599. scaleGizmo: Nullable<ScaleGizmo>;
  48600. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48601. };
  48602. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48603. clearGizmoOnEmptyPointerEvent: boolean;
  48604. /** Fires an event when the manager is attached to a mesh */
  48605. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48606. private _gizmosEnabled;
  48607. private _pointerObserver;
  48608. private _attachedMesh;
  48609. private _boundingBoxColor;
  48610. private _defaultUtilityLayer;
  48611. private _defaultKeepDepthUtilityLayer;
  48612. /**
  48613. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48614. */
  48615. boundingBoxDragBehavior: SixDofDragBehavior;
  48616. /**
  48617. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48618. */
  48619. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48620. /**
  48621. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48622. */
  48623. usePointerToAttachGizmos: boolean;
  48624. /**
  48625. * Utility layer that the bounding box gizmo belongs to
  48626. */
  48627. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48628. /**
  48629. * Utility layer that all gizmos besides bounding box belong to
  48630. */
  48631. get utilityLayer(): UtilityLayerRenderer;
  48632. /**
  48633. * Instatiates a gizmo manager
  48634. * @param scene the scene to overlay the gizmos on top of
  48635. */
  48636. constructor(scene: Scene);
  48637. /**
  48638. * Attaches a set of gizmos to the specified mesh
  48639. * @param mesh The mesh the gizmo's should be attached to
  48640. */
  48641. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48642. /**
  48643. * If the position gizmo is enabled
  48644. */
  48645. set positionGizmoEnabled(value: boolean);
  48646. get positionGizmoEnabled(): boolean;
  48647. /**
  48648. * If the rotation gizmo is enabled
  48649. */
  48650. set rotationGizmoEnabled(value: boolean);
  48651. get rotationGizmoEnabled(): boolean;
  48652. /**
  48653. * If the scale gizmo is enabled
  48654. */
  48655. set scaleGizmoEnabled(value: boolean);
  48656. get scaleGizmoEnabled(): boolean;
  48657. /**
  48658. * If the boundingBox gizmo is enabled
  48659. */
  48660. set boundingBoxGizmoEnabled(value: boolean);
  48661. get boundingBoxGizmoEnabled(): boolean;
  48662. /**
  48663. * Disposes of the gizmo manager
  48664. */
  48665. dispose(): void;
  48666. }
  48667. }
  48668. declare module BABYLON {
  48669. /**
  48670. * A directional light is defined by a direction (what a surprise!).
  48671. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48672. * 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.
  48673. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48674. */
  48675. export class DirectionalLight extends ShadowLight {
  48676. private _shadowFrustumSize;
  48677. /**
  48678. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48679. */
  48680. get shadowFrustumSize(): number;
  48681. /**
  48682. * Specifies a fix frustum size for the shadow generation.
  48683. */
  48684. set shadowFrustumSize(value: number);
  48685. private _shadowOrthoScale;
  48686. /**
  48687. * Gets the shadow projection scale against the optimal computed one.
  48688. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48689. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48690. */
  48691. get shadowOrthoScale(): number;
  48692. /**
  48693. * Sets the shadow projection scale against the optimal computed one.
  48694. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48695. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48696. */
  48697. set shadowOrthoScale(value: number);
  48698. /**
  48699. * Automatically compute the projection matrix to best fit (including all the casters)
  48700. * on each frame.
  48701. */
  48702. autoUpdateExtends: boolean;
  48703. /**
  48704. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48705. * on each frame. autoUpdateExtends must be set to true for this to work
  48706. */
  48707. autoCalcShadowZBounds: boolean;
  48708. private _orthoLeft;
  48709. private _orthoRight;
  48710. private _orthoTop;
  48711. private _orthoBottom;
  48712. /**
  48713. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48714. * The directional light is emitted from everywhere in the given direction.
  48715. * It can cast shadows.
  48716. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48717. * @param name The friendly name of the light
  48718. * @param direction The direction of the light
  48719. * @param scene The scene the light belongs to
  48720. */
  48721. constructor(name: string, direction: Vector3, scene: Scene);
  48722. /**
  48723. * Returns the string "DirectionalLight".
  48724. * @return The class name
  48725. */
  48726. getClassName(): string;
  48727. /**
  48728. * Returns the integer 1.
  48729. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48730. */
  48731. getTypeID(): number;
  48732. /**
  48733. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48734. * Returns the DirectionalLight Shadow projection matrix.
  48735. */
  48736. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48737. /**
  48738. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48739. * Returns the DirectionalLight Shadow projection matrix.
  48740. */
  48741. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48742. /**
  48743. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48744. * Returns the DirectionalLight Shadow projection matrix.
  48745. */
  48746. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48747. protected _buildUniformLayout(): void;
  48748. /**
  48749. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48750. * @param effect The effect to update
  48751. * @param lightIndex The index of the light in the effect to update
  48752. * @returns The directional light
  48753. */
  48754. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48755. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48756. /**
  48757. * Gets the minZ used for shadow according to both the scene and the light.
  48758. *
  48759. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48760. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48761. * @param activeCamera The camera we are returning the min for
  48762. * @returns the depth min z
  48763. */
  48764. getDepthMinZ(activeCamera: Camera): number;
  48765. /**
  48766. * Gets the maxZ used for shadow according to both the scene and the light.
  48767. *
  48768. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48769. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48770. * @param activeCamera The camera we are returning the max for
  48771. * @returns the depth max z
  48772. */
  48773. getDepthMaxZ(activeCamera: Camera): number;
  48774. /**
  48775. * Prepares the list of defines specific to the light type.
  48776. * @param defines the list of defines
  48777. * @param lightIndex defines the index of the light for the effect
  48778. */
  48779. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48780. }
  48781. }
  48782. declare module BABYLON {
  48783. /**
  48784. * Class containing static functions to help procedurally build meshes
  48785. */
  48786. export class HemisphereBuilder {
  48787. /**
  48788. * Creates a hemisphere mesh
  48789. * @param name defines the name of the mesh
  48790. * @param options defines the options used to create the mesh
  48791. * @param scene defines the hosting scene
  48792. * @returns the hemisphere mesh
  48793. */
  48794. static CreateHemisphere(name: string, options: {
  48795. segments?: number;
  48796. diameter?: number;
  48797. sideOrientation?: number;
  48798. }, scene: any): Mesh;
  48799. }
  48800. }
  48801. declare module BABYLON {
  48802. /**
  48803. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48804. * These values define a cone of light starting from the position, emitting toward the direction.
  48805. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48806. * and the exponent defines the speed of the decay of the light with distance (reach).
  48807. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48808. */
  48809. export class SpotLight extends ShadowLight {
  48810. private _angle;
  48811. private _innerAngle;
  48812. private _cosHalfAngle;
  48813. private _lightAngleScale;
  48814. private _lightAngleOffset;
  48815. /**
  48816. * Gets the cone angle of the spot light in Radians.
  48817. */
  48818. get angle(): number;
  48819. /**
  48820. * Sets the cone angle of the spot light in Radians.
  48821. */
  48822. set angle(value: number);
  48823. /**
  48824. * Only used in gltf falloff mode, this defines the angle where
  48825. * the directional falloff will start before cutting at angle which could be seen
  48826. * as outer angle.
  48827. */
  48828. get innerAngle(): number;
  48829. /**
  48830. * Only used in gltf falloff mode, this defines the angle where
  48831. * the directional falloff will start before cutting at angle which could be seen
  48832. * as outer angle.
  48833. */
  48834. set innerAngle(value: number);
  48835. private _shadowAngleScale;
  48836. /**
  48837. * Allows scaling the angle of the light for shadow generation only.
  48838. */
  48839. get shadowAngleScale(): number;
  48840. /**
  48841. * Allows scaling the angle of the light for shadow generation only.
  48842. */
  48843. set shadowAngleScale(value: number);
  48844. /**
  48845. * The light decay speed with the distance from the emission spot.
  48846. */
  48847. exponent: number;
  48848. private _projectionTextureMatrix;
  48849. /**
  48850. * Allows reading the projecton texture
  48851. */
  48852. get projectionTextureMatrix(): Matrix;
  48853. protected _projectionTextureLightNear: number;
  48854. /**
  48855. * Gets the near clip of the Spotlight for texture projection.
  48856. */
  48857. get projectionTextureLightNear(): number;
  48858. /**
  48859. * Sets the near clip of the Spotlight for texture projection.
  48860. */
  48861. set projectionTextureLightNear(value: number);
  48862. protected _projectionTextureLightFar: number;
  48863. /**
  48864. * Gets the far clip of the Spotlight for texture projection.
  48865. */
  48866. get projectionTextureLightFar(): number;
  48867. /**
  48868. * Sets the far clip of the Spotlight for texture projection.
  48869. */
  48870. set projectionTextureLightFar(value: number);
  48871. protected _projectionTextureUpDirection: Vector3;
  48872. /**
  48873. * Gets the Up vector of the Spotlight for texture projection.
  48874. */
  48875. get projectionTextureUpDirection(): Vector3;
  48876. /**
  48877. * Sets the Up vector of the Spotlight for texture projection.
  48878. */
  48879. set projectionTextureUpDirection(value: Vector3);
  48880. private _projectionTexture;
  48881. /**
  48882. * Gets the projection texture of the light.
  48883. */
  48884. get projectionTexture(): Nullable<BaseTexture>;
  48885. /**
  48886. * Sets the projection texture of the light.
  48887. */
  48888. set projectionTexture(value: Nullable<BaseTexture>);
  48889. private _projectionTextureViewLightDirty;
  48890. private _projectionTextureProjectionLightDirty;
  48891. private _projectionTextureDirty;
  48892. private _projectionTextureViewTargetVector;
  48893. private _projectionTextureViewLightMatrix;
  48894. private _projectionTextureProjectionLightMatrix;
  48895. private _projectionTextureScalingMatrix;
  48896. /**
  48897. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48898. * It can cast shadows.
  48899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48900. * @param name The light friendly name
  48901. * @param position The position of the spot light in the scene
  48902. * @param direction The direction of the light in the scene
  48903. * @param angle The cone angle of the light in Radians
  48904. * @param exponent The light decay speed with the distance from the emission spot
  48905. * @param scene The scene the lights belongs to
  48906. */
  48907. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48908. /**
  48909. * Returns the string "SpotLight".
  48910. * @returns the class name
  48911. */
  48912. getClassName(): string;
  48913. /**
  48914. * Returns the integer 2.
  48915. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48916. */
  48917. getTypeID(): number;
  48918. /**
  48919. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48920. */
  48921. protected _setDirection(value: Vector3): void;
  48922. /**
  48923. * Overrides the position setter to recompute the projection texture view light Matrix.
  48924. */
  48925. protected _setPosition(value: Vector3): void;
  48926. /**
  48927. * 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.
  48928. * Returns the SpotLight.
  48929. */
  48930. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48931. protected _computeProjectionTextureViewLightMatrix(): void;
  48932. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48933. /**
  48934. * Main function for light texture projection matrix computing.
  48935. */
  48936. protected _computeProjectionTextureMatrix(): void;
  48937. protected _buildUniformLayout(): void;
  48938. private _computeAngleValues;
  48939. /**
  48940. * Sets the passed Effect "effect" with the Light textures.
  48941. * @param effect The effect to update
  48942. * @param lightIndex The index of the light in the effect to update
  48943. * @returns The light
  48944. */
  48945. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48946. /**
  48947. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48948. * @param effect The effect to update
  48949. * @param lightIndex The index of the light in the effect to update
  48950. * @returns The spot light
  48951. */
  48952. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48953. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48954. /**
  48955. * Disposes the light and the associated resources.
  48956. */
  48957. dispose(): void;
  48958. /**
  48959. * Prepares the list of defines specific to the light type.
  48960. * @param defines the list of defines
  48961. * @param lightIndex defines the index of the light for the effect
  48962. */
  48963. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48964. }
  48965. }
  48966. declare module BABYLON {
  48967. /**
  48968. * Gizmo that enables viewing a light
  48969. */
  48970. export class LightGizmo extends Gizmo {
  48971. private _lightMesh;
  48972. private _material;
  48973. private _cachedPosition;
  48974. private _cachedForward;
  48975. private _attachedMeshParent;
  48976. /**
  48977. * Creates a LightGizmo
  48978. * @param gizmoLayer The utility layer the gizmo will be added to
  48979. */
  48980. constructor(gizmoLayer?: UtilityLayerRenderer);
  48981. private _light;
  48982. /**
  48983. * The light that the gizmo is attached to
  48984. */
  48985. set light(light: Nullable<Light>);
  48986. get light(): Nullable<Light>;
  48987. /**
  48988. * Gets the material used to render the light gizmo
  48989. */
  48990. get material(): StandardMaterial;
  48991. /**
  48992. * @hidden
  48993. * Updates the gizmo to match the attached mesh's position/rotation
  48994. */
  48995. protected _update(): void;
  48996. private static _Scale;
  48997. /**
  48998. * Creates the lines for a light mesh
  48999. */
  49000. private static _CreateLightLines;
  49001. /**
  49002. * Disposes of the light gizmo
  49003. */
  49004. dispose(): void;
  49005. private static _CreateHemisphericLightMesh;
  49006. private static _CreatePointLightMesh;
  49007. private static _CreateSpotLightMesh;
  49008. private static _CreateDirectionalLightMesh;
  49009. }
  49010. }
  49011. declare module BABYLON {
  49012. /** @hidden */
  49013. export var backgroundFragmentDeclaration: {
  49014. name: string;
  49015. shader: string;
  49016. };
  49017. }
  49018. declare module BABYLON {
  49019. /** @hidden */
  49020. export var backgroundUboDeclaration: {
  49021. name: string;
  49022. shader: string;
  49023. };
  49024. }
  49025. declare module BABYLON {
  49026. /** @hidden */
  49027. export var backgroundPixelShader: {
  49028. name: string;
  49029. shader: string;
  49030. };
  49031. }
  49032. declare module BABYLON {
  49033. /** @hidden */
  49034. export var backgroundVertexDeclaration: {
  49035. name: string;
  49036. shader: string;
  49037. };
  49038. }
  49039. declare module BABYLON {
  49040. /** @hidden */
  49041. export var backgroundVertexShader: {
  49042. name: string;
  49043. shader: string;
  49044. };
  49045. }
  49046. declare module BABYLON {
  49047. /**
  49048. * Background material used to create an efficient environement around your scene.
  49049. */
  49050. export class BackgroundMaterial extends PushMaterial {
  49051. /**
  49052. * Standard reflectance value at parallel view angle.
  49053. */
  49054. static StandardReflectance0: number;
  49055. /**
  49056. * Standard reflectance value at grazing angle.
  49057. */
  49058. static StandardReflectance90: number;
  49059. protected _primaryColor: Color3;
  49060. /**
  49061. * Key light Color (multiply against the environement texture)
  49062. */
  49063. primaryColor: Color3;
  49064. protected __perceptualColor: Nullable<Color3>;
  49065. /**
  49066. * Experimental Internal Use Only.
  49067. *
  49068. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49069. * This acts as a helper to set the primary color to a more "human friendly" value.
  49070. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49071. * output color as close as possible from the chosen value.
  49072. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49073. * part of lighting setup.)
  49074. */
  49075. get _perceptualColor(): Nullable<Color3>;
  49076. set _perceptualColor(value: Nullable<Color3>);
  49077. protected _primaryColorShadowLevel: float;
  49078. /**
  49079. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49080. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49081. */
  49082. get primaryColorShadowLevel(): float;
  49083. set primaryColorShadowLevel(value: float);
  49084. protected _primaryColorHighlightLevel: float;
  49085. /**
  49086. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49087. * The primary color is used at the level chosen to define what the white area would look.
  49088. */
  49089. get primaryColorHighlightLevel(): float;
  49090. set primaryColorHighlightLevel(value: float);
  49091. protected _reflectionTexture: Nullable<BaseTexture>;
  49092. /**
  49093. * Reflection Texture used in the material.
  49094. * Should be author in a specific way for the best result (refer to the documentation).
  49095. */
  49096. reflectionTexture: Nullable<BaseTexture>;
  49097. protected _reflectionBlur: float;
  49098. /**
  49099. * Reflection Texture level of blur.
  49100. *
  49101. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49102. * texture twice.
  49103. */
  49104. reflectionBlur: float;
  49105. protected _diffuseTexture: Nullable<BaseTexture>;
  49106. /**
  49107. * Diffuse Texture used in the material.
  49108. * Should be author in a specific way for the best result (refer to the documentation).
  49109. */
  49110. diffuseTexture: Nullable<BaseTexture>;
  49111. protected _shadowLights: Nullable<IShadowLight[]>;
  49112. /**
  49113. * Specify the list of lights casting shadow on the material.
  49114. * All scene shadow lights will be included if null.
  49115. */
  49116. shadowLights: Nullable<IShadowLight[]>;
  49117. protected _shadowLevel: float;
  49118. /**
  49119. * Helps adjusting the shadow to a softer level if required.
  49120. * 0 means black shadows and 1 means no shadows.
  49121. */
  49122. shadowLevel: float;
  49123. protected _sceneCenter: Vector3;
  49124. /**
  49125. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49126. * It is usually zero but might be interesting to modify according to your setup.
  49127. */
  49128. sceneCenter: Vector3;
  49129. protected _opacityFresnel: boolean;
  49130. /**
  49131. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49132. * This helps ensuring a nice transition when the camera goes under the ground.
  49133. */
  49134. opacityFresnel: boolean;
  49135. protected _reflectionFresnel: boolean;
  49136. /**
  49137. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49138. * This helps adding a mirror texture on the ground.
  49139. */
  49140. reflectionFresnel: boolean;
  49141. protected _reflectionFalloffDistance: number;
  49142. /**
  49143. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49144. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49145. */
  49146. reflectionFalloffDistance: number;
  49147. protected _reflectionAmount: number;
  49148. /**
  49149. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49150. */
  49151. reflectionAmount: number;
  49152. protected _reflectionReflectance0: number;
  49153. /**
  49154. * This specifies the weight of the reflection at grazing angle.
  49155. */
  49156. reflectionReflectance0: number;
  49157. protected _reflectionReflectance90: number;
  49158. /**
  49159. * This specifies the weight of the reflection at a perpendicular point of view.
  49160. */
  49161. reflectionReflectance90: number;
  49162. /**
  49163. * Sets the reflection reflectance fresnel values according to the default standard
  49164. * empirically know to work well :-)
  49165. */
  49166. set reflectionStandardFresnelWeight(value: number);
  49167. protected _useRGBColor: boolean;
  49168. /**
  49169. * Helps to directly use the maps channels instead of their level.
  49170. */
  49171. useRGBColor: boolean;
  49172. protected _enableNoise: boolean;
  49173. /**
  49174. * This helps reducing the banding effect that could occur on the background.
  49175. */
  49176. enableNoise: boolean;
  49177. /**
  49178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49179. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49180. * Recommended to be keep at 1.0 except for special cases.
  49181. */
  49182. get fovMultiplier(): number;
  49183. set fovMultiplier(value: number);
  49184. private _fovMultiplier;
  49185. /**
  49186. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49187. */
  49188. useEquirectangularFOV: boolean;
  49189. private _maxSimultaneousLights;
  49190. /**
  49191. * Number of Simultaneous lights allowed on the material.
  49192. */
  49193. maxSimultaneousLights: int;
  49194. /**
  49195. * Default configuration related to image processing available in the Background Material.
  49196. */
  49197. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49198. /**
  49199. * Keep track of the image processing observer to allow dispose and replace.
  49200. */
  49201. private _imageProcessingObserver;
  49202. /**
  49203. * Attaches a new image processing configuration to the PBR Material.
  49204. * @param configuration (if null the scene configuration will be use)
  49205. */
  49206. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49207. /**
  49208. * Gets the image processing configuration used either in this material.
  49209. */
  49210. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49211. /**
  49212. * Sets the Default image processing configuration used either in the this material.
  49213. *
  49214. * If sets to null, the scene one is in use.
  49215. */
  49216. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49217. /**
  49218. * Gets wether the color curves effect is enabled.
  49219. */
  49220. get cameraColorCurvesEnabled(): boolean;
  49221. /**
  49222. * Sets wether the color curves effect is enabled.
  49223. */
  49224. set cameraColorCurvesEnabled(value: boolean);
  49225. /**
  49226. * Gets wether the color grading effect is enabled.
  49227. */
  49228. get cameraColorGradingEnabled(): boolean;
  49229. /**
  49230. * Gets wether the color grading effect is enabled.
  49231. */
  49232. set cameraColorGradingEnabled(value: boolean);
  49233. /**
  49234. * Gets wether tonemapping is enabled or not.
  49235. */
  49236. get cameraToneMappingEnabled(): boolean;
  49237. /**
  49238. * Sets wether tonemapping is enabled or not
  49239. */
  49240. set cameraToneMappingEnabled(value: boolean);
  49241. /**
  49242. * The camera exposure used on this material.
  49243. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49244. * This corresponds to a photographic exposure.
  49245. */
  49246. get cameraExposure(): float;
  49247. /**
  49248. * The camera exposure used on this material.
  49249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49250. * This corresponds to a photographic exposure.
  49251. */
  49252. set cameraExposure(value: float);
  49253. /**
  49254. * Gets The camera contrast used on this material.
  49255. */
  49256. get cameraContrast(): float;
  49257. /**
  49258. * Sets The camera contrast used on this material.
  49259. */
  49260. set cameraContrast(value: float);
  49261. /**
  49262. * Gets the Color Grading 2D Lookup Texture.
  49263. */
  49264. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49265. /**
  49266. * Sets the Color Grading 2D Lookup Texture.
  49267. */
  49268. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49269. /**
  49270. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49271. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49272. * 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;
  49273. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49274. */
  49275. get cameraColorCurves(): Nullable<ColorCurves>;
  49276. /**
  49277. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49278. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49279. * 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;
  49280. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49281. */
  49282. set cameraColorCurves(value: Nullable<ColorCurves>);
  49283. /**
  49284. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49285. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49286. */
  49287. switchToBGR: boolean;
  49288. private _renderTargets;
  49289. private _reflectionControls;
  49290. private _white;
  49291. private _primaryShadowColor;
  49292. private _primaryHighlightColor;
  49293. /**
  49294. * Instantiates a Background Material in the given scene
  49295. * @param name The friendly name of the material
  49296. * @param scene The scene to add the material to
  49297. */
  49298. constructor(name: string, scene: Scene);
  49299. /**
  49300. * Gets a boolean indicating that current material needs to register RTT
  49301. */
  49302. get hasRenderTargetTextures(): boolean;
  49303. /**
  49304. * The entire material has been created in order to prevent overdraw.
  49305. * @returns false
  49306. */
  49307. needAlphaTesting(): boolean;
  49308. /**
  49309. * The entire material has been created in order to prevent overdraw.
  49310. * @returns true if blending is enable
  49311. */
  49312. needAlphaBlending(): boolean;
  49313. /**
  49314. * Checks wether the material is ready to be rendered for a given mesh.
  49315. * @param mesh The mesh to render
  49316. * @param subMesh The submesh to check against
  49317. * @param useInstances Specify wether or not the material is used with instances
  49318. * @returns true if all the dependencies are ready (Textures, Effects...)
  49319. */
  49320. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49321. /**
  49322. * Compute the primary color according to the chosen perceptual color.
  49323. */
  49324. private _computePrimaryColorFromPerceptualColor;
  49325. /**
  49326. * Compute the highlights and shadow colors according to their chosen levels.
  49327. */
  49328. private _computePrimaryColors;
  49329. /**
  49330. * Build the uniform buffer used in the material.
  49331. */
  49332. buildUniformLayout(): void;
  49333. /**
  49334. * Unbind the material.
  49335. */
  49336. unbind(): void;
  49337. /**
  49338. * Bind only the world matrix to the material.
  49339. * @param world The world matrix to bind.
  49340. */
  49341. bindOnlyWorldMatrix(world: Matrix): void;
  49342. /**
  49343. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49344. * @param world The world matrix to bind.
  49345. * @param subMesh The submesh to bind for.
  49346. */
  49347. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49348. /**
  49349. * Checks to see if a texture is used in the material.
  49350. * @param texture - Base texture to use.
  49351. * @returns - Boolean specifying if a texture is used in the material.
  49352. */
  49353. hasTexture(texture: BaseTexture): boolean;
  49354. /**
  49355. * Dispose the material.
  49356. * @param forceDisposeEffect Force disposal of the associated effect.
  49357. * @param forceDisposeTextures Force disposal of the associated textures.
  49358. */
  49359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49360. /**
  49361. * Clones the material.
  49362. * @param name The cloned name.
  49363. * @returns The cloned material.
  49364. */
  49365. clone(name: string): BackgroundMaterial;
  49366. /**
  49367. * Serializes the current material to its JSON representation.
  49368. * @returns The JSON representation.
  49369. */
  49370. serialize(): any;
  49371. /**
  49372. * Gets the class name of the material
  49373. * @returns "BackgroundMaterial"
  49374. */
  49375. getClassName(): string;
  49376. /**
  49377. * Parse a JSON input to create back a background material.
  49378. * @param source The JSON data to parse
  49379. * @param scene The scene to create the parsed material in
  49380. * @param rootUrl The root url of the assets the material depends upon
  49381. * @returns the instantiated BackgroundMaterial.
  49382. */
  49383. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49384. }
  49385. }
  49386. declare module BABYLON {
  49387. /**
  49388. * Represents the different options available during the creation of
  49389. * a Environment helper.
  49390. *
  49391. * This can control the default ground, skybox and image processing setup of your scene.
  49392. */
  49393. export interface IEnvironmentHelperOptions {
  49394. /**
  49395. * Specifies whether or not to create a ground.
  49396. * True by default.
  49397. */
  49398. createGround: boolean;
  49399. /**
  49400. * Specifies the ground size.
  49401. * 15 by default.
  49402. */
  49403. groundSize: number;
  49404. /**
  49405. * The texture used on the ground for the main color.
  49406. * Comes from the BabylonJS CDN by default.
  49407. *
  49408. * Remarks: Can be either a texture or a url.
  49409. */
  49410. groundTexture: string | BaseTexture;
  49411. /**
  49412. * The color mixed in the ground texture by default.
  49413. * BabylonJS clearColor by default.
  49414. */
  49415. groundColor: Color3;
  49416. /**
  49417. * Specifies the ground opacity.
  49418. * 1 by default.
  49419. */
  49420. groundOpacity: number;
  49421. /**
  49422. * Enables the ground to receive shadows.
  49423. * True by default.
  49424. */
  49425. enableGroundShadow: boolean;
  49426. /**
  49427. * Helps preventing the shadow to be fully black on the ground.
  49428. * 0.5 by default.
  49429. */
  49430. groundShadowLevel: number;
  49431. /**
  49432. * Creates a mirror texture attach to the ground.
  49433. * false by default.
  49434. */
  49435. enableGroundMirror: boolean;
  49436. /**
  49437. * Specifies the ground mirror size ratio.
  49438. * 0.3 by default as the default kernel is 64.
  49439. */
  49440. groundMirrorSizeRatio: number;
  49441. /**
  49442. * Specifies the ground mirror blur kernel size.
  49443. * 64 by default.
  49444. */
  49445. groundMirrorBlurKernel: number;
  49446. /**
  49447. * Specifies the ground mirror visibility amount.
  49448. * 1 by default
  49449. */
  49450. groundMirrorAmount: number;
  49451. /**
  49452. * Specifies the ground mirror reflectance weight.
  49453. * This uses the standard weight of the background material to setup the fresnel effect
  49454. * of the mirror.
  49455. * 1 by default.
  49456. */
  49457. groundMirrorFresnelWeight: number;
  49458. /**
  49459. * Specifies the ground mirror Falloff distance.
  49460. * This can helps reducing the size of the reflection.
  49461. * 0 by Default.
  49462. */
  49463. groundMirrorFallOffDistance: number;
  49464. /**
  49465. * Specifies the ground mirror texture type.
  49466. * Unsigned Int by Default.
  49467. */
  49468. groundMirrorTextureType: number;
  49469. /**
  49470. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49471. * the shown objects.
  49472. */
  49473. groundYBias: number;
  49474. /**
  49475. * Specifies whether or not to create a skybox.
  49476. * True by default.
  49477. */
  49478. createSkybox: boolean;
  49479. /**
  49480. * Specifies the skybox size.
  49481. * 20 by default.
  49482. */
  49483. skyboxSize: number;
  49484. /**
  49485. * The texture used on the skybox for the main color.
  49486. * Comes from the BabylonJS CDN by default.
  49487. *
  49488. * Remarks: Can be either a texture or a url.
  49489. */
  49490. skyboxTexture: string | BaseTexture;
  49491. /**
  49492. * The color mixed in the skybox texture by default.
  49493. * BabylonJS clearColor by default.
  49494. */
  49495. skyboxColor: Color3;
  49496. /**
  49497. * The background rotation around the Y axis of the scene.
  49498. * This helps aligning the key lights of your scene with the background.
  49499. * 0 by default.
  49500. */
  49501. backgroundYRotation: number;
  49502. /**
  49503. * Compute automatically the size of the elements to best fit with the scene.
  49504. */
  49505. sizeAuto: boolean;
  49506. /**
  49507. * Default position of the rootMesh if autoSize is not true.
  49508. */
  49509. rootPosition: Vector3;
  49510. /**
  49511. * Sets up the image processing in the scene.
  49512. * true by default.
  49513. */
  49514. setupImageProcessing: boolean;
  49515. /**
  49516. * The texture used as your environment texture in the scene.
  49517. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49518. *
  49519. * Remarks: Can be either a texture or a url.
  49520. */
  49521. environmentTexture: string | BaseTexture;
  49522. /**
  49523. * The value of the exposure to apply to the scene.
  49524. * 0.6 by default if setupImageProcessing is true.
  49525. */
  49526. cameraExposure: number;
  49527. /**
  49528. * The value of the contrast to apply to the scene.
  49529. * 1.6 by default if setupImageProcessing is true.
  49530. */
  49531. cameraContrast: number;
  49532. /**
  49533. * Specifies whether or not tonemapping should be enabled in the scene.
  49534. * true by default if setupImageProcessing is true.
  49535. */
  49536. toneMappingEnabled: boolean;
  49537. }
  49538. /**
  49539. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49540. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49541. * It also helps with the default setup of your imageProcessing configuration.
  49542. */
  49543. export class EnvironmentHelper {
  49544. /**
  49545. * Default ground texture URL.
  49546. */
  49547. private static _groundTextureCDNUrl;
  49548. /**
  49549. * Default skybox texture URL.
  49550. */
  49551. private static _skyboxTextureCDNUrl;
  49552. /**
  49553. * Default environment texture URL.
  49554. */
  49555. private static _environmentTextureCDNUrl;
  49556. /**
  49557. * Creates the default options for the helper.
  49558. */
  49559. private static _getDefaultOptions;
  49560. private _rootMesh;
  49561. /**
  49562. * Gets the root mesh created by the helper.
  49563. */
  49564. get rootMesh(): Mesh;
  49565. private _skybox;
  49566. /**
  49567. * Gets the skybox created by the helper.
  49568. */
  49569. get skybox(): Nullable<Mesh>;
  49570. private _skyboxTexture;
  49571. /**
  49572. * Gets the skybox texture created by the helper.
  49573. */
  49574. get skyboxTexture(): Nullable<BaseTexture>;
  49575. private _skyboxMaterial;
  49576. /**
  49577. * Gets the skybox material created by the helper.
  49578. */
  49579. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49580. private _ground;
  49581. /**
  49582. * Gets the ground mesh created by the helper.
  49583. */
  49584. get ground(): Nullable<Mesh>;
  49585. private _groundTexture;
  49586. /**
  49587. * Gets the ground texture created by the helper.
  49588. */
  49589. get groundTexture(): Nullable<BaseTexture>;
  49590. private _groundMirror;
  49591. /**
  49592. * Gets the ground mirror created by the helper.
  49593. */
  49594. get groundMirror(): Nullable<MirrorTexture>;
  49595. /**
  49596. * Gets the ground mirror render list to helps pushing the meshes
  49597. * you wish in the ground reflection.
  49598. */
  49599. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49600. private _groundMaterial;
  49601. /**
  49602. * Gets the ground material created by the helper.
  49603. */
  49604. get groundMaterial(): Nullable<BackgroundMaterial>;
  49605. /**
  49606. * Stores the creation options.
  49607. */
  49608. private readonly _scene;
  49609. private _options;
  49610. /**
  49611. * This observable will be notified with any error during the creation of the environment,
  49612. * mainly texture creation errors.
  49613. */
  49614. onErrorObservable: Observable<{
  49615. message?: string;
  49616. exception?: any;
  49617. }>;
  49618. /**
  49619. * constructor
  49620. * @param options Defines the options we want to customize the helper
  49621. * @param scene The scene to add the material to
  49622. */
  49623. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49624. /**
  49625. * Updates the background according to the new options
  49626. * @param options
  49627. */
  49628. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49629. /**
  49630. * Sets the primary color of all the available elements.
  49631. * @param color the main color to affect to the ground and the background
  49632. */
  49633. setMainColor(color: Color3): void;
  49634. /**
  49635. * Setup the image processing according to the specified options.
  49636. */
  49637. private _setupImageProcessing;
  49638. /**
  49639. * Setup the environment texture according to the specified options.
  49640. */
  49641. private _setupEnvironmentTexture;
  49642. /**
  49643. * Setup the background according to the specified options.
  49644. */
  49645. private _setupBackground;
  49646. /**
  49647. * Get the scene sizes according to the setup.
  49648. */
  49649. private _getSceneSize;
  49650. /**
  49651. * Setup the ground according to the specified options.
  49652. */
  49653. private _setupGround;
  49654. /**
  49655. * Setup the ground material according to the specified options.
  49656. */
  49657. private _setupGroundMaterial;
  49658. /**
  49659. * Setup the ground diffuse texture according to the specified options.
  49660. */
  49661. private _setupGroundDiffuseTexture;
  49662. /**
  49663. * Setup the ground mirror texture according to the specified options.
  49664. */
  49665. private _setupGroundMirrorTexture;
  49666. /**
  49667. * Setup the ground to receive the mirror texture.
  49668. */
  49669. private _setupMirrorInGroundMaterial;
  49670. /**
  49671. * Setup the skybox according to the specified options.
  49672. */
  49673. private _setupSkybox;
  49674. /**
  49675. * Setup the skybox material according to the specified options.
  49676. */
  49677. private _setupSkyboxMaterial;
  49678. /**
  49679. * Setup the skybox reflection texture according to the specified options.
  49680. */
  49681. private _setupSkyboxReflectionTexture;
  49682. private _errorHandler;
  49683. /**
  49684. * Dispose all the elements created by the Helper.
  49685. */
  49686. dispose(): void;
  49687. }
  49688. }
  49689. declare module BABYLON {
  49690. /**
  49691. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49692. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49693. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49695. */
  49696. export class PhotoDome extends TransformNode {
  49697. /**
  49698. * Define the image as a Monoscopic panoramic 360 image.
  49699. */
  49700. static readonly MODE_MONOSCOPIC: number;
  49701. /**
  49702. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49703. */
  49704. static readonly MODE_TOPBOTTOM: number;
  49705. /**
  49706. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49707. */
  49708. static readonly MODE_SIDEBYSIDE: number;
  49709. private _useDirectMapping;
  49710. /**
  49711. * The texture being displayed on the sphere
  49712. */
  49713. protected _photoTexture: Texture;
  49714. /**
  49715. * Gets or sets the texture being displayed on the sphere
  49716. */
  49717. get photoTexture(): Texture;
  49718. set photoTexture(value: Texture);
  49719. /**
  49720. * Observable raised when an error occured while loading the 360 image
  49721. */
  49722. onLoadErrorObservable: Observable<string>;
  49723. /**
  49724. * The skybox material
  49725. */
  49726. protected _material: BackgroundMaterial;
  49727. /**
  49728. * The surface used for the skybox
  49729. */
  49730. protected _mesh: Mesh;
  49731. /**
  49732. * Gets the mesh used for the skybox.
  49733. */
  49734. get mesh(): Mesh;
  49735. /**
  49736. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49737. * Also see the options.resolution property.
  49738. */
  49739. get fovMultiplier(): number;
  49740. set fovMultiplier(value: number);
  49741. private _imageMode;
  49742. /**
  49743. * Gets or set the current video mode for the video. It can be:
  49744. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49745. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49746. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49747. */
  49748. get imageMode(): number;
  49749. set imageMode(value: number);
  49750. /**
  49751. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49752. * @param name Element's name, child elements will append suffixes for their own names.
  49753. * @param urlsOfPhoto defines the url of the photo to display
  49754. * @param options defines an object containing optional or exposed sub element properties
  49755. * @param onError defines a callback called when an error occured while loading the texture
  49756. */
  49757. constructor(name: string, urlOfPhoto: string, options: {
  49758. resolution?: number;
  49759. size?: number;
  49760. useDirectMapping?: boolean;
  49761. faceForward?: boolean;
  49762. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49763. private _onBeforeCameraRenderObserver;
  49764. private _changeImageMode;
  49765. /**
  49766. * Releases resources associated with this node.
  49767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49769. */
  49770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49771. }
  49772. }
  49773. declare module BABYLON {
  49774. /**
  49775. * Class used to host RGBD texture specific utilities
  49776. */
  49777. export class RGBDTextureTools {
  49778. /**
  49779. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49780. * @param texture the texture to expand.
  49781. */
  49782. static ExpandRGBDTexture(texture: Texture): void;
  49783. }
  49784. }
  49785. declare module BABYLON {
  49786. /**
  49787. * Class used to host texture specific utilities
  49788. */
  49789. export class BRDFTextureTools {
  49790. /**
  49791. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49792. * @param scene defines the hosting scene
  49793. * @returns the environment BRDF texture
  49794. */
  49795. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49796. private static _environmentBRDFBase64Texture;
  49797. }
  49798. }
  49799. declare module BABYLON {
  49800. /**
  49801. * @hidden
  49802. */
  49803. export interface IMaterialClearCoatDefines {
  49804. CLEARCOAT: boolean;
  49805. CLEARCOAT_DEFAULTIOR: boolean;
  49806. CLEARCOAT_TEXTURE: boolean;
  49807. CLEARCOAT_TEXTUREDIRECTUV: number;
  49808. CLEARCOAT_BUMP: boolean;
  49809. CLEARCOAT_BUMPDIRECTUV: number;
  49810. CLEARCOAT_TINT: boolean;
  49811. CLEARCOAT_TINT_TEXTURE: boolean;
  49812. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49813. /** @hidden */
  49814. _areTexturesDirty: boolean;
  49815. }
  49816. /**
  49817. * Define the code related to the clear coat parameters of the pbr material.
  49818. */
  49819. export class PBRClearCoatConfiguration {
  49820. /**
  49821. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49822. * The default fits with a polyurethane material.
  49823. */
  49824. private static readonly _DefaultIndexOfRefraction;
  49825. private _isEnabled;
  49826. /**
  49827. * Defines if the clear coat is enabled in the material.
  49828. */
  49829. isEnabled: boolean;
  49830. /**
  49831. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49832. */
  49833. intensity: number;
  49834. /**
  49835. * Defines the clear coat layer roughness.
  49836. */
  49837. roughness: number;
  49838. private _indexOfRefraction;
  49839. /**
  49840. * Defines the index of refraction of the clear coat.
  49841. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49842. * The default fits with a polyurethane material.
  49843. * Changing the default value is more performance intensive.
  49844. */
  49845. indexOfRefraction: number;
  49846. private _texture;
  49847. /**
  49848. * Stores the clear coat values in a texture.
  49849. */
  49850. texture: Nullable<BaseTexture>;
  49851. private _bumpTexture;
  49852. /**
  49853. * Define the clear coat specific bump texture.
  49854. */
  49855. bumpTexture: Nullable<BaseTexture>;
  49856. private _isTintEnabled;
  49857. /**
  49858. * Defines if the clear coat tint is enabled in the material.
  49859. */
  49860. isTintEnabled: boolean;
  49861. /**
  49862. * Defines the clear coat tint of the material.
  49863. * This is only use if tint is enabled
  49864. */
  49865. tintColor: Color3;
  49866. /**
  49867. * Defines the distance at which the tint color should be found in the
  49868. * clear coat media.
  49869. * This is only use if tint is enabled
  49870. */
  49871. tintColorAtDistance: number;
  49872. /**
  49873. * Defines the clear coat layer thickness.
  49874. * This is only use if tint is enabled
  49875. */
  49876. tintThickness: number;
  49877. private _tintTexture;
  49878. /**
  49879. * Stores the clear tint values in a texture.
  49880. * rgb is tint
  49881. * a is a thickness factor
  49882. */
  49883. tintTexture: Nullable<BaseTexture>;
  49884. /** @hidden */
  49885. private _internalMarkAllSubMeshesAsTexturesDirty;
  49886. /** @hidden */
  49887. _markAllSubMeshesAsTexturesDirty(): void;
  49888. /**
  49889. * Instantiate a new istance of clear coat configuration.
  49890. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49891. */
  49892. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49893. /**
  49894. * Gets wehter the submesh is ready to be used or not.
  49895. * @param defines the list of "defines" to update.
  49896. * @param scene defines the scene the material belongs to.
  49897. * @param engine defines the engine the material belongs to.
  49898. * @param disableBumpMap defines wether the material disables bump or not.
  49899. * @returns - boolean indicating that the submesh is ready or not.
  49900. */
  49901. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49902. /**
  49903. * Checks to see if a texture is used in the material.
  49904. * @param defines the list of "defines" to update.
  49905. * @param scene defines the scene to the material belongs to.
  49906. */
  49907. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49908. /**
  49909. * Binds the material data.
  49910. * @param uniformBuffer defines the Uniform buffer to fill in.
  49911. * @param scene defines the scene the material belongs to.
  49912. * @param engine defines the engine the material belongs to.
  49913. * @param disableBumpMap defines wether the material disables bump or not.
  49914. * @param isFrozen defines wether the material is frozen or not.
  49915. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49916. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49917. */
  49918. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49919. /**
  49920. * Checks to see if a texture is used in the material.
  49921. * @param texture - Base texture to use.
  49922. * @returns - Boolean specifying if a texture is used in the material.
  49923. */
  49924. hasTexture(texture: BaseTexture): boolean;
  49925. /**
  49926. * Returns an array of the actively used textures.
  49927. * @param activeTextures Array of BaseTextures
  49928. */
  49929. getActiveTextures(activeTextures: BaseTexture[]): void;
  49930. /**
  49931. * Returns the animatable textures.
  49932. * @param animatables Array of animatable textures.
  49933. */
  49934. getAnimatables(animatables: IAnimatable[]): void;
  49935. /**
  49936. * Disposes the resources of the material.
  49937. * @param forceDisposeTextures - Forces the disposal of all textures.
  49938. */
  49939. dispose(forceDisposeTextures?: boolean): void;
  49940. /**
  49941. * Get the current class name of the texture useful for serialization or dynamic coding.
  49942. * @returns "PBRClearCoatConfiguration"
  49943. */
  49944. getClassName(): string;
  49945. /**
  49946. * Add fallbacks to the effect fallbacks list.
  49947. * @param defines defines the Base texture to use.
  49948. * @param fallbacks defines the current fallback list.
  49949. * @param currentRank defines the current fallback rank.
  49950. * @returns the new fallback rank.
  49951. */
  49952. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49953. /**
  49954. * Add the required uniforms to the current list.
  49955. * @param uniforms defines the current uniform list.
  49956. */
  49957. static AddUniforms(uniforms: string[]): void;
  49958. /**
  49959. * Add the required samplers to the current list.
  49960. * @param samplers defines the current sampler list.
  49961. */
  49962. static AddSamplers(samplers: string[]): void;
  49963. /**
  49964. * Add the required uniforms to the current buffer.
  49965. * @param uniformBuffer defines the current uniform buffer.
  49966. */
  49967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49968. /**
  49969. * Makes a duplicate of the current configuration into another one.
  49970. * @param clearCoatConfiguration define the config where to copy the info
  49971. */
  49972. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49973. /**
  49974. * Serializes this clear coat configuration.
  49975. * @returns - An object with the serialized config.
  49976. */
  49977. serialize(): any;
  49978. /**
  49979. * Parses a anisotropy Configuration from a serialized object.
  49980. * @param source - Serialized object.
  49981. * @param scene Defines the scene we are parsing for
  49982. * @param rootUrl Defines the rootUrl to load from
  49983. */
  49984. parse(source: any, scene: Scene, rootUrl: string): void;
  49985. }
  49986. }
  49987. declare module BABYLON {
  49988. /**
  49989. * @hidden
  49990. */
  49991. export interface IMaterialAnisotropicDefines {
  49992. ANISOTROPIC: boolean;
  49993. ANISOTROPIC_TEXTURE: boolean;
  49994. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49995. MAINUV1: boolean;
  49996. _areTexturesDirty: boolean;
  49997. _needUVs: boolean;
  49998. }
  49999. /**
  50000. * Define the code related to the anisotropic parameters of the pbr material.
  50001. */
  50002. export class PBRAnisotropicConfiguration {
  50003. private _isEnabled;
  50004. /**
  50005. * Defines if the anisotropy is enabled in the material.
  50006. */
  50007. isEnabled: boolean;
  50008. /**
  50009. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50010. */
  50011. intensity: number;
  50012. /**
  50013. * Defines if the effect is along the tangents, bitangents or in between.
  50014. * By default, the effect is "strectching" the highlights along the tangents.
  50015. */
  50016. direction: Vector2;
  50017. private _texture;
  50018. /**
  50019. * Stores the anisotropy values in a texture.
  50020. * rg is direction (like normal from -1 to 1)
  50021. * b is a intensity
  50022. */
  50023. texture: Nullable<BaseTexture>;
  50024. /** @hidden */
  50025. private _internalMarkAllSubMeshesAsTexturesDirty;
  50026. /** @hidden */
  50027. _markAllSubMeshesAsTexturesDirty(): void;
  50028. /**
  50029. * Instantiate a new istance of anisotropy configuration.
  50030. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50031. */
  50032. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50033. /**
  50034. * Specifies that the submesh is ready to be used.
  50035. * @param defines the list of "defines" to update.
  50036. * @param scene defines the scene the material belongs to.
  50037. * @returns - boolean indicating that the submesh is ready or not.
  50038. */
  50039. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50040. /**
  50041. * Checks to see if a texture is used in the material.
  50042. * @param defines the list of "defines" to update.
  50043. * @param mesh the mesh we are preparing the defines for.
  50044. * @param scene defines the scene the material belongs to.
  50045. */
  50046. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50047. /**
  50048. * Binds the material data.
  50049. * @param uniformBuffer defines the Uniform buffer to fill in.
  50050. * @param scene defines the scene the material belongs to.
  50051. * @param isFrozen defines wether the material is frozen or not.
  50052. */
  50053. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50054. /**
  50055. * Checks to see if a texture is used in the material.
  50056. * @param texture - Base texture to use.
  50057. * @returns - Boolean specifying if a texture is used in the material.
  50058. */
  50059. hasTexture(texture: BaseTexture): boolean;
  50060. /**
  50061. * Returns an array of the actively used textures.
  50062. * @param activeTextures Array of BaseTextures
  50063. */
  50064. getActiveTextures(activeTextures: BaseTexture[]): void;
  50065. /**
  50066. * Returns the animatable textures.
  50067. * @param animatables Array of animatable textures.
  50068. */
  50069. getAnimatables(animatables: IAnimatable[]): void;
  50070. /**
  50071. * Disposes the resources of the material.
  50072. * @param forceDisposeTextures - Forces the disposal of all textures.
  50073. */
  50074. dispose(forceDisposeTextures?: boolean): void;
  50075. /**
  50076. * Get the current class name of the texture useful for serialization or dynamic coding.
  50077. * @returns "PBRAnisotropicConfiguration"
  50078. */
  50079. getClassName(): string;
  50080. /**
  50081. * Add fallbacks to the effect fallbacks list.
  50082. * @param defines defines the Base texture to use.
  50083. * @param fallbacks defines the current fallback list.
  50084. * @param currentRank defines the current fallback rank.
  50085. * @returns the new fallback rank.
  50086. */
  50087. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50088. /**
  50089. * Add the required uniforms to the current list.
  50090. * @param uniforms defines the current uniform list.
  50091. */
  50092. static AddUniforms(uniforms: string[]): void;
  50093. /**
  50094. * Add the required uniforms to the current buffer.
  50095. * @param uniformBuffer defines the current uniform buffer.
  50096. */
  50097. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50098. /**
  50099. * Add the required samplers to the current list.
  50100. * @param samplers defines the current sampler list.
  50101. */
  50102. static AddSamplers(samplers: string[]): void;
  50103. /**
  50104. * Makes a duplicate of the current configuration into another one.
  50105. * @param anisotropicConfiguration define the config where to copy the info
  50106. */
  50107. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50108. /**
  50109. * Serializes this anisotropy configuration.
  50110. * @returns - An object with the serialized config.
  50111. */
  50112. serialize(): any;
  50113. /**
  50114. * Parses a anisotropy Configuration from a serialized object.
  50115. * @param source - Serialized object.
  50116. * @param scene Defines the scene we are parsing for
  50117. * @param rootUrl Defines the rootUrl to load from
  50118. */
  50119. parse(source: any, scene: Scene, rootUrl: string): void;
  50120. }
  50121. }
  50122. declare module BABYLON {
  50123. /**
  50124. * @hidden
  50125. */
  50126. export interface IMaterialBRDFDefines {
  50127. BRDF_V_HEIGHT_CORRELATED: boolean;
  50128. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50129. SPHERICAL_HARMONICS: boolean;
  50130. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50131. /** @hidden */
  50132. _areMiscDirty: boolean;
  50133. }
  50134. /**
  50135. * Define the code related to the BRDF parameters of the pbr material.
  50136. */
  50137. export class PBRBRDFConfiguration {
  50138. /**
  50139. * Default value used for the energy conservation.
  50140. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50141. */
  50142. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50143. /**
  50144. * Default value used for the Smith Visibility Height Correlated mode.
  50145. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50146. */
  50147. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50148. /**
  50149. * Default value used for the IBL diffuse part.
  50150. * This can help switching back to the polynomials mode globally which is a tiny bit
  50151. * less GPU intensive at the drawback of a lower quality.
  50152. */
  50153. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50154. /**
  50155. * Default value used for activating energy conservation for the specular workflow.
  50156. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50157. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50158. */
  50159. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50160. private _useEnergyConservation;
  50161. /**
  50162. * Defines if the material uses energy conservation.
  50163. */
  50164. useEnergyConservation: boolean;
  50165. private _useSmithVisibilityHeightCorrelated;
  50166. /**
  50167. * LEGACY Mode set to false
  50168. * Defines if the material uses height smith correlated visibility term.
  50169. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50170. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50171. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50172. * Not relying on height correlated will also disable energy conservation.
  50173. */
  50174. useSmithVisibilityHeightCorrelated: boolean;
  50175. private _useSphericalHarmonics;
  50176. /**
  50177. * LEGACY Mode set to false
  50178. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50179. * diffuse part of the IBL.
  50180. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50181. * to the ground truth.
  50182. */
  50183. useSphericalHarmonics: boolean;
  50184. private _useSpecularGlossinessInputEnergyConservation;
  50185. /**
  50186. * Defines if the material uses energy conservation, when the specular workflow is active.
  50187. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50188. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50189. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50190. */
  50191. useSpecularGlossinessInputEnergyConservation: boolean;
  50192. /** @hidden */
  50193. private _internalMarkAllSubMeshesAsMiscDirty;
  50194. /** @hidden */
  50195. _markAllSubMeshesAsMiscDirty(): void;
  50196. /**
  50197. * Instantiate a new istance of clear coat configuration.
  50198. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50199. */
  50200. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50201. /**
  50202. * Checks to see if a texture is used in the material.
  50203. * @param defines the list of "defines" to update.
  50204. */
  50205. prepareDefines(defines: IMaterialBRDFDefines): void;
  50206. /**
  50207. * Get the current class name of the texture useful for serialization or dynamic coding.
  50208. * @returns "PBRClearCoatConfiguration"
  50209. */
  50210. getClassName(): string;
  50211. /**
  50212. * Makes a duplicate of the current configuration into another one.
  50213. * @param brdfConfiguration define the config where to copy the info
  50214. */
  50215. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50216. /**
  50217. * Serializes this BRDF configuration.
  50218. * @returns - An object with the serialized config.
  50219. */
  50220. serialize(): any;
  50221. /**
  50222. * Parses a anisotropy Configuration from a serialized object.
  50223. * @param source - Serialized object.
  50224. * @param scene Defines the scene we are parsing for
  50225. * @param rootUrl Defines the rootUrl to load from
  50226. */
  50227. parse(source: any, scene: Scene, rootUrl: string): void;
  50228. }
  50229. }
  50230. declare module BABYLON {
  50231. /**
  50232. * @hidden
  50233. */
  50234. export interface IMaterialSheenDefines {
  50235. SHEEN: boolean;
  50236. SHEEN_TEXTURE: boolean;
  50237. SHEEN_TEXTUREDIRECTUV: number;
  50238. SHEEN_LINKWITHALBEDO: boolean;
  50239. /** @hidden */
  50240. _areTexturesDirty: boolean;
  50241. }
  50242. /**
  50243. * Define the code related to the Sheen parameters of the pbr material.
  50244. */
  50245. export class PBRSheenConfiguration {
  50246. private _isEnabled;
  50247. /**
  50248. * Defines if the material uses sheen.
  50249. */
  50250. isEnabled: boolean;
  50251. private _linkSheenWithAlbedo;
  50252. /**
  50253. * Defines if the sheen is linked to the sheen color.
  50254. */
  50255. linkSheenWithAlbedo: boolean;
  50256. /**
  50257. * Defines the sheen intensity.
  50258. */
  50259. intensity: number;
  50260. /**
  50261. * Defines the sheen color.
  50262. */
  50263. color: Color3;
  50264. private _texture;
  50265. /**
  50266. * Stores the sheen tint values in a texture.
  50267. * rgb is tint
  50268. * a is a intensity
  50269. */
  50270. texture: Nullable<BaseTexture>;
  50271. /** @hidden */
  50272. private _internalMarkAllSubMeshesAsTexturesDirty;
  50273. /** @hidden */
  50274. _markAllSubMeshesAsTexturesDirty(): void;
  50275. /**
  50276. * Instantiate a new istance of clear coat configuration.
  50277. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50278. */
  50279. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50280. /**
  50281. * Specifies that the submesh is ready to be used.
  50282. * @param defines the list of "defines" to update.
  50283. * @param scene defines the scene the material belongs to.
  50284. * @returns - boolean indicating that the submesh is ready or not.
  50285. */
  50286. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50287. /**
  50288. * Checks to see if a texture is used in the material.
  50289. * @param defines the list of "defines" to update.
  50290. * @param scene defines the scene the material belongs to.
  50291. */
  50292. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50293. /**
  50294. * Binds the material data.
  50295. * @param uniformBuffer defines the Uniform buffer to fill in.
  50296. * @param scene defines the scene the material belongs to.
  50297. * @param isFrozen defines wether the material is frozen or not.
  50298. */
  50299. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50300. /**
  50301. * Checks to see if a texture is used in the material.
  50302. * @param texture - Base texture to use.
  50303. * @returns - Boolean specifying if a texture is used in the material.
  50304. */
  50305. hasTexture(texture: BaseTexture): boolean;
  50306. /**
  50307. * Returns an array of the actively used textures.
  50308. * @param activeTextures Array of BaseTextures
  50309. */
  50310. getActiveTextures(activeTextures: BaseTexture[]): void;
  50311. /**
  50312. * Returns the animatable textures.
  50313. * @param animatables Array of animatable textures.
  50314. */
  50315. getAnimatables(animatables: IAnimatable[]): void;
  50316. /**
  50317. * Disposes the resources of the material.
  50318. * @param forceDisposeTextures - Forces the disposal of all textures.
  50319. */
  50320. dispose(forceDisposeTextures?: boolean): void;
  50321. /**
  50322. * Get the current class name of the texture useful for serialization or dynamic coding.
  50323. * @returns "PBRSheenConfiguration"
  50324. */
  50325. getClassName(): string;
  50326. /**
  50327. * Add fallbacks to the effect fallbacks list.
  50328. * @param defines defines the Base texture to use.
  50329. * @param fallbacks defines the current fallback list.
  50330. * @param currentRank defines the current fallback rank.
  50331. * @returns the new fallback rank.
  50332. */
  50333. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50334. /**
  50335. * Add the required uniforms to the current list.
  50336. * @param uniforms defines the current uniform list.
  50337. */
  50338. static AddUniforms(uniforms: string[]): void;
  50339. /**
  50340. * Add the required uniforms to the current buffer.
  50341. * @param uniformBuffer defines the current uniform buffer.
  50342. */
  50343. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50344. /**
  50345. * Add the required samplers to the current list.
  50346. * @param samplers defines the current sampler list.
  50347. */
  50348. static AddSamplers(samplers: string[]): void;
  50349. /**
  50350. * Makes a duplicate of the current configuration into another one.
  50351. * @param sheenConfiguration define the config where to copy the info
  50352. */
  50353. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50354. /**
  50355. * Serializes this BRDF configuration.
  50356. * @returns - An object with the serialized config.
  50357. */
  50358. serialize(): any;
  50359. /**
  50360. * Parses a anisotropy Configuration from a serialized object.
  50361. * @param source - Serialized object.
  50362. * @param scene Defines the scene we are parsing for
  50363. * @param rootUrl Defines the rootUrl to load from
  50364. */
  50365. parse(source: any, scene: Scene, rootUrl: string): void;
  50366. }
  50367. }
  50368. declare module BABYLON {
  50369. /**
  50370. * @hidden
  50371. */
  50372. export interface IMaterialSubSurfaceDefines {
  50373. SUBSURFACE: boolean;
  50374. SS_REFRACTION: boolean;
  50375. SS_TRANSLUCENCY: boolean;
  50376. SS_SCATERRING: boolean;
  50377. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50378. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50379. SS_REFRACTIONMAP_3D: boolean;
  50380. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50381. SS_LODINREFRACTIONALPHA: boolean;
  50382. SS_GAMMAREFRACTION: boolean;
  50383. SS_RGBDREFRACTION: boolean;
  50384. SS_LINEARSPECULARREFRACTION: boolean;
  50385. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50386. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50387. /** @hidden */
  50388. _areTexturesDirty: boolean;
  50389. }
  50390. /**
  50391. * Define the code related to the sub surface parameters of the pbr material.
  50392. */
  50393. export class PBRSubSurfaceConfiguration {
  50394. private _isRefractionEnabled;
  50395. /**
  50396. * Defines if the refraction is enabled in the material.
  50397. */
  50398. isRefractionEnabled: boolean;
  50399. private _isTranslucencyEnabled;
  50400. /**
  50401. * Defines if the translucency is enabled in the material.
  50402. */
  50403. isTranslucencyEnabled: boolean;
  50404. private _isScatteringEnabled;
  50405. /**
  50406. * Defines the refraction intensity of the material.
  50407. * The refraction when enabled replaces the Diffuse part of the material.
  50408. * The intensity helps transitionning between diffuse and refraction.
  50409. */
  50410. refractionIntensity: number;
  50411. /**
  50412. * Defines the translucency intensity of the material.
  50413. * When translucency has been enabled, this defines how much of the "translucency"
  50414. * is addded to the diffuse part of the material.
  50415. */
  50416. translucencyIntensity: number;
  50417. /**
  50418. * Defines the scattering intensity of the material.
  50419. * When scattering has been enabled, this defines how much of the "scattered light"
  50420. * is addded to the diffuse part of the material.
  50421. */
  50422. scatteringIntensity: number;
  50423. private _thicknessTexture;
  50424. /**
  50425. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50426. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50427. * 0 would mean minimumThickness
  50428. * 1 would mean maximumThickness
  50429. * The other channels might be use as a mask to vary the different effects intensity.
  50430. */
  50431. thicknessTexture: Nullable<BaseTexture>;
  50432. private _refractionTexture;
  50433. /**
  50434. * Defines the texture to use for refraction.
  50435. */
  50436. refractionTexture: Nullable<BaseTexture>;
  50437. private _indexOfRefraction;
  50438. /**
  50439. * Defines the index of refraction used in the material.
  50440. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50441. */
  50442. indexOfRefraction: number;
  50443. private _invertRefractionY;
  50444. /**
  50445. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50446. */
  50447. invertRefractionY: boolean;
  50448. private _linkRefractionWithTransparency;
  50449. /**
  50450. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50451. * Materials half opaque for instance using refraction could benefit from this control.
  50452. */
  50453. linkRefractionWithTransparency: boolean;
  50454. /**
  50455. * Defines the minimum thickness stored in the thickness map.
  50456. * If no thickness map is defined, this value will be used to simulate thickness.
  50457. */
  50458. minimumThickness: number;
  50459. /**
  50460. * Defines the maximum thickness stored in the thickness map.
  50461. */
  50462. maximumThickness: number;
  50463. /**
  50464. * Defines the volume tint of the material.
  50465. * This is used for both translucency and scattering.
  50466. */
  50467. tintColor: Color3;
  50468. /**
  50469. * Defines the distance at which the tint color should be found in the media.
  50470. * This is used for refraction only.
  50471. */
  50472. tintColorAtDistance: number;
  50473. /**
  50474. * Defines how far each channel transmit through the media.
  50475. * It is defined as a color to simplify it selection.
  50476. */
  50477. diffusionDistance: Color3;
  50478. private _useMaskFromThicknessTexture;
  50479. /**
  50480. * Stores the intensity of the different subsurface effects in the thickness texture.
  50481. * * the green channel is the translucency intensity.
  50482. * * the blue channel is the scattering intensity.
  50483. * * the alpha channel is the refraction intensity.
  50484. */
  50485. useMaskFromThicknessTexture: boolean;
  50486. /** @hidden */
  50487. private _internalMarkAllSubMeshesAsTexturesDirty;
  50488. /** @hidden */
  50489. _markAllSubMeshesAsTexturesDirty(): void;
  50490. /**
  50491. * Instantiate a new istance of sub surface configuration.
  50492. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50493. */
  50494. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50495. /**
  50496. * Gets wehter the submesh is ready to be used or not.
  50497. * @param defines the list of "defines" to update.
  50498. * @param scene defines the scene the material belongs to.
  50499. * @returns - boolean indicating that the submesh is ready or not.
  50500. */
  50501. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50502. /**
  50503. * Checks to see if a texture is used in the material.
  50504. * @param defines the list of "defines" to update.
  50505. * @param scene defines the scene to the material belongs to.
  50506. */
  50507. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50508. /**
  50509. * Binds the material data.
  50510. * @param uniformBuffer defines the Uniform buffer to fill in.
  50511. * @param scene defines the scene the material belongs to.
  50512. * @param engine defines the engine the material belongs to.
  50513. * @param isFrozen defines wether the material is frozen or not.
  50514. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50515. */
  50516. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50517. /**
  50518. * Unbinds the material from the mesh.
  50519. * @param activeEffect defines the effect that should be unbound from.
  50520. * @returns true if unbound, otherwise false
  50521. */
  50522. unbind(activeEffect: Effect): boolean;
  50523. /**
  50524. * Returns the texture used for refraction or null if none is used.
  50525. * @param scene defines the scene the material belongs to.
  50526. * @returns - Refraction texture if present. If no refraction texture and refraction
  50527. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50528. */
  50529. private _getRefractionTexture;
  50530. /**
  50531. * Returns true if alpha blending should be disabled.
  50532. */
  50533. get disableAlphaBlending(): boolean;
  50534. /**
  50535. * Fills the list of render target textures.
  50536. * @param renderTargets the list of render targets to update
  50537. */
  50538. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50539. /**
  50540. * Checks to see if a texture is used in the material.
  50541. * @param texture - Base texture to use.
  50542. * @returns - Boolean specifying if a texture is used in the material.
  50543. */
  50544. hasTexture(texture: BaseTexture): boolean;
  50545. /**
  50546. * Gets a boolean indicating that current material needs to register RTT
  50547. * @returns true if this uses a render target otherwise false.
  50548. */
  50549. hasRenderTargetTextures(): boolean;
  50550. /**
  50551. * Returns an array of the actively used textures.
  50552. * @param activeTextures Array of BaseTextures
  50553. */
  50554. getActiveTextures(activeTextures: BaseTexture[]): void;
  50555. /**
  50556. * Returns the animatable textures.
  50557. * @param animatables Array of animatable textures.
  50558. */
  50559. getAnimatables(animatables: IAnimatable[]): void;
  50560. /**
  50561. * Disposes the resources of the material.
  50562. * @param forceDisposeTextures - Forces the disposal of all textures.
  50563. */
  50564. dispose(forceDisposeTextures?: boolean): void;
  50565. /**
  50566. * Get the current class name of the texture useful for serialization or dynamic coding.
  50567. * @returns "PBRSubSurfaceConfiguration"
  50568. */
  50569. getClassName(): string;
  50570. /**
  50571. * Add fallbacks to the effect fallbacks list.
  50572. * @param defines defines the Base texture to use.
  50573. * @param fallbacks defines the current fallback list.
  50574. * @param currentRank defines the current fallback rank.
  50575. * @returns the new fallback rank.
  50576. */
  50577. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50578. /**
  50579. * Add the required uniforms to the current list.
  50580. * @param uniforms defines the current uniform list.
  50581. */
  50582. static AddUniforms(uniforms: string[]): void;
  50583. /**
  50584. * Add the required samplers to the current list.
  50585. * @param samplers defines the current sampler list.
  50586. */
  50587. static AddSamplers(samplers: string[]): void;
  50588. /**
  50589. * Add the required uniforms to the current buffer.
  50590. * @param uniformBuffer defines the current uniform buffer.
  50591. */
  50592. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50593. /**
  50594. * Makes a duplicate of the current configuration into another one.
  50595. * @param configuration define the config where to copy the info
  50596. */
  50597. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50598. /**
  50599. * Serializes this Sub Surface configuration.
  50600. * @returns - An object with the serialized config.
  50601. */
  50602. serialize(): any;
  50603. /**
  50604. * Parses a anisotropy Configuration from a serialized object.
  50605. * @param source - Serialized object.
  50606. * @param scene Defines the scene we are parsing for
  50607. * @param rootUrl Defines the rootUrl to load from
  50608. */
  50609. parse(source: any, scene: Scene, rootUrl: string): void;
  50610. }
  50611. }
  50612. declare module BABYLON {
  50613. /** @hidden */
  50614. export var pbrFragmentDeclaration: {
  50615. name: string;
  50616. shader: string;
  50617. };
  50618. }
  50619. declare module BABYLON {
  50620. /** @hidden */
  50621. export var pbrUboDeclaration: {
  50622. name: string;
  50623. shader: string;
  50624. };
  50625. }
  50626. declare module BABYLON {
  50627. /** @hidden */
  50628. export var pbrFragmentExtraDeclaration: {
  50629. name: string;
  50630. shader: string;
  50631. };
  50632. }
  50633. declare module BABYLON {
  50634. /** @hidden */
  50635. export var pbrFragmentSamplersDeclaration: {
  50636. name: string;
  50637. shader: string;
  50638. };
  50639. }
  50640. declare module BABYLON {
  50641. /** @hidden */
  50642. export var pbrHelperFunctions: {
  50643. name: string;
  50644. shader: string;
  50645. };
  50646. }
  50647. declare module BABYLON {
  50648. /** @hidden */
  50649. export var harmonicsFunctions: {
  50650. name: string;
  50651. shader: string;
  50652. };
  50653. }
  50654. declare module BABYLON {
  50655. /** @hidden */
  50656. export var pbrDirectLightingSetupFunctions: {
  50657. name: string;
  50658. shader: string;
  50659. };
  50660. }
  50661. declare module BABYLON {
  50662. /** @hidden */
  50663. export var pbrDirectLightingFalloffFunctions: {
  50664. name: string;
  50665. shader: string;
  50666. };
  50667. }
  50668. declare module BABYLON {
  50669. /** @hidden */
  50670. export var pbrBRDFFunctions: {
  50671. name: string;
  50672. shader: string;
  50673. };
  50674. }
  50675. declare module BABYLON {
  50676. /** @hidden */
  50677. export var pbrDirectLightingFunctions: {
  50678. name: string;
  50679. shader: string;
  50680. };
  50681. }
  50682. declare module BABYLON {
  50683. /** @hidden */
  50684. export var pbrIBLFunctions: {
  50685. name: string;
  50686. shader: string;
  50687. };
  50688. }
  50689. declare module BABYLON {
  50690. /** @hidden */
  50691. export var pbrDebug: {
  50692. name: string;
  50693. shader: string;
  50694. };
  50695. }
  50696. declare module BABYLON {
  50697. /** @hidden */
  50698. export var pbrPixelShader: {
  50699. name: string;
  50700. shader: string;
  50701. };
  50702. }
  50703. declare module BABYLON {
  50704. /** @hidden */
  50705. export var pbrVertexDeclaration: {
  50706. name: string;
  50707. shader: string;
  50708. };
  50709. }
  50710. declare module BABYLON {
  50711. /** @hidden */
  50712. export var pbrVertexShader: {
  50713. name: string;
  50714. shader: string;
  50715. };
  50716. }
  50717. declare module BABYLON {
  50718. /**
  50719. * Manages the defines for the PBR Material.
  50720. * @hidden
  50721. */
  50722. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50723. PBR: boolean;
  50724. MAINUV1: boolean;
  50725. MAINUV2: boolean;
  50726. UV1: boolean;
  50727. UV2: boolean;
  50728. ALBEDO: boolean;
  50729. ALBEDODIRECTUV: number;
  50730. VERTEXCOLOR: boolean;
  50731. AMBIENT: boolean;
  50732. AMBIENTDIRECTUV: number;
  50733. AMBIENTINGRAYSCALE: boolean;
  50734. OPACITY: boolean;
  50735. VERTEXALPHA: boolean;
  50736. OPACITYDIRECTUV: number;
  50737. OPACITYRGB: boolean;
  50738. ALPHATEST: boolean;
  50739. DEPTHPREPASS: boolean;
  50740. ALPHABLEND: boolean;
  50741. ALPHAFROMALBEDO: boolean;
  50742. ALPHATESTVALUE: string;
  50743. SPECULAROVERALPHA: boolean;
  50744. RADIANCEOVERALPHA: boolean;
  50745. ALPHAFRESNEL: boolean;
  50746. LINEARALPHAFRESNEL: boolean;
  50747. PREMULTIPLYALPHA: boolean;
  50748. EMISSIVE: boolean;
  50749. EMISSIVEDIRECTUV: number;
  50750. REFLECTIVITY: boolean;
  50751. REFLECTIVITYDIRECTUV: number;
  50752. SPECULARTERM: boolean;
  50753. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50754. MICROSURFACEAUTOMATIC: boolean;
  50755. LODBASEDMICROSFURACE: boolean;
  50756. MICROSURFACEMAP: boolean;
  50757. MICROSURFACEMAPDIRECTUV: number;
  50758. METALLICWORKFLOW: boolean;
  50759. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50760. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50761. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50762. AOSTOREINMETALMAPRED: boolean;
  50763. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50764. ENVIRONMENTBRDF: boolean;
  50765. ENVIRONMENTBRDF_RGBD: boolean;
  50766. NORMAL: boolean;
  50767. TANGENT: boolean;
  50768. BUMP: boolean;
  50769. BUMPDIRECTUV: number;
  50770. OBJECTSPACE_NORMALMAP: boolean;
  50771. PARALLAX: boolean;
  50772. PARALLAXOCCLUSION: boolean;
  50773. NORMALXYSCALE: boolean;
  50774. LIGHTMAP: boolean;
  50775. LIGHTMAPDIRECTUV: number;
  50776. USELIGHTMAPASSHADOWMAP: boolean;
  50777. GAMMALIGHTMAP: boolean;
  50778. RGBDLIGHTMAP: boolean;
  50779. REFLECTION: boolean;
  50780. REFLECTIONMAP_3D: boolean;
  50781. REFLECTIONMAP_SPHERICAL: boolean;
  50782. REFLECTIONMAP_PLANAR: boolean;
  50783. REFLECTIONMAP_CUBIC: boolean;
  50784. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50785. REFLECTIONMAP_PROJECTION: boolean;
  50786. REFLECTIONMAP_SKYBOX: boolean;
  50787. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50788. REFLECTIONMAP_EXPLICIT: boolean;
  50789. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50790. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50791. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50792. INVERTCUBICMAP: boolean;
  50793. USESPHERICALFROMREFLECTIONMAP: boolean;
  50794. USEIRRADIANCEMAP: boolean;
  50795. SPHERICAL_HARMONICS: boolean;
  50796. USESPHERICALINVERTEX: boolean;
  50797. REFLECTIONMAP_OPPOSITEZ: boolean;
  50798. LODINREFLECTIONALPHA: boolean;
  50799. GAMMAREFLECTION: boolean;
  50800. RGBDREFLECTION: boolean;
  50801. LINEARSPECULARREFLECTION: boolean;
  50802. RADIANCEOCCLUSION: boolean;
  50803. HORIZONOCCLUSION: boolean;
  50804. INSTANCES: boolean;
  50805. NUM_BONE_INFLUENCERS: number;
  50806. BonesPerMesh: number;
  50807. BONETEXTURE: boolean;
  50808. NONUNIFORMSCALING: boolean;
  50809. MORPHTARGETS: boolean;
  50810. MORPHTARGETS_NORMAL: boolean;
  50811. MORPHTARGETS_TANGENT: boolean;
  50812. MORPHTARGETS_UV: boolean;
  50813. NUM_MORPH_INFLUENCERS: number;
  50814. IMAGEPROCESSING: boolean;
  50815. VIGNETTE: boolean;
  50816. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50817. VIGNETTEBLENDMODEOPAQUE: boolean;
  50818. TONEMAPPING: boolean;
  50819. TONEMAPPING_ACES: boolean;
  50820. CONTRAST: boolean;
  50821. COLORCURVES: boolean;
  50822. COLORGRADING: boolean;
  50823. COLORGRADING3D: boolean;
  50824. SAMPLER3DGREENDEPTH: boolean;
  50825. SAMPLER3DBGRMAP: boolean;
  50826. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50827. EXPOSURE: boolean;
  50828. MULTIVIEW: boolean;
  50829. USEPHYSICALLIGHTFALLOFF: boolean;
  50830. USEGLTFLIGHTFALLOFF: boolean;
  50831. TWOSIDEDLIGHTING: boolean;
  50832. SHADOWFLOAT: boolean;
  50833. CLIPPLANE: boolean;
  50834. CLIPPLANE2: boolean;
  50835. CLIPPLANE3: boolean;
  50836. CLIPPLANE4: boolean;
  50837. CLIPPLANE5: boolean;
  50838. CLIPPLANE6: boolean;
  50839. POINTSIZE: boolean;
  50840. FOG: boolean;
  50841. LOGARITHMICDEPTH: boolean;
  50842. FORCENORMALFORWARD: boolean;
  50843. SPECULARAA: boolean;
  50844. CLEARCOAT: boolean;
  50845. CLEARCOAT_DEFAULTIOR: boolean;
  50846. CLEARCOAT_TEXTURE: boolean;
  50847. CLEARCOAT_TEXTUREDIRECTUV: number;
  50848. CLEARCOAT_BUMP: boolean;
  50849. CLEARCOAT_BUMPDIRECTUV: number;
  50850. CLEARCOAT_TINT: boolean;
  50851. CLEARCOAT_TINT_TEXTURE: boolean;
  50852. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50853. ANISOTROPIC: boolean;
  50854. ANISOTROPIC_TEXTURE: boolean;
  50855. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50856. BRDF_V_HEIGHT_CORRELATED: boolean;
  50857. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50858. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50859. SHEEN: boolean;
  50860. SHEEN_TEXTURE: boolean;
  50861. SHEEN_TEXTUREDIRECTUV: number;
  50862. SHEEN_LINKWITHALBEDO: boolean;
  50863. SUBSURFACE: boolean;
  50864. SS_REFRACTION: boolean;
  50865. SS_TRANSLUCENCY: boolean;
  50866. SS_SCATERRING: boolean;
  50867. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50868. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50869. SS_REFRACTIONMAP_3D: boolean;
  50870. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50871. SS_LODINREFRACTIONALPHA: boolean;
  50872. SS_GAMMAREFRACTION: boolean;
  50873. SS_RGBDREFRACTION: boolean;
  50874. SS_LINEARSPECULARREFRACTION: boolean;
  50875. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50876. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50877. UNLIT: boolean;
  50878. DEBUGMODE: number;
  50879. /**
  50880. * Initializes the PBR Material defines.
  50881. */
  50882. constructor();
  50883. /**
  50884. * Resets the PBR Material defines.
  50885. */
  50886. reset(): void;
  50887. }
  50888. /**
  50889. * The Physically based material base class of BJS.
  50890. *
  50891. * This offers the main features of a standard PBR material.
  50892. * For more information, please refer to the documentation :
  50893. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50894. */
  50895. export abstract class PBRBaseMaterial extends PushMaterial {
  50896. /**
  50897. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50898. */
  50899. static readonly PBRMATERIAL_OPAQUE: number;
  50900. /**
  50901. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50902. */
  50903. static readonly PBRMATERIAL_ALPHATEST: number;
  50904. /**
  50905. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50906. */
  50907. static readonly PBRMATERIAL_ALPHABLEND: number;
  50908. /**
  50909. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50910. * They are also discarded below the alpha cutoff threshold to improve performances.
  50911. */
  50912. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50913. /**
  50914. * Defines the default value of how much AO map is occluding the analytical lights
  50915. * (point spot...).
  50916. */
  50917. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50918. /**
  50919. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50920. */
  50921. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50922. /**
  50923. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50924. * to enhance interoperability with other engines.
  50925. */
  50926. static readonly LIGHTFALLOFF_GLTF: number;
  50927. /**
  50928. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50929. * to enhance interoperability with other materials.
  50930. */
  50931. static readonly LIGHTFALLOFF_STANDARD: number;
  50932. /**
  50933. * Intensity of the direct lights e.g. the four lights available in your scene.
  50934. * This impacts both the direct diffuse and specular highlights.
  50935. */
  50936. protected _directIntensity: number;
  50937. /**
  50938. * Intensity of the emissive part of the material.
  50939. * This helps controlling the emissive effect without modifying the emissive color.
  50940. */
  50941. protected _emissiveIntensity: number;
  50942. /**
  50943. * Intensity of the environment e.g. how much the environment will light the object
  50944. * either through harmonics for rough material or through the refelction for shiny ones.
  50945. */
  50946. protected _environmentIntensity: number;
  50947. /**
  50948. * This is a special control allowing the reduction of the specular highlights coming from the
  50949. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50950. */
  50951. protected _specularIntensity: number;
  50952. /**
  50953. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50954. */
  50955. private _lightingInfos;
  50956. /**
  50957. * Debug Control allowing disabling the bump map on this material.
  50958. */
  50959. protected _disableBumpMap: boolean;
  50960. /**
  50961. * AKA Diffuse Texture in standard nomenclature.
  50962. */
  50963. protected _albedoTexture: Nullable<BaseTexture>;
  50964. /**
  50965. * AKA Occlusion Texture in other nomenclature.
  50966. */
  50967. protected _ambientTexture: Nullable<BaseTexture>;
  50968. /**
  50969. * AKA Occlusion Texture Intensity in other nomenclature.
  50970. */
  50971. protected _ambientTextureStrength: number;
  50972. /**
  50973. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50974. * 1 means it completely occludes it
  50975. * 0 mean it has no impact
  50976. */
  50977. protected _ambientTextureImpactOnAnalyticalLights: number;
  50978. /**
  50979. * Stores the alpha values in a texture.
  50980. */
  50981. protected _opacityTexture: Nullable<BaseTexture>;
  50982. /**
  50983. * Stores the reflection values in a texture.
  50984. */
  50985. protected _reflectionTexture: Nullable<BaseTexture>;
  50986. /**
  50987. * Stores the emissive values in a texture.
  50988. */
  50989. protected _emissiveTexture: Nullable<BaseTexture>;
  50990. /**
  50991. * AKA Specular texture in other nomenclature.
  50992. */
  50993. protected _reflectivityTexture: Nullable<BaseTexture>;
  50994. /**
  50995. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50996. */
  50997. protected _metallicTexture: Nullable<BaseTexture>;
  50998. /**
  50999. * Specifies the metallic scalar of the metallic/roughness workflow.
  51000. * Can also be used to scale the metalness values of the metallic texture.
  51001. */
  51002. protected _metallic: Nullable<number>;
  51003. /**
  51004. * Specifies the roughness scalar of the metallic/roughness workflow.
  51005. * Can also be used to scale the roughness values of the metallic texture.
  51006. */
  51007. protected _roughness: Nullable<number>;
  51008. /**
  51009. * Specifies the an F0 factor to help configuring the material F0.
  51010. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51011. * to 0.5 the previously hard coded value stays the same.
  51012. * Can also be used to scale the F0 values of the metallic texture.
  51013. */
  51014. protected _metallicF0Factor: number;
  51015. /**
  51016. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51017. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51018. * your expectation as it multiplies with the texture data.
  51019. */
  51020. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51021. /**
  51022. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51023. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51024. */
  51025. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51026. /**
  51027. * Stores surface normal data used to displace a mesh in a texture.
  51028. */
  51029. protected _bumpTexture: Nullable<BaseTexture>;
  51030. /**
  51031. * Stores the pre-calculated light information of a mesh in a texture.
  51032. */
  51033. protected _lightmapTexture: Nullable<BaseTexture>;
  51034. /**
  51035. * The color of a material in ambient lighting.
  51036. */
  51037. protected _ambientColor: Color3;
  51038. /**
  51039. * AKA Diffuse Color in other nomenclature.
  51040. */
  51041. protected _albedoColor: Color3;
  51042. /**
  51043. * AKA Specular Color in other nomenclature.
  51044. */
  51045. protected _reflectivityColor: Color3;
  51046. /**
  51047. * The color applied when light is reflected from a material.
  51048. */
  51049. protected _reflectionColor: Color3;
  51050. /**
  51051. * The color applied when light is emitted from a material.
  51052. */
  51053. protected _emissiveColor: Color3;
  51054. /**
  51055. * AKA Glossiness in other nomenclature.
  51056. */
  51057. protected _microSurface: number;
  51058. /**
  51059. * Specifies that the material will use the light map as a show map.
  51060. */
  51061. protected _useLightmapAsShadowmap: boolean;
  51062. /**
  51063. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51064. * makes the reflect vector face the model (under horizon).
  51065. */
  51066. protected _useHorizonOcclusion: boolean;
  51067. /**
  51068. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51069. * too much the area relying on ambient texture to define their ambient occlusion.
  51070. */
  51071. protected _useRadianceOcclusion: boolean;
  51072. /**
  51073. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51074. */
  51075. protected _useAlphaFromAlbedoTexture: boolean;
  51076. /**
  51077. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51078. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51079. */
  51080. protected _useSpecularOverAlpha: boolean;
  51081. /**
  51082. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51083. */
  51084. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51085. /**
  51086. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51087. */
  51088. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51089. /**
  51090. * Specifies if the metallic texture contains the roughness information in its green channel.
  51091. */
  51092. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51093. /**
  51094. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51095. */
  51096. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51097. /**
  51098. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51099. */
  51100. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51101. /**
  51102. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51103. */
  51104. protected _useAmbientInGrayScale: boolean;
  51105. /**
  51106. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51107. * The material will try to infer what glossiness each pixel should be.
  51108. */
  51109. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51110. /**
  51111. * Defines the falloff type used in this material.
  51112. * It by default is Physical.
  51113. */
  51114. protected _lightFalloff: number;
  51115. /**
  51116. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51117. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51118. */
  51119. protected _useRadianceOverAlpha: boolean;
  51120. /**
  51121. * Allows using an object space normal map (instead of tangent space).
  51122. */
  51123. protected _useObjectSpaceNormalMap: boolean;
  51124. /**
  51125. * Allows using the bump map in parallax mode.
  51126. */
  51127. protected _useParallax: boolean;
  51128. /**
  51129. * Allows using the bump map in parallax occlusion mode.
  51130. */
  51131. protected _useParallaxOcclusion: boolean;
  51132. /**
  51133. * Controls the scale bias of the parallax mode.
  51134. */
  51135. protected _parallaxScaleBias: number;
  51136. /**
  51137. * If sets to true, disables all the lights affecting the material.
  51138. */
  51139. protected _disableLighting: boolean;
  51140. /**
  51141. * Number of Simultaneous lights allowed on the material.
  51142. */
  51143. protected _maxSimultaneousLights: number;
  51144. /**
  51145. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51146. */
  51147. protected _invertNormalMapX: boolean;
  51148. /**
  51149. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51150. */
  51151. protected _invertNormalMapY: boolean;
  51152. /**
  51153. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51154. */
  51155. protected _twoSidedLighting: boolean;
  51156. /**
  51157. * Defines the alpha limits in alpha test mode.
  51158. */
  51159. protected _alphaCutOff: number;
  51160. /**
  51161. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51162. */
  51163. protected _forceAlphaTest: boolean;
  51164. /**
  51165. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51166. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51167. */
  51168. protected _useAlphaFresnel: boolean;
  51169. /**
  51170. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51171. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51172. */
  51173. protected _useLinearAlphaFresnel: boolean;
  51174. /**
  51175. * The transparency mode of the material.
  51176. */
  51177. protected _transparencyMode: Nullable<number>;
  51178. /**
  51179. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51180. * from cos thetav and roughness:
  51181. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51182. */
  51183. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51184. /**
  51185. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51186. */
  51187. protected _forceIrradianceInFragment: boolean;
  51188. /**
  51189. * Force normal to face away from face.
  51190. */
  51191. protected _forceNormalForward: boolean;
  51192. /**
  51193. * Enables specular anti aliasing in the PBR shader.
  51194. * It will both interacts on the Geometry for analytical and IBL lighting.
  51195. * It also prefilter the roughness map based on the bump values.
  51196. */
  51197. protected _enableSpecularAntiAliasing: boolean;
  51198. /**
  51199. * Default configuration related to image processing available in the PBR Material.
  51200. */
  51201. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51202. /**
  51203. * Keep track of the image processing observer to allow dispose and replace.
  51204. */
  51205. private _imageProcessingObserver;
  51206. /**
  51207. * Attaches a new image processing configuration to the PBR Material.
  51208. * @param configuration
  51209. */
  51210. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51211. /**
  51212. * Stores the available render targets.
  51213. */
  51214. private _renderTargets;
  51215. /**
  51216. * Sets the global ambient color for the material used in lighting calculations.
  51217. */
  51218. private _globalAmbientColor;
  51219. /**
  51220. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51221. */
  51222. private _useLogarithmicDepth;
  51223. /**
  51224. * If set to true, no lighting calculations will be applied.
  51225. */
  51226. private _unlit;
  51227. private _debugMode;
  51228. /**
  51229. * @hidden
  51230. * This is reserved for the inspector.
  51231. * Defines the material debug mode.
  51232. * It helps seeing only some components of the material while troubleshooting.
  51233. */
  51234. debugMode: number;
  51235. /**
  51236. * @hidden
  51237. * This is reserved for the inspector.
  51238. * Specify from where on screen the debug mode should start.
  51239. * The value goes from -1 (full screen) to 1 (not visible)
  51240. * It helps with side by side comparison against the final render
  51241. * This defaults to -1
  51242. */
  51243. private debugLimit;
  51244. /**
  51245. * @hidden
  51246. * This is reserved for the inspector.
  51247. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51248. * You can use the factor to better multiply the final value.
  51249. */
  51250. private debugFactor;
  51251. /**
  51252. * Defines the clear coat layer parameters for the material.
  51253. */
  51254. readonly clearCoat: PBRClearCoatConfiguration;
  51255. /**
  51256. * Defines the anisotropic parameters for the material.
  51257. */
  51258. readonly anisotropy: PBRAnisotropicConfiguration;
  51259. /**
  51260. * Defines the BRDF parameters for the material.
  51261. */
  51262. readonly brdf: PBRBRDFConfiguration;
  51263. /**
  51264. * Defines the Sheen parameters for the material.
  51265. */
  51266. readonly sheen: PBRSheenConfiguration;
  51267. /**
  51268. * Defines the SubSurface parameters for the material.
  51269. */
  51270. readonly subSurface: PBRSubSurfaceConfiguration;
  51271. /**
  51272. * Custom callback helping to override the default shader used in the material.
  51273. */
  51274. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51275. protected _rebuildInParallel: boolean;
  51276. /**
  51277. * Instantiates a new PBRMaterial instance.
  51278. *
  51279. * @param name The material name
  51280. * @param scene The scene the material will be use in.
  51281. */
  51282. constructor(name: string, scene: Scene);
  51283. /**
  51284. * Gets a boolean indicating that current material needs to register RTT
  51285. */
  51286. get hasRenderTargetTextures(): boolean;
  51287. /**
  51288. * Gets the name of the material class.
  51289. */
  51290. getClassName(): string;
  51291. /**
  51292. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51293. */
  51294. get useLogarithmicDepth(): boolean;
  51295. /**
  51296. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51297. */
  51298. set useLogarithmicDepth(value: boolean);
  51299. /**
  51300. * Gets the current transparency mode.
  51301. */
  51302. get transparencyMode(): Nullable<number>;
  51303. /**
  51304. * Sets the transparency mode of the material.
  51305. *
  51306. * | Value | Type | Description |
  51307. * | ----- | ----------------------------------- | ----------- |
  51308. * | 0 | OPAQUE | |
  51309. * | 1 | ALPHATEST | |
  51310. * | 2 | ALPHABLEND | |
  51311. * | 3 | ALPHATESTANDBLEND | |
  51312. *
  51313. */
  51314. set transparencyMode(value: Nullable<number>);
  51315. /**
  51316. * Returns true if alpha blending should be disabled.
  51317. */
  51318. private get _disableAlphaBlending();
  51319. /**
  51320. * Specifies whether or not this material should be rendered in alpha blend mode.
  51321. */
  51322. needAlphaBlending(): boolean;
  51323. /**
  51324. * Specifies if the mesh will require alpha blending.
  51325. * @param mesh - BJS mesh.
  51326. */
  51327. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51328. /**
  51329. * Specifies whether or not this material should be rendered in alpha test mode.
  51330. */
  51331. needAlphaTesting(): boolean;
  51332. /**
  51333. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51334. */
  51335. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51336. /**
  51337. * Gets the texture used for the alpha test.
  51338. */
  51339. getAlphaTestTexture(): Nullable<BaseTexture>;
  51340. /**
  51341. * Specifies that the submesh is ready to be used.
  51342. * @param mesh - BJS mesh.
  51343. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51344. * @param useInstances - Specifies that instances should be used.
  51345. * @returns - boolean indicating that the submesh is ready or not.
  51346. */
  51347. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51348. /**
  51349. * Specifies if the material uses metallic roughness workflow.
  51350. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51351. */
  51352. isMetallicWorkflow(): boolean;
  51353. private _prepareEffect;
  51354. private _prepareDefines;
  51355. /**
  51356. * Force shader compilation
  51357. */
  51358. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51359. /**
  51360. * Initializes the uniform buffer layout for the shader.
  51361. */
  51362. buildUniformLayout(): void;
  51363. /**
  51364. * Unbinds the material from the mesh
  51365. */
  51366. unbind(): void;
  51367. /**
  51368. * Binds the submesh data.
  51369. * @param world - The world matrix.
  51370. * @param mesh - The BJS mesh.
  51371. * @param subMesh - A submesh of the BJS mesh.
  51372. */
  51373. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51374. /**
  51375. * Returns the animatable textures.
  51376. * @returns - Array of animatable textures.
  51377. */
  51378. getAnimatables(): IAnimatable[];
  51379. /**
  51380. * Returns the texture used for reflections.
  51381. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51382. */
  51383. private _getReflectionTexture;
  51384. /**
  51385. * Returns an array of the actively used textures.
  51386. * @returns - Array of BaseTextures
  51387. */
  51388. getActiveTextures(): BaseTexture[];
  51389. /**
  51390. * Checks to see if a texture is used in the material.
  51391. * @param texture - Base texture to use.
  51392. * @returns - Boolean specifying if a texture is used in the material.
  51393. */
  51394. hasTexture(texture: BaseTexture): boolean;
  51395. /**
  51396. * Disposes the resources of the material.
  51397. * @param forceDisposeEffect - Forces the disposal of effects.
  51398. * @param forceDisposeTextures - Forces the disposal of all textures.
  51399. */
  51400. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51401. }
  51402. }
  51403. declare module BABYLON {
  51404. /**
  51405. * The Physically based material of BJS.
  51406. *
  51407. * This offers the main features of a standard PBR material.
  51408. * For more information, please refer to the documentation :
  51409. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51410. */
  51411. export class PBRMaterial extends PBRBaseMaterial {
  51412. /**
  51413. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51414. */
  51415. static readonly PBRMATERIAL_OPAQUE: number;
  51416. /**
  51417. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51418. */
  51419. static readonly PBRMATERIAL_ALPHATEST: number;
  51420. /**
  51421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51422. */
  51423. static readonly PBRMATERIAL_ALPHABLEND: number;
  51424. /**
  51425. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51426. * They are also discarded below the alpha cutoff threshold to improve performances.
  51427. */
  51428. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51429. /**
  51430. * Defines the default value of how much AO map is occluding the analytical lights
  51431. * (point spot...).
  51432. */
  51433. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51434. /**
  51435. * Intensity of the direct lights e.g. the four lights available in your scene.
  51436. * This impacts both the direct diffuse and specular highlights.
  51437. */
  51438. directIntensity: number;
  51439. /**
  51440. * Intensity of the emissive part of the material.
  51441. * This helps controlling the emissive effect without modifying the emissive color.
  51442. */
  51443. emissiveIntensity: number;
  51444. /**
  51445. * Intensity of the environment e.g. how much the environment will light the object
  51446. * either through harmonics for rough material or through the refelction for shiny ones.
  51447. */
  51448. environmentIntensity: number;
  51449. /**
  51450. * This is a special control allowing the reduction of the specular highlights coming from the
  51451. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51452. */
  51453. specularIntensity: number;
  51454. /**
  51455. * Debug Control allowing disabling the bump map on this material.
  51456. */
  51457. disableBumpMap: boolean;
  51458. /**
  51459. * AKA Diffuse Texture in standard nomenclature.
  51460. */
  51461. albedoTexture: BaseTexture;
  51462. /**
  51463. * AKA Occlusion Texture in other nomenclature.
  51464. */
  51465. ambientTexture: BaseTexture;
  51466. /**
  51467. * AKA Occlusion Texture Intensity in other nomenclature.
  51468. */
  51469. ambientTextureStrength: number;
  51470. /**
  51471. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51472. * 1 means it completely occludes it
  51473. * 0 mean it has no impact
  51474. */
  51475. ambientTextureImpactOnAnalyticalLights: number;
  51476. /**
  51477. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51478. */
  51479. opacityTexture: BaseTexture;
  51480. /**
  51481. * Stores the reflection values in a texture.
  51482. */
  51483. reflectionTexture: Nullable<BaseTexture>;
  51484. /**
  51485. * Stores the emissive values in a texture.
  51486. */
  51487. emissiveTexture: BaseTexture;
  51488. /**
  51489. * AKA Specular texture in other nomenclature.
  51490. */
  51491. reflectivityTexture: BaseTexture;
  51492. /**
  51493. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51494. */
  51495. metallicTexture: BaseTexture;
  51496. /**
  51497. * Specifies the metallic scalar of the metallic/roughness workflow.
  51498. * Can also be used to scale the metalness values of the metallic texture.
  51499. */
  51500. metallic: Nullable<number>;
  51501. /**
  51502. * Specifies the roughness scalar of the metallic/roughness workflow.
  51503. * Can also be used to scale the roughness values of the metallic texture.
  51504. */
  51505. roughness: Nullable<number>;
  51506. /**
  51507. * Specifies the an F0 factor to help configuring the material F0.
  51508. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51509. * to 0.5 the previously hard coded value stays the same.
  51510. * Can also be used to scale the F0 values of the metallic texture.
  51511. */
  51512. metallicF0Factor: number;
  51513. /**
  51514. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51515. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51516. * your expectation as it multiplies with the texture data.
  51517. */
  51518. useMetallicF0FactorFromMetallicTexture: boolean;
  51519. /**
  51520. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51521. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51522. */
  51523. microSurfaceTexture: BaseTexture;
  51524. /**
  51525. * Stores surface normal data used to displace a mesh in a texture.
  51526. */
  51527. bumpTexture: BaseTexture;
  51528. /**
  51529. * Stores the pre-calculated light information of a mesh in a texture.
  51530. */
  51531. lightmapTexture: BaseTexture;
  51532. /**
  51533. * Stores the refracted light information in a texture.
  51534. */
  51535. get refractionTexture(): Nullable<BaseTexture>;
  51536. set refractionTexture(value: Nullable<BaseTexture>);
  51537. /**
  51538. * The color of a material in ambient lighting.
  51539. */
  51540. ambientColor: Color3;
  51541. /**
  51542. * AKA Diffuse Color in other nomenclature.
  51543. */
  51544. albedoColor: Color3;
  51545. /**
  51546. * AKA Specular Color in other nomenclature.
  51547. */
  51548. reflectivityColor: Color3;
  51549. /**
  51550. * The color reflected from the material.
  51551. */
  51552. reflectionColor: Color3;
  51553. /**
  51554. * The color emitted from the material.
  51555. */
  51556. emissiveColor: Color3;
  51557. /**
  51558. * AKA Glossiness in other nomenclature.
  51559. */
  51560. microSurface: number;
  51561. /**
  51562. * source material index of refraction (IOR)' / 'destination material IOR.
  51563. */
  51564. get indexOfRefraction(): number;
  51565. set indexOfRefraction(value: number);
  51566. /**
  51567. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51568. */
  51569. get invertRefractionY(): boolean;
  51570. set invertRefractionY(value: boolean);
  51571. /**
  51572. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51573. * Materials half opaque for instance using refraction could benefit from this control.
  51574. */
  51575. get linkRefractionWithTransparency(): boolean;
  51576. set linkRefractionWithTransparency(value: boolean);
  51577. /**
  51578. * If true, the light map contains occlusion information instead of lighting info.
  51579. */
  51580. useLightmapAsShadowmap: boolean;
  51581. /**
  51582. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51583. */
  51584. useAlphaFromAlbedoTexture: boolean;
  51585. /**
  51586. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51587. */
  51588. forceAlphaTest: boolean;
  51589. /**
  51590. * Defines the alpha limits in alpha test mode.
  51591. */
  51592. alphaCutOff: number;
  51593. /**
  51594. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51595. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51596. */
  51597. useSpecularOverAlpha: boolean;
  51598. /**
  51599. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51600. */
  51601. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51602. /**
  51603. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51604. */
  51605. useRoughnessFromMetallicTextureAlpha: boolean;
  51606. /**
  51607. * Specifies if the metallic texture contains the roughness information in its green channel.
  51608. */
  51609. useRoughnessFromMetallicTextureGreen: boolean;
  51610. /**
  51611. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51612. */
  51613. useMetallnessFromMetallicTextureBlue: boolean;
  51614. /**
  51615. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51616. */
  51617. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51618. /**
  51619. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51620. */
  51621. useAmbientInGrayScale: boolean;
  51622. /**
  51623. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51624. * The material will try to infer what glossiness each pixel should be.
  51625. */
  51626. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51627. /**
  51628. * BJS is using an harcoded light falloff based on a manually sets up range.
  51629. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51630. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51631. */
  51632. get usePhysicalLightFalloff(): boolean;
  51633. /**
  51634. * BJS is using an harcoded light falloff based on a manually sets up range.
  51635. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51636. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51637. */
  51638. set usePhysicalLightFalloff(value: boolean);
  51639. /**
  51640. * In order to support the falloff compatibility with gltf, a special mode has been added
  51641. * to reproduce the gltf light falloff.
  51642. */
  51643. get useGLTFLightFalloff(): boolean;
  51644. /**
  51645. * In order to support the falloff compatibility with gltf, a special mode has been added
  51646. * to reproduce the gltf light falloff.
  51647. */
  51648. set useGLTFLightFalloff(value: boolean);
  51649. /**
  51650. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51651. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51652. */
  51653. useRadianceOverAlpha: boolean;
  51654. /**
  51655. * Allows using an object space normal map (instead of tangent space).
  51656. */
  51657. useObjectSpaceNormalMap: boolean;
  51658. /**
  51659. * Allows using the bump map in parallax mode.
  51660. */
  51661. useParallax: boolean;
  51662. /**
  51663. * Allows using the bump map in parallax occlusion mode.
  51664. */
  51665. useParallaxOcclusion: boolean;
  51666. /**
  51667. * Controls the scale bias of the parallax mode.
  51668. */
  51669. parallaxScaleBias: number;
  51670. /**
  51671. * If sets to true, disables all the lights affecting the material.
  51672. */
  51673. disableLighting: boolean;
  51674. /**
  51675. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51676. */
  51677. forceIrradianceInFragment: boolean;
  51678. /**
  51679. * Number of Simultaneous lights allowed on the material.
  51680. */
  51681. maxSimultaneousLights: number;
  51682. /**
  51683. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51684. */
  51685. invertNormalMapX: boolean;
  51686. /**
  51687. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51688. */
  51689. invertNormalMapY: boolean;
  51690. /**
  51691. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51692. */
  51693. twoSidedLighting: boolean;
  51694. /**
  51695. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51696. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51697. */
  51698. useAlphaFresnel: boolean;
  51699. /**
  51700. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51701. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51702. */
  51703. useLinearAlphaFresnel: boolean;
  51704. /**
  51705. * Let user defines the brdf lookup texture used for IBL.
  51706. * A default 8bit version is embedded but you could point at :
  51707. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51708. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51709. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51710. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51711. */
  51712. environmentBRDFTexture: Nullable<BaseTexture>;
  51713. /**
  51714. * Force normal to face away from face.
  51715. */
  51716. forceNormalForward: boolean;
  51717. /**
  51718. * Enables specular anti aliasing in the PBR shader.
  51719. * It will both interacts on the Geometry for analytical and IBL lighting.
  51720. * It also prefilter the roughness map based on the bump values.
  51721. */
  51722. enableSpecularAntiAliasing: boolean;
  51723. /**
  51724. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51725. * makes the reflect vector face the model (under horizon).
  51726. */
  51727. useHorizonOcclusion: boolean;
  51728. /**
  51729. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51730. * too much the area relying on ambient texture to define their ambient occlusion.
  51731. */
  51732. useRadianceOcclusion: boolean;
  51733. /**
  51734. * If set to true, no lighting calculations will be applied.
  51735. */
  51736. unlit: boolean;
  51737. /**
  51738. * Gets the image processing configuration used either in this material.
  51739. */
  51740. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51741. /**
  51742. * Sets the Default image processing configuration used either in the this material.
  51743. *
  51744. * If sets to null, the scene one is in use.
  51745. */
  51746. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51747. /**
  51748. * Gets wether the color curves effect is enabled.
  51749. */
  51750. get cameraColorCurvesEnabled(): boolean;
  51751. /**
  51752. * Sets wether the color curves effect is enabled.
  51753. */
  51754. set cameraColorCurvesEnabled(value: boolean);
  51755. /**
  51756. * Gets wether the color grading effect is enabled.
  51757. */
  51758. get cameraColorGradingEnabled(): boolean;
  51759. /**
  51760. * Gets wether the color grading effect is enabled.
  51761. */
  51762. set cameraColorGradingEnabled(value: boolean);
  51763. /**
  51764. * Gets wether tonemapping is enabled or not.
  51765. */
  51766. get cameraToneMappingEnabled(): boolean;
  51767. /**
  51768. * Sets wether tonemapping is enabled or not
  51769. */
  51770. set cameraToneMappingEnabled(value: boolean);
  51771. /**
  51772. * The camera exposure used on this material.
  51773. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51774. * This corresponds to a photographic exposure.
  51775. */
  51776. get cameraExposure(): number;
  51777. /**
  51778. * The camera exposure used on this material.
  51779. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51780. * This corresponds to a photographic exposure.
  51781. */
  51782. set cameraExposure(value: number);
  51783. /**
  51784. * Gets The camera contrast used on this material.
  51785. */
  51786. get cameraContrast(): number;
  51787. /**
  51788. * Sets The camera contrast used on this material.
  51789. */
  51790. set cameraContrast(value: number);
  51791. /**
  51792. * Gets the Color Grading 2D Lookup Texture.
  51793. */
  51794. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51795. /**
  51796. * Sets the Color Grading 2D Lookup Texture.
  51797. */
  51798. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51799. /**
  51800. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51801. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51802. * 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;
  51803. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51804. */
  51805. get cameraColorCurves(): Nullable<ColorCurves>;
  51806. /**
  51807. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51808. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51809. * 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;
  51810. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51811. */
  51812. set cameraColorCurves(value: Nullable<ColorCurves>);
  51813. /**
  51814. * Instantiates a new PBRMaterial instance.
  51815. *
  51816. * @param name The material name
  51817. * @param scene The scene the material will be use in.
  51818. */
  51819. constructor(name: string, scene: Scene);
  51820. /**
  51821. * Returns the name of this material class.
  51822. */
  51823. getClassName(): string;
  51824. /**
  51825. * Makes a duplicate of the current material.
  51826. * @param name - name to use for the new material.
  51827. */
  51828. clone(name: string): PBRMaterial;
  51829. /**
  51830. * Serializes this PBR Material.
  51831. * @returns - An object with the serialized material.
  51832. */
  51833. serialize(): any;
  51834. /**
  51835. * Parses a PBR Material from a serialized object.
  51836. * @param source - Serialized object.
  51837. * @param scene - BJS scene instance.
  51838. * @param rootUrl - url for the scene object
  51839. * @returns - PBRMaterial
  51840. */
  51841. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51842. }
  51843. }
  51844. declare module BABYLON {
  51845. /**
  51846. * Direct draw surface info
  51847. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51848. */
  51849. export interface DDSInfo {
  51850. /**
  51851. * Width of the texture
  51852. */
  51853. width: number;
  51854. /**
  51855. * Width of the texture
  51856. */
  51857. height: number;
  51858. /**
  51859. * Number of Mipmaps for the texture
  51860. * @see https://en.wikipedia.org/wiki/Mipmap
  51861. */
  51862. mipmapCount: number;
  51863. /**
  51864. * If the textures format is a known fourCC format
  51865. * @see https://www.fourcc.org/
  51866. */
  51867. isFourCC: boolean;
  51868. /**
  51869. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51870. */
  51871. isRGB: boolean;
  51872. /**
  51873. * If the texture is a lumincance format
  51874. */
  51875. isLuminance: boolean;
  51876. /**
  51877. * If this is a cube texture
  51878. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51879. */
  51880. isCube: boolean;
  51881. /**
  51882. * If the texture is a compressed format eg. FOURCC_DXT1
  51883. */
  51884. isCompressed: boolean;
  51885. /**
  51886. * The dxgiFormat of the texture
  51887. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51888. */
  51889. dxgiFormat: number;
  51890. /**
  51891. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51892. */
  51893. textureType: number;
  51894. /**
  51895. * Sphericle polynomial created for the dds texture
  51896. */
  51897. sphericalPolynomial?: SphericalPolynomial;
  51898. }
  51899. /**
  51900. * Class used to provide DDS decompression tools
  51901. */
  51902. export class DDSTools {
  51903. /**
  51904. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51905. */
  51906. static StoreLODInAlphaChannel: boolean;
  51907. /**
  51908. * Gets DDS information from an array buffer
  51909. * @param data defines the array buffer view to read data from
  51910. * @returns the DDS information
  51911. */
  51912. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51913. private static _FloatView;
  51914. private static _Int32View;
  51915. private static _ToHalfFloat;
  51916. private static _FromHalfFloat;
  51917. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51918. private static _GetHalfFloatRGBAArrayBuffer;
  51919. private static _GetFloatRGBAArrayBuffer;
  51920. private static _GetFloatAsUIntRGBAArrayBuffer;
  51921. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51922. private static _GetRGBAArrayBuffer;
  51923. private static _ExtractLongWordOrder;
  51924. private static _GetRGBArrayBuffer;
  51925. private static _GetLuminanceArrayBuffer;
  51926. /**
  51927. * Uploads DDS Levels to a Babylon Texture
  51928. * @hidden
  51929. */
  51930. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51931. }
  51932. interface ThinEngine {
  51933. /**
  51934. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51935. * @param rootUrl defines the url where the file to load is located
  51936. * @param scene defines the current scene
  51937. * @param lodScale defines scale to apply to the mip map selection
  51938. * @param lodOffset defines offset to apply to the mip map selection
  51939. * @param onLoad defines an optional callback raised when the texture is loaded
  51940. * @param onError defines an optional callback raised if there is an issue to load the texture
  51941. * @param format defines the format of the data
  51942. * @param forcedExtension defines the extension to use to pick the right loader
  51943. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51944. * @returns the cube texture as an InternalTexture
  51945. */
  51946. 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;
  51947. }
  51948. }
  51949. declare module BABYLON {
  51950. /**
  51951. * Implementation of the DDS Texture Loader.
  51952. * @hidden
  51953. */
  51954. export class _DDSTextureLoader implements IInternalTextureLoader {
  51955. /**
  51956. * Defines wether the loader supports cascade loading the different faces.
  51957. */
  51958. readonly supportCascades: boolean;
  51959. /**
  51960. * This returns if the loader support the current file information.
  51961. * @param extension defines the file extension of the file being loaded
  51962. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51963. * @param fallback defines the fallback internal texture if any
  51964. * @param isBase64 defines whether the texture is encoded as a base64
  51965. * @param isBuffer defines whether the texture data are stored as a buffer
  51966. * @returns true if the loader can load the specified file
  51967. */
  51968. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51969. /**
  51970. * Transform the url before loading if required.
  51971. * @param rootUrl the url of the texture
  51972. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51973. * @returns the transformed texture
  51974. */
  51975. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51976. /**
  51977. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51978. * @param rootUrl the url of the texture
  51979. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51980. * @returns the fallback texture
  51981. */
  51982. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51983. /**
  51984. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51985. * @param data contains the texture data
  51986. * @param texture defines the BabylonJS internal texture
  51987. * @param createPolynomials will be true if polynomials have been requested
  51988. * @param onLoad defines the callback to trigger once the texture is ready
  51989. * @param onError defines the callback to trigger in case of error
  51990. */
  51991. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51992. /**
  51993. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51994. * @param data contains the texture data
  51995. * @param texture defines the BabylonJS internal texture
  51996. * @param callback defines the method to call once ready to upload
  51997. */
  51998. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51999. }
  52000. }
  52001. declare module BABYLON {
  52002. /**
  52003. * Implementation of the ENV Texture Loader.
  52004. * @hidden
  52005. */
  52006. export class _ENVTextureLoader implements IInternalTextureLoader {
  52007. /**
  52008. * Defines wether the loader supports cascade loading the different faces.
  52009. */
  52010. readonly supportCascades: boolean;
  52011. /**
  52012. * This returns if the loader support the current file information.
  52013. * @param extension defines the file extension of the file being loaded
  52014. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52015. * @param fallback defines the fallback internal texture if any
  52016. * @param isBase64 defines whether the texture is encoded as a base64
  52017. * @param isBuffer defines whether the texture data are stored as a buffer
  52018. * @returns true if the loader can load the specified file
  52019. */
  52020. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52021. /**
  52022. * Transform the url before loading if required.
  52023. * @param rootUrl the url of the texture
  52024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52025. * @returns the transformed texture
  52026. */
  52027. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52028. /**
  52029. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52030. * @param rootUrl the url of the texture
  52031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52032. * @returns the fallback texture
  52033. */
  52034. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52035. /**
  52036. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52037. * @param data contains the texture data
  52038. * @param texture defines the BabylonJS internal texture
  52039. * @param createPolynomials will be true if polynomials have been requested
  52040. * @param onLoad defines the callback to trigger once the texture is ready
  52041. * @param onError defines the callback to trigger in case of error
  52042. */
  52043. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52044. /**
  52045. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52046. * @param data contains the texture data
  52047. * @param texture defines the BabylonJS internal texture
  52048. * @param callback defines the method to call once ready to upload
  52049. */
  52050. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52051. }
  52052. }
  52053. declare module BABYLON {
  52054. /**
  52055. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52056. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52057. */
  52058. export class KhronosTextureContainer {
  52059. /** contents of the KTX container file */
  52060. data: ArrayBufferView;
  52061. private static HEADER_LEN;
  52062. private static COMPRESSED_2D;
  52063. private static COMPRESSED_3D;
  52064. private static TEX_2D;
  52065. private static TEX_3D;
  52066. /**
  52067. * Gets the openGL type
  52068. */
  52069. glType: number;
  52070. /**
  52071. * Gets the openGL type size
  52072. */
  52073. glTypeSize: number;
  52074. /**
  52075. * Gets the openGL format
  52076. */
  52077. glFormat: number;
  52078. /**
  52079. * Gets the openGL internal format
  52080. */
  52081. glInternalFormat: number;
  52082. /**
  52083. * Gets the base internal format
  52084. */
  52085. glBaseInternalFormat: number;
  52086. /**
  52087. * Gets image width in pixel
  52088. */
  52089. pixelWidth: number;
  52090. /**
  52091. * Gets image height in pixel
  52092. */
  52093. pixelHeight: number;
  52094. /**
  52095. * Gets image depth in pixels
  52096. */
  52097. pixelDepth: number;
  52098. /**
  52099. * Gets the number of array elements
  52100. */
  52101. numberOfArrayElements: number;
  52102. /**
  52103. * Gets the number of faces
  52104. */
  52105. numberOfFaces: number;
  52106. /**
  52107. * Gets the number of mipmap levels
  52108. */
  52109. numberOfMipmapLevels: number;
  52110. /**
  52111. * Gets the bytes of key value data
  52112. */
  52113. bytesOfKeyValueData: number;
  52114. /**
  52115. * Gets the load type
  52116. */
  52117. loadType: number;
  52118. /**
  52119. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52120. */
  52121. isInvalid: boolean;
  52122. /**
  52123. * Creates a new KhronosTextureContainer
  52124. * @param data contents of the KTX container file
  52125. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52126. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52127. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52128. */
  52129. constructor(
  52130. /** contents of the KTX container file */
  52131. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52132. /**
  52133. * Uploads KTX content to a Babylon Texture.
  52134. * It is assumed that the texture has already been created & is currently bound
  52135. * @hidden
  52136. */
  52137. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52138. private _upload2DCompressedLevels;
  52139. }
  52140. }
  52141. declare module BABYLON {
  52142. /**
  52143. * Implementation of the KTX Texture Loader.
  52144. * @hidden
  52145. */
  52146. export class _KTXTextureLoader implements IInternalTextureLoader {
  52147. /**
  52148. * Defines wether the loader supports cascade loading the different faces.
  52149. */
  52150. readonly supportCascades: boolean;
  52151. /**
  52152. * This returns if the loader support the current file information.
  52153. * @param extension defines the file extension of the file being loaded
  52154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52155. * @param fallback defines the fallback internal texture if any
  52156. * @param isBase64 defines whether the texture is encoded as a base64
  52157. * @param isBuffer defines whether the texture data are stored as a buffer
  52158. * @returns true if the loader can load the specified file
  52159. */
  52160. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52161. /**
  52162. * Transform the url before loading if required.
  52163. * @param rootUrl the url of the texture
  52164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52165. * @returns the transformed texture
  52166. */
  52167. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52168. /**
  52169. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52170. * @param rootUrl the url of the texture
  52171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52172. * @returns the fallback texture
  52173. */
  52174. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52175. /**
  52176. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52177. * @param data contains the texture data
  52178. * @param texture defines the BabylonJS internal texture
  52179. * @param createPolynomials will be true if polynomials have been requested
  52180. * @param onLoad defines the callback to trigger once the texture is ready
  52181. * @param onError defines the callback to trigger in case of error
  52182. */
  52183. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52184. /**
  52185. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52186. * @param data contains the texture data
  52187. * @param texture defines the BabylonJS internal texture
  52188. * @param callback defines the method to call once ready to upload
  52189. */
  52190. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52191. }
  52192. }
  52193. declare module BABYLON {
  52194. /** @hidden */
  52195. export var _forceSceneHelpersToBundle: boolean;
  52196. interface Scene {
  52197. /**
  52198. * Creates a default light for the scene.
  52199. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52200. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52201. */
  52202. createDefaultLight(replace?: boolean): void;
  52203. /**
  52204. * Creates a default camera for the scene.
  52205. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52206. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52207. * @param replace has default false, when true replaces the active camera in the scene
  52208. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52209. */
  52210. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52211. /**
  52212. * Creates a default camera and a default light.
  52213. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52214. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52215. * @param replace has the default false, when true replaces the active camera/light in the scene
  52216. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52217. */
  52218. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52219. /**
  52220. * Creates a new sky box
  52221. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52222. * @param environmentTexture defines the texture to use as environment texture
  52223. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52224. * @param scale defines the overall scale of the skybox
  52225. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52226. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52227. * @returns a new mesh holding the sky box
  52228. */
  52229. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52230. /**
  52231. * Creates a new environment
  52232. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52233. * @param options defines the options you can use to configure the environment
  52234. * @returns the new EnvironmentHelper
  52235. */
  52236. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52237. /**
  52238. * Creates a new VREXperienceHelper
  52239. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52240. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52241. * @returns a new VREXperienceHelper
  52242. */
  52243. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52244. /**
  52245. * Creates a new WebXRDefaultExperience
  52246. * @see http://doc.babylonjs.com/how_to/webxr
  52247. * @param options experience options
  52248. * @returns a promise for a new WebXRDefaultExperience
  52249. */
  52250. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52251. }
  52252. }
  52253. declare module BABYLON {
  52254. /**
  52255. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52256. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52257. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52258. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52259. */
  52260. export class VideoDome extends TransformNode {
  52261. /**
  52262. * Define the video source as a Monoscopic panoramic 360 video.
  52263. */
  52264. static readonly MODE_MONOSCOPIC: number;
  52265. /**
  52266. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52267. */
  52268. static readonly MODE_TOPBOTTOM: number;
  52269. /**
  52270. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52271. */
  52272. static readonly MODE_SIDEBYSIDE: number;
  52273. private _halfDome;
  52274. private _useDirectMapping;
  52275. /**
  52276. * The video texture being displayed on the sphere
  52277. */
  52278. protected _videoTexture: VideoTexture;
  52279. /**
  52280. * Gets the video texture being displayed on the sphere
  52281. */
  52282. get videoTexture(): VideoTexture;
  52283. /**
  52284. * The skybox material
  52285. */
  52286. protected _material: BackgroundMaterial;
  52287. /**
  52288. * The surface used for the skybox
  52289. */
  52290. protected _mesh: Mesh;
  52291. /**
  52292. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52293. */
  52294. private _halfDomeMask;
  52295. /**
  52296. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52297. * Also see the options.resolution property.
  52298. */
  52299. get fovMultiplier(): number;
  52300. set fovMultiplier(value: number);
  52301. private _videoMode;
  52302. /**
  52303. * Gets or set the current video mode for the video. It can be:
  52304. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52305. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52306. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52307. */
  52308. get videoMode(): number;
  52309. set videoMode(value: number);
  52310. /**
  52311. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52312. *
  52313. */
  52314. get halfDome(): boolean;
  52315. /**
  52316. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52317. */
  52318. set halfDome(enabled: boolean);
  52319. /**
  52320. * Oberserver used in Stereoscopic VR Mode.
  52321. */
  52322. private _onBeforeCameraRenderObserver;
  52323. /**
  52324. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52325. * @param name Element's name, child elements will append suffixes for their own names.
  52326. * @param urlsOrVideo defines the url(s) or the video element to use
  52327. * @param options An object containing optional or exposed sub element properties
  52328. */
  52329. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52330. resolution?: number;
  52331. clickToPlay?: boolean;
  52332. autoPlay?: boolean;
  52333. loop?: boolean;
  52334. size?: number;
  52335. poster?: string;
  52336. faceForward?: boolean;
  52337. useDirectMapping?: boolean;
  52338. halfDomeMode?: boolean;
  52339. }, scene: Scene);
  52340. private _changeVideoMode;
  52341. /**
  52342. * Releases resources associated with this node.
  52343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52345. */
  52346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52347. }
  52348. }
  52349. declare module BABYLON {
  52350. /**
  52351. * This class can be used to get instrumentation data from a Babylon engine
  52352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52353. */
  52354. export class EngineInstrumentation implements IDisposable {
  52355. /**
  52356. * Define the instrumented engine.
  52357. */
  52358. engine: Engine;
  52359. private _captureGPUFrameTime;
  52360. private _gpuFrameTimeToken;
  52361. private _gpuFrameTime;
  52362. private _captureShaderCompilationTime;
  52363. private _shaderCompilationTime;
  52364. private _onBeginFrameObserver;
  52365. private _onEndFrameObserver;
  52366. private _onBeforeShaderCompilationObserver;
  52367. private _onAfterShaderCompilationObserver;
  52368. /**
  52369. * Gets the perf counter used for GPU frame time
  52370. */
  52371. get gpuFrameTimeCounter(): PerfCounter;
  52372. /**
  52373. * Gets the GPU frame time capture status
  52374. */
  52375. get captureGPUFrameTime(): boolean;
  52376. /**
  52377. * Enable or disable the GPU frame time capture
  52378. */
  52379. set captureGPUFrameTime(value: boolean);
  52380. /**
  52381. * Gets the perf counter used for shader compilation time
  52382. */
  52383. get shaderCompilationTimeCounter(): PerfCounter;
  52384. /**
  52385. * Gets the shader compilation time capture status
  52386. */
  52387. get captureShaderCompilationTime(): boolean;
  52388. /**
  52389. * Enable or disable the shader compilation time capture
  52390. */
  52391. set captureShaderCompilationTime(value: boolean);
  52392. /**
  52393. * Instantiates a new engine instrumentation.
  52394. * This class can be used to get instrumentation data from a Babylon engine
  52395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52396. * @param engine Defines the engine to instrument
  52397. */
  52398. constructor(
  52399. /**
  52400. * Define the instrumented engine.
  52401. */
  52402. engine: Engine);
  52403. /**
  52404. * Dispose and release associated resources.
  52405. */
  52406. dispose(): void;
  52407. }
  52408. }
  52409. declare module BABYLON {
  52410. /**
  52411. * This class can be used to get instrumentation data from a Babylon engine
  52412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52413. */
  52414. export class SceneInstrumentation implements IDisposable {
  52415. /**
  52416. * Defines the scene to instrument
  52417. */
  52418. scene: Scene;
  52419. private _captureActiveMeshesEvaluationTime;
  52420. private _activeMeshesEvaluationTime;
  52421. private _captureRenderTargetsRenderTime;
  52422. private _renderTargetsRenderTime;
  52423. private _captureFrameTime;
  52424. private _frameTime;
  52425. private _captureRenderTime;
  52426. private _renderTime;
  52427. private _captureInterFrameTime;
  52428. private _interFrameTime;
  52429. private _captureParticlesRenderTime;
  52430. private _particlesRenderTime;
  52431. private _captureSpritesRenderTime;
  52432. private _spritesRenderTime;
  52433. private _capturePhysicsTime;
  52434. private _physicsTime;
  52435. private _captureAnimationsTime;
  52436. private _animationsTime;
  52437. private _captureCameraRenderTime;
  52438. private _cameraRenderTime;
  52439. private _onBeforeActiveMeshesEvaluationObserver;
  52440. private _onAfterActiveMeshesEvaluationObserver;
  52441. private _onBeforeRenderTargetsRenderObserver;
  52442. private _onAfterRenderTargetsRenderObserver;
  52443. private _onAfterRenderObserver;
  52444. private _onBeforeDrawPhaseObserver;
  52445. private _onAfterDrawPhaseObserver;
  52446. private _onBeforeAnimationsObserver;
  52447. private _onBeforeParticlesRenderingObserver;
  52448. private _onAfterParticlesRenderingObserver;
  52449. private _onBeforeSpritesRenderingObserver;
  52450. private _onAfterSpritesRenderingObserver;
  52451. private _onBeforePhysicsObserver;
  52452. private _onAfterPhysicsObserver;
  52453. private _onAfterAnimationsObserver;
  52454. private _onBeforeCameraRenderObserver;
  52455. private _onAfterCameraRenderObserver;
  52456. /**
  52457. * Gets the perf counter used for active meshes evaluation time
  52458. */
  52459. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52460. /**
  52461. * Gets the active meshes evaluation time capture status
  52462. */
  52463. get captureActiveMeshesEvaluationTime(): boolean;
  52464. /**
  52465. * Enable or disable the active meshes evaluation time capture
  52466. */
  52467. set captureActiveMeshesEvaluationTime(value: boolean);
  52468. /**
  52469. * Gets the perf counter used for render targets render time
  52470. */
  52471. get renderTargetsRenderTimeCounter(): PerfCounter;
  52472. /**
  52473. * Gets the render targets render time capture status
  52474. */
  52475. get captureRenderTargetsRenderTime(): boolean;
  52476. /**
  52477. * Enable or disable the render targets render time capture
  52478. */
  52479. set captureRenderTargetsRenderTime(value: boolean);
  52480. /**
  52481. * Gets the perf counter used for particles render time
  52482. */
  52483. get particlesRenderTimeCounter(): PerfCounter;
  52484. /**
  52485. * Gets the particles render time capture status
  52486. */
  52487. get captureParticlesRenderTime(): boolean;
  52488. /**
  52489. * Enable or disable the particles render time capture
  52490. */
  52491. set captureParticlesRenderTime(value: boolean);
  52492. /**
  52493. * Gets the perf counter used for sprites render time
  52494. */
  52495. get spritesRenderTimeCounter(): PerfCounter;
  52496. /**
  52497. * Gets the sprites render time capture status
  52498. */
  52499. get captureSpritesRenderTime(): boolean;
  52500. /**
  52501. * Enable or disable the sprites render time capture
  52502. */
  52503. set captureSpritesRenderTime(value: boolean);
  52504. /**
  52505. * Gets the perf counter used for physics time
  52506. */
  52507. get physicsTimeCounter(): PerfCounter;
  52508. /**
  52509. * Gets the physics time capture status
  52510. */
  52511. get capturePhysicsTime(): boolean;
  52512. /**
  52513. * Enable or disable the physics time capture
  52514. */
  52515. set capturePhysicsTime(value: boolean);
  52516. /**
  52517. * Gets the perf counter used for animations time
  52518. */
  52519. get animationsTimeCounter(): PerfCounter;
  52520. /**
  52521. * Gets the animations time capture status
  52522. */
  52523. get captureAnimationsTime(): boolean;
  52524. /**
  52525. * Enable or disable the animations time capture
  52526. */
  52527. set captureAnimationsTime(value: boolean);
  52528. /**
  52529. * Gets the perf counter used for frame time capture
  52530. */
  52531. get frameTimeCounter(): PerfCounter;
  52532. /**
  52533. * Gets the frame time capture status
  52534. */
  52535. get captureFrameTime(): boolean;
  52536. /**
  52537. * Enable or disable the frame time capture
  52538. */
  52539. set captureFrameTime(value: boolean);
  52540. /**
  52541. * Gets the perf counter used for inter-frames time capture
  52542. */
  52543. get interFrameTimeCounter(): PerfCounter;
  52544. /**
  52545. * Gets the inter-frames time capture status
  52546. */
  52547. get captureInterFrameTime(): boolean;
  52548. /**
  52549. * Enable or disable the inter-frames time capture
  52550. */
  52551. set captureInterFrameTime(value: boolean);
  52552. /**
  52553. * Gets the perf counter used for render time capture
  52554. */
  52555. get renderTimeCounter(): PerfCounter;
  52556. /**
  52557. * Gets the render time capture status
  52558. */
  52559. get captureRenderTime(): boolean;
  52560. /**
  52561. * Enable or disable the render time capture
  52562. */
  52563. set captureRenderTime(value: boolean);
  52564. /**
  52565. * Gets the perf counter used for camera render time capture
  52566. */
  52567. get cameraRenderTimeCounter(): PerfCounter;
  52568. /**
  52569. * Gets the camera render time capture status
  52570. */
  52571. get captureCameraRenderTime(): boolean;
  52572. /**
  52573. * Enable or disable the camera render time capture
  52574. */
  52575. set captureCameraRenderTime(value: boolean);
  52576. /**
  52577. * Gets the perf counter used for draw calls
  52578. */
  52579. get drawCallsCounter(): PerfCounter;
  52580. /**
  52581. * Instantiates a new scene instrumentation.
  52582. * This class can be used to get instrumentation data from a Babylon engine
  52583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52584. * @param scene Defines the scene to instrument
  52585. */
  52586. constructor(
  52587. /**
  52588. * Defines the scene to instrument
  52589. */
  52590. scene: Scene);
  52591. /**
  52592. * Dispose and release associated resources.
  52593. */
  52594. dispose(): void;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /** @hidden */
  52599. export var glowMapGenerationPixelShader: {
  52600. name: string;
  52601. shader: string;
  52602. };
  52603. }
  52604. declare module BABYLON {
  52605. /** @hidden */
  52606. export var glowMapGenerationVertexShader: {
  52607. name: string;
  52608. shader: string;
  52609. };
  52610. }
  52611. declare module BABYLON {
  52612. /**
  52613. * Effect layer options. This helps customizing the behaviour
  52614. * of the effect layer.
  52615. */
  52616. export interface IEffectLayerOptions {
  52617. /**
  52618. * Multiplication factor apply to the canvas size to compute the render target size
  52619. * used to generated the objects (the smaller the faster).
  52620. */
  52621. mainTextureRatio: number;
  52622. /**
  52623. * Enforces a fixed size texture to ensure effect stability across devices.
  52624. */
  52625. mainTextureFixedSize?: number;
  52626. /**
  52627. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52628. */
  52629. alphaBlendingMode: number;
  52630. /**
  52631. * The camera attached to the layer.
  52632. */
  52633. camera: Nullable<Camera>;
  52634. /**
  52635. * The rendering group to draw the layer in.
  52636. */
  52637. renderingGroupId: number;
  52638. }
  52639. /**
  52640. * The effect layer Helps adding post process effect blended with the main pass.
  52641. *
  52642. * This can be for instance use to generate glow or higlight effects on the scene.
  52643. *
  52644. * The effect layer class can not be used directly and is intented to inherited from to be
  52645. * customized per effects.
  52646. */
  52647. export abstract class EffectLayer {
  52648. private _vertexBuffers;
  52649. private _indexBuffer;
  52650. private _cachedDefines;
  52651. private _effectLayerMapGenerationEffect;
  52652. private _effectLayerOptions;
  52653. private _mergeEffect;
  52654. protected _scene: Scene;
  52655. protected _engine: Engine;
  52656. protected _maxSize: number;
  52657. protected _mainTextureDesiredSize: ISize;
  52658. protected _mainTexture: RenderTargetTexture;
  52659. protected _shouldRender: boolean;
  52660. protected _postProcesses: PostProcess[];
  52661. protected _textures: BaseTexture[];
  52662. protected _emissiveTextureAndColor: {
  52663. texture: Nullable<BaseTexture>;
  52664. color: Color4;
  52665. };
  52666. /**
  52667. * The name of the layer
  52668. */
  52669. name: string;
  52670. /**
  52671. * The clear color of the texture used to generate the glow map.
  52672. */
  52673. neutralColor: Color4;
  52674. /**
  52675. * Specifies whether the highlight layer is enabled or not.
  52676. */
  52677. isEnabled: boolean;
  52678. /**
  52679. * Gets the camera attached to the layer.
  52680. */
  52681. get camera(): Nullable<Camera>;
  52682. /**
  52683. * Gets the rendering group id the layer should render in.
  52684. */
  52685. get renderingGroupId(): number;
  52686. set renderingGroupId(renderingGroupId: number);
  52687. /**
  52688. * An event triggered when the effect layer has been disposed.
  52689. */
  52690. onDisposeObservable: Observable<EffectLayer>;
  52691. /**
  52692. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52693. */
  52694. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52695. /**
  52696. * An event triggered when the generated texture is being merged in the scene.
  52697. */
  52698. onBeforeComposeObservable: Observable<EffectLayer>;
  52699. /**
  52700. * An event triggered when the mesh is rendered into the effect render target.
  52701. */
  52702. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52703. /**
  52704. * An event triggered after the mesh has been rendered into the effect render target.
  52705. */
  52706. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52707. /**
  52708. * An event triggered when the generated texture has been merged in the scene.
  52709. */
  52710. onAfterComposeObservable: Observable<EffectLayer>;
  52711. /**
  52712. * An event triggered when the efffect layer changes its size.
  52713. */
  52714. onSizeChangedObservable: Observable<EffectLayer>;
  52715. /** @hidden */
  52716. static _SceneComponentInitialization: (scene: Scene) => void;
  52717. /**
  52718. * Instantiates a new effect Layer and references it in the scene.
  52719. * @param name The name of the layer
  52720. * @param scene The scene to use the layer in
  52721. */
  52722. constructor(
  52723. /** The Friendly of the effect in the scene */
  52724. name: string, scene: Scene);
  52725. /**
  52726. * Get the effect name of the layer.
  52727. * @return The effect name
  52728. */
  52729. abstract getEffectName(): string;
  52730. /**
  52731. * Checks for the readiness of the element composing the layer.
  52732. * @param subMesh the mesh to check for
  52733. * @param useInstances specify whether or not to use instances to render the mesh
  52734. * @return true if ready otherwise, false
  52735. */
  52736. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52737. /**
  52738. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52739. * @returns true if the effect requires stencil during the main canvas render pass.
  52740. */
  52741. abstract needStencil(): boolean;
  52742. /**
  52743. * Create the merge effect. This is the shader use to blit the information back
  52744. * to the main canvas at the end of the scene rendering.
  52745. * @returns The effect containing the shader used to merge the effect on the main canvas
  52746. */
  52747. protected abstract _createMergeEffect(): Effect;
  52748. /**
  52749. * Creates the render target textures and post processes used in the effect layer.
  52750. */
  52751. protected abstract _createTextureAndPostProcesses(): void;
  52752. /**
  52753. * Implementation specific of rendering the generating effect on the main canvas.
  52754. * @param effect The effect used to render through
  52755. */
  52756. protected abstract _internalRender(effect: Effect): void;
  52757. /**
  52758. * Sets the required values for both the emissive texture and and the main color.
  52759. */
  52760. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52761. /**
  52762. * Free any resources and references associated to a mesh.
  52763. * Internal use
  52764. * @param mesh The mesh to free.
  52765. */
  52766. abstract _disposeMesh(mesh: Mesh): void;
  52767. /**
  52768. * Serializes this layer (Glow or Highlight for example)
  52769. * @returns a serialized layer object
  52770. */
  52771. abstract serialize?(): any;
  52772. /**
  52773. * Initializes the effect layer with the required options.
  52774. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52775. */
  52776. protected _init(options: Partial<IEffectLayerOptions>): void;
  52777. /**
  52778. * Generates the index buffer of the full screen quad blending to the main canvas.
  52779. */
  52780. private _generateIndexBuffer;
  52781. /**
  52782. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52783. */
  52784. private _generateVertexBuffer;
  52785. /**
  52786. * Sets the main texture desired size which is the closest power of two
  52787. * of the engine canvas size.
  52788. */
  52789. private _setMainTextureSize;
  52790. /**
  52791. * Creates the main texture for the effect layer.
  52792. */
  52793. protected _createMainTexture(): void;
  52794. /**
  52795. * Adds specific effects defines.
  52796. * @param defines The defines to add specifics to.
  52797. */
  52798. protected _addCustomEffectDefines(defines: string[]): void;
  52799. /**
  52800. * Checks for the readiness of the element composing the layer.
  52801. * @param subMesh the mesh to check for
  52802. * @param useInstances specify whether or not to use instances to render the mesh
  52803. * @param emissiveTexture the associated emissive texture used to generate the glow
  52804. * @return true if ready otherwise, false
  52805. */
  52806. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52807. /**
  52808. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52809. */
  52810. render(): void;
  52811. /**
  52812. * Determine if a given mesh will be used in the current effect.
  52813. * @param mesh mesh to test
  52814. * @returns true if the mesh will be used
  52815. */
  52816. hasMesh(mesh: AbstractMesh): boolean;
  52817. /**
  52818. * Returns true if the layer contains information to display, otherwise false.
  52819. * @returns true if the glow layer should be rendered
  52820. */
  52821. shouldRender(): boolean;
  52822. /**
  52823. * Returns true if the mesh should render, otherwise false.
  52824. * @param mesh The mesh to render
  52825. * @returns true if it should render otherwise false
  52826. */
  52827. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52828. /**
  52829. * Returns true if the mesh can be rendered, otherwise false.
  52830. * @param mesh The mesh to render
  52831. * @param material The material used on the mesh
  52832. * @returns true if it can be rendered otherwise false
  52833. */
  52834. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52835. /**
  52836. * Returns true if the mesh should render, otherwise false.
  52837. * @param mesh The mesh to render
  52838. * @returns true if it should render otherwise false
  52839. */
  52840. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52841. /**
  52842. * Renders the submesh passed in parameter to the generation map.
  52843. */
  52844. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52845. /**
  52846. * Defines whether the current material of the mesh should be use to render the effect.
  52847. * @param mesh defines the current mesh to render
  52848. */
  52849. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52850. /**
  52851. * Rebuild the required buffers.
  52852. * @hidden Internal use only.
  52853. */
  52854. _rebuild(): void;
  52855. /**
  52856. * Dispose only the render target textures and post process.
  52857. */
  52858. private _disposeTextureAndPostProcesses;
  52859. /**
  52860. * Dispose the highlight layer and free resources.
  52861. */
  52862. dispose(): void;
  52863. /**
  52864. * Gets the class name of the effect layer
  52865. * @returns the string with the class name of the effect layer
  52866. */
  52867. getClassName(): string;
  52868. /**
  52869. * Creates an effect layer from parsed effect layer data
  52870. * @param parsedEffectLayer defines effect layer data
  52871. * @param scene defines the current scene
  52872. * @param rootUrl defines the root URL containing the effect layer information
  52873. * @returns a parsed effect Layer
  52874. */
  52875. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52876. }
  52877. }
  52878. declare module BABYLON {
  52879. interface AbstractScene {
  52880. /**
  52881. * The list of effect layers (highlights/glow) added to the scene
  52882. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52883. * @see http://doc.babylonjs.com/how_to/glow_layer
  52884. */
  52885. effectLayers: Array<EffectLayer>;
  52886. /**
  52887. * Removes the given effect layer from this scene.
  52888. * @param toRemove defines the effect layer to remove
  52889. * @returns the index of the removed effect layer
  52890. */
  52891. removeEffectLayer(toRemove: EffectLayer): number;
  52892. /**
  52893. * Adds the given effect layer to this scene
  52894. * @param newEffectLayer defines the effect layer to add
  52895. */
  52896. addEffectLayer(newEffectLayer: EffectLayer): void;
  52897. }
  52898. /**
  52899. * Defines the layer scene component responsible to manage any effect layers
  52900. * in a given scene.
  52901. */
  52902. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52903. /**
  52904. * The component name helpfull to identify the component in the list of scene components.
  52905. */
  52906. readonly name: string;
  52907. /**
  52908. * The scene the component belongs to.
  52909. */
  52910. scene: Scene;
  52911. private _engine;
  52912. private _renderEffects;
  52913. private _needStencil;
  52914. private _previousStencilState;
  52915. /**
  52916. * Creates a new instance of the component for the given scene
  52917. * @param scene Defines the scene to register the component in
  52918. */
  52919. constructor(scene: Scene);
  52920. /**
  52921. * Registers the component in a given scene
  52922. */
  52923. register(): void;
  52924. /**
  52925. * Rebuilds the elements related to this component in case of
  52926. * context lost for instance.
  52927. */
  52928. rebuild(): void;
  52929. /**
  52930. * Serializes the component data to the specified json object
  52931. * @param serializationObject The object to serialize to
  52932. */
  52933. serialize(serializationObject: any): void;
  52934. /**
  52935. * Adds all the elements from the container to the scene
  52936. * @param container the container holding the elements
  52937. */
  52938. addFromContainer(container: AbstractScene): void;
  52939. /**
  52940. * Removes all the elements in the container from the scene
  52941. * @param container contains the elements to remove
  52942. * @param dispose if the removed element should be disposed (default: false)
  52943. */
  52944. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52945. /**
  52946. * Disposes the component and the associated ressources.
  52947. */
  52948. dispose(): void;
  52949. private _isReadyForMesh;
  52950. private _renderMainTexture;
  52951. private _setStencil;
  52952. private _setStencilBack;
  52953. private _draw;
  52954. private _drawCamera;
  52955. private _drawRenderingGroup;
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /** @hidden */
  52960. export var glowMapMergePixelShader: {
  52961. name: string;
  52962. shader: string;
  52963. };
  52964. }
  52965. declare module BABYLON {
  52966. /** @hidden */
  52967. export var glowMapMergeVertexShader: {
  52968. name: string;
  52969. shader: string;
  52970. };
  52971. }
  52972. declare module BABYLON {
  52973. interface AbstractScene {
  52974. /**
  52975. * Return a the first highlight layer of the scene with a given name.
  52976. * @param name The name of the highlight layer to look for.
  52977. * @return The highlight layer if found otherwise null.
  52978. */
  52979. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52980. }
  52981. /**
  52982. * Glow layer options. This helps customizing the behaviour
  52983. * of the glow layer.
  52984. */
  52985. export interface IGlowLayerOptions {
  52986. /**
  52987. * Multiplication factor apply to the canvas size to compute the render target size
  52988. * used to generated the glowing objects (the smaller the faster).
  52989. */
  52990. mainTextureRatio: number;
  52991. /**
  52992. * Enforces a fixed size texture to ensure resize independant blur.
  52993. */
  52994. mainTextureFixedSize?: number;
  52995. /**
  52996. * How big is the kernel of the blur texture.
  52997. */
  52998. blurKernelSize: number;
  52999. /**
  53000. * The camera attached to the layer.
  53001. */
  53002. camera: Nullable<Camera>;
  53003. /**
  53004. * Enable MSAA by chosing the number of samples.
  53005. */
  53006. mainTextureSamples?: number;
  53007. /**
  53008. * The rendering group to draw the layer in.
  53009. */
  53010. renderingGroupId: number;
  53011. }
  53012. /**
  53013. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53014. *
  53015. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53016. *
  53017. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53018. */
  53019. export class GlowLayer extends EffectLayer {
  53020. /**
  53021. * Effect Name of the layer.
  53022. */
  53023. static readonly EffectName: string;
  53024. /**
  53025. * The default blur kernel size used for the glow.
  53026. */
  53027. static DefaultBlurKernelSize: number;
  53028. /**
  53029. * The default texture size ratio used for the glow.
  53030. */
  53031. static DefaultTextureRatio: number;
  53032. /**
  53033. * Sets the kernel size of the blur.
  53034. */
  53035. set blurKernelSize(value: number);
  53036. /**
  53037. * Gets the kernel size of the blur.
  53038. */
  53039. get blurKernelSize(): number;
  53040. /**
  53041. * Sets the glow intensity.
  53042. */
  53043. set intensity(value: number);
  53044. /**
  53045. * Gets the glow intensity.
  53046. */
  53047. get intensity(): number;
  53048. private _options;
  53049. private _intensity;
  53050. private _horizontalBlurPostprocess1;
  53051. private _verticalBlurPostprocess1;
  53052. private _horizontalBlurPostprocess2;
  53053. private _verticalBlurPostprocess2;
  53054. private _blurTexture1;
  53055. private _blurTexture2;
  53056. private _postProcesses1;
  53057. private _postProcesses2;
  53058. private _includedOnlyMeshes;
  53059. private _excludedMeshes;
  53060. private _meshesUsingTheirOwnMaterials;
  53061. /**
  53062. * Callback used to let the user override the color selection on a per mesh basis
  53063. */
  53064. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53065. /**
  53066. * Callback used to let the user override the texture selection on a per mesh basis
  53067. */
  53068. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53069. /**
  53070. * Instantiates a new glow Layer and references it to the scene.
  53071. * @param name The name of the layer
  53072. * @param scene The scene to use the layer in
  53073. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53074. */
  53075. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53076. /**
  53077. * Get the effect name of the layer.
  53078. * @return The effect name
  53079. */
  53080. getEffectName(): string;
  53081. /**
  53082. * Create the merge effect. This is the shader use to blit the information back
  53083. * to the main canvas at the end of the scene rendering.
  53084. */
  53085. protected _createMergeEffect(): Effect;
  53086. /**
  53087. * Creates the render target textures and post processes used in the glow layer.
  53088. */
  53089. protected _createTextureAndPostProcesses(): void;
  53090. /**
  53091. * Checks for the readiness of the element composing the layer.
  53092. * @param subMesh the mesh to check for
  53093. * @param useInstances specify wether or not to use instances to render the mesh
  53094. * @param emissiveTexture the associated emissive texture used to generate the glow
  53095. * @return true if ready otherwise, false
  53096. */
  53097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53098. /**
  53099. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53100. */
  53101. needStencil(): boolean;
  53102. /**
  53103. * Returns true if the mesh can be rendered, otherwise false.
  53104. * @param mesh The mesh to render
  53105. * @param material The material used on the mesh
  53106. * @returns true if it can be rendered otherwise false
  53107. */
  53108. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53109. /**
  53110. * Implementation specific of rendering the generating effect on the main canvas.
  53111. * @param effect The effect used to render through
  53112. */
  53113. protected _internalRender(effect: Effect): void;
  53114. /**
  53115. * Sets the required values for both the emissive texture and and the main color.
  53116. */
  53117. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53118. /**
  53119. * Returns true if the mesh should render, otherwise false.
  53120. * @param mesh The mesh to render
  53121. * @returns true if it should render otherwise false
  53122. */
  53123. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53124. /**
  53125. * Adds specific effects defines.
  53126. * @param defines The defines to add specifics to.
  53127. */
  53128. protected _addCustomEffectDefines(defines: string[]): void;
  53129. /**
  53130. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53131. * @param mesh The mesh to exclude from the glow layer
  53132. */
  53133. addExcludedMesh(mesh: Mesh): void;
  53134. /**
  53135. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53136. * @param mesh The mesh to remove
  53137. */
  53138. removeExcludedMesh(mesh: Mesh): void;
  53139. /**
  53140. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53141. * @param mesh The mesh to include in the glow layer
  53142. */
  53143. addIncludedOnlyMesh(mesh: Mesh): void;
  53144. /**
  53145. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53146. * @param mesh The mesh to remove
  53147. */
  53148. removeIncludedOnlyMesh(mesh: Mesh): void;
  53149. /**
  53150. * Determine if a given mesh will be used in the glow layer
  53151. * @param mesh The mesh to test
  53152. * @returns true if the mesh will be highlighted by the current glow layer
  53153. */
  53154. hasMesh(mesh: AbstractMesh): boolean;
  53155. /**
  53156. * Defines whether the current material of the mesh should be use to render the effect.
  53157. * @param mesh defines the current mesh to render
  53158. */
  53159. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53160. /**
  53161. * Add a mesh to be rendered through its own material and not with emissive only.
  53162. * @param mesh The mesh for which we need to use its material
  53163. */
  53164. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53165. /**
  53166. * Remove a mesh from being rendered through its own material and not with emissive only.
  53167. * @param mesh The mesh for which we need to not use its material
  53168. */
  53169. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53170. /**
  53171. * Free any resources and references associated to a mesh.
  53172. * Internal use
  53173. * @param mesh The mesh to free.
  53174. * @hidden
  53175. */
  53176. _disposeMesh(mesh: Mesh): void;
  53177. /**
  53178. * Gets the class name of the effect layer
  53179. * @returns the string with the class name of the effect layer
  53180. */
  53181. getClassName(): string;
  53182. /**
  53183. * Serializes this glow layer
  53184. * @returns a serialized glow layer object
  53185. */
  53186. serialize(): any;
  53187. /**
  53188. * Creates a Glow Layer from parsed glow layer data
  53189. * @param parsedGlowLayer defines glow layer data
  53190. * @param scene defines the current scene
  53191. * @param rootUrl defines the root URL containing the glow layer information
  53192. * @returns a parsed Glow Layer
  53193. */
  53194. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53195. }
  53196. }
  53197. declare module BABYLON {
  53198. /** @hidden */
  53199. export var glowBlurPostProcessPixelShader: {
  53200. name: string;
  53201. shader: string;
  53202. };
  53203. }
  53204. declare module BABYLON {
  53205. interface AbstractScene {
  53206. /**
  53207. * Return a the first highlight layer of the scene with a given name.
  53208. * @param name The name of the highlight layer to look for.
  53209. * @return The highlight layer if found otherwise null.
  53210. */
  53211. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53212. }
  53213. /**
  53214. * Highlight layer options. This helps customizing the behaviour
  53215. * of the highlight layer.
  53216. */
  53217. export interface IHighlightLayerOptions {
  53218. /**
  53219. * Multiplication factor apply to the canvas size to compute the render target size
  53220. * used to generated the glowing objects (the smaller the faster).
  53221. */
  53222. mainTextureRatio: number;
  53223. /**
  53224. * Enforces a fixed size texture to ensure resize independant blur.
  53225. */
  53226. mainTextureFixedSize?: number;
  53227. /**
  53228. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53229. * of the picture to blur (the smaller the faster).
  53230. */
  53231. blurTextureSizeRatio: number;
  53232. /**
  53233. * How big in texel of the blur texture is the vertical blur.
  53234. */
  53235. blurVerticalSize: number;
  53236. /**
  53237. * How big in texel of the blur texture is the horizontal blur.
  53238. */
  53239. blurHorizontalSize: number;
  53240. /**
  53241. * Alpha blending mode used to apply the blur. Default is combine.
  53242. */
  53243. alphaBlendingMode: number;
  53244. /**
  53245. * The camera attached to the layer.
  53246. */
  53247. camera: Nullable<Camera>;
  53248. /**
  53249. * Should we display highlight as a solid stroke?
  53250. */
  53251. isStroke?: boolean;
  53252. /**
  53253. * The rendering group to draw the layer in.
  53254. */
  53255. renderingGroupId: number;
  53256. }
  53257. /**
  53258. * The highlight layer Helps adding a glow effect around a mesh.
  53259. *
  53260. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53261. * glowy meshes to your scene.
  53262. *
  53263. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53264. */
  53265. export class HighlightLayer extends EffectLayer {
  53266. name: string;
  53267. /**
  53268. * Effect Name of the highlight layer.
  53269. */
  53270. static readonly EffectName: string;
  53271. /**
  53272. * The neutral color used during the preparation of the glow effect.
  53273. * This is black by default as the blend operation is a blend operation.
  53274. */
  53275. static NeutralColor: Color4;
  53276. /**
  53277. * Stencil value used for glowing meshes.
  53278. */
  53279. static GlowingMeshStencilReference: number;
  53280. /**
  53281. * Stencil value used for the other meshes in the scene.
  53282. */
  53283. static NormalMeshStencilReference: number;
  53284. /**
  53285. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53286. */
  53287. innerGlow: boolean;
  53288. /**
  53289. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53290. */
  53291. outerGlow: boolean;
  53292. /**
  53293. * Specifies the horizontal size of the blur.
  53294. */
  53295. set blurHorizontalSize(value: number);
  53296. /**
  53297. * Specifies the vertical size of the blur.
  53298. */
  53299. set blurVerticalSize(value: number);
  53300. /**
  53301. * Gets the horizontal size of the blur.
  53302. */
  53303. get blurHorizontalSize(): number;
  53304. /**
  53305. * Gets the vertical size of the blur.
  53306. */
  53307. get blurVerticalSize(): number;
  53308. /**
  53309. * An event triggered when the highlight layer is being blurred.
  53310. */
  53311. onBeforeBlurObservable: Observable<HighlightLayer>;
  53312. /**
  53313. * An event triggered when the highlight layer has been blurred.
  53314. */
  53315. onAfterBlurObservable: Observable<HighlightLayer>;
  53316. private _instanceGlowingMeshStencilReference;
  53317. private _options;
  53318. private _downSamplePostprocess;
  53319. private _horizontalBlurPostprocess;
  53320. private _verticalBlurPostprocess;
  53321. private _blurTexture;
  53322. private _meshes;
  53323. private _excludedMeshes;
  53324. /**
  53325. * Instantiates a new highlight Layer and references it to the scene..
  53326. * @param name The name of the layer
  53327. * @param scene The scene to use the layer in
  53328. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53329. */
  53330. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53331. /**
  53332. * Get the effect name of the layer.
  53333. * @return The effect name
  53334. */
  53335. getEffectName(): string;
  53336. /**
  53337. * Create the merge effect. This is the shader use to blit the information back
  53338. * to the main canvas at the end of the scene rendering.
  53339. */
  53340. protected _createMergeEffect(): Effect;
  53341. /**
  53342. * Creates the render target textures and post processes used in the highlight layer.
  53343. */
  53344. protected _createTextureAndPostProcesses(): void;
  53345. /**
  53346. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53347. */
  53348. needStencil(): boolean;
  53349. /**
  53350. * Checks for the readiness of the element composing the layer.
  53351. * @param subMesh the mesh to check for
  53352. * @param useInstances specify wether or not to use instances to render the mesh
  53353. * @param emissiveTexture the associated emissive texture used to generate the glow
  53354. * @return true if ready otherwise, false
  53355. */
  53356. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53357. /**
  53358. * Implementation specific of rendering the generating effect on the main canvas.
  53359. * @param effect The effect used to render through
  53360. */
  53361. protected _internalRender(effect: Effect): void;
  53362. /**
  53363. * Returns true if the layer contains information to display, otherwise false.
  53364. */
  53365. shouldRender(): boolean;
  53366. /**
  53367. * Returns true if the mesh should render, otherwise false.
  53368. * @param mesh The mesh to render
  53369. * @returns true if it should render otherwise false
  53370. */
  53371. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53372. /**
  53373. * Sets the required values for both the emissive texture and and the main color.
  53374. */
  53375. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53376. /**
  53377. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53378. * @param mesh The mesh to exclude from the highlight layer
  53379. */
  53380. addExcludedMesh(mesh: Mesh): void;
  53381. /**
  53382. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53383. * @param mesh The mesh to highlight
  53384. */
  53385. removeExcludedMesh(mesh: Mesh): void;
  53386. /**
  53387. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53388. * @param mesh mesh to test
  53389. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53390. */
  53391. hasMesh(mesh: AbstractMesh): boolean;
  53392. /**
  53393. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53394. * @param mesh The mesh to highlight
  53395. * @param color The color of the highlight
  53396. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53397. */
  53398. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53399. /**
  53400. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53401. * @param mesh The mesh to highlight
  53402. */
  53403. removeMesh(mesh: Mesh): void;
  53404. /**
  53405. * Force the stencil to the normal expected value for none glowing parts
  53406. */
  53407. private _defaultStencilReference;
  53408. /**
  53409. * Free any resources and references associated to a mesh.
  53410. * Internal use
  53411. * @param mesh The mesh to free.
  53412. * @hidden
  53413. */
  53414. _disposeMesh(mesh: Mesh): void;
  53415. /**
  53416. * Dispose the highlight layer and free resources.
  53417. */
  53418. dispose(): void;
  53419. /**
  53420. * Gets the class name of the effect layer
  53421. * @returns the string with the class name of the effect layer
  53422. */
  53423. getClassName(): string;
  53424. /**
  53425. * Serializes this Highlight layer
  53426. * @returns a serialized Highlight layer object
  53427. */
  53428. serialize(): any;
  53429. /**
  53430. * Creates a Highlight layer from parsed Highlight layer data
  53431. * @param parsedHightlightLayer defines the Highlight layer data
  53432. * @param scene defines the current scene
  53433. * @param rootUrl defines the root URL containing the Highlight layer information
  53434. * @returns a parsed Highlight layer
  53435. */
  53436. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53437. }
  53438. }
  53439. declare module BABYLON {
  53440. interface AbstractScene {
  53441. /**
  53442. * The list of layers (background and foreground) of the scene
  53443. */
  53444. layers: Array<Layer>;
  53445. }
  53446. /**
  53447. * Defines the layer scene component responsible to manage any layers
  53448. * in a given scene.
  53449. */
  53450. export class LayerSceneComponent implements ISceneComponent {
  53451. /**
  53452. * The component name helpfull to identify the component in the list of scene components.
  53453. */
  53454. readonly name: string;
  53455. /**
  53456. * The scene the component belongs to.
  53457. */
  53458. scene: Scene;
  53459. private _engine;
  53460. /**
  53461. * Creates a new instance of the component for the given scene
  53462. * @param scene Defines the scene to register the component in
  53463. */
  53464. constructor(scene: Scene);
  53465. /**
  53466. * Registers the component in a given scene
  53467. */
  53468. register(): void;
  53469. /**
  53470. * Rebuilds the elements related to this component in case of
  53471. * context lost for instance.
  53472. */
  53473. rebuild(): void;
  53474. /**
  53475. * Disposes the component and the associated ressources.
  53476. */
  53477. dispose(): void;
  53478. private _draw;
  53479. private _drawCameraPredicate;
  53480. private _drawCameraBackground;
  53481. private _drawCameraForeground;
  53482. private _drawRenderTargetPredicate;
  53483. private _drawRenderTargetBackground;
  53484. private _drawRenderTargetForeground;
  53485. /**
  53486. * Adds all the elements from the container to the scene
  53487. * @param container the container holding the elements
  53488. */
  53489. addFromContainer(container: AbstractScene): void;
  53490. /**
  53491. * Removes all the elements in the container from the scene
  53492. * @param container contains the elements to remove
  53493. * @param dispose if the removed element should be disposed (default: false)
  53494. */
  53495. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53496. }
  53497. }
  53498. declare module BABYLON {
  53499. /** @hidden */
  53500. export var layerPixelShader: {
  53501. name: string;
  53502. shader: string;
  53503. };
  53504. }
  53505. declare module BABYLON {
  53506. /** @hidden */
  53507. export var layerVertexShader: {
  53508. name: string;
  53509. shader: string;
  53510. };
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * This represents a full screen 2d layer.
  53515. * This can be useful to display a picture in the background of your scene for instance.
  53516. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53517. */
  53518. export class Layer {
  53519. /**
  53520. * Define the name of the layer.
  53521. */
  53522. name: string;
  53523. /**
  53524. * Define the texture the layer should display.
  53525. */
  53526. texture: Nullable<Texture>;
  53527. /**
  53528. * Is the layer in background or foreground.
  53529. */
  53530. isBackground: boolean;
  53531. /**
  53532. * Define the color of the layer (instead of texture).
  53533. */
  53534. color: Color4;
  53535. /**
  53536. * Define the scale of the layer in order to zoom in out of the texture.
  53537. */
  53538. scale: Vector2;
  53539. /**
  53540. * Define an offset for the layer in order to shift the texture.
  53541. */
  53542. offset: Vector2;
  53543. /**
  53544. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53545. */
  53546. alphaBlendingMode: number;
  53547. /**
  53548. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53549. * Alpha test will not mix with the background color in case of transparency.
  53550. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53551. */
  53552. alphaTest: boolean;
  53553. /**
  53554. * Define a mask to restrict the layer to only some of the scene cameras.
  53555. */
  53556. layerMask: number;
  53557. /**
  53558. * Define the list of render target the layer is visible into.
  53559. */
  53560. renderTargetTextures: RenderTargetTexture[];
  53561. /**
  53562. * Define if the layer is only used in renderTarget or if it also
  53563. * renders in the main frame buffer of the canvas.
  53564. */
  53565. renderOnlyInRenderTargetTextures: boolean;
  53566. private _scene;
  53567. private _vertexBuffers;
  53568. private _indexBuffer;
  53569. private _effect;
  53570. private _previousDefines;
  53571. /**
  53572. * An event triggered when the layer is disposed.
  53573. */
  53574. onDisposeObservable: Observable<Layer>;
  53575. private _onDisposeObserver;
  53576. /**
  53577. * Back compatibility with callback before the onDisposeObservable existed.
  53578. * The set callback will be triggered when the layer has been disposed.
  53579. */
  53580. set onDispose(callback: () => void);
  53581. /**
  53582. * An event triggered before rendering the scene
  53583. */
  53584. onBeforeRenderObservable: Observable<Layer>;
  53585. private _onBeforeRenderObserver;
  53586. /**
  53587. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53588. * The set callback will be triggered just before rendering the layer.
  53589. */
  53590. set onBeforeRender(callback: () => void);
  53591. /**
  53592. * An event triggered after rendering the scene
  53593. */
  53594. onAfterRenderObservable: Observable<Layer>;
  53595. private _onAfterRenderObserver;
  53596. /**
  53597. * Back compatibility with callback before the onAfterRenderObservable existed.
  53598. * The set callback will be triggered just after rendering the layer.
  53599. */
  53600. set onAfterRender(callback: () => void);
  53601. /**
  53602. * Instantiates a new layer.
  53603. * This represents a full screen 2d layer.
  53604. * This can be useful to display a picture in the background of your scene for instance.
  53605. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53606. * @param name Define the name of the layer in the scene
  53607. * @param imgUrl Define the url of the texture to display in the layer
  53608. * @param scene Define the scene the layer belongs to
  53609. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53610. * @param color Defines a color for the layer
  53611. */
  53612. constructor(
  53613. /**
  53614. * Define the name of the layer.
  53615. */
  53616. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53617. private _createIndexBuffer;
  53618. /** @hidden */
  53619. _rebuild(): void;
  53620. /**
  53621. * Renders the layer in the scene.
  53622. */
  53623. render(): void;
  53624. /**
  53625. * Disposes and releases the associated ressources.
  53626. */
  53627. dispose(): void;
  53628. }
  53629. }
  53630. declare module BABYLON {
  53631. /** @hidden */
  53632. export var lensFlarePixelShader: {
  53633. name: string;
  53634. shader: string;
  53635. };
  53636. }
  53637. declare module BABYLON {
  53638. /** @hidden */
  53639. export var lensFlareVertexShader: {
  53640. name: string;
  53641. shader: string;
  53642. };
  53643. }
  53644. declare module BABYLON {
  53645. /**
  53646. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53647. * It is usually composed of several `lensFlare`.
  53648. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53649. */
  53650. export class LensFlareSystem {
  53651. /**
  53652. * Define the name of the lens flare system
  53653. */
  53654. name: string;
  53655. /**
  53656. * List of lens flares used in this system.
  53657. */
  53658. lensFlares: LensFlare[];
  53659. /**
  53660. * Define a limit from the border the lens flare can be visible.
  53661. */
  53662. borderLimit: number;
  53663. /**
  53664. * Define a viewport border we do not want to see the lens flare in.
  53665. */
  53666. viewportBorder: number;
  53667. /**
  53668. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53669. */
  53670. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53671. /**
  53672. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53673. */
  53674. layerMask: number;
  53675. /**
  53676. * Define the id of the lens flare system in the scene.
  53677. * (equal to name by default)
  53678. */
  53679. id: string;
  53680. private _scene;
  53681. private _emitter;
  53682. private _vertexBuffers;
  53683. private _indexBuffer;
  53684. private _effect;
  53685. private _positionX;
  53686. private _positionY;
  53687. private _isEnabled;
  53688. /** @hidden */
  53689. static _SceneComponentInitialization: (scene: Scene) => void;
  53690. /**
  53691. * Instantiates a lens flare system.
  53692. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53693. * It is usually composed of several `lensFlare`.
  53694. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53695. * @param name Define the name of the lens flare system in the scene
  53696. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53697. * @param scene Define the scene the lens flare system belongs to
  53698. */
  53699. constructor(
  53700. /**
  53701. * Define the name of the lens flare system
  53702. */
  53703. name: string, emitter: any, scene: Scene);
  53704. /**
  53705. * Define if the lens flare system is enabled.
  53706. */
  53707. get isEnabled(): boolean;
  53708. set isEnabled(value: boolean);
  53709. /**
  53710. * Get the scene the effects belongs to.
  53711. * @returns the scene holding the lens flare system
  53712. */
  53713. getScene(): Scene;
  53714. /**
  53715. * Get the emitter of the lens flare system.
  53716. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53717. * @returns the emitter of the lens flare system
  53718. */
  53719. getEmitter(): any;
  53720. /**
  53721. * Set the emitter of the lens flare system.
  53722. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53723. * @param newEmitter Define the new emitter of the system
  53724. */
  53725. setEmitter(newEmitter: any): void;
  53726. /**
  53727. * Get the lens flare system emitter position.
  53728. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53729. * @returns the position
  53730. */
  53731. getEmitterPosition(): Vector3;
  53732. /**
  53733. * @hidden
  53734. */
  53735. computeEffectivePosition(globalViewport: Viewport): boolean;
  53736. /** @hidden */
  53737. _isVisible(): boolean;
  53738. /**
  53739. * @hidden
  53740. */
  53741. render(): boolean;
  53742. /**
  53743. * Dispose and release the lens flare with its associated resources.
  53744. */
  53745. dispose(): void;
  53746. /**
  53747. * Parse a lens flare system from a JSON repressentation
  53748. * @param parsedLensFlareSystem Define the JSON to parse
  53749. * @param scene Define the scene the parsed system should be instantiated in
  53750. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53751. * @returns the parsed system
  53752. */
  53753. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53754. /**
  53755. * Serialize the current Lens Flare System into a JSON representation.
  53756. * @returns the serialized JSON
  53757. */
  53758. serialize(): any;
  53759. }
  53760. }
  53761. declare module BABYLON {
  53762. /**
  53763. * This represents one of the lens effect in a `lensFlareSystem`.
  53764. * It controls one of the indiviual texture used in the effect.
  53765. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53766. */
  53767. export class LensFlare {
  53768. /**
  53769. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53770. */
  53771. size: number;
  53772. /**
  53773. * 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.
  53774. */
  53775. position: number;
  53776. /**
  53777. * Define the lens color.
  53778. */
  53779. color: Color3;
  53780. /**
  53781. * Define the lens texture.
  53782. */
  53783. texture: Nullable<Texture>;
  53784. /**
  53785. * Define the alpha mode to render this particular lens.
  53786. */
  53787. alphaMode: number;
  53788. private _system;
  53789. /**
  53790. * Creates a new Lens Flare.
  53791. * This represents one of the lens effect in a `lensFlareSystem`.
  53792. * It controls one of the indiviual texture used in the effect.
  53793. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53794. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53795. * @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.
  53796. * @param color Define the lens color
  53797. * @param imgUrl Define the lens texture url
  53798. * @param system Define the `lensFlareSystem` this flare is part of
  53799. * @returns The newly created Lens Flare
  53800. */
  53801. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53802. /**
  53803. * Instantiates a new Lens Flare.
  53804. * This represents one of the lens effect in a `lensFlareSystem`.
  53805. * It controls one of the indiviual texture used in the effect.
  53806. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53807. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53808. * @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.
  53809. * @param color Define the lens color
  53810. * @param imgUrl Define the lens texture url
  53811. * @param system Define the `lensFlareSystem` this flare is part of
  53812. */
  53813. constructor(
  53814. /**
  53815. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53816. */
  53817. size: number,
  53818. /**
  53819. * 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.
  53820. */
  53821. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53822. /**
  53823. * Dispose and release the lens flare with its associated resources.
  53824. */
  53825. dispose(): void;
  53826. }
  53827. }
  53828. declare module BABYLON {
  53829. interface AbstractScene {
  53830. /**
  53831. * The list of lens flare system added to the scene
  53832. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53833. */
  53834. lensFlareSystems: Array<LensFlareSystem>;
  53835. /**
  53836. * Removes the given lens flare system from this scene.
  53837. * @param toRemove The lens flare system to remove
  53838. * @returns The index of the removed lens flare system
  53839. */
  53840. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53841. /**
  53842. * Adds the given lens flare system to this scene
  53843. * @param newLensFlareSystem The lens flare system to add
  53844. */
  53845. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53846. /**
  53847. * Gets a lens flare system using its name
  53848. * @param name defines the name to look for
  53849. * @returns the lens flare system or null if not found
  53850. */
  53851. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53852. /**
  53853. * Gets a lens flare system using its id
  53854. * @param id defines the id to look for
  53855. * @returns the lens flare system or null if not found
  53856. */
  53857. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53858. }
  53859. /**
  53860. * Defines the lens flare scene component responsible to manage any lens flares
  53861. * in a given scene.
  53862. */
  53863. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53864. /**
  53865. * The component name helpfull to identify the component in the list of scene components.
  53866. */
  53867. readonly name: string;
  53868. /**
  53869. * The scene the component belongs to.
  53870. */
  53871. scene: Scene;
  53872. /**
  53873. * Creates a new instance of the component for the given scene
  53874. * @param scene Defines the scene to register the component in
  53875. */
  53876. constructor(scene: Scene);
  53877. /**
  53878. * Registers the component in a given scene
  53879. */
  53880. register(): void;
  53881. /**
  53882. * Rebuilds the elements related to this component in case of
  53883. * context lost for instance.
  53884. */
  53885. rebuild(): void;
  53886. /**
  53887. * Adds all the elements from the container to the scene
  53888. * @param container the container holding the elements
  53889. */
  53890. addFromContainer(container: AbstractScene): void;
  53891. /**
  53892. * Removes all the elements in the container from the scene
  53893. * @param container contains the elements to remove
  53894. * @param dispose if the removed element should be disposed (default: false)
  53895. */
  53896. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53897. /**
  53898. * Serializes the component data to the specified json object
  53899. * @param serializationObject The object to serialize to
  53900. */
  53901. serialize(serializationObject: any): void;
  53902. /**
  53903. * Disposes the component and the associated ressources.
  53904. */
  53905. dispose(): void;
  53906. private _draw;
  53907. }
  53908. }
  53909. declare module BABYLON {
  53910. /** @hidden */
  53911. export var depthPixelShader: {
  53912. name: string;
  53913. shader: string;
  53914. };
  53915. }
  53916. declare module BABYLON {
  53917. /** @hidden */
  53918. export var depthVertexShader: {
  53919. name: string;
  53920. shader: string;
  53921. };
  53922. }
  53923. declare module BABYLON {
  53924. /**
  53925. * This represents a depth renderer in Babylon.
  53926. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53927. */
  53928. export class DepthRenderer {
  53929. private _scene;
  53930. private _depthMap;
  53931. private _effect;
  53932. private readonly _storeNonLinearDepth;
  53933. private readonly _clearColor;
  53934. /** Get if the depth renderer is using packed depth or not */
  53935. readonly isPacked: boolean;
  53936. private _cachedDefines;
  53937. private _camera;
  53938. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53939. enabled: boolean;
  53940. /**
  53941. * Specifiess that the depth renderer will only be used within
  53942. * the camera it is created for.
  53943. * This can help forcing its rendering during the camera processing.
  53944. */
  53945. useOnlyInActiveCamera: boolean;
  53946. /** @hidden */
  53947. static _SceneComponentInitialization: (scene: Scene) => void;
  53948. /**
  53949. * Instantiates a depth renderer
  53950. * @param scene The scene the renderer belongs to
  53951. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53952. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53953. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53954. */
  53955. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  53956. /**
  53957. * Creates the depth rendering effect and checks if the effect is ready.
  53958. * @param subMesh The submesh to be used to render the depth map of
  53959. * @param useInstances If multiple world instances should be used
  53960. * @returns if the depth renderer is ready to render the depth map
  53961. */
  53962. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53963. /**
  53964. * Gets the texture which the depth map will be written to.
  53965. * @returns The depth map texture
  53966. */
  53967. getDepthMap(): RenderTargetTexture;
  53968. /**
  53969. * Disposes of the depth renderer.
  53970. */
  53971. dispose(): void;
  53972. }
  53973. }
  53974. declare module BABYLON {
  53975. /** @hidden */
  53976. export var minmaxReduxPixelShader: {
  53977. name: string;
  53978. shader: string;
  53979. };
  53980. }
  53981. declare module BABYLON {
  53982. /**
  53983. * This class computes a min/max reduction from a texture: it means it computes the minimum
  53984. * and maximum values from all values of the texture.
  53985. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  53986. * The source values are read from the red channel of the texture.
  53987. */
  53988. export class MinMaxReducer {
  53989. /**
  53990. * Observable triggered when the computation has been performed
  53991. */
  53992. onAfterReductionPerformed: Observable<{
  53993. min: number;
  53994. max: number;
  53995. }>;
  53996. protected _camera: Camera;
  53997. protected _sourceTexture: Nullable<RenderTargetTexture>;
  53998. protected _reductionSteps: Nullable<Array<PostProcess>>;
  53999. protected _postProcessManager: PostProcessManager;
  54000. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54001. protected _forceFullscreenViewport: boolean;
  54002. /**
  54003. * Creates a min/max reducer
  54004. * @param camera The camera to use for the post processes
  54005. */
  54006. constructor(camera: Camera);
  54007. /**
  54008. * Gets the texture used to read the values from.
  54009. */
  54010. get sourceTexture(): Nullable<RenderTargetTexture>;
  54011. /**
  54012. * Sets the source texture to read the values from.
  54013. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54014. * because in such textures '1' value must not be taken into account to compute the maximum
  54015. * as this value is used to clear the texture.
  54016. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54017. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54018. * @param depthRedux Indicates if the texture is a depth texture or not
  54019. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54020. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54021. */
  54022. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54023. /**
  54024. * Defines the refresh rate of the computation.
  54025. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54026. */
  54027. get refreshRate(): number;
  54028. set refreshRate(value: number);
  54029. protected _activated: boolean;
  54030. /**
  54031. * Gets the activation status of the reducer
  54032. */
  54033. get activated(): boolean;
  54034. /**
  54035. * Activates the reduction computation.
  54036. * When activated, the observers registered in onAfterReductionPerformed are
  54037. * called after the compuation is performed
  54038. */
  54039. activate(): void;
  54040. /**
  54041. * Deactivates the reduction computation.
  54042. */
  54043. deactivate(): void;
  54044. /**
  54045. * Disposes the min/max reducer
  54046. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54047. */
  54048. dispose(disposeAll?: boolean): void;
  54049. }
  54050. }
  54051. declare module BABYLON {
  54052. /**
  54053. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54054. */
  54055. export class DepthReducer extends MinMaxReducer {
  54056. private _depthRenderer;
  54057. private _depthRendererId;
  54058. /**
  54059. * Gets the depth renderer used for the computation.
  54060. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54061. */
  54062. get depthRenderer(): Nullable<DepthRenderer>;
  54063. /**
  54064. * Creates a depth reducer
  54065. * @param camera The camera used to render the depth texture
  54066. */
  54067. constructor(camera: Camera);
  54068. /**
  54069. * Sets the depth renderer to use to generate the depth map
  54070. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54071. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54072. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54073. */
  54074. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54075. /** @hidden */
  54076. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54077. /**
  54078. * Activates the reduction computation.
  54079. * When activated, the observers registered in onAfterReductionPerformed are
  54080. * called after the compuation is performed
  54081. */
  54082. activate(): void;
  54083. /**
  54084. * Deactivates the reduction computation.
  54085. */
  54086. deactivate(): void;
  54087. /**
  54088. * Disposes the depth reducer
  54089. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54090. */
  54091. dispose(disposeAll?: boolean): void;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /**
  54096. * A CSM implementation allowing casting shadows on large scenes.
  54097. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54098. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54099. */
  54100. export class CascadedShadowGenerator extends ShadowGenerator {
  54101. private static readonly frustumCornersNDCSpace;
  54102. /**
  54103. * Name of the CSM class
  54104. */
  54105. static CLASSNAME: string;
  54106. /**
  54107. * Defines the default number of cascades used by the CSM.
  54108. */
  54109. static readonly DEFAULT_CASCADES_COUNT: number;
  54110. /**
  54111. * Defines the minimum number of cascades used by the CSM.
  54112. */
  54113. static readonly MIN_CASCADES_COUNT: number;
  54114. /**
  54115. * Defines the maximum number of cascades used by the CSM.
  54116. */
  54117. static readonly MAX_CASCADES_COUNT: number;
  54118. protected _validateFilter(filter: number): number;
  54119. /**
  54120. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54121. */
  54122. penumbraDarkness: number;
  54123. private _numCascades;
  54124. /**
  54125. * Gets or set the number of cascades used by the CSM.
  54126. */
  54127. get numCascades(): number;
  54128. set numCascades(value: number);
  54129. /**
  54130. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54131. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54132. */
  54133. stabilizeCascades: boolean;
  54134. private _freezeShadowCastersBoundingInfo;
  54135. private _freezeShadowCastersBoundingInfoObservable;
  54136. /**
  54137. * Enables or disables the shadow casters bounding info computation.
  54138. * If your shadow casters don't move, you can disable this feature.
  54139. * If it is enabled, the bounding box computation is done every frame.
  54140. */
  54141. get freezeShadowCastersBoundingInfo(): boolean;
  54142. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54143. private _scbiMin;
  54144. private _scbiMax;
  54145. protected _computeShadowCastersBoundingInfo(): void;
  54146. protected _shadowCastersBoundingInfo: BoundingInfo;
  54147. /**
  54148. * Gets or sets the shadow casters bounding info.
  54149. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54150. * so that the system won't overwrite the bounds you provide
  54151. */
  54152. get shadowCastersBoundingInfo(): BoundingInfo;
  54153. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54154. protected _breaksAreDirty: boolean;
  54155. protected _minDistance: number;
  54156. protected _maxDistance: number;
  54157. /**
  54158. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54159. *
  54160. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54161. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54162. * @param min minimal distance for the breaks (default to 0.)
  54163. * @param max maximal distance for the breaks (default to 1.)
  54164. */
  54165. setMinMaxDistance(min: number, max: number): void;
  54166. /** Gets the minimal distance used in the cascade break computation */
  54167. get minDistance(): number;
  54168. /** Gets the maximal distance used in the cascade break computation */
  54169. get maxDistance(): number;
  54170. /**
  54171. * Gets the class name of that object
  54172. * @returns "CascadedShadowGenerator"
  54173. */
  54174. getClassName(): string;
  54175. private _cascadeMinExtents;
  54176. private _cascadeMaxExtents;
  54177. /**
  54178. * Gets a cascade minimum extents
  54179. * @param cascadeIndex index of the cascade
  54180. * @returns the minimum cascade extents
  54181. */
  54182. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54183. /**
  54184. * Gets a cascade maximum extents
  54185. * @param cascadeIndex index of the cascade
  54186. * @returns the maximum cascade extents
  54187. */
  54188. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54189. private _cascades;
  54190. private _currentLayer;
  54191. private _viewSpaceFrustumsZ;
  54192. private _viewMatrices;
  54193. private _projectionMatrices;
  54194. private _transformMatrices;
  54195. private _transformMatricesAsArray;
  54196. private _frustumLengths;
  54197. private _lightSizeUVCorrection;
  54198. private _depthCorrection;
  54199. private _frustumCornersWorldSpace;
  54200. private _frustumCenter;
  54201. private _shadowCameraPos;
  54202. private _shadowMaxZ;
  54203. /**
  54204. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54205. * It defaults to camera.maxZ
  54206. */
  54207. get shadowMaxZ(): number;
  54208. /**
  54209. * Sets the shadow max z distance.
  54210. */
  54211. set shadowMaxZ(value: number);
  54212. protected _debug: boolean;
  54213. /**
  54214. * Gets or sets the debug flag.
  54215. * When enabled, the cascades are materialized by different colors on the screen.
  54216. */
  54217. get debug(): boolean;
  54218. set debug(dbg: boolean);
  54219. private _depthClamp;
  54220. /**
  54221. * Gets or sets the depth clamping value.
  54222. *
  54223. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54224. * to account for the shadow casters far away.
  54225. *
  54226. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54227. */
  54228. get depthClamp(): boolean;
  54229. set depthClamp(value: boolean);
  54230. private _cascadeBlendPercentage;
  54231. /**
  54232. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54233. * It defaults to 0.1 (10% blending).
  54234. */
  54235. get cascadeBlendPercentage(): number;
  54236. set cascadeBlendPercentage(value: number);
  54237. private _lambda;
  54238. /**
  54239. * Gets or set the lambda parameter.
  54240. * This parameter is used to split the camera frustum and create the cascades.
  54241. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54242. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54243. */
  54244. get lambda(): number;
  54245. set lambda(value: number);
  54246. /**
  54247. * Gets the view matrix corresponding to a given cascade
  54248. * @param cascadeNum cascade to retrieve the view matrix from
  54249. * @returns the cascade view matrix
  54250. */
  54251. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54252. /**
  54253. * Gets the projection matrix corresponding to a given cascade
  54254. * @param cascadeNum cascade to retrieve the projection matrix from
  54255. * @returns the cascade projection matrix
  54256. */
  54257. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54258. /**
  54259. * Gets the transformation matrix corresponding to a given cascade
  54260. * @param cascadeNum cascade to retrieve the transformation matrix from
  54261. * @returns the cascade transformation matrix
  54262. */
  54263. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54264. private _depthRenderer;
  54265. /**
  54266. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54267. *
  54268. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54269. *
  54270. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54271. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54272. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54273. */
  54274. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54275. private _depthReducer;
  54276. private _autoCalcDepthBounds;
  54277. /**
  54278. * Gets or sets the autoCalcDepthBounds property.
  54279. *
  54280. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54281. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54282. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54283. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54284. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54285. */
  54286. get autoCalcDepthBounds(): boolean;
  54287. set autoCalcDepthBounds(value: boolean);
  54288. /**
  54289. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54290. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54291. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54292. * for setting the refresh rate on the renderer yourself!
  54293. */
  54294. get autoCalcDepthBoundsRefreshRate(): number;
  54295. set autoCalcDepthBoundsRefreshRate(value: number);
  54296. /**
  54297. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54298. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54299. * you change the camera near/far planes!
  54300. */
  54301. splitFrustum(): void;
  54302. private _splitFrustum;
  54303. private _computeMatrices;
  54304. private _computeFrustumInWorldSpace;
  54305. private _computeCascadeFrustum;
  54306. /** @hidden */
  54307. static _SceneComponentInitialization: (scene: Scene) => void;
  54308. /**
  54309. * Creates a Cascaded Shadow Generator object.
  54310. * A ShadowGenerator is the required tool to use the shadows.
  54311. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54312. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54313. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54314. * @param light The directional light object generating the shadows.
  54315. * @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.
  54316. */
  54317. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54318. protected _initializeGenerator(): void;
  54319. protected _createTargetRenderTexture(): void;
  54320. protected _initializeShadowMap(): void;
  54321. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54322. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54323. /**
  54324. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54325. * @param defines Defines of the material we want to update
  54326. * @param lightIndex Index of the light in the enabled light list of the material
  54327. */
  54328. prepareDefines(defines: any, lightIndex: number): void;
  54329. /**
  54330. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54331. * defined in the generator but impacting the effect).
  54332. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54333. * @param effect The effect we are binfing the information for
  54334. */
  54335. bindShadowLight(lightIndex: string, effect: Effect): void;
  54336. /**
  54337. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54338. * (eq to view projection * shadow projection matrices)
  54339. * @returns The transform matrix used to create the shadow map
  54340. */
  54341. getTransformMatrix(): Matrix;
  54342. /**
  54343. * Disposes the ShadowGenerator.
  54344. * Returns nothing.
  54345. */
  54346. dispose(): void;
  54347. /**
  54348. * Serializes the shadow generator setup to a json object.
  54349. * @returns The serialized JSON object
  54350. */
  54351. serialize(): any;
  54352. /**
  54353. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54354. * @param parsedShadowGenerator The JSON object to parse
  54355. * @param scene The scene to create the shadow map for
  54356. * @returns The parsed shadow generator
  54357. */
  54358. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54359. }
  54360. }
  54361. declare module BABYLON {
  54362. /**
  54363. * Defines the shadow generator component responsible to manage any shadow generators
  54364. * in a given scene.
  54365. */
  54366. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54367. /**
  54368. * The component name helpfull to identify the component in the list of scene components.
  54369. */
  54370. readonly name: string;
  54371. /**
  54372. * The scene the component belongs to.
  54373. */
  54374. scene: Scene;
  54375. /**
  54376. * Creates a new instance of the component for the given scene
  54377. * @param scene Defines the scene to register the component in
  54378. */
  54379. constructor(scene: Scene);
  54380. /**
  54381. * Registers the component in a given scene
  54382. */
  54383. register(): void;
  54384. /**
  54385. * Rebuilds the elements related to this component in case of
  54386. * context lost for instance.
  54387. */
  54388. rebuild(): void;
  54389. /**
  54390. * Serializes the component data to the specified json object
  54391. * @param serializationObject The object to serialize to
  54392. */
  54393. serialize(serializationObject: any): void;
  54394. /**
  54395. * Adds all the elements from the container to the scene
  54396. * @param container the container holding the elements
  54397. */
  54398. addFromContainer(container: AbstractScene): void;
  54399. /**
  54400. * Removes all the elements in the container from the scene
  54401. * @param container contains the elements to remove
  54402. * @param dispose if the removed element should be disposed (default: false)
  54403. */
  54404. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54405. /**
  54406. * Rebuilds the elements related to this component in case of
  54407. * context lost for instance.
  54408. */
  54409. dispose(): void;
  54410. private _gatherRenderTargets;
  54411. }
  54412. }
  54413. declare module BABYLON {
  54414. /**
  54415. * A point light is a light defined by an unique point in world space.
  54416. * The light is emitted in every direction from this point.
  54417. * A good example of a point light is a standard light bulb.
  54418. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54419. */
  54420. export class PointLight extends ShadowLight {
  54421. private _shadowAngle;
  54422. /**
  54423. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54424. * This specifies what angle the shadow will use to be created.
  54425. *
  54426. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54427. */
  54428. get shadowAngle(): number;
  54429. /**
  54430. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54431. * This specifies what angle the shadow will use to be created.
  54432. *
  54433. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54434. */
  54435. set shadowAngle(value: number);
  54436. /**
  54437. * Gets the direction if it has been set.
  54438. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54439. */
  54440. get direction(): Vector3;
  54441. /**
  54442. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54443. */
  54444. set direction(value: Vector3);
  54445. /**
  54446. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54447. * A PointLight emits the light in every direction.
  54448. * It can cast shadows.
  54449. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54450. * ```javascript
  54451. * var pointLight = new PointLight("pl", camera.position, scene);
  54452. * ```
  54453. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54454. * @param name The light friendly name
  54455. * @param position The position of the point light in the scene
  54456. * @param scene The scene the lights belongs to
  54457. */
  54458. constructor(name: string, position: Vector3, scene: Scene);
  54459. /**
  54460. * Returns the string "PointLight"
  54461. * @returns the class name
  54462. */
  54463. getClassName(): string;
  54464. /**
  54465. * Returns the integer 0.
  54466. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54467. */
  54468. getTypeID(): number;
  54469. /**
  54470. * Specifies wether or not the shadowmap should be a cube texture.
  54471. * @returns true if the shadowmap needs to be a cube texture.
  54472. */
  54473. needCube(): boolean;
  54474. /**
  54475. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54476. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54477. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54478. */
  54479. getShadowDirection(faceIndex?: number): Vector3;
  54480. /**
  54481. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54482. * - fov = PI / 2
  54483. * - aspect ratio : 1.0
  54484. * - z-near and far equal to the active camera minZ and maxZ.
  54485. * Returns the PointLight.
  54486. */
  54487. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54488. protected _buildUniformLayout(): void;
  54489. /**
  54490. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54491. * @param effect The effect to update
  54492. * @param lightIndex The index of the light in the effect to update
  54493. * @returns The point light
  54494. */
  54495. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54496. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54497. /**
  54498. * Prepares the list of defines specific to the light type.
  54499. * @param defines the list of defines
  54500. * @param lightIndex defines the index of the light for the effect
  54501. */
  54502. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54503. }
  54504. }
  54505. declare module BABYLON {
  54506. /**
  54507. * Header information of HDR texture files.
  54508. */
  54509. export interface HDRInfo {
  54510. /**
  54511. * The height of the texture in pixels.
  54512. */
  54513. height: number;
  54514. /**
  54515. * The width of the texture in pixels.
  54516. */
  54517. width: number;
  54518. /**
  54519. * The index of the beginning of the data in the binary file.
  54520. */
  54521. dataPosition: number;
  54522. }
  54523. /**
  54524. * This groups tools to convert HDR texture to native colors array.
  54525. */
  54526. export class HDRTools {
  54527. private static Ldexp;
  54528. private static Rgbe2float;
  54529. private static readStringLine;
  54530. /**
  54531. * Reads header information from an RGBE texture stored in a native array.
  54532. * More information on this format are available here:
  54533. * https://en.wikipedia.org/wiki/RGBE_image_format
  54534. *
  54535. * @param uint8array The binary file stored in native array.
  54536. * @return The header information.
  54537. */
  54538. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54539. /**
  54540. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54541. * This RGBE texture needs to store the information as a panorama.
  54542. *
  54543. * More information on this format are available here:
  54544. * https://en.wikipedia.org/wiki/RGBE_image_format
  54545. *
  54546. * @param buffer The binary file stored in an array buffer.
  54547. * @param size The expected size of the extracted cubemap.
  54548. * @return The Cube Map information.
  54549. */
  54550. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54551. /**
  54552. * Returns the pixels data extracted from an RGBE texture.
  54553. * This pixels will be stored left to right up to down in the R G B order in one array.
  54554. *
  54555. * More information on this format are available here:
  54556. * https://en.wikipedia.org/wiki/RGBE_image_format
  54557. *
  54558. * @param uint8array The binary file stored in an array buffer.
  54559. * @param hdrInfo The header information of the file.
  54560. * @return The pixels data in RGB right to left up to down order.
  54561. */
  54562. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54563. private static RGBE_ReadPixels_RLE;
  54564. }
  54565. }
  54566. declare module BABYLON {
  54567. /**
  54568. * This represents a texture coming from an HDR input.
  54569. *
  54570. * The only supported format is currently panorama picture stored in RGBE format.
  54571. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54572. */
  54573. export class HDRCubeTexture extends BaseTexture {
  54574. private static _facesMapping;
  54575. private _generateHarmonics;
  54576. private _noMipmap;
  54577. private _textureMatrix;
  54578. private _size;
  54579. private _onLoad;
  54580. private _onError;
  54581. /**
  54582. * The texture URL.
  54583. */
  54584. url: string;
  54585. /**
  54586. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54587. */
  54588. coordinatesMode: number;
  54589. protected _isBlocking: boolean;
  54590. /**
  54591. * Sets wether or not the texture is blocking during loading.
  54592. */
  54593. set isBlocking(value: boolean);
  54594. /**
  54595. * Gets wether or not the texture is blocking during loading.
  54596. */
  54597. get isBlocking(): boolean;
  54598. protected _rotationY: number;
  54599. /**
  54600. * Sets texture matrix rotation angle around Y axis in radians.
  54601. */
  54602. set rotationY(value: number);
  54603. /**
  54604. * Gets texture matrix rotation angle around Y axis radians.
  54605. */
  54606. get rotationY(): number;
  54607. /**
  54608. * Gets or sets the center of the bounding box associated with the cube texture
  54609. * It must define where the camera used to render the texture was set
  54610. */
  54611. boundingBoxPosition: Vector3;
  54612. private _boundingBoxSize;
  54613. /**
  54614. * Gets or sets the size of the bounding box associated with the cube texture
  54615. * When defined, the cubemap will switch to local mode
  54616. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54617. * @example https://www.babylonjs-playground.com/#RNASML
  54618. */
  54619. set boundingBoxSize(value: Vector3);
  54620. get boundingBoxSize(): Vector3;
  54621. /**
  54622. * Instantiates an HDRTexture from the following parameters.
  54623. *
  54624. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54625. * @param scene The scene the texture will be used in
  54626. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54627. * @param noMipmap Forces to not generate the mipmap if true
  54628. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54629. * @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)
  54630. * @param reserved Reserved flag for internal use.
  54631. */
  54632. 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>);
  54633. /**
  54634. * Get the current class name of the texture useful for serialization or dynamic coding.
  54635. * @returns "HDRCubeTexture"
  54636. */
  54637. getClassName(): string;
  54638. /**
  54639. * Occurs when the file is raw .hdr file.
  54640. */
  54641. private loadTexture;
  54642. clone(): HDRCubeTexture;
  54643. delayLoad(): void;
  54644. /**
  54645. * Get the texture reflection matrix used to rotate/transform the reflection.
  54646. * @returns the reflection matrix
  54647. */
  54648. getReflectionTextureMatrix(): Matrix;
  54649. /**
  54650. * Set the texture reflection matrix used to rotate/transform the reflection.
  54651. * @param value Define the reflection matrix to set
  54652. */
  54653. setReflectionTextureMatrix(value: Matrix): void;
  54654. /**
  54655. * Parses a JSON representation of an HDR Texture in order to create the texture
  54656. * @param parsedTexture Define the JSON representation
  54657. * @param scene Define the scene the texture should be created in
  54658. * @param rootUrl Define the root url in case we need to load relative dependencies
  54659. * @returns the newly created texture after parsing
  54660. */
  54661. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54662. serialize(): any;
  54663. }
  54664. }
  54665. declare module BABYLON {
  54666. /**
  54667. * Class used to control physics engine
  54668. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54669. */
  54670. export class PhysicsEngine implements IPhysicsEngine {
  54671. private _physicsPlugin;
  54672. /**
  54673. * Global value used to control the smallest number supported by the simulation
  54674. */
  54675. static Epsilon: number;
  54676. private _impostors;
  54677. private _joints;
  54678. private _subTimeStep;
  54679. /**
  54680. * Gets the gravity vector used by the simulation
  54681. */
  54682. gravity: Vector3;
  54683. /**
  54684. * Factory used to create the default physics plugin.
  54685. * @returns The default physics plugin
  54686. */
  54687. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54688. /**
  54689. * Creates a new Physics Engine
  54690. * @param gravity defines the gravity vector used by the simulation
  54691. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54692. */
  54693. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54694. /**
  54695. * Sets the gravity vector used by the simulation
  54696. * @param gravity defines the gravity vector to use
  54697. */
  54698. setGravity(gravity: Vector3): void;
  54699. /**
  54700. * Set the time step of the physics engine.
  54701. * Default is 1/60.
  54702. * To slow it down, enter 1/600 for example.
  54703. * To speed it up, 1/30
  54704. * @param newTimeStep defines the new timestep to apply to this world.
  54705. */
  54706. setTimeStep(newTimeStep?: number): void;
  54707. /**
  54708. * Get the time step of the physics engine.
  54709. * @returns the current time step
  54710. */
  54711. getTimeStep(): number;
  54712. /**
  54713. * Set the sub time step of the physics engine.
  54714. * Default is 0 meaning there is no sub steps
  54715. * To increase physics resolution precision, set a small value (like 1 ms)
  54716. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54717. */
  54718. setSubTimeStep(subTimeStep?: number): void;
  54719. /**
  54720. * Get the sub time step of the physics engine.
  54721. * @returns the current sub time step
  54722. */
  54723. getSubTimeStep(): number;
  54724. /**
  54725. * Release all resources
  54726. */
  54727. dispose(): void;
  54728. /**
  54729. * Gets the name of the current physics plugin
  54730. * @returns the name of the plugin
  54731. */
  54732. getPhysicsPluginName(): string;
  54733. /**
  54734. * Adding a new impostor for the impostor tracking.
  54735. * This will be done by the impostor itself.
  54736. * @param impostor the impostor to add
  54737. */
  54738. addImpostor(impostor: PhysicsImpostor): void;
  54739. /**
  54740. * Remove an impostor from the engine.
  54741. * This impostor and its mesh will not longer be updated by the physics engine.
  54742. * @param impostor the impostor to remove
  54743. */
  54744. removeImpostor(impostor: PhysicsImpostor): void;
  54745. /**
  54746. * Add a joint to the physics engine
  54747. * @param mainImpostor defines the main impostor to which the joint is added.
  54748. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54749. * @param joint defines the joint that will connect both impostors.
  54750. */
  54751. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54752. /**
  54753. * Removes a joint from the simulation
  54754. * @param mainImpostor defines the impostor used with the joint
  54755. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54756. * @param joint defines the joint to remove
  54757. */
  54758. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54759. /**
  54760. * Called by the scene. No need to call it.
  54761. * @param delta defines the timespam between frames
  54762. */
  54763. _step(delta: number): void;
  54764. /**
  54765. * Gets the current plugin used to run the simulation
  54766. * @returns current plugin
  54767. */
  54768. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54769. /**
  54770. * Gets the list of physic impostors
  54771. * @returns an array of PhysicsImpostor
  54772. */
  54773. getImpostors(): Array<PhysicsImpostor>;
  54774. /**
  54775. * Gets the impostor for a physics enabled object
  54776. * @param object defines the object impersonated by the impostor
  54777. * @returns the PhysicsImpostor or null if not found
  54778. */
  54779. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54780. /**
  54781. * Gets the impostor for a physics body object
  54782. * @param body defines physics body used by the impostor
  54783. * @returns the PhysicsImpostor or null if not found
  54784. */
  54785. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54786. /**
  54787. * Does a raycast in the physics world
  54788. * @param from when should the ray start?
  54789. * @param to when should the ray end?
  54790. * @returns PhysicsRaycastResult
  54791. */
  54792. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54793. }
  54794. }
  54795. declare module BABYLON {
  54796. /** @hidden */
  54797. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54798. private _useDeltaForWorldStep;
  54799. world: any;
  54800. name: string;
  54801. private _physicsMaterials;
  54802. private _fixedTimeStep;
  54803. private _cannonRaycastResult;
  54804. private _raycastResult;
  54805. private _physicsBodysToRemoveAfterStep;
  54806. BJSCANNON: any;
  54807. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54808. setGravity(gravity: Vector3): void;
  54809. setTimeStep(timeStep: number): void;
  54810. getTimeStep(): number;
  54811. executeStep(delta: number): void;
  54812. private _removeMarkedPhysicsBodiesFromWorld;
  54813. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54814. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54815. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54816. private _processChildMeshes;
  54817. removePhysicsBody(impostor: PhysicsImpostor): void;
  54818. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54819. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54820. private _addMaterial;
  54821. private _checkWithEpsilon;
  54822. private _createShape;
  54823. private _createHeightmap;
  54824. private _minus90X;
  54825. private _plus90X;
  54826. private _tmpPosition;
  54827. private _tmpDeltaPosition;
  54828. private _tmpUnityRotation;
  54829. private _updatePhysicsBodyTransformation;
  54830. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54831. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54832. isSupported(): boolean;
  54833. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54834. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54835. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54836. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54837. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54838. getBodyMass(impostor: PhysicsImpostor): number;
  54839. getBodyFriction(impostor: PhysicsImpostor): number;
  54840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54841. getBodyRestitution(impostor: PhysicsImpostor): number;
  54842. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54843. sleepBody(impostor: PhysicsImpostor): void;
  54844. wakeUpBody(impostor: PhysicsImpostor): void;
  54845. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54846. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54848. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54849. getRadius(impostor: PhysicsImpostor): number;
  54850. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54851. dispose(): void;
  54852. private _extendNamespace;
  54853. /**
  54854. * Does a raycast in the physics world
  54855. * @param from when should the ray start?
  54856. * @param to when should the ray end?
  54857. * @returns PhysicsRaycastResult
  54858. */
  54859. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54860. }
  54861. }
  54862. declare module BABYLON {
  54863. /** @hidden */
  54864. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54865. world: any;
  54866. name: string;
  54867. BJSOIMO: any;
  54868. private _raycastResult;
  54869. constructor(iterations?: number, oimoInjection?: any);
  54870. setGravity(gravity: Vector3): void;
  54871. setTimeStep(timeStep: number): void;
  54872. getTimeStep(): number;
  54873. private _tmpImpostorsArray;
  54874. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54875. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54876. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54877. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54878. private _tmpPositionVector;
  54879. removePhysicsBody(impostor: PhysicsImpostor): void;
  54880. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54881. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54882. isSupported(): boolean;
  54883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54884. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54890. getBodyMass(impostor: PhysicsImpostor): number;
  54891. getBodyFriction(impostor: PhysicsImpostor): number;
  54892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54893. getBodyRestitution(impostor: PhysicsImpostor): number;
  54894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54895. sleepBody(impostor: PhysicsImpostor): void;
  54896. wakeUpBody(impostor: PhysicsImpostor): void;
  54897. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54898. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54899. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54900. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54901. getRadius(impostor: PhysicsImpostor): number;
  54902. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54903. dispose(): void;
  54904. /**
  54905. * Does a raycast in the physics world
  54906. * @param from when should the ray start?
  54907. * @param to when should the ray end?
  54908. * @returns PhysicsRaycastResult
  54909. */
  54910. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54911. }
  54912. }
  54913. declare module BABYLON {
  54914. /**
  54915. * Class containing static functions to help procedurally build meshes
  54916. */
  54917. export class RibbonBuilder {
  54918. /**
  54919. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54920. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54921. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54922. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54923. * * 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
  54924. * * 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
  54925. * * 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
  54926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54927. * * 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
  54928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54929. * * 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
  54930. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54931. * * 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
  54932. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54934. * @param name defines the name of the mesh
  54935. * @param options defines the options used to create the mesh
  54936. * @param scene defines the hosting scene
  54937. * @returns the ribbon mesh
  54938. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54939. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54940. */
  54941. static CreateRibbon(name: string, options: {
  54942. pathArray: Vector3[][];
  54943. closeArray?: boolean;
  54944. closePath?: boolean;
  54945. offset?: number;
  54946. updatable?: boolean;
  54947. sideOrientation?: number;
  54948. frontUVs?: Vector4;
  54949. backUVs?: Vector4;
  54950. instance?: Mesh;
  54951. invertUV?: boolean;
  54952. uvs?: Vector2[];
  54953. colors?: Color4[];
  54954. }, scene?: Nullable<Scene>): Mesh;
  54955. }
  54956. }
  54957. declare module BABYLON {
  54958. /**
  54959. * Class containing static functions to help procedurally build meshes
  54960. */
  54961. export class ShapeBuilder {
  54962. /**
  54963. * 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.
  54964. * * 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.
  54965. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54966. * * 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.
  54967. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54968. * * 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
  54969. * * 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
  54970. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54972. * * 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
  54973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54975. * @param name defines the name of the mesh
  54976. * @param options defines the options used to create the mesh
  54977. * @param scene defines the hosting scene
  54978. * @returns the extruded shape mesh
  54979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54981. */
  54982. static ExtrudeShape(name: string, options: {
  54983. shape: Vector3[];
  54984. path: Vector3[];
  54985. scale?: number;
  54986. rotation?: number;
  54987. cap?: number;
  54988. updatable?: boolean;
  54989. sideOrientation?: number;
  54990. frontUVs?: Vector4;
  54991. backUVs?: Vector4;
  54992. instance?: Mesh;
  54993. invertUV?: boolean;
  54994. }, scene?: Nullable<Scene>): Mesh;
  54995. /**
  54996. * Creates an custom extruded shape mesh.
  54997. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54998. * * 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.
  54999. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55000. * * 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
  55001. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55002. * * 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
  55003. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55004. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55005. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55006. * * 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
  55007. * * 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
  55008. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55010. * * 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
  55011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55013. * @param name defines the name of the mesh
  55014. * @param options defines the options used to create the mesh
  55015. * @param scene defines the hosting scene
  55016. * @returns the custom extruded shape mesh
  55017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55020. */
  55021. static ExtrudeShapeCustom(name: string, options: {
  55022. shape: Vector3[];
  55023. path: Vector3[];
  55024. scaleFunction?: any;
  55025. rotationFunction?: any;
  55026. ribbonCloseArray?: boolean;
  55027. ribbonClosePath?: boolean;
  55028. cap?: number;
  55029. updatable?: boolean;
  55030. sideOrientation?: number;
  55031. frontUVs?: Vector4;
  55032. backUVs?: Vector4;
  55033. instance?: Mesh;
  55034. invertUV?: boolean;
  55035. }, scene?: Nullable<Scene>): Mesh;
  55036. private static _ExtrudeShapeGeneric;
  55037. }
  55038. }
  55039. declare module BABYLON {
  55040. /**
  55041. * AmmoJS Physics plugin
  55042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55043. * @see https://github.com/kripken/ammo.js/
  55044. */
  55045. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55046. private _useDeltaForWorldStep;
  55047. /**
  55048. * Reference to the Ammo library
  55049. */
  55050. bjsAMMO: any;
  55051. /**
  55052. * Created ammoJS world which physics bodies are added to
  55053. */
  55054. world: any;
  55055. /**
  55056. * Name of the plugin
  55057. */
  55058. name: string;
  55059. private _timeStep;
  55060. private _fixedTimeStep;
  55061. private _maxSteps;
  55062. private _tmpQuaternion;
  55063. private _tmpAmmoTransform;
  55064. private _tmpAmmoQuaternion;
  55065. private _tmpAmmoConcreteContactResultCallback;
  55066. private _collisionConfiguration;
  55067. private _dispatcher;
  55068. private _overlappingPairCache;
  55069. private _solver;
  55070. private _softBodySolver;
  55071. private _tmpAmmoVectorA;
  55072. private _tmpAmmoVectorB;
  55073. private _tmpAmmoVectorC;
  55074. private _tmpAmmoVectorD;
  55075. private _tmpContactCallbackResult;
  55076. private _tmpAmmoVectorRCA;
  55077. private _tmpAmmoVectorRCB;
  55078. private _raycastResult;
  55079. private static readonly DISABLE_COLLISION_FLAG;
  55080. private static readonly KINEMATIC_FLAG;
  55081. private static readonly DISABLE_DEACTIVATION_FLAG;
  55082. /**
  55083. * Initializes the ammoJS plugin
  55084. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55085. * @param ammoInjection can be used to inject your own ammo reference
  55086. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55087. */
  55088. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55089. /**
  55090. * Sets the gravity of the physics world (m/(s^2))
  55091. * @param gravity Gravity to set
  55092. */
  55093. setGravity(gravity: Vector3): void;
  55094. /**
  55095. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55096. * @param timeStep timestep to use in seconds
  55097. */
  55098. setTimeStep(timeStep: number): void;
  55099. /**
  55100. * 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)
  55101. * @param fixedTimeStep fixedTimeStep to use in seconds
  55102. */
  55103. setFixedTimeStep(fixedTimeStep: number): void;
  55104. /**
  55105. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55106. * @param maxSteps the maximum number of steps by the physics engine per frame
  55107. */
  55108. setMaxSteps(maxSteps: number): void;
  55109. /**
  55110. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55111. * @returns the current timestep in seconds
  55112. */
  55113. getTimeStep(): number;
  55114. /**
  55115. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55116. */
  55117. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55118. private _isImpostorInContact;
  55119. private _isImpostorPairInContact;
  55120. private _stepSimulation;
  55121. /**
  55122. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55123. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55124. * After the step the babylon meshes are set to the position of the physics imposters
  55125. * @param delta amount of time to step forward
  55126. * @param impostors array of imposters to update before/after the step
  55127. */
  55128. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55129. /**
  55130. * Update babylon mesh to match physics world object
  55131. * @param impostor imposter to match
  55132. */
  55133. private _afterSoftStep;
  55134. /**
  55135. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55136. * @param impostor imposter to match
  55137. */
  55138. private _ropeStep;
  55139. /**
  55140. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55141. * @param impostor imposter to match
  55142. */
  55143. private _softbodyOrClothStep;
  55144. private _tmpVector;
  55145. private _tmpMatrix;
  55146. /**
  55147. * Applies an impulse on the imposter
  55148. * @param impostor imposter to apply impulse to
  55149. * @param force amount of force to be applied to the imposter
  55150. * @param contactPoint the location to apply the impulse on the imposter
  55151. */
  55152. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55153. /**
  55154. * Applies a force on the imposter
  55155. * @param impostor imposter to apply force
  55156. * @param force amount of force to be applied to the imposter
  55157. * @param contactPoint the location to apply the force on the imposter
  55158. */
  55159. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55160. /**
  55161. * Creates a physics body using the plugin
  55162. * @param impostor the imposter to create the physics body on
  55163. */
  55164. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55165. /**
  55166. * Removes the physics body from the imposter and disposes of the body's memory
  55167. * @param impostor imposter to remove the physics body from
  55168. */
  55169. removePhysicsBody(impostor: PhysicsImpostor): void;
  55170. /**
  55171. * Generates a joint
  55172. * @param impostorJoint the imposter joint to create the joint with
  55173. */
  55174. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55175. /**
  55176. * Removes a joint
  55177. * @param impostorJoint the imposter joint to remove the joint from
  55178. */
  55179. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55180. private _addMeshVerts;
  55181. /**
  55182. * Initialise the soft body vertices to match its object's (mesh) vertices
  55183. * Softbody vertices (nodes) are in world space and to match this
  55184. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55185. * @param impostor to create the softbody for
  55186. */
  55187. private _softVertexData;
  55188. /**
  55189. * Create an impostor's soft body
  55190. * @param impostor to create the softbody for
  55191. */
  55192. private _createSoftbody;
  55193. /**
  55194. * Create cloth for an impostor
  55195. * @param impostor to create the softbody for
  55196. */
  55197. private _createCloth;
  55198. /**
  55199. * Create rope for an impostor
  55200. * @param impostor to create the softbody for
  55201. */
  55202. private _createRope;
  55203. /**
  55204. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55205. * @param impostor to create the custom physics shape for
  55206. */
  55207. private _createCustom;
  55208. private _addHullVerts;
  55209. private _createShape;
  55210. /**
  55211. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55212. * @param impostor imposter containing the physics body and babylon object
  55213. */
  55214. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55215. /**
  55216. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55217. * @param impostor imposter containing the physics body and babylon object
  55218. * @param newPosition new position
  55219. * @param newRotation new rotation
  55220. */
  55221. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55222. /**
  55223. * If this plugin is supported
  55224. * @returns true if its supported
  55225. */
  55226. isSupported(): boolean;
  55227. /**
  55228. * Sets the linear velocity of the physics body
  55229. * @param impostor imposter to set the velocity on
  55230. * @param velocity velocity to set
  55231. */
  55232. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55233. /**
  55234. * Sets the angular velocity of the physics body
  55235. * @param impostor imposter to set the velocity on
  55236. * @param velocity velocity to set
  55237. */
  55238. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55239. /**
  55240. * gets the linear velocity
  55241. * @param impostor imposter to get linear velocity from
  55242. * @returns linear velocity
  55243. */
  55244. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55245. /**
  55246. * gets the angular velocity
  55247. * @param impostor imposter to get angular velocity from
  55248. * @returns angular velocity
  55249. */
  55250. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55251. /**
  55252. * Sets the mass of physics body
  55253. * @param impostor imposter to set the mass on
  55254. * @param mass mass to set
  55255. */
  55256. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55257. /**
  55258. * Gets the mass of the physics body
  55259. * @param impostor imposter to get the mass from
  55260. * @returns mass
  55261. */
  55262. getBodyMass(impostor: PhysicsImpostor): number;
  55263. /**
  55264. * Gets friction of the impostor
  55265. * @param impostor impostor to get friction from
  55266. * @returns friction value
  55267. */
  55268. getBodyFriction(impostor: PhysicsImpostor): number;
  55269. /**
  55270. * Sets friction of the impostor
  55271. * @param impostor impostor to set friction on
  55272. * @param friction friction value
  55273. */
  55274. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55275. /**
  55276. * Gets restitution of the impostor
  55277. * @param impostor impostor to get restitution from
  55278. * @returns restitution value
  55279. */
  55280. getBodyRestitution(impostor: PhysicsImpostor): number;
  55281. /**
  55282. * Sets resitution of the impostor
  55283. * @param impostor impostor to set resitution on
  55284. * @param restitution resitution value
  55285. */
  55286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55287. /**
  55288. * Gets pressure inside the impostor
  55289. * @param impostor impostor to get pressure from
  55290. * @returns pressure value
  55291. */
  55292. getBodyPressure(impostor: PhysicsImpostor): number;
  55293. /**
  55294. * Sets pressure inside a soft body impostor
  55295. * Cloth and rope must remain 0 pressure
  55296. * @param impostor impostor to set pressure on
  55297. * @param pressure pressure value
  55298. */
  55299. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55300. /**
  55301. * Gets stiffness of the impostor
  55302. * @param impostor impostor to get stiffness from
  55303. * @returns pressure value
  55304. */
  55305. getBodyStiffness(impostor: PhysicsImpostor): number;
  55306. /**
  55307. * Sets stiffness of the impostor
  55308. * @param impostor impostor to set stiffness on
  55309. * @param stiffness stiffness value from 0 to 1
  55310. */
  55311. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55312. /**
  55313. * Gets velocityIterations of the impostor
  55314. * @param impostor impostor to get velocity iterations from
  55315. * @returns velocityIterations value
  55316. */
  55317. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55318. /**
  55319. * Sets velocityIterations of the impostor
  55320. * @param impostor impostor to set velocity iterations on
  55321. * @param velocityIterations velocityIterations value
  55322. */
  55323. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55324. /**
  55325. * Gets positionIterations of the impostor
  55326. * @param impostor impostor to get position iterations from
  55327. * @returns positionIterations value
  55328. */
  55329. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55330. /**
  55331. * Sets positionIterations of the impostor
  55332. * @param impostor impostor to set position on
  55333. * @param positionIterations positionIterations value
  55334. */
  55335. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55336. /**
  55337. * Append an anchor to a cloth object
  55338. * @param impostor is the cloth impostor to add anchor to
  55339. * @param otherImpostor is the rigid impostor to anchor to
  55340. * @param width ratio across width from 0 to 1
  55341. * @param height ratio up height from 0 to 1
  55342. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55343. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55344. */
  55345. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55346. /**
  55347. * Append an hook to a rope object
  55348. * @param impostor is the rope impostor to add hook to
  55349. * @param otherImpostor is the rigid impostor to hook to
  55350. * @param length ratio along the rope from 0 to 1
  55351. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55352. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55353. */
  55354. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55355. /**
  55356. * Sleeps the physics body and stops it from being active
  55357. * @param impostor impostor to sleep
  55358. */
  55359. sleepBody(impostor: PhysicsImpostor): void;
  55360. /**
  55361. * Activates the physics body
  55362. * @param impostor impostor to activate
  55363. */
  55364. wakeUpBody(impostor: PhysicsImpostor): void;
  55365. /**
  55366. * Updates the distance parameters of the joint
  55367. * @param joint joint to update
  55368. * @param maxDistance maximum distance of the joint
  55369. * @param minDistance minimum distance of the joint
  55370. */
  55371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55372. /**
  55373. * Sets a motor on the joint
  55374. * @param joint joint to set motor on
  55375. * @param speed speed of the motor
  55376. * @param maxForce maximum force of the motor
  55377. * @param motorIndex index of the motor
  55378. */
  55379. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55380. /**
  55381. * Sets the motors limit
  55382. * @param joint joint to set limit on
  55383. * @param upperLimit upper limit
  55384. * @param lowerLimit lower limit
  55385. */
  55386. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55387. /**
  55388. * Syncs the position and rotation of a mesh with the impostor
  55389. * @param mesh mesh to sync
  55390. * @param impostor impostor to update the mesh with
  55391. */
  55392. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55393. /**
  55394. * Gets the radius of the impostor
  55395. * @param impostor impostor to get radius from
  55396. * @returns the radius
  55397. */
  55398. getRadius(impostor: PhysicsImpostor): number;
  55399. /**
  55400. * Gets the box size of the impostor
  55401. * @param impostor impostor to get box size from
  55402. * @param result the resulting box size
  55403. */
  55404. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55405. /**
  55406. * Disposes of the impostor
  55407. */
  55408. dispose(): void;
  55409. /**
  55410. * Does a raycast in the physics world
  55411. * @param from when should the ray start?
  55412. * @param to when should the ray end?
  55413. * @returns PhysicsRaycastResult
  55414. */
  55415. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55416. }
  55417. }
  55418. declare module BABYLON {
  55419. interface AbstractScene {
  55420. /**
  55421. * The list of reflection probes added to the scene
  55422. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55423. */
  55424. reflectionProbes: Array<ReflectionProbe>;
  55425. /**
  55426. * Removes the given reflection probe from this scene.
  55427. * @param toRemove The reflection probe to remove
  55428. * @returns The index of the removed reflection probe
  55429. */
  55430. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55431. /**
  55432. * Adds the given reflection probe to this scene.
  55433. * @param newReflectionProbe The reflection probe to add
  55434. */
  55435. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55436. }
  55437. /**
  55438. * Class used to generate realtime reflection / refraction cube textures
  55439. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55440. */
  55441. export class ReflectionProbe {
  55442. /** defines the name of the probe */
  55443. name: string;
  55444. private _scene;
  55445. private _renderTargetTexture;
  55446. private _projectionMatrix;
  55447. private _viewMatrix;
  55448. private _target;
  55449. private _add;
  55450. private _attachedMesh;
  55451. private _invertYAxis;
  55452. /** Gets or sets probe position (center of the cube map) */
  55453. position: Vector3;
  55454. /**
  55455. * Creates a new reflection probe
  55456. * @param name defines the name of the probe
  55457. * @param size defines the texture resolution (for each face)
  55458. * @param scene defines the hosting scene
  55459. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55460. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55461. */
  55462. constructor(
  55463. /** defines the name of the probe */
  55464. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55465. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55466. get samples(): number;
  55467. set samples(value: number);
  55468. /** Gets or sets the refresh rate to use (on every frame by default) */
  55469. get refreshRate(): number;
  55470. set refreshRate(value: number);
  55471. /**
  55472. * Gets the hosting scene
  55473. * @returns a Scene
  55474. */
  55475. getScene(): Scene;
  55476. /** Gets the internal CubeTexture used to render to */
  55477. get cubeTexture(): RenderTargetTexture;
  55478. /** Gets the list of meshes to render */
  55479. get renderList(): Nullable<AbstractMesh[]>;
  55480. /**
  55481. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55482. * @param mesh defines the mesh to attach to
  55483. */
  55484. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55485. /**
  55486. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55487. * @param renderingGroupId The rendering group id corresponding to its index
  55488. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55489. */
  55490. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55491. /**
  55492. * Clean all associated resources
  55493. */
  55494. dispose(): void;
  55495. /**
  55496. * Converts the reflection probe information to a readable string for debug purpose.
  55497. * @param fullDetails Supports for multiple levels of logging within scene loading
  55498. * @returns the human readable reflection probe info
  55499. */
  55500. toString(fullDetails?: boolean): string;
  55501. /**
  55502. * Get the class name of the relfection probe.
  55503. * @returns "ReflectionProbe"
  55504. */
  55505. getClassName(): string;
  55506. /**
  55507. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55508. * @returns The JSON representation of the texture
  55509. */
  55510. serialize(): any;
  55511. /**
  55512. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55513. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55514. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55515. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55516. * @returns The parsed reflection probe if successful
  55517. */
  55518. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55519. }
  55520. }
  55521. declare module BABYLON {
  55522. /** @hidden */
  55523. export var _BabylonLoaderRegistered: boolean;
  55524. /**
  55525. * Helps setting up some configuration for the babylon file loader.
  55526. */
  55527. export class BabylonFileLoaderConfiguration {
  55528. /**
  55529. * The loader does not allow injecting custom physix engine into the plugins.
  55530. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55531. * So you could set this variable to your engine import to make it work.
  55532. */
  55533. static LoaderInjectedPhysicsEngine: any;
  55534. }
  55535. }
  55536. declare module BABYLON {
  55537. /**
  55538. * The Physically based simple base material of BJS.
  55539. *
  55540. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55541. * It is used as the base class for both the specGloss and metalRough conventions.
  55542. */
  55543. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55544. /**
  55545. * Number of Simultaneous lights allowed on the material.
  55546. */
  55547. maxSimultaneousLights: number;
  55548. /**
  55549. * If sets to true, disables all the lights affecting the material.
  55550. */
  55551. disableLighting: boolean;
  55552. /**
  55553. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55554. */
  55555. environmentTexture: BaseTexture;
  55556. /**
  55557. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55558. */
  55559. invertNormalMapX: boolean;
  55560. /**
  55561. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55562. */
  55563. invertNormalMapY: boolean;
  55564. /**
  55565. * Normal map used in the model.
  55566. */
  55567. normalTexture: BaseTexture;
  55568. /**
  55569. * Emissivie color used to self-illuminate the model.
  55570. */
  55571. emissiveColor: Color3;
  55572. /**
  55573. * Emissivie texture used to self-illuminate the model.
  55574. */
  55575. emissiveTexture: BaseTexture;
  55576. /**
  55577. * Occlusion Channel Strenght.
  55578. */
  55579. occlusionStrength: number;
  55580. /**
  55581. * Occlusion Texture of the material (adding extra occlusion effects).
  55582. */
  55583. occlusionTexture: BaseTexture;
  55584. /**
  55585. * Defines the alpha limits in alpha test mode.
  55586. */
  55587. alphaCutOff: number;
  55588. /**
  55589. * Gets the current double sided mode.
  55590. */
  55591. get doubleSided(): boolean;
  55592. /**
  55593. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55594. */
  55595. set doubleSided(value: boolean);
  55596. /**
  55597. * Stores the pre-calculated light information of a mesh in a texture.
  55598. */
  55599. lightmapTexture: BaseTexture;
  55600. /**
  55601. * If true, the light map contains occlusion information instead of lighting info.
  55602. */
  55603. useLightmapAsShadowmap: boolean;
  55604. /**
  55605. * Instantiates a new PBRMaterial instance.
  55606. *
  55607. * @param name The material name
  55608. * @param scene The scene the material will be use in.
  55609. */
  55610. constructor(name: string, scene: Scene);
  55611. getClassName(): string;
  55612. }
  55613. }
  55614. declare module BABYLON {
  55615. /**
  55616. * The PBR material of BJS following the metal roughness convention.
  55617. *
  55618. * This fits to the PBR convention in the GLTF definition:
  55619. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55620. */
  55621. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55622. /**
  55623. * The base color has two different interpretations depending on the value of metalness.
  55624. * When the material is a metal, the base color is the specific measured reflectance value
  55625. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55626. * of the material.
  55627. */
  55628. baseColor: Color3;
  55629. /**
  55630. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55631. * well as opacity information in the alpha channel.
  55632. */
  55633. baseTexture: BaseTexture;
  55634. /**
  55635. * Specifies the metallic scalar value of the material.
  55636. * Can also be used to scale the metalness values of the metallic texture.
  55637. */
  55638. metallic: number;
  55639. /**
  55640. * Specifies the roughness scalar value of the material.
  55641. * Can also be used to scale the roughness values of the metallic texture.
  55642. */
  55643. roughness: number;
  55644. /**
  55645. * Texture containing both the metallic value in the B channel and the
  55646. * roughness value in the G channel to keep better precision.
  55647. */
  55648. metallicRoughnessTexture: BaseTexture;
  55649. /**
  55650. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55651. *
  55652. * @param name The material name
  55653. * @param scene The scene the material will be use in.
  55654. */
  55655. constructor(name: string, scene: Scene);
  55656. /**
  55657. * Return the currrent class name of the material.
  55658. */
  55659. getClassName(): string;
  55660. /**
  55661. * Makes a duplicate of the current material.
  55662. * @param name - name to use for the new material.
  55663. */
  55664. clone(name: string): PBRMetallicRoughnessMaterial;
  55665. /**
  55666. * Serialize the material to a parsable JSON object.
  55667. */
  55668. serialize(): any;
  55669. /**
  55670. * Parses a JSON object correponding to the serialize function.
  55671. */
  55672. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55673. }
  55674. }
  55675. declare module BABYLON {
  55676. /**
  55677. * The PBR material of BJS following the specular glossiness convention.
  55678. *
  55679. * This fits to the PBR convention in the GLTF definition:
  55680. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55681. */
  55682. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55683. /**
  55684. * Specifies the diffuse color of the material.
  55685. */
  55686. diffuseColor: Color3;
  55687. /**
  55688. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55689. * channel.
  55690. */
  55691. diffuseTexture: BaseTexture;
  55692. /**
  55693. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55694. */
  55695. specularColor: Color3;
  55696. /**
  55697. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55698. */
  55699. glossiness: number;
  55700. /**
  55701. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55702. */
  55703. specularGlossinessTexture: BaseTexture;
  55704. /**
  55705. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55706. *
  55707. * @param name The material name
  55708. * @param scene The scene the material will be use in.
  55709. */
  55710. constructor(name: string, scene: Scene);
  55711. /**
  55712. * Return the currrent class name of the material.
  55713. */
  55714. getClassName(): string;
  55715. /**
  55716. * Makes a duplicate of the current material.
  55717. * @param name - name to use for the new material.
  55718. */
  55719. clone(name: string): PBRSpecularGlossinessMaterial;
  55720. /**
  55721. * Serialize the material to a parsable JSON object.
  55722. */
  55723. serialize(): any;
  55724. /**
  55725. * Parses a JSON object correponding to the serialize function.
  55726. */
  55727. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55733. * It can help converting any input color in a desired output one. This can then be used to create effects
  55734. * from sepia, black and white to sixties or futuristic rendering...
  55735. *
  55736. * The only supported format is currently 3dl.
  55737. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55738. */
  55739. export class ColorGradingTexture extends BaseTexture {
  55740. /**
  55741. * The current texture matrix. (will always be identity in color grading texture)
  55742. */
  55743. private _textureMatrix;
  55744. /**
  55745. * The texture URL.
  55746. */
  55747. url: string;
  55748. /**
  55749. * Empty line regex stored for GC.
  55750. */
  55751. private static _noneEmptyLineRegex;
  55752. private _engine;
  55753. /**
  55754. * Instantiates a ColorGradingTexture from the following parameters.
  55755. *
  55756. * @param url The location of the color gradind data (currently only supporting 3dl)
  55757. * @param scene The scene the texture will be used in
  55758. */
  55759. constructor(url: string, scene: Scene);
  55760. /**
  55761. * Returns the texture matrix used in most of the material.
  55762. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55763. */
  55764. getTextureMatrix(): Matrix;
  55765. /**
  55766. * Occurs when the file being loaded is a .3dl LUT file.
  55767. */
  55768. private load3dlTexture;
  55769. /**
  55770. * Starts the loading process of the texture.
  55771. */
  55772. private loadTexture;
  55773. /**
  55774. * Clones the color gradind texture.
  55775. */
  55776. clone(): ColorGradingTexture;
  55777. /**
  55778. * Called during delayed load for textures.
  55779. */
  55780. delayLoad(): void;
  55781. /**
  55782. * Parses a color grading texture serialized by Babylon.
  55783. * @param parsedTexture The texture information being parsedTexture
  55784. * @param scene The scene to load the texture in
  55785. * @param rootUrl The root url of the data assets to load
  55786. * @return A color gradind texture
  55787. */
  55788. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55789. /**
  55790. * Serializes the LUT texture to json format.
  55791. */
  55792. serialize(): any;
  55793. }
  55794. }
  55795. declare module BABYLON {
  55796. /**
  55797. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55798. */
  55799. export class EquiRectangularCubeTexture extends BaseTexture {
  55800. /** The six faces of the cube. */
  55801. private static _FacesMapping;
  55802. private _noMipmap;
  55803. private _onLoad;
  55804. private _onError;
  55805. /** The size of the cubemap. */
  55806. private _size;
  55807. /** The buffer of the image. */
  55808. private _buffer;
  55809. /** The width of the input image. */
  55810. private _width;
  55811. /** The height of the input image. */
  55812. private _height;
  55813. /** The URL to the image. */
  55814. url: string;
  55815. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55816. coordinatesMode: number;
  55817. /**
  55818. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55819. * @param url The location of the image
  55820. * @param scene The scene the texture will be used in
  55821. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55822. * @param noMipmap Forces to not generate the mipmap if true
  55823. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55824. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55825. * @param onLoad — defines a callback called when texture is loaded
  55826. * @param onError — defines a callback called if there is an error
  55827. */
  55828. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55829. /**
  55830. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55831. */
  55832. private loadImage;
  55833. /**
  55834. * Convert the image buffer into a cubemap and create a CubeTexture.
  55835. */
  55836. private loadTexture;
  55837. /**
  55838. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55839. * @param buffer The ArrayBuffer that should be converted.
  55840. * @returns The buffer as Float32Array.
  55841. */
  55842. private getFloat32ArrayFromArrayBuffer;
  55843. /**
  55844. * Get the current class name of the texture useful for serialization or dynamic coding.
  55845. * @returns "EquiRectangularCubeTexture"
  55846. */
  55847. getClassName(): string;
  55848. /**
  55849. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55850. * @returns A clone of the current EquiRectangularCubeTexture.
  55851. */
  55852. clone(): EquiRectangularCubeTexture;
  55853. }
  55854. }
  55855. declare module BABYLON {
  55856. /**
  55857. * Based on jsTGALoader - Javascript loader for TGA file
  55858. * By Vincent Thibault
  55859. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55860. */
  55861. export class TGATools {
  55862. private static _TYPE_INDEXED;
  55863. private static _TYPE_RGB;
  55864. private static _TYPE_GREY;
  55865. private static _TYPE_RLE_INDEXED;
  55866. private static _TYPE_RLE_RGB;
  55867. private static _TYPE_RLE_GREY;
  55868. private static _ORIGIN_MASK;
  55869. private static _ORIGIN_SHIFT;
  55870. private static _ORIGIN_BL;
  55871. private static _ORIGIN_BR;
  55872. private static _ORIGIN_UL;
  55873. private static _ORIGIN_UR;
  55874. /**
  55875. * Gets the header of a TGA file
  55876. * @param data defines the TGA data
  55877. * @returns the header
  55878. */
  55879. static GetTGAHeader(data: Uint8Array): any;
  55880. /**
  55881. * Uploads TGA content to a Babylon Texture
  55882. * @hidden
  55883. */
  55884. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55885. /** @hidden */
  55886. 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;
  55887. /** @hidden */
  55888. 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;
  55889. /** @hidden */
  55890. 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;
  55891. /** @hidden */
  55892. 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;
  55893. /** @hidden */
  55894. 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;
  55895. /** @hidden */
  55896. 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;
  55897. }
  55898. }
  55899. declare module BABYLON {
  55900. /**
  55901. * Implementation of the TGA Texture Loader.
  55902. * @hidden
  55903. */
  55904. export class _TGATextureLoader implements IInternalTextureLoader {
  55905. /**
  55906. * Defines wether the loader supports cascade loading the different faces.
  55907. */
  55908. readonly supportCascades: boolean;
  55909. /**
  55910. * This returns if the loader support the current file information.
  55911. * @param extension defines the file extension of the file being loaded
  55912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55913. * @param fallback defines the fallback internal texture if any
  55914. * @param isBase64 defines whether the texture is encoded as a base64
  55915. * @param isBuffer defines whether the texture data are stored as a buffer
  55916. * @returns true if the loader can load the specified file
  55917. */
  55918. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55919. /**
  55920. * Transform the url before loading if required.
  55921. * @param rootUrl the url of the texture
  55922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55923. * @returns the transformed texture
  55924. */
  55925. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55926. /**
  55927. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55928. * @param rootUrl the url of the texture
  55929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55930. * @returns the fallback texture
  55931. */
  55932. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55933. /**
  55934. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55935. * @param data contains the texture data
  55936. * @param texture defines the BabylonJS internal texture
  55937. * @param createPolynomials will be true if polynomials have been requested
  55938. * @param onLoad defines the callback to trigger once the texture is ready
  55939. * @param onError defines the callback to trigger in case of error
  55940. */
  55941. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55942. /**
  55943. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55944. * @param data contains the texture data
  55945. * @param texture defines the BabylonJS internal texture
  55946. * @param callback defines the method to call once ready to upload
  55947. */
  55948. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55949. }
  55950. }
  55951. declare module BABYLON {
  55952. /**
  55953. * Info about the .basis files
  55954. */
  55955. class BasisFileInfo {
  55956. /**
  55957. * If the file has alpha
  55958. */
  55959. hasAlpha: boolean;
  55960. /**
  55961. * Info about each image of the basis file
  55962. */
  55963. images: Array<{
  55964. levels: Array<{
  55965. width: number;
  55966. height: number;
  55967. transcodedPixels: ArrayBufferView;
  55968. }>;
  55969. }>;
  55970. }
  55971. /**
  55972. * Result of transcoding a basis file
  55973. */
  55974. class TranscodeResult {
  55975. /**
  55976. * Info about the .basis file
  55977. */
  55978. fileInfo: BasisFileInfo;
  55979. /**
  55980. * Format to use when loading the file
  55981. */
  55982. format: number;
  55983. }
  55984. /**
  55985. * Configuration options for the Basis transcoder
  55986. */
  55987. export class BasisTranscodeConfiguration {
  55988. /**
  55989. * Supported compression formats used to determine the supported output format of the transcoder
  55990. */
  55991. supportedCompressionFormats?: {
  55992. /**
  55993. * etc1 compression format
  55994. */
  55995. etc1?: boolean;
  55996. /**
  55997. * s3tc compression format
  55998. */
  55999. s3tc?: boolean;
  56000. /**
  56001. * pvrtc compression format
  56002. */
  56003. pvrtc?: boolean;
  56004. /**
  56005. * etc2 compression format
  56006. */
  56007. etc2?: boolean;
  56008. };
  56009. /**
  56010. * If mipmap levels should be loaded for transcoded images (Default: true)
  56011. */
  56012. loadMipmapLevels?: boolean;
  56013. /**
  56014. * Index of a single image to load (Default: all images)
  56015. */
  56016. loadSingleImage?: number;
  56017. }
  56018. /**
  56019. * Used to load .Basis files
  56020. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56021. */
  56022. export class BasisTools {
  56023. private static _IgnoreSupportedFormats;
  56024. /**
  56025. * URL to use when loading the basis transcoder
  56026. */
  56027. static JSModuleURL: string;
  56028. /**
  56029. * URL to use when loading the wasm module for the transcoder
  56030. */
  56031. static WasmModuleURL: string;
  56032. /**
  56033. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56034. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56035. * @returns internal format corresponding to the Basis format
  56036. */
  56037. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56038. private static _WorkerPromise;
  56039. private static _Worker;
  56040. private static _actionId;
  56041. private static _CreateWorkerAsync;
  56042. /**
  56043. * Transcodes a loaded image file to compressed pixel data
  56044. * @param data image data to transcode
  56045. * @param config configuration options for the transcoding
  56046. * @returns a promise resulting in the transcoded image
  56047. */
  56048. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56049. /**
  56050. * Loads a texture from the transcode result
  56051. * @param texture texture load to
  56052. * @param transcodeResult the result of transcoding the basis file to load from
  56053. */
  56054. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56055. }
  56056. }
  56057. declare module BABYLON {
  56058. /**
  56059. * Loader for .basis file format
  56060. */
  56061. export class _BasisTextureLoader implements IInternalTextureLoader {
  56062. /**
  56063. * Defines whether the loader supports cascade loading the different faces.
  56064. */
  56065. readonly supportCascades: boolean;
  56066. /**
  56067. * This returns if the loader support the current file information.
  56068. * @param extension defines the file extension of the file being loaded
  56069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56070. * @param fallback defines the fallback internal texture if any
  56071. * @param isBase64 defines whether the texture is encoded as a base64
  56072. * @param isBuffer defines whether the texture data are stored as a buffer
  56073. * @returns true if the loader can load the specified file
  56074. */
  56075. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56076. /**
  56077. * Transform the url before loading if required.
  56078. * @param rootUrl the url of the texture
  56079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56080. * @returns the transformed texture
  56081. */
  56082. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56083. /**
  56084. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56085. * @param rootUrl the url of the texture
  56086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56087. * @returns the fallback texture
  56088. */
  56089. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56090. /**
  56091. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56092. * @param data contains the texture data
  56093. * @param texture defines the BabylonJS internal texture
  56094. * @param createPolynomials will be true if polynomials have been requested
  56095. * @param onLoad defines the callback to trigger once the texture is ready
  56096. * @param onError defines the callback to trigger in case of error
  56097. */
  56098. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56099. /**
  56100. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56101. * @param data contains the texture data
  56102. * @param texture defines the BabylonJS internal texture
  56103. * @param callback defines the method to call once ready to upload
  56104. */
  56105. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56106. }
  56107. }
  56108. declare module BABYLON {
  56109. /**
  56110. * 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.
  56111. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56112. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56113. */
  56114. export class CustomProceduralTexture extends ProceduralTexture {
  56115. private _animate;
  56116. private _time;
  56117. private _config;
  56118. private _texturePath;
  56119. /**
  56120. * Instantiates a new Custom Procedural Texture.
  56121. * 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.
  56122. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56123. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56124. * @param name Define the name of the texture
  56125. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56126. * @param size Define the size of the texture to create
  56127. * @param scene Define the scene the texture belongs to
  56128. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56129. * @param generateMipMaps Define if the texture should creates mip maps or not
  56130. */
  56131. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56132. private _loadJson;
  56133. /**
  56134. * Is the texture ready to be used ? (rendered at least once)
  56135. * @returns true if ready, otherwise, false.
  56136. */
  56137. isReady(): boolean;
  56138. /**
  56139. * Render the texture to its associated render target.
  56140. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56141. */
  56142. render(useCameraPostProcess?: boolean): void;
  56143. /**
  56144. * Update the list of dependant textures samplers in the shader.
  56145. */
  56146. updateTextures(): void;
  56147. /**
  56148. * Update the uniform values of the procedural texture in the shader.
  56149. */
  56150. updateShaderUniforms(): void;
  56151. /**
  56152. * Define if the texture animates or not.
  56153. */
  56154. get animate(): boolean;
  56155. set animate(value: boolean);
  56156. }
  56157. }
  56158. declare module BABYLON {
  56159. /** @hidden */
  56160. export var noisePixelShader: {
  56161. name: string;
  56162. shader: string;
  56163. };
  56164. }
  56165. declare module BABYLON {
  56166. /**
  56167. * Class used to generate noise procedural textures
  56168. */
  56169. export class NoiseProceduralTexture extends ProceduralTexture {
  56170. private _time;
  56171. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56172. brightness: number;
  56173. /** Defines the number of octaves to process */
  56174. octaves: number;
  56175. /** Defines the level of persistence (0.8 by default) */
  56176. persistence: number;
  56177. /** Gets or sets animation speed factor (default is 1) */
  56178. animationSpeedFactor: number;
  56179. /**
  56180. * Creates a new NoiseProceduralTexture
  56181. * @param name defines the name fo the texture
  56182. * @param size defines the size of the texture (default is 256)
  56183. * @param scene defines the hosting scene
  56184. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56185. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56186. */
  56187. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56188. private _updateShaderUniforms;
  56189. protected _getDefines(): string;
  56190. /** Generate the current state of the procedural texture */
  56191. render(useCameraPostProcess?: boolean): void;
  56192. /**
  56193. * Serializes this noise procedural texture
  56194. * @returns a serialized noise procedural texture object
  56195. */
  56196. serialize(): any;
  56197. /**
  56198. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56199. * @param parsedTexture defines parsed texture data
  56200. * @param scene defines the current scene
  56201. * @param rootUrl defines the root URL containing noise procedural texture information
  56202. * @returns a parsed NoiseProceduralTexture
  56203. */
  56204. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56205. }
  56206. }
  56207. declare module BABYLON {
  56208. /**
  56209. * Raw cube texture where the raw buffers are passed in
  56210. */
  56211. export class RawCubeTexture extends CubeTexture {
  56212. /**
  56213. * Creates a cube texture where the raw buffers are passed in.
  56214. * @param scene defines the scene the texture is attached to
  56215. * @param data defines the array of data to use to create each face
  56216. * @param size defines the size of the textures
  56217. * @param format defines the format of the data
  56218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56219. * @param generateMipMaps defines if the engine should generate the mip levels
  56220. * @param invertY defines if data must be stored with Y axis inverted
  56221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56222. * @param compression defines the compression used (null by default)
  56223. */
  56224. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56225. /**
  56226. * Updates the raw cube texture.
  56227. * @param data defines the data to store
  56228. * @param format defines the data format
  56229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56230. * @param invertY defines if data must be stored with Y axis inverted
  56231. * @param compression defines the compression used (null by default)
  56232. * @param level defines which level of the texture to update
  56233. */
  56234. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56235. /**
  56236. * Updates a raw cube texture with RGBD encoded data.
  56237. * @param data defines the array of data [mipmap][face] to use to create each face
  56238. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56239. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56240. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56241. * @returns a promsie that resolves when the operation is complete
  56242. */
  56243. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56244. /**
  56245. * Clones the raw cube texture.
  56246. * @return a new cube texture
  56247. */
  56248. clone(): CubeTexture;
  56249. /** @hidden */
  56250. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56251. }
  56252. }
  56253. declare module BABYLON {
  56254. /**
  56255. * Class used to store 3D textures containing user data
  56256. */
  56257. export class RawTexture3D extends Texture {
  56258. /** Gets or sets the texture format to use */
  56259. format: number;
  56260. private _engine;
  56261. /**
  56262. * Create a new RawTexture3D
  56263. * @param data defines the data of the texture
  56264. * @param width defines the width of the texture
  56265. * @param height defines the height of the texture
  56266. * @param depth defines the depth of the texture
  56267. * @param format defines the texture format to use
  56268. * @param scene defines the hosting scene
  56269. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56270. * @param invertY defines if texture must be stored with Y axis inverted
  56271. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56272. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56273. */
  56274. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56275. /** Gets or sets the texture format to use */
  56276. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56277. /**
  56278. * Update the texture with new data
  56279. * @param data defines the data to store in the texture
  56280. */
  56281. update(data: ArrayBufferView): void;
  56282. }
  56283. }
  56284. declare module BABYLON {
  56285. /**
  56286. * Class used to store 2D array textures containing user data
  56287. */
  56288. export class RawTexture2DArray extends Texture {
  56289. /** Gets or sets the texture format to use */
  56290. format: number;
  56291. private _engine;
  56292. /**
  56293. * Create a new RawTexture2DArray
  56294. * @param data defines the data of the texture
  56295. * @param width defines the width of the texture
  56296. * @param height defines the height of the texture
  56297. * @param depth defines the number of layers of the texture
  56298. * @param format defines the texture format to use
  56299. * @param scene defines the hosting scene
  56300. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56301. * @param invertY defines if texture must be stored with Y axis inverted
  56302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56303. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56304. */
  56305. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56306. /** Gets or sets the texture format to use */
  56307. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56308. /**
  56309. * Update the texture with new data
  56310. * @param data defines the data to store in the texture
  56311. */
  56312. update(data: ArrayBufferView): void;
  56313. }
  56314. }
  56315. declare module BABYLON {
  56316. /**
  56317. * Creates a refraction texture used by refraction channel of the standard material.
  56318. * It is like a mirror but to see through a material.
  56319. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56320. */
  56321. export class RefractionTexture extends RenderTargetTexture {
  56322. /**
  56323. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56324. * 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.
  56325. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56326. */
  56327. refractionPlane: Plane;
  56328. /**
  56329. * Define how deep under the surface we should see.
  56330. */
  56331. depth: number;
  56332. /**
  56333. * Creates a refraction texture used by refraction channel of the standard material.
  56334. * It is like a mirror but to see through a material.
  56335. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56336. * @param name Define the texture name
  56337. * @param size Define the size of the underlying texture
  56338. * @param scene Define the scene the refraction belongs to
  56339. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56340. */
  56341. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56342. /**
  56343. * Clone the refraction texture.
  56344. * @returns the cloned texture
  56345. */
  56346. clone(): RefractionTexture;
  56347. /**
  56348. * Serialize the texture to a JSON representation you could use in Parse later on
  56349. * @returns the serialized JSON representation
  56350. */
  56351. serialize(): any;
  56352. }
  56353. }
  56354. declare module BABYLON {
  56355. /**
  56356. * Defines the options related to the creation of an HtmlElementTexture
  56357. */
  56358. export interface IHtmlElementTextureOptions {
  56359. /**
  56360. * Defines wether mip maps should be created or not.
  56361. */
  56362. generateMipMaps?: boolean;
  56363. /**
  56364. * Defines the sampling mode of the texture.
  56365. */
  56366. samplingMode?: number;
  56367. /**
  56368. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56369. */
  56370. engine: Nullable<ThinEngine>;
  56371. /**
  56372. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56373. */
  56374. scene: Nullable<Scene>;
  56375. }
  56376. /**
  56377. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56378. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56379. * is automatically managed.
  56380. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56381. * in your application.
  56382. *
  56383. * As the update is not automatic, you need to call them manually.
  56384. */
  56385. export class HtmlElementTexture extends BaseTexture {
  56386. /**
  56387. * The texture URL.
  56388. */
  56389. element: HTMLVideoElement | HTMLCanvasElement;
  56390. private static readonly DefaultOptions;
  56391. private _textureMatrix;
  56392. private _engine;
  56393. private _isVideo;
  56394. private _generateMipMaps;
  56395. private _samplingMode;
  56396. /**
  56397. * Instantiates a HtmlElementTexture from the following parameters.
  56398. *
  56399. * @param name Defines the name of the texture
  56400. * @param element Defines the video or canvas the texture is filled with
  56401. * @param options Defines the other none mandatory texture creation options
  56402. */
  56403. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56404. private _createInternalTexture;
  56405. /**
  56406. * Returns the texture matrix used in most of the material.
  56407. */
  56408. getTextureMatrix(): Matrix;
  56409. /**
  56410. * Updates the content of the texture.
  56411. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56412. */
  56413. update(invertY?: Nullable<boolean>): void;
  56414. }
  56415. }
  56416. declare module BABYLON {
  56417. /**
  56418. * Enum used to define the target of a block
  56419. */
  56420. export enum NodeMaterialBlockTargets {
  56421. /** Vertex shader */
  56422. Vertex = 1,
  56423. /** Fragment shader */
  56424. Fragment = 2,
  56425. /** Neutral */
  56426. Neutral = 4,
  56427. /** Vertex and Fragment */
  56428. VertexAndFragment = 3
  56429. }
  56430. }
  56431. declare module BABYLON {
  56432. /**
  56433. * Defines the kind of connection point for node based material
  56434. */
  56435. export enum NodeMaterialBlockConnectionPointTypes {
  56436. /** Float */
  56437. Float = 1,
  56438. /** Int */
  56439. Int = 2,
  56440. /** Vector2 */
  56441. Vector2 = 4,
  56442. /** Vector3 */
  56443. Vector3 = 8,
  56444. /** Vector4 */
  56445. Vector4 = 16,
  56446. /** Color3 */
  56447. Color3 = 32,
  56448. /** Color4 */
  56449. Color4 = 64,
  56450. /** Matrix */
  56451. Matrix = 128,
  56452. /** Detect type based on connection */
  56453. AutoDetect = 1024,
  56454. /** Output type that will be defined by input type */
  56455. BasedOnInput = 2048
  56456. }
  56457. }
  56458. declare module BABYLON {
  56459. /**
  56460. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56461. */
  56462. export enum NodeMaterialBlockConnectionPointMode {
  56463. /** Value is an uniform */
  56464. Uniform = 0,
  56465. /** Value is a mesh attribute */
  56466. Attribute = 1,
  56467. /** Value is a varying between vertex and fragment shaders */
  56468. Varying = 2,
  56469. /** Mode is undefined */
  56470. Undefined = 3
  56471. }
  56472. }
  56473. declare module BABYLON {
  56474. /**
  56475. * Enum used to define system values e.g. values automatically provided by the system
  56476. */
  56477. export enum NodeMaterialSystemValues {
  56478. /** World */
  56479. World = 1,
  56480. /** View */
  56481. View = 2,
  56482. /** Projection */
  56483. Projection = 3,
  56484. /** ViewProjection */
  56485. ViewProjection = 4,
  56486. /** WorldView */
  56487. WorldView = 5,
  56488. /** WorldViewProjection */
  56489. WorldViewProjection = 6,
  56490. /** CameraPosition */
  56491. CameraPosition = 7,
  56492. /** Fog Color */
  56493. FogColor = 8,
  56494. /** Delta time */
  56495. DeltaTime = 9
  56496. }
  56497. }
  56498. declare module BABYLON {
  56499. /**
  56500. * Root class for all node material optimizers
  56501. */
  56502. export class NodeMaterialOptimizer {
  56503. /**
  56504. * Function used to optimize a NodeMaterial graph
  56505. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56506. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56507. */
  56508. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56509. }
  56510. }
  56511. declare module BABYLON {
  56512. /**
  56513. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56514. */
  56515. export class TransformBlock extends NodeMaterialBlock {
  56516. /**
  56517. * Defines the value to use to complement W value to transform it to a Vector4
  56518. */
  56519. complementW: number;
  56520. /**
  56521. * Defines the value to use to complement z value to transform it to a Vector4
  56522. */
  56523. complementZ: number;
  56524. /**
  56525. * Creates a new TransformBlock
  56526. * @param name defines the block name
  56527. */
  56528. constructor(name: string);
  56529. /**
  56530. * Gets the current class name
  56531. * @returns the class name
  56532. */
  56533. getClassName(): string;
  56534. /**
  56535. * Gets the vector input
  56536. */
  56537. get vector(): NodeMaterialConnectionPoint;
  56538. /**
  56539. * Gets the output component
  56540. */
  56541. get output(): NodeMaterialConnectionPoint;
  56542. /**
  56543. * Gets the matrix transform input
  56544. */
  56545. get transform(): NodeMaterialConnectionPoint;
  56546. protected _buildBlock(state: NodeMaterialBuildState): this;
  56547. serialize(): any;
  56548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56549. protected _dumpPropertiesCode(): string;
  56550. }
  56551. }
  56552. declare module BABYLON {
  56553. /**
  56554. * Block used to output the vertex position
  56555. */
  56556. export class VertexOutputBlock extends NodeMaterialBlock {
  56557. /**
  56558. * Creates a new VertexOutputBlock
  56559. * @param name defines the block name
  56560. */
  56561. constructor(name: string);
  56562. /**
  56563. * Gets the current class name
  56564. * @returns the class name
  56565. */
  56566. getClassName(): string;
  56567. /**
  56568. * Gets the vector input component
  56569. */
  56570. get vector(): NodeMaterialConnectionPoint;
  56571. protected _buildBlock(state: NodeMaterialBuildState): this;
  56572. }
  56573. }
  56574. declare module BABYLON {
  56575. /**
  56576. * Block used to output the final color
  56577. */
  56578. export class FragmentOutputBlock extends NodeMaterialBlock {
  56579. /**
  56580. * Create a new FragmentOutputBlock
  56581. * @param name defines the block name
  56582. */
  56583. constructor(name: string);
  56584. /**
  56585. * Gets the current class name
  56586. * @returns the class name
  56587. */
  56588. getClassName(): string;
  56589. /**
  56590. * Gets the rgba input component
  56591. */
  56592. get rgba(): NodeMaterialConnectionPoint;
  56593. /**
  56594. * Gets the rgb input component
  56595. */
  56596. get rgb(): NodeMaterialConnectionPoint;
  56597. /**
  56598. * Gets the a input component
  56599. */
  56600. get a(): NodeMaterialConnectionPoint;
  56601. protected _buildBlock(state: NodeMaterialBuildState): this;
  56602. }
  56603. }
  56604. declare module BABYLON {
  56605. /**
  56606. * Block used to read a reflection texture from a sampler
  56607. */
  56608. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56609. private _define3DName;
  56610. private _defineCubicName;
  56611. private _defineExplicitName;
  56612. private _defineProjectionName;
  56613. private _defineLocalCubicName;
  56614. private _defineSphericalName;
  56615. private _definePlanarName;
  56616. private _defineEquirectangularName;
  56617. private _defineMirroredEquirectangularFixedName;
  56618. private _defineEquirectangularFixedName;
  56619. private _defineSkyboxName;
  56620. private _cubeSamplerName;
  56621. private _2DSamplerName;
  56622. private _positionUVWName;
  56623. private _directionWName;
  56624. private _reflectionCoordsName;
  56625. private _reflection2DCoordsName;
  56626. private _reflectionColorName;
  56627. private _reflectionMatrixName;
  56628. /**
  56629. * Gets or sets the texture associated with the node
  56630. */
  56631. texture: Nullable<BaseTexture>;
  56632. /**
  56633. * Create a new TextureBlock
  56634. * @param name defines the block name
  56635. */
  56636. constructor(name: string);
  56637. /**
  56638. * Gets the current class name
  56639. * @returns the class name
  56640. */
  56641. getClassName(): string;
  56642. /**
  56643. * Gets the world position input component
  56644. */
  56645. get position(): NodeMaterialConnectionPoint;
  56646. /**
  56647. * Gets the world position input component
  56648. */
  56649. get worldPosition(): NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the world normal input component
  56652. */
  56653. get worldNormal(): NodeMaterialConnectionPoint;
  56654. /**
  56655. * Gets the world input component
  56656. */
  56657. get world(): NodeMaterialConnectionPoint;
  56658. /**
  56659. * Gets the camera (or eye) position component
  56660. */
  56661. get cameraPosition(): NodeMaterialConnectionPoint;
  56662. /**
  56663. * Gets the view input component
  56664. */
  56665. get view(): NodeMaterialConnectionPoint;
  56666. /**
  56667. * Gets the rgb output component
  56668. */
  56669. get rgb(): NodeMaterialConnectionPoint;
  56670. /**
  56671. * Gets the r output component
  56672. */
  56673. get r(): NodeMaterialConnectionPoint;
  56674. /**
  56675. * Gets the g output component
  56676. */
  56677. get g(): NodeMaterialConnectionPoint;
  56678. /**
  56679. * Gets the b output component
  56680. */
  56681. get b(): NodeMaterialConnectionPoint;
  56682. autoConfigure(material: NodeMaterial): void;
  56683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56684. isReady(): boolean;
  56685. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56686. private _injectVertexCode;
  56687. private _writeOutput;
  56688. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56689. protected _dumpPropertiesCode(): string;
  56690. serialize(): any;
  56691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56692. }
  56693. }
  56694. declare module BABYLON {
  56695. /**
  56696. * Interface used to configure the node material editor
  56697. */
  56698. export interface INodeMaterialEditorOptions {
  56699. /** Define the URl to load node editor script */
  56700. editorURL?: string;
  56701. }
  56702. /** @hidden */
  56703. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56704. NORMAL: boolean;
  56705. TANGENT: boolean;
  56706. UV1: boolean;
  56707. /** BONES */
  56708. NUM_BONE_INFLUENCERS: number;
  56709. BonesPerMesh: number;
  56710. BONETEXTURE: boolean;
  56711. /** MORPH TARGETS */
  56712. MORPHTARGETS: boolean;
  56713. MORPHTARGETS_NORMAL: boolean;
  56714. MORPHTARGETS_TANGENT: boolean;
  56715. MORPHTARGETS_UV: boolean;
  56716. NUM_MORPH_INFLUENCERS: number;
  56717. /** IMAGE PROCESSING */
  56718. IMAGEPROCESSING: boolean;
  56719. VIGNETTE: boolean;
  56720. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56721. VIGNETTEBLENDMODEOPAQUE: boolean;
  56722. TONEMAPPING: boolean;
  56723. TONEMAPPING_ACES: boolean;
  56724. CONTRAST: boolean;
  56725. EXPOSURE: boolean;
  56726. COLORCURVES: boolean;
  56727. COLORGRADING: boolean;
  56728. COLORGRADING3D: boolean;
  56729. SAMPLER3DGREENDEPTH: boolean;
  56730. SAMPLER3DBGRMAP: boolean;
  56731. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56732. /** MISC. */
  56733. BUMPDIRECTUV: number;
  56734. constructor();
  56735. setValue(name: string, value: boolean): void;
  56736. }
  56737. /**
  56738. * Class used to configure NodeMaterial
  56739. */
  56740. export interface INodeMaterialOptions {
  56741. /**
  56742. * Defines if blocks should emit comments
  56743. */
  56744. emitComments: boolean;
  56745. }
  56746. /**
  56747. * Class used to create a node based material built by assembling shader blocks
  56748. */
  56749. export class NodeMaterial extends PushMaterial {
  56750. private static _BuildIdGenerator;
  56751. private _options;
  56752. private _vertexCompilationState;
  56753. private _fragmentCompilationState;
  56754. private _sharedData;
  56755. private _buildId;
  56756. private _buildWasSuccessful;
  56757. private _cachedWorldViewMatrix;
  56758. private _cachedWorldViewProjectionMatrix;
  56759. private _optimizers;
  56760. private _animationFrame;
  56761. /** Define the Url to load node editor script */
  56762. static EditorURL: string;
  56763. /** Define the Url to load snippets */
  56764. static SnippetUrl: string;
  56765. private BJSNODEMATERIALEDITOR;
  56766. /** Get the inspector from bundle or global */
  56767. private _getGlobalNodeMaterialEditor;
  56768. /**
  56769. * Gets or sets data used by visual editor
  56770. * @see https://nme.babylonjs.com
  56771. */
  56772. editorData: any;
  56773. /**
  56774. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  56775. */
  56776. ignoreAlpha: boolean;
  56777. /**
  56778. * Defines the maximum number of lights that can be used in the material
  56779. */
  56780. maxSimultaneousLights: number;
  56781. /**
  56782. * Observable raised when the material is built
  56783. */
  56784. onBuildObservable: Observable<NodeMaterial>;
  56785. /**
  56786. * Gets or sets the root nodes of the material vertex shader
  56787. */
  56788. _vertexOutputNodes: NodeMaterialBlock[];
  56789. /**
  56790. * Gets or sets the root nodes of the material fragment (pixel) shader
  56791. */
  56792. _fragmentOutputNodes: NodeMaterialBlock[];
  56793. /** Gets or sets options to control the node material overall behavior */
  56794. get options(): INodeMaterialOptions;
  56795. set options(options: INodeMaterialOptions);
  56796. /**
  56797. * Default configuration related to image processing available in the standard Material.
  56798. */
  56799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56800. /**
  56801. * Gets the image processing configuration used either in this material.
  56802. */
  56803. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56804. /**
  56805. * Sets the Default image processing configuration used either in the this material.
  56806. *
  56807. * If sets to null, the scene one is in use.
  56808. */
  56809. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56810. /**
  56811. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56812. */
  56813. attachedBlocks: NodeMaterialBlock[];
  56814. /**
  56815. * Create a new node based material
  56816. * @param name defines the material name
  56817. * @param scene defines the hosting scene
  56818. * @param options defines creation option
  56819. */
  56820. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56821. /**
  56822. * Gets the current class name of the material e.g. "NodeMaterial"
  56823. * @returns the class name
  56824. */
  56825. getClassName(): string;
  56826. /**
  56827. * Keep track of the image processing observer to allow dispose and replace.
  56828. */
  56829. private _imageProcessingObserver;
  56830. /**
  56831. * Attaches a new image processing configuration to the Standard Material.
  56832. * @param configuration
  56833. */
  56834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56835. /**
  56836. * Get a block by its name
  56837. * @param name defines the name of the block to retrieve
  56838. * @returns the required block or null if not found
  56839. */
  56840. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56841. /**
  56842. * Get a block by its name
  56843. * @param predicate defines the predicate used to find the good candidate
  56844. * @returns the required block or null if not found
  56845. */
  56846. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56847. /**
  56848. * Get an input block by its name
  56849. * @param predicate defines the predicate used to find the good candidate
  56850. * @returns the required input block or null if not found
  56851. */
  56852. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56853. /**
  56854. * Gets the list of input blocks attached to this material
  56855. * @returns an array of InputBlocks
  56856. */
  56857. getInputBlocks(): InputBlock[];
  56858. /**
  56859. * Adds a new optimizer to the list of optimizers
  56860. * @param optimizer defines the optimizers to add
  56861. * @returns the current material
  56862. */
  56863. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56864. /**
  56865. * Remove an optimizer from the list of optimizers
  56866. * @param optimizer defines the optimizers to remove
  56867. * @returns the current material
  56868. */
  56869. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56870. /**
  56871. * Add a new block to the list of output nodes
  56872. * @param node defines the node to add
  56873. * @returns the current material
  56874. */
  56875. addOutputNode(node: NodeMaterialBlock): this;
  56876. /**
  56877. * Remove a block from the list of root nodes
  56878. * @param node defines the node to remove
  56879. * @returns the current material
  56880. */
  56881. removeOutputNode(node: NodeMaterialBlock): this;
  56882. private _addVertexOutputNode;
  56883. private _removeVertexOutputNode;
  56884. private _addFragmentOutputNode;
  56885. private _removeFragmentOutputNode;
  56886. /**
  56887. * Specifies if the material will require alpha blending
  56888. * @returns a boolean specifying if alpha blending is needed
  56889. */
  56890. needAlphaBlending(): boolean;
  56891. /**
  56892. * Specifies if this material should be rendered in alpha test mode
  56893. * @returns a boolean specifying if an alpha test is needed.
  56894. */
  56895. needAlphaTesting(): boolean;
  56896. private _initializeBlock;
  56897. private _resetDualBlocks;
  56898. /**
  56899. * Remove a block from the current node material
  56900. * @param block defines the block to remove
  56901. */
  56902. removeBlock(block: NodeMaterialBlock): void;
  56903. /**
  56904. * Build the material and generates the inner effect
  56905. * @param verbose defines if the build should log activity
  56906. */
  56907. build(verbose?: boolean): void;
  56908. /**
  56909. * Runs an otpimization phase to try to improve the shader code
  56910. */
  56911. optimize(): void;
  56912. private _prepareDefinesForAttributes;
  56913. /**
  56914. * Get if the submesh is ready to be used and all its information available.
  56915. * Child classes can use it to update shaders
  56916. * @param mesh defines the mesh to check
  56917. * @param subMesh defines which submesh to check
  56918. * @param useInstances specifies that instances should be used
  56919. * @returns a boolean indicating that the submesh is ready or not
  56920. */
  56921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56922. /**
  56923. * Get a string representing the shaders built by the current node graph
  56924. */
  56925. get compiledShaders(): string;
  56926. /**
  56927. * Binds the world matrix to the material
  56928. * @param world defines the world transformation matrix
  56929. */
  56930. bindOnlyWorldMatrix(world: Matrix): void;
  56931. /**
  56932. * Binds the submesh to this material by preparing the effect and shader to draw
  56933. * @param world defines the world transformation matrix
  56934. * @param mesh defines the mesh containing the submesh
  56935. * @param subMesh defines the submesh to bind the material to
  56936. */
  56937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56938. /**
  56939. * Gets the active textures from the material
  56940. * @returns an array of textures
  56941. */
  56942. getActiveTextures(): BaseTexture[];
  56943. /**
  56944. * Gets the list of texture blocks
  56945. * @returns an array of texture blocks
  56946. */
  56947. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56948. /**
  56949. * Specifies if the material uses a texture
  56950. * @param texture defines the texture to check against the material
  56951. * @returns a boolean specifying if the material uses the texture
  56952. */
  56953. hasTexture(texture: BaseTexture): boolean;
  56954. /**
  56955. * Disposes the material
  56956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56959. */
  56960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56961. /** Creates the node editor window. */
  56962. private _createNodeEditor;
  56963. /**
  56964. * Launch the node material editor
  56965. * @param config Define the configuration of the editor
  56966. * @return a promise fulfilled when the node editor is visible
  56967. */
  56968. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56969. /**
  56970. * Clear the current material
  56971. */
  56972. clear(): void;
  56973. /**
  56974. * Clear the current material and set it to a default state
  56975. */
  56976. setToDefault(): void;
  56977. /**
  56978. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56979. * @param url defines the url to load from
  56980. * @returns a promise that will fullfil when the material is fully loaded
  56981. */
  56982. loadAsync(url: string): Promise<void>;
  56983. private _gatherBlocks;
  56984. /**
  56985. * Generate a string containing the code declaration required to create an equivalent of this material
  56986. * @returns a string
  56987. */
  56988. generateCode(): string;
  56989. /**
  56990. * Serializes this material in a JSON representation
  56991. * @returns the serialized material object
  56992. */
  56993. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  56994. private _restoreConnections;
  56995. /**
  56996. * Clear the current graph and load a new one from a serialization object
  56997. * @param source defines the JSON representation of the material
  56998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56999. */
  57000. loadFromSerialization(source: any, rootUrl?: string): void;
  57001. /**
  57002. * Creates a node material from parsed material data
  57003. * @param source defines the JSON representation of the material
  57004. * @param scene defines the hosting scene
  57005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57006. * @returns a new node material
  57007. */
  57008. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57009. /**
  57010. * Creates a node material from a snippet saved by the node material editor
  57011. * @param snippetId defines the snippet to load
  57012. * @param scene defines the hosting scene
  57013. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57014. * @returns a promise that will resolve to the new node material
  57015. */
  57016. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57017. /**
  57018. * Creates a new node material set to default basic configuration
  57019. * @param name defines the name of the material
  57020. * @param scene defines the hosting scene
  57021. * @returns a new NodeMaterial
  57022. */
  57023. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57024. }
  57025. }
  57026. declare module BABYLON {
  57027. /**
  57028. * Block used to read a texture from a sampler
  57029. */
  57030. export class TextureBlock extends NodeMaterialBlock {
  57031. private _defineName;
  57032. private _linearDefineName;
  57033. private _tempTextureRead;
  57034. private _samplerName;
  57035. private _transformedUVName;
  57036. private _textureTransformName;
  57037. private _textureInfoName;
  57038. private _mainUVName;
  57039. private _mainUVDefineName;
  57040. /**
  57041. * Gets or sets the texture associated with the node
  57042. */
  57043. texture: Nullable<Texture>;
  57044. /**
  57045. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57046. */
  57047. convertToGammaSpace: boolean;
  57048. /**
  57049. * Create a new TextureBlock
  57050. * @param name defines the block name
  57051. */
  57052. constructor(name: string);
  57053. /**
  57054. * Gets the current class name
  57055. * @returns the class name
  57056. */
  57057. getClassName(): string;
  57058. /**
  57059. * Gets the uv input component
  57060. */
  57061. get uv(): NodeMaterialConnectionPoint;
  57062. /**
  57063. * Gets the rgba output component
  57064. */
  57065. get rgba(): NodeMaterialConnectionPoint;
  57066. /**
  57067. * Gets the rgb output component
  57068. */
  57069. get rgb(): NodeMaterialConnectionPoint;
  57070. /**
  57071. * Gets the r output component
  57072. */
  57073. get r(): NodeMaterialConnectionPoint;
  57074. /**
  57075. * Gets the g output component
  57076. */
  57077. get g(): NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the b output component
  57080. */
  57081. get b(): NodeMaterialConnectionPoint;
  57082. /**
  57083. * Gets the a output component
  57084. */
  57085. get a(): NodeMaterialConnectionPoint;
  57086. get target(): NodeMaterialBlockTargets;
  57087. autoConfigure(material: NodeMaterial): void;
  57088. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57090. isReady(): boolean;
  57091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57092. private get _isMixed();
  57093. private _injectVertexCode;
  57094. private _writeTextureRead;
  57095. private _writeOutput;
  57096. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57097. protected _dumpPropertiesCode(): string;
  57098. serialize(): any;
  57099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57100. }
  57101. }
  57102. declare module BABYLON {
  57103. /**
  57104. * Class used to store shared data between 2 NodeMaterialBuildState
  57105. */
  57106. export class NodeMaterialBuildStateSharedData {
  57107. /**
  57108. * Gets the list of emitted varyings
  57109. */
  57110. temps: string[];
  57111. /**
  57112. * Gets the list of emitted varyings
  57113. */
  57114. varyings: string[];
  57115. /**
  57116. * Gets the varying declaration string
  57117. */
  57118. varyingDeclaration: string;
  57119. /**
  57120. * Input blocks
  57121. */
  57122. inputBlocks: InputBlock[];
  57123. /**
  57124. * Input blocks
  57125. */
  57126. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57127. /**
  57128. * Bindable blocks (Blocks that need to set data to the effect)
  57129. */
  57130. bindableBlocks: NodeMaterialBlock[];
  57131. /**
  57132. * List of blocks that can provide a compilation fallback
  57133. */
  57134. blocksWithFallbacks: NodeMaterialBlock[];
  57135. /**
  57136. * List of blocks that can provide a define update
  57137. */
  57138. blocksWithDefines: NodeMaterialBlock[];
  57139. /**
  57140. * List of blocks that can provide a repeatable content
  57141. */
  57142. repeatableContentBlocks: NodeMaterialBlock[];
  57143. /**
  57144. * List of blocks that can provide a dynamic list of uniforms
  57145. */
  57146. dynamicUniformBlocks: NodeMaterialBlock[];
  57147. /**
  57148. * List of blocks that can block the isReady function for the material
  57149. */
  57150. blockingBlocks: NodeMaterialBlock[];
  57151. /**
  57152. * Gets the list of animated inputs
  57153. */
  57154. animatedInputs: InputBlock[];
  57155. /**
  57156. * Build Id used to avoid multiple recompilations
  57157. */
  57158. buildId: number;
  57159. /** List of emitted variables */
  57160. variableNames: {
  57161. [key: string]: number;
  57162. };
  57163. /** List of emitted defines */
  57164. defineNames: {
  57165. [key: string]: number;
  57166. };
  57167. /** Should emit comments? */
  57168. emitComments: boolean;
  57169. /** Emit build activity */
  57170. verbose: boolean;
  57171. /** Gets or sets the hosting scene */
  57172. scene: Scene;
  57173. /**
  57174. * Gets the compilation hints emitted at compilation time
  57175. */
  57176. hints: {
  57177. needWorldViewMatrix: boolean;
  57178. needWorldViewProjectionMatrix: boolean;
  57179. needAlphaBlending: boolean;
  57180. needAlphaTesting: boolean;
  57181. };
  57182. /**
  57183. * List of compilation checks
  57184. */
  57185. checks: {
  57186. emitVertex: boolean;
  57187. emitFragment: boolean;
  57188. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57189. };
  57190. /** Creates a new shared data */
  57191. constructor();
  57192. /**
  57193. * Emits console errors and exceptions if there is a failing check
  57194. */
  57195. emitErrors(): void;
  57196. }
  57197. }
  57198. declare module BABYLON {
  57199. /**
  57200. * Class used to store node based material build state
  57201. */
  57202. export class NodeMaterialBuildState {
  57203. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57204. supportUniformBuffers: boolean;
  57205. /**
  57206. * Gets the list of emitted attributes
  57207. */
  57208. attributes: string[];
  57209. /**
  57210. * Gets the list of emitted uniforms
  57211. */
  57212. uniforms: string[];
  57213. /**
  57214. * Gets the list of emitted constants
  57215. */
  57216. constants: string[];
  57217. /**
  57218. * Gets the list of emitted samplers
  57219. */
  57220. samplers: string[];
  57221. /**
  57222. * Gets the list of emitted functions
  57223. */
  57224. functions: {
  57225. [key: string]: string;
  57226. };
  57227. /**
  57228. * Gets the list of emitted extensions
  57229. */
  57230. extensions: {
  57231. [key: string]: string;
  57232. };
  57233. /**
  57234. * Gets the target of the compilation state
  57235. */
  57236. target: NodeMaterialBlockTargets;
  57237. /**
  57238. * Gets the list of emitted counters
  57239. */
  57240. counters: {
  57241. [key: string]: number;
  57242. };
  57243. /**
  57244. * Shared data between multiple NodeMaterialBuildState instances
  57245. */
  57246. sharedData: NodeMaterialBuildStateSharedData;
  57247. /** @hidden */
  57248. _vertexState: NodeMaterialBuildState;
  57249. /** @hidden */
  57250. _attributeDeclaration: string;
  57251. /** @hidden */
  57252. _uniformDeclaration: string;
  57253. /** @hidden */
  57254. _constantDeclaration: string;
  57255. /** @hidden */
  57256. _samplerDeclaration: string;
  57257. /** @hidden */
  57258. _varyingTransfer: string;
  57259. private _repeatableContentAnchorIndex;
  57260. /** @hidden */
  57261. _builtCompilationString: string;
  57262. /**
  57263. * Gets the emitted compilation strings
  57264. */
  57265. compilationString: string;
  57266. /**
  57267. * Finalize the compilation strings
  57268. * @param state defines the current compilation state
  57269. */
  57270. finalize(state: NodeMaterialBuildState): void;
  57271. /** @hidden */
  57272. get _repeatableContentAnchor(): string;
  57273. /** @hidden */
  57274. _getFreeVariableName(prefix: string): string;
  57275. /** @hidden */
  57276. _getFreeDefineName(prefix: string): string;
  57277. /** @hidden */
  57278. _excludeVariableName(name: string): void;
  57279. /** @hidden */
  57280. _emit2DSampler(name: string): void;
  57281. /** @hidden */
  57282. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57283. /** @hidden */
  57284. _emitExtension(name: string, extension: string): void;
  57285. /** @hidden */
  57286. _emitFunction(name: string, code: string, comments: string): void;
  57287. /** @hidden */
  57288. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57289. replaceStrings?: {
  57290. search: RegExp;
  57291. replace: string;
  57292. }[];
  57293. repeatKey?: string;
  57294. }): string;
  57295. /** @hidden */
  57296. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57297. repeatKey?: string;
  57298. removeAttributes?: boolean;
  57299. removeUniforms?: boolean;
  57300. removeVaryings?: boolean;
  57301. removeIfDef?: boolean;
  57302. replaceStrings?: {
  57303. search: RegExp;
  57304. replace: string;
  57305. }[];
  57306. }, storeKey?: string): void;
  57307. /** @hidden */
  57308. _registerTempVariable(name: string): boolean;
  57309. /** @hidden */
  57310. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57311. /** @hidden */
  57312. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57313. /** @hidden */
  57314. _emitFloat(value: number): string;
  57315. }
  57316. }
  57317. declare module BABYLON {
  57318. /**
  57319. * Defines a block that can be used inside a node based material
  57320. */
  57321. export class NodeMaterialBlock {
  57322. private _buildId;
  57323. private _buildTarget;
  57324. private _target;
  57325. private _isFinalMerger;
  57326. private _isInput;
  57327. protected _isUnique: boolean;
  57328. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57329. inputsAreExclusive: boolean;
  57330. /** @hidden */
  57331. _codeVariableName: string;
  57332. /** @hidden */
  57333. _inputs: NodeMaterialConnectionPoint[];
  57334. /** @hidden */
  57335. _outputs: NodeMaterialConnectionPoint[];
  57336. /** @hidden */
  57337. _preparationId: number;
  57338. /**
  57339. * Gets or sets the name of the block
  57340. */
  57341. name: string;
  57342. /**
  57343. * Gets or sets the unique id of the node
  57344. */
  57345. uniqueId: number;
  57346. /**
  57347. * Gets or sets the comments associated with this block
  57348. */
  57349. comments: string;
  57350. /**
  57351. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57352. */
  57353. get isUnique(): boolean;
  57354. /**
  57355. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57356. */
  57357. get isFinalMerger(): boolean;
  57358. /**
  57359. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57360. */
  57361. get isInput(): boolean;
  57362. /**
  57363. * Gets or sets the build Id
  57364. */
  57365. get buildId(): number;
  57366. set buildId(value: number);
  57367. /**
  57368. * Gets or sets the target of the block
  57369. */
  57370. get target(): NodeMaterialBlockTargets;
  57371. set target(value: NodeMaterialBlockTargets);
  57372. /**
  57373. * Gets the list of input points
  57374. */
  57375. get inputs(): NodeMaterialConnectionPoint[];
  57376. /** Gets the list of output points */
  57377. get outputs(): NodeMaterialConnectionPoint[];
  57378. /**
  57379. * Find an input by its name
  57380. * @param name defines the name of the input to look for
  57381. * @returns the input or null if not found
  57382. */
  57383. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57384. /**
  57385. * Find an output by its name
  57386. * @param name defines the name of the outputto look for
  57387. * @returns the output or null if not found
  57388. */
  57389. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57390. /**
  57391. * Creates a new NodeMaterialBlock
  57392. * @param name defines the block name
  57393. * @param target defines the target of that block (Vertex by default)
  57394. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57395. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57396. */
  57397. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57398. /**
  57399. * Initialize the block and prepare the context for build
  57400. * @param state defines the state that will be used for the build
  57401. */
  57402. initialize(state: NodeMaterialBuildState): void;
  57403. /**
  57404. * Bind data to effect. Will only be called for blocks with isBindable === true
  57405. * @param effect defines the effect to bind data to
  57406. * @param nodeMaterial defines the hosting NodeMaterial
  57407. * @param mesh defines the mesh that will be rendered
  57408. */
  57409. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57410. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57411. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57412. protected _writeFloat(value: number): string;
  57413. /**
  57414. * Gets the current class name e.g. "NodeMaterialBlock"
  57415. * @returns the class name
  57416. */
  57417. getClassName(): string;
  57418. /**
  57419. * Register a new input. Must be called inside a block constructor
  57420. * @param name defines the connection point name
  57421. * @param type defines the connection point type
  57422. * @param isOptional defines a boolean indicating that this input can be omitted
  57423. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57424. * @returns the current block
  57425. */
  57426. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57427. /**
  57428. * Register a new output. Must be called inside a block constructor
  57429. * @param name defines the connection point name
  57430. * @param type defines the connection point type
  57431. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57432. * @returns the current block
  57433. */
  57434. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57435. /**
  57436. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57437. * @param forOutput defines an optional connection point to check compatibility with
  57438. * @returns the first available input or null
  57439. */
  57440. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57441. /**
  57442. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57443. * @param forBlock defines an optional block to check compatibility with
  57444. * @returns the first available input or null
  57445. */
  57446. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57447. /**
  57448. * Gets the sibling of the given output
  57449. * @param current defines the current output
  57450. * @returns the next output in the list or null
  57451. */
  57452. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57453. /**
  57454. * Connect current block with another block
  57455. * @param other defines the block to connect with
  57456. * @param options define the various options to help pick the right connections
  57457. * @returns the current block
  57458. */
  57459. connectTo(other: NodeMaterialBlock, options?: {
  57460. input?: string;
  57461. output?: string;
  57462. outputSwizzle?: string;
  57463. }): this | undefined;
  57464. protected _buildBlock(state: NodeMaterialBuildState): void;
  57465. /**
  57466. * Add uniforms, samplers and uniform buffers at compilation time
  57467. * @param state defines the state to update
  57468. * @param nodeMaterial defines the node material requesting the update
  57469. * @param defines defines the material defines to update
  57470. * @param uniformBuffers defines the list of uniform buffer names
  57471. */
  57472. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57473. /**
  57474. * Add potential fallbacks if shader compilation fails
  57475. * @param mesh defines the mesh to be rendered
  57476. * @param fallbacks defines the current prioritized list of fallbacks
  57477. */
  57478. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57479. /**
  57480. * Initialize defines for shader compilation
  57481. * @param mesh defines the mesh to be rendered
  57482. * @param nodeMaterial defines the node material requesting the update
  57483. * @param defines defines the material defines to update
  57484. * @param useInstances specifies that instances should be used
  57485. */
  57486. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57487. /**
  57488. * Update defines for shader compilation
  57489. * @param mesh defines the mesh to be rendered
  57490. * @param nodeMaterial defines the node material requesting the update
  57491. * @param defines defines the material defines to update
  57492. * @param useInstances specifies that instances should be used
  57493. */
  57494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57495. /**
  57496. * Lets the block try to connect some inputs automatically
  57497. * @param material defines the hosting NodeMaterial
  57498. */
  57499. autoConfigure(material: NodeMaterial): void;
  57500. /**
  57501. * Function called when a block is declared as repeatable content generator
  57502. * @param vertexShaderState defines the current compilation state for the vertex shader
  57503. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57504. * @param mesh defines the mesh to be rendered
  57505. * @param defines defines the material defines to update
  57506. */
  57507. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57508. /**
  57509. * Checks if the block is ready
  57510. * @param mesh defines the mesh to be rendered
  57511. * @param nodeMaterial defines the node material requesting the update
  57512. * @param defines defines the material defines to update
  57513. * @param useInstances specifies that instances should be used
  57514. * @returns true if the block is ready
  57515. */
  57516. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57517. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57518. private _processBuild;
  57519. /**
  57520. * Compile the current node and generate the shader code
  57521. * @param state defines the current compilation state (uniforms, samplers, current string)
  57522. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57523. * @returns true if already built
  57524. */
  57525. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57526. protected _inputRename(name: string): string;
  57527. protected _outputRename(name: string): string;
  57528. protected _dumpPropertiesCode(): string;
  57529. /** @hidden */
  57530. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57531. /** @hidden */
  57532. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57533. /**
  57534. * Clone the current block to a new identical block
  57535. * @param scene defines the hosting scene
  57536. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57537. * @returns a copy of the current block
  57538. */
  57539. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57540. /**
  57541. * Serializes this block in a JSON representation
  57542. * @returns the serialized block object
  57543. */
  57544. serialize(): any;
  57545. /** @hidden */
  57546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57547. /**
  57548. * Release resources
  57549. */
  57550. dispose(): void;
  57551. }
  57552. }
  57553. declare module BABYLON {
  57554. /**
  57555. * Enum defining the type of animations supported by InputBlock
  57556. */
  57557. export enum AnimatedInputBlockTypes {
  57558. /** No animation */
  57559. None = 0,
  57560. /** Time based animation. Will only work for floats */
  57561. Time = 1
  57562. }
  57563. }
  57564. declare module BABYLON {
  57565. /**
  57566. * Block used to expose an input value
  57567. */
  57568. export class InputBlock extends NodeMaterialBlock {
  57569. private _mode;
  57570. private _associatedVariableName;
  57571. private _storedValue;
  57572. private _valueCallback;
  57573. private _type;
  57574. private _animationType;
  57575. /** Gets or set a value used to limit the range of float values */
  57576. min: number;
  57577. /** Gets or set a value used to limit the range of float values */
  57578. max: number;
  57579. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57580. isBoolean: boolean;
  57581. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57582. matrixMode: number;
  57583. /** @hidden */
  57584. _systemValue: Nullable<NodeMaterialSystemValues>;
  57585. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57586. visibleInInspector: boolean;
  57587. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57588. isConstant: boolean;
  57589. /** Gets or sets the group to use to display this block in the Inspector */
  57590. groupInInspector: string;
  57591. /**
  57592. * Gets or sets the connection point type (default is float)
  57593. */
  57594. get type(): NodeMaterialBlockConnectionPointTypes;
  57595. /**
  57596. * Creates a new InputBlock
  57597. * @param name defines the block name
  57598. * @param target defines the target of that block (Vertex by default)
  57599. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57600. */
  57601. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57602. /**
  57603. * Gets the output component
  57604. */
  57605. get output(): NodeMaterialConnectionPoint;
  57606. /**
  57607. * Set the source of this connection point to a vertex attribute
  57608. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57609. * @returns the current connection point
  57610. */
  57611. setAsAttribute(attributeName?: string): InputBlock;
  57612. /**
  57613. * Set the source of this connection point to a system value
  57614. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57615. * @returns the current connection point
  57616. */
  57617. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57618. /**
  57619. * Gets or sets the value of that point.
  57620. * Please note that this value will be ignored if valueCallback is defined
  57621. */
  57622. get value(): any;
  57623. set value(value: any);
  57624. /**
  57625. * Gets or sets a callback used to get the value of that point.
  57626. * Please note that setting this value will force the connection point to ignore the value property
  57627. */
  57628. get valueCallback(): () => any;
  57629. set valueCallback(value: () => any);
  57630. /**
  57631. * Gets or sets the associated variable name in the shader
  57632. */
  57633. get associatedVariableName(): string;
  57634. set associatedVariableName(value: string);
  57635. /** Gets or sets the type of animation applied to the input */
  57636. get animationType(): AnimatedInputBlockTypes;
  57637. set animationType(value: AnimatedInputBlockTypes);
  57638. /**
  57639. * Gets a boolean indicating that this connection point not defined yet
  57640. */
  57641. get isUndefined(): boolean;
  57642. /**
  57643. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57644. * In this case the connection point name must be the name of the uniform to use.
  57645. * Can only be set on inputs
  57646. */
  57647. get isUniform(): boolean;
  57648. set isUniform(value: boolean);
  57649. /**
  57650. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57651. * In this case the connection point name must be the name of the attribute to use
  57652. * Can only be set on inputs
  57653. */
  57654. get isAttribute(): boolean;
  57655. set isAttribute(value: boolean);
  57656. /**
  57657. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57658. * Can only be set on exit points
  57659. */
  57660. get isVarying(): boolean;
  57661. set isVarying(value: boolean);
  57662. /**
  57663. * Gets a boolean indicating that the current connection point is a system value
  57664. */
  57665. get isSystemValue(): boolean;
  57666. /**
  57667. * Gets or sets the current well known value or null if not defined as a system value
  57668. */
  57669. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57670. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57671. /**
  57672. * Gets the current class name
  57673. * @returns the class name
  57674. */
  57675. getClassName(): string;
  57676. /**
  57677. * Animate the input if animationType !== None
  57678. * @param scene defines the rendering scene
  57679. */
  57680. animate(scene: Scene): void;
  57681. private _emitDefine;
  57682. initialize(state: NodeMaterialBuildState): void;
  57683. /**
  57684. * Set the input block to its default value (based on its type)
  57685. */
  57686. setDefaultValue(): void;
  57687. private _emitConstant;
  57688. private _emit;
  57689. /** @hidden */
  57690. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57691. /** @hidden */
  57692. _transmit(effect: Effect, scene: Scene): void;
  57693. protected _buildBlock(state: NodeMaterialBuildState): void;
  57694. protected _dumpPropertiesCode(): string;
  57695. serialize(): any;
  57696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57697. }
  57698. }
  57699. declare module BABYLON {
  57700. /**
  57701. * Enum used to define the compatibility state between two connection points
  57702. */
  57703. export enum NodeMaterialConnectionPointCompatibilityStates {
  57704. /** Points are compatibles */
  57705. Compatible = 0,
  57706. /** Points are incompatible because of their types */
  57707. TypeIncompatible = 1,
  57708. /** Points are incompatible because of their targets (vertex vs fragment) */
  57709. TargetIncompatible = 2
  57710. }
  57711. /**
  57712. * Defines the direction of a connection point
  57713. */
  57714. export enum NodeMaterialConnectionPointDirection {
  57715. /** Input */
  57716. Input = 0,
  57717. /** Output */
  57718. Output = 1
  57719. }
  57720. /**
  57721. * Defines a connection point for a block
  57722. */
  57723. export class NodeMaterialConnectionPoint {
  57724. /** @hidden */
  57725. _ownerBlock: NodeMaterialBlock;
  57726. /** @hidden */
  57727. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57728. private _endpoints;
  57729. private _associatedVariableName;
  57730. private _direction;
  57731. /** @hidden */
  57732. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57733. /** @hidden */
  57734. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57735. private _type;
  57736. /** @hidden */
  57737. _enforceAssociatedVariableName: boolean;
  57738. /** Gets the direction of the point */
  57739. get direction(): NodeMaterialConnectionPointDirection;
  57740. /**
  57741. * Gets or sets the additional types supported by this connection point
  57742. */
  57743. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57744. /**
  57745. * Gets or sets the additional types excluded by this connection point
  57746. */
  57747. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57748. /**
  57749. * Observable triggered when this point is connected
  57750. */
  57751. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57752. /**
  57753. * Gets or sets the associated variable name in the shader
  57754. */
  57755. get associatedVariableName(): string;
  57756. set associatedVariableName(value: string);
  57757. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  57758. get innerType(): NodeMaterialBlockConnectionPointTypes;
  57759. /**
  57760. * Gets or sets the connection point type (default is float)
  57761. */
  57762. get type(): NodeMaterialBlockConnectionPointTypes;
  57763. set type(value: NodeMaterialBlockConnectionPointTypes);
  57764. /**
  57765. * Gets or sets the connection point name
  57766. */
  57767. name: string;
  57768. /**
  57769. * Gets or sets a boolean indicating that this connection point can be omitted
  57770. */
  57771. isOptional: boolean;
  57772. /**
  57773. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57774. */
  57775. define: string;
  57776. /** @hidden */
  57777. _prioritizeVertex: boolean;
  57778. private _target;
  57779. /** Gets or sets the target of that connection point */
  57780. get target(): NodeMaterialBlockTargets;
  57781. set target(value: NodeMaterialBlockTargets);
  57782. /**
  57783. * Gets a boolean indicating that the current point is connected
  57784. */
  57785. get isConnected(): boolean;
  57786. /**
  57787. * Gets a boolean indicating that the current point is connected to an input block
  57788. */
  57789. get isConnectedToInputBlock(): boolean;
  57790. /**
  57791. * Gets a the connected input block (if any)
  57792. */
  57793. get connectInputBlock(): Nullable<InputBlock>;
  57794. /** Get the other side of the connection (if any) */
  57795. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  57796. /** Get the block that owns this connection point */
  57797. get ownerBlock(): NodeMaterialBlock;
  57798. /** Get the block connected on the other side of this connection (if any) */
  57799. get sourceBlock(): Nullable<NodeMaterialBlock>;
  57800. /** Get the block connected on the endpoints of this connection (if any) */
  57801. get connectedBlocks(): Array<NodeMaterialBlock>;
  57802. /** Gets the list of connected endpoints */
  57803. get endpoints(): NodeMaterialConnectionPoint[];
  57804. /** Gets a boolean indicating if that output point is connected to at least one input */
  57805. get hasEndpoints(): boolean;
  57806. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57807. get isConnectedInVertexShader(): boolean;
  57808. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57809. get isConnectedInFragmentShader(): boolean;
  57810. /**
  57811. * Creates a new connection point
  57812. * @param name defines the connection point name
  57813. * @param ownerBlock defines the block hosting this connection point
  57814. * @param direction defines the direction of the connection point
  57815. */
  57816. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57817. /**
  57818. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57819. * @returns the class name
  57820. */
  57821. getClassName(): string;
  57822. /**
  57823. * Gets a boolean indicating if the current point can be connected to another point
  57824. * @param connectionPoint defines the other connection point
  57825. * @returns a boolean
  57826. */
  57827. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57828. /**
  57829. * Gets a number indicating if the current point can be connected to another point
  57830. * @param connectionPoint defines the other connection point
  57831. * @returns a number defining the compatibility state
  57832. */
  57833. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57834. /**
  57835. * Connect this point to another connection point
  57836. * @param connectionPoint defines the other connection point
  57837. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57838. * @returns the current connection point
  57839. */
  57840. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57841. /**
  57842. * Disconnect this point from one of his endpoint
  57843. * @param endpoint defines the other connection point
  57844. * @returns the current connection point
  57845. */
  57846. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57847. /**
  57848. * Serializes this point in a JSON representation
  57849. * @returns the serialized point object
  57850. */
  57851. serialize(): any;
  57852. /**
  57853. * Release resources
  57854. */
  57855. dispose(): void;
  57856. }
  57857. }
  57858. declare module BABYLON {
  57859. /**
  57860. * Block used to add support for vertex skinning (bones)
  57861. */
  57862. export class BonesBlock extends NodeMaterialBlock {
  57863. /**
  57864. * Creates a new BonesBlock
  57865. * @param name defines the block name
  57866. */
  57867. constructor(name: string);
  57868. /**
  57869. * Initialize the block and prepare the context for build
  57870. * @param state defines the state that will be used for the build
  57871. */
  57872. initialize(state: NodeMaterialBuildState): void;
  57873. /**
  57874. * Gets the current class name
  57875. * @returns the class name
  57876. */
  57877. getClassName(): string;
  57878. /**
  57879. * Gets the matrix indices input component
  57880. */
  57881. get matricesIndices(): NodeMaterialConnectionPoint;
  57882. /**
  57883. * Gets the matrix weights input component
  57884. */
  57885. get matricesWeights(): NodeMaterialConnectionPoint;
  57886. /**
  57887. * Gets the extra matrix indices input component
  57888. */
  57889. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  57890. /**
  57891. * Gets the extra matrix weights input component
  57892. */
  57893. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  57894. /**
  57895. * Gets the world input component
  57896. */
  57897. get world(): NodeMaterialConnectionPoint;
  57898. /**
  57899. * Gets the output component
  57900. */
  57901. get output(): NodeMaterialConnectionPoint;
  57902. autoConfigure(material: NodeMaterial): void;
  57903. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57906. protected _buildBlock(state: NodeMaterialBuildState): this;
  57907. }
  57908. }
  57909. declare module BABYLON {
  57910. /**
  57911. * Block used to add support for instances
  57912. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57913. */
  57914. export class InstancesBlock extends NodeMaterialBlock {
  57915. /**
  57916. * Creates a new InstancesBlock
  57917. * @param name defines the block name
  57918. */
  57919. constructor(name: string);
  57920. /**
  57921. * Gets the current class name
  57922. * @returns the class name
  57923. */
  57924. getClassName(): string;
  57925. /**
  57926. * Gets the first world row input component
  57927. */
  57928. get world0(): NodeMaterialConnectionPoint;
  57929. /**
  57930. * Gets the second world row input component
  57931. */
  57932. get world1(): NodeMaterialConnectionPoint;
  57933. /**
  57934. * Gets the third world row input component
  57935. */
  57936. get world2(): NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the forth world row input component
  57939. */
  57940. get world3(): NodeMaterialConnectionPoint;
  57941. /**
  57942. * Gets the world input component
  57943. */
  57944. get world(): NodeMaterialConnectionPoint;
  57945. /**
  57946. * Gets the output component
  57947. */
  57948. get output(): NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the isntanceID component
  57951. */
  57952. get instanceID(): NodeMaterialConnectionPoint;
  57953. autoConfigure(material: NodeMaterial): void;
  57954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57955. protected _buildBlock(state: NodeMaterialBuildState): this;
  57956. }
  57957. }
  57958. declare module BABYLON {
  57959. /**
  57960. * Block used to add morph targets support to vertex shader
  57961. */
  57962. export class MorphTargetsBlock extends NodeMaterialBlock {
  57963. private _repeatableContentAnchor;
  57964. /**
  57965. * Create a new MorphTargetsBlock
  57966. * @param name defines the block name
  57967. */
  57968. constructor(name: string);
  57969. /**
  57970. * Gets the current class name
  57971. * @returns the class name
  57972. */
  57973. getClassName(): string;
  57974. /**
  57975. * Gets the position input component
  57976. */
  57977. get position(): NodeMaterialConnectionPoint;
  57978. /**
  57979. * Gets the normal input component
  57980. */
  57981. get normal(): NodeMaterialConnectionPoint;
  57982. /**
  57983. * Gets the tangent input component
  57984. */
  57985. get tangent(): NodeMaterialConnectionPoint;
  57986. /**
  57987. * Gets the tangent input component
  57988. */
  57989. get uv(): NodeMaterialConnectionPoint;
  57990. /**
  57991. * Gets the position output component
  57992. */
  57993. get positionOutput(): NodeMaterialConnectionPoint;
  57994. /**
  57995. * Gets the normal output component
  57996. */
  57997. get normalOutput(): NodeMaterialConnectionPoint;
  57998. /**
  57999. * Gets the tangent output component
  58000. */
  58001. get tangentOutput(): NodeMaterialConnectionPoint;
  58002. /**
  58003. * Gets the tangent output component
  58004. */
  58005. get uvOutput(): NodeMaterialConnectionPoint;
  58006. initialize(state: NodeMaterialBuildState): void;
  58007. autoConfigure(material: NodeMaterial): void;
  58008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58010. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58011. protected _buildBlock(state: NodeMaterialBuildState): this;
  58012. }
  58013. }
  58014. declare module BABYLON {
  58015. /**
  58016. * Block used to get data information from a light
  58017. */
  58018. export class LightInformationBlock extends NodeMaterialBlock {
  58019. private _lightDataUniformName;
  58020. private _lightColorUniformName;
  58021. private _lightTypeDefineName;
  58022. /**
  58023. * Gets or sets the light associated with this block
  58024. */
  58025. light: Nullable<Light>;
  58026. /**
  58027. * Creates a new LightInformationBlock
  58028. * @param name defines the block name
  58029. */
  58030. constructor(name: string);
  58031. /**
  58032. * Gets the current class name
  58033. * @returns the class name
  58034. */
  58035. getClassName(): string;
  58036. /**
  58037. * Gets the world position input component
  58038. */
  58039. get worldPosition(): NodeMaterialConnectionPoint;
  58040. /**
  58041. * Gets the direction output component
  58042. */
  58043. get direction(): NodeMaterialConnectionPoint;
  58044. /**
  58045. * Gets the direction output component
  58046. */
  58047. get color(): NodeMaterialConnectionPoint;
  58048. /**
  58049. * Gets the direction output component
  58050. */
  58051. get intensity(): NodeMaterialConnectionPoint;
  58052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58054. protected _buildBlock(state: NodeMaterialBuildState): this;
  58055. serialize(): any;
  58056. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58057. }
  58058. }
  58059. declare module BABYLON {
  58060. /**
  58061. * Block used to add image processing support to fragment shader
  58062. */
  58063. export class ImageProcessingBlock extends NodeMaterialBlock {
  58064. /**
  58065. * Create a new ImageProcessingBlock
  58066. * @param name defines the block name
  58067. */
  58068. constructor(name: string);
  58069. /**
  58070. * Gets the current class name
  58071. * @returns the class name
  58072. */
  58073. getClassName(): string;
  58074. /**
  58075. * Gets the color input component
  58076. */
  58077. get color(): NodeMaterialConnectionPoint;
  58078. /**
  58079. * Gets the output component
  58080. */
  58081. get output(): NodeMaterialConnectionPoint;
  58082. /**
  58083. * Initialize the block and prepare the context for build
  58084. * @param state defines the state that will be used for the build
  58085. */
  58086. initialize(state: NodeMaterialBuildState): void;
  58087. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58090. protected _buildBlock(state: NodeMaterialBuildState): this;
  58091. }
  58092. }
  58093. declare module BABYLON {
  58094. /**
  58095. * Block used to pertub normals based on a normal map
  58096. */
  58097. export class PerturbNormalBlock extends NodeMaterialBlock {
  58098. private _tangentSpaceParameterName;
  58099. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58100. invertX: boolean;
  58101. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58102. invertY: boolean;
  58103. /**
  58104. * Create a new PerturbNormalBlock
  58105. * @param name defines the block name
  58106. */
  58107. constructor(name: string);
  58108. /**
  58109. * Gets the current class name
  58110. * @returns the class name
  58111. */
  58112. getClassName(): string;
  58113. /**
  58114. * Gets the world position input component
  58115. */
  58116. get worldPosition(): NodeMaterialConnectionPoint;
  58117. /**
  58118. * Gets the world normal input component
  58119. */
  58120. get worldNormal(): NodeMaterialConnectionPoint;
  58121. /**
  58122. * Gets the world tangent input component
  58123. */
  58124. get worldTangent(): NodeMaterialConnectionPoint;
  58125. /**
  58126. * Gets the uv input component
  58127. */
  58128. get uv(): NodeMaterialConnectionPoint;
  58129. /**
  58130. * Gets the normal map color input component
  58131. */
  58132. get normalMapColor(): NodeMaterialConnectionPoint;
  58133. /**
  58134. * Gets the strength input component
  58135. */
  58136. get strength(): NodeMaterialConnectionPoint;
  58137. /**
  58138. * Gets the output component
  58139. */
  58140. get output(): NodeMaterialConnectionPoint;
  58141. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58143. autoConfigure(material: NodeMaterial): void;
  58144. protected _buildBlock(state: NodeMaterialBuildState): this;
  58145. protected _dumpPropertiesCode(): string;
  58146. serialize(): any;
  58147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58148. }
  58149. }
  58150. declare module BABYLON {
  58151. /**
  58152. * Block used to discard a pixel if a value is smaller than a cutoff
  58153. */
  58154. export class DiscardBlock extends NodeMaterialBlock {
  58155. /**
  58156. * Create a new DiscardBlock
  58157. * @param name defines the block name
  58158. */
  58159. constructor(name: string);
  58160. /**
  58161. * Gets the current class name
  58162. * @returns the class name
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * Gets the color input component
  58167. */
  58168. get value(): NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the cutoff input component
  58171. */
  58172. get cutoff(): NodeMaterialConnectionPoint;
  58173. protected _buildBlock(state: NodeMaterialBuildState): this;
  58174. }
  58175. }
  58176. declare module BABYLON {
  58177. /**
  58178. * Block used to test if the fragment shader is front facing
  58179. */
  58180. export class FrontFacingBlock extends NodeMaterialBlock {
  58181. /**
  58182. * Creates a new FrontFacingBlock
  58183. * @param name defines the block name
  58184. */
  58185. constructor(name: string);
  58186. /**
  58187. * Gets the current class name
  58188. * @returns the class name
  58189. */
  58190. getClassName(): string;
  58191. /**
  58192. * Gets the output component
  58193. */
  58194. get output(): NodeMaterialConnectionPoint;
  58195. protected _buildBlock(state: NodeMaterialBuildState): this;
  58196. }
  58197. }
  58198. declare module BABYLON {
  58199. /**
  58200. * Block used to get the derivative value on x and y of a given input
  58201. */
  58202. export class DerivativeBlock extends NodeMaterialBlock {
  58203. /**
  58204. * Create a new DerivativeBlock
  58205. * @param name defines the block name
  58206. */
  58207. constructor(name: string);
  58208. /**
  58209. * Gets the current class name
  58210. * @returns the class name
  58211. */
  58212. getClassName(): string;
  58213. /**
  58214. * Gets the input component
  58215. */
  58216. get input(): NodeMaterialConnectionPoint;
  58217. /**
  58218. * Gets the derivative output on x
  58219. */
  58220. get dx(): NodeMaterialConnectionPoint;
  58221. /**
  58222. * Gets the derivative output on y
  58223. */
  58224. get dy(): NodeMaterialConnectionPoint;
  58225. protected _buildBlock(state: NodeMaterialBuildState): this;
  58226. }
  58227. }
  58228. declare module BABYLON {
  58229. /**
  58230. * Block used to add support for scene fog
  58231. */
  58232. export class FogBlock extends NodeMaterialBlock {
  58233. private _fogDistanceName;
  58234. private _fogParameters;
  58235. /**
  58236. * Create a new FogBlock
  58237. * @param name defines the block name
  58238. */
  58239. constructor(name: string);
  58240. /**
  58241. * Gets the current class name
  58242. * @returns the class name
  58243. */
  58244. getClassName(): string;
  58245. /**
  58246. * Gets the world position input component
  58247. */
  58248. get worldPosition(): NodeMaterialConnectionPoint;
  58249. /**
  58250. * Gets the view input component
  58251. */
  58252. get view(): NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the color input component
  58255. */
  58256. get input(): NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the fog color input component
  58259. */
  58260. get fogColor(): NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the output component
  58263. */
  58264. get output(): NodeMaterialConnectionPoint;
  58265. autoConfigure(material: NodeMaterial): void;
  58266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58267. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58268. protected _buildBlock(state: NodeMaterialBuildState): this;
  58269. }
  58270. }
  58271. declare module BABYLON {
  58272. /**
  58273. * Block used to add light in the fragment shader
  58274. */
  58275. export class LightBlock extends NodeMaterialBlock {
  58276. private _lightId;
  58277. /**
  58278. * Gets or sets the light associated with this block
  58279. */
  58280. light: Nullable<Light>;
  58281. /**
  58282. * Create a new LightBlock
  58283. * @param name defines the block name
  58284. */
  58285. constructor(name: string);
  58286. /**
  58287. * Gets the current class name
  58288. * @returns the class name
  58289. */
  58290. getClassName(): string;
  58291. /**
  58292. * Gets the world position input component
  58293. */
  58294. get worldPosition(): NodeMaterialConnectionPoint;
  58295. /**
  58296. * Gets the world normal input component
  58297. */
  58298. get worldNormal(): NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the camera (or eye) position component
  58301. */
  58302. get cameraPosition(): NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the glossiness component
  58305. */
  58306. get glossiness(): NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the glossinness power component
  58309. */
  58310. get glossPower(): NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the diffuse color component
  58313. */
  58314. get diffuseColor(): NodeMaterialConnectionPoint;
  58315. /**
  58316. * Gets the specular color component
  58317. */
  58318. get specularColor(): NodeMaterialConnectionPoint;
  58319. /**
  58320. * Gets the diffuse output component
  58321. */
  58322. get diffuseOutput(): NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the specular output component
  58325. */
  58326. get specularOutput(): NodeMaterialConnectionPoint;
  58327. /**
  58328. * Gets the shadow output component
  58329. */
  58330. get shadow(): NodeMaterialConnectionPoint;
  58331. autoConfigure(material: NodeMaterial): void;
  58332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58333. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58334. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58335. private _injectVertexCode;
  58336. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58337. serialize(): any;
  58338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58339. }
  58340. }
  58341. declare module BABYLON {
  58342. /**
  58343. * Block used to multiply 2 values
  58344. */
  58345. export class MultiplyBlock extends NodeMaterialBlock {
  58346. /**
  58347. * Creates a new MultiplyBlock
  58348. * @param name defines the block name
  58349. */
  58350. constructor(name: string);
  58351. /**
  58352. * Gets the current class name
  58353. * @returns the class name
  58354. */
  58355. getClassName(): string;
  58356. /**
  58357. * Gets the left operand input component
  58358. */
  58359. get left(): NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the right operand input component
  58362. */
  58363. get right(): NodeMaterialConnectionPoint;
  58364. /**
  58365. * Gets the output component
  58366. */
  58367. get output(): NodeMaterialConnectionPoint;
  58368. protected _buildBlock(state: NodeMaterialBuildState): this;
  58369. }
  58370. }
  58371. declare module BABYLON {
  58372. /**
  58373. * Block used to add 2 vectors
  58374. */
  58375. export class AddBlock extends NodeMaterialBlock {
  58376. /**
  58377. * Creates a new AddBlock
  58378. * @param name defines the block name
  58379. */
  58380. constructor(name: string);
  58381. /**
  58382. * Gets the current class name
  58383. * @returns the class name
  58384. */
  58385. getClassName(): string;
  58386. /**
  58387. * Gets the left operand input component
  58388. */
  58389. get left(): NodeMaterialConnectionPoint;
  58390. /**
  58391. * Gets the right operand input component
  58392. */
  58393. get right(): NodeMaterialConnectionPoint;
  58394. /**
  58395. * Gets the output component
  58396. */
  58397. get output(): NodeMaterialConnectionPoint;
  58398. protected _buildBlock(state: NodeMaterialBuildState): this;
  58399. }
  58400. }
  58401. declare module BABYLON {
  58402. /**
  58403. * Block used to scale a vector by a float
  58404. */
  58405. export class ScaleBlock extends NodeMaterialBlock {
  58406. /**
  58407. * Creates a new ScaleBlock
  58408. * @param name defines the block name
  58409. */
  58410. constructor(name: string);
  58411. /**
  58412. * Gets the current class name
  58413. * @returns the class name
  58414. */
  58415. getClassName(): string;
  58416. /**
  58417. * Gets the input component
  58418. */
  58419. get input(): NodeMaterialConnectionPoint;
  58420. /**
  58421. * Gets the factor input component
  58422. */
  58423. get factor(): NodeMaterialConnectionPoint;
  58424. /**
  58425. * Gets the output component
  58426. */
  58427. get output(): NodeMaterialConnectionPoint;
  58428. protected _buildBlock(state: NodeMaterialBuildState): this;
  58429. }
  58430. }
  58431. declare module BABYLON {
  58432. /**
  58433. * Block used to clamp a float
  58434. */
  58435. export class ClampBlock extends NodeMaterialBlock {
  58436. /** Gets or sets the minimum range */
  58437. minimum: number;
  58438. /** Gets or sets the maximum range */
  58439. maximum: number;
  58440. /**
  58441. * Creates a new ClampBlock
  58442. * @param name defines the block name
  58443. */
  58444. constructor(name: string);
  58445. /**
  58446. * Gets the current class name
  58447. * @returns the class name
  58448. */
  58449. getClassName(): string;
  58450. /**
  58451. * Gets the value input component
  58452. */
  58453. get value(): NodeMaterialConnectionPoint;
  58454. /**
  58455. * Gets the output component
  58456. */
  58457. get output(): NodeMaterialConnectionPoint;
  58458. protected _buildBlock(state: NodeMaterialBuildState): this;
  58459. protected _dumpPropertiesCode(): string;
  58460. serialize(): any;
  58461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58462. }
  58463. }
  58464. declare module BABYLON {
  58465. /**
  58466. * Block used to apply a cross product between 2 vectors
  58467. */
  58468. export class CrossBlock extends NodeMaterialBlock {
  58469. /**
  58470. * Creates a new CrossBlock
  58471. * @param name defines the block name
  58472. */
  58473. constructor(name: string);
  58474. /**
  58475. * Gets the current class name
  58476. * @returns the class name
  58477. */
  58478. getClassName(): string;
  58479. /**
  58480. * Gets the left operand input component
  58481. */
  58482. get left(): NodeMaterialConnectionPoint;
  58483. /**
  58484. * Gets the right operand input component
  58485. */
  58486. get right(): NodeMaterialConnectionPoint;
  58487. /**
  58488. * Gets the output component
  58489. */
  58490. get output(): NodeMaterialConnectionPoint;
  58491. protected _buildBlock(state: NodeMaterialBuildState): this;
  58492. }
  58493. }
  58494. declare module BABYLON {
  58495. /**
  58496. * Block used to apply a dot product between 2 vectors
  58497. */
  58498. export class DotBlock extends NodeMaterialBlock {
  58499. /**
  58500. * Creates a new DotBlock
  58501. * @param name defines the block name
  58502. */
  58503. constructor(name: string);
  58504. /**
  58505. * Gets the current class name
  58506. * @returns the class name
  58507. */
  58508. getClassName(): string;
  58509. /**
  58510. * Gets the left operand input component
  58511. */
  58512. get left(): NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the right operand input component
  58515. */
  58516. get right(): NodeMaterialConnectionPoint;
  58517. /**
  58518. * Gets the output component
  58519. */
  58520. get output(): NodeMaterialConnectionPoint;
  58521. protected _buildBlock(state: NodeMaterialBuildState): this;
  58522. }
  58523. }
  58524. declare module BABYLON {
  58525. /**
  58526. * Block used to remap a float from a range to a new one
  58527. */
  58528. export class RemapBlock extends NodeMaterialBlock {
  58529. /**
  58530. * Gets or sets the source range
  58531. */
  58532. sourceRange: Vector2;
  58533. /**
  58534. * Gets or sets the target range
  58535. */
  58536. targetRange: Vector2;
  58537. /**
  58538. * Creates a new RemapBlock
  58539. * @param name defines the block name
  58540. */
  58541. constructor(name: string);
  58542. /**
  58543. * Gets the current class name
  58544. * @returns the class name
  58545. */
  58546. getClassName(): string;
  58547. /**
  58548. * Gets the input component
  58549. */
  58550. get input(): NodeMaterialConnectionPoint;
  58551. /**
  58552. * Gets the source min input component
  58553. */
  58554. get sourceMin(): NodeMaterialConnectionPoint;
  58555. /**
  58556. * Gets the source max input component
  58557. */
  58558. get sourceMax(): NodeMaterialConnectionPoint;
  58559. /**
  58560. * Gets the target min input component
  58561. */
  58562. get targetMin(): NodeMaterialConnectionPoint;
  58563. /**
  58564. * Gets the target max input component
  58565. */
  58566. get targetMax(): NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the output component
  58569. */
  58570. get output(): NodeMaterialConnectionPoint;
  58571. protected _buildBlock(state: NodeMaterialBuildState): this;
  58572. protected _dumpPropertiesCode(): string;
  58573. serialize(): any;
  58574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58575. }
  58576. }
  58577. declare module BABYLON {
  58578. /**
  58579. * Block used to normalize a vector
  58580. */
  58581. export class NormalizeBlock extends NodeMaterialBlock {
  58582. /**
  58583. * Creates a new NormalizeBlock
  58584. * @param name defines the block name
  58585. */
  58586. constructor(name: string);
  58587. /**
  58588. * Gets the current class name
  58589. * @returns the class name
  58590. */
  58591. getClassName(): string;
  58592. /**
  58593. * Gets the input component
  58594. */
  58595. get input(): NodeMaterialConnectionPoint;
  58596. /**
  58597. * Gets the output component
  58598. */
  58599. get output(): NodeMaterialConnectionPoint;
  58600. protected _buildBlock(state: NodeMaterialBuildState): this;
  58601. }
  58602. }
  58603. declare module BABYLON {
  58604. /**
  58605. * Operations supported by the Trigonometry block
  58606. */
  58607. export enum TrigonometryBlockOperations {
  58608. /** Cos */
  58609. Cos = 0,
  58610. /** Sin */
  58611. Sin = 1,
  58612. /** Abs */
  58613. Abs = 2,
  58614. /** Exp */
  58615. Exp = 3,
  58616. /** Exp2 */
  58617. Exp2 = 4,
  58618. /** Round */
  58619. Round = 5,
  58620. /** Floor */
  58621. Floor = 6,
  58622. /** Ceiling */
  58623. Ceiling = 7,
  58624. /** Square root */
  58625. Sqrt = 8,
  58626. /** Log */
  58627. Log = 9,
  58628. /** Tangent */
  58629. Tan = 10,
  58630. /** Arc tangent */
  58631. ArcTan = 11,
  58632. /** Arc cosinus */
  58633. ArcCos = 12,
  58634. /** Arc sinus */
  58635. ArcSin = 13,
  58636. /** Fraction */
  58637. Fract = 14,
  58638. /** Sign */
  58639. Sign = 15,
  58640. /** To radians (from degrees) */
  58641. Radians = 16,
  58642. /** To degrees (from radians) */
  58643. Degrees = 17
  58644. }
  58645. /**
  58646. * Block used to apply trigonometry operation to floats
  58647. */
  58648. export class TrigonometryBlock extends NodeMaterialBlock {
  58649. /**
  58650. * Gets or sets the operation applied by the block
  58651. */
  58652. operation: TrigonometryBlockOperations;
  58653. /**
  58654. * Creates a new TrigonometryBlock
  58655. * @param name defines the block name
  58656. */
  58657. constructor(name: string);
  58658. /**
  58659. * Gets the current class name
  58660. * @returns the class name
  58661. */
  58662. getClassName(): string;
  58663. /**
  58664. * Gets the input component
  58665. */
  58666. get input(): NodeMaterialConnectionPoint;
  58667. /**
  58668. * Gets the output component
  58669. */
  58670. get output(): NodeMaterialConnectionPoint;
  58671. protected _buildBlock(state: NodeMaterialBuildState): this;
  58672. serialize(): any;
  58673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58674. protected _dumpPropertiesCode(): string;
  58675. }
  58676. }
  58677. declare module BABYLON {
  58678. /**
  58679. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58680. */
  58681. export class ColorMergerBlock extends NodeMaterialBlock {
  58682. /**
  58683. * Create a new ColorMergerBlock
  58684. * @param name defines the block name
  58685. */
  58686. constructor(name: string);
  58687. /**
  58688. * Gets the current class name
  58689. * @returns the class name
  58690. */
  58691. getClassName(): string;
  58692. /**
  58693. * Gets the rgb component (input)
  58694. */
  58695. get rgbIn(): NodeMaterialConnectionPoint;
  58696. /**
  58697. * Gets the r component (input)
  58698. */
  58699. get r(): NodeMaterialConnectionPoint;
  58700. /**
  58701. * Gets the g component (input)
  58702. */
  58703. get g(): NodeMaterialConnectionPoint;
  58704. /**
  58705. * Gets the b component (input)
  58706. */
  58707. get b(): NodeMaterialConnectionPoint;
  58708. /**
  58709. * Gets the a component (input)
  58710. */
  58711. get a(): NodeMaterialConnectionPoint;
  58712. /**
  58713. * Gets the rgba component (output)
  58714. */
  58715. get rgba(): NodeMaterialConnectionPoint;
  58716. /**
  58717. * Gets the rgb component (output)
  58718. */
  58719. get rgbOut(): NodeMaterialConnectionPoint;
  58720. /**
  58721. * Gets the rgb component (output)
  58722. * @deprecated Please use rgbOut instead.
  58723. */
  58724. get rgb(): NodeMaterialConnectionPoint;
  58725. protected _buildBlock(state: NodeMaterialBuildState): this;
  58726. }
  58727. }
  58728. declare module BABYLON {
  58729. /**
  58730. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58731. */
  58732. export class VectorMergerBlock extends NodeMaterialBlock {
  58733. /**
  58734. * Create a new VectorMergerBlock
  58735. * @param name defines the block name
  58736. */
  58737. constructor(name: string);
  58738. /**
  58739. * Gets the current class name
  58740. * @returns the class name
  58741. */
  58742. getClassName(): string;
  58743. /**
  58744. * Gets the xyz component (input)
  58745. */
  58746. get xyzIn(): NodeMaterialConnectionPoint;
  58747. /**
  58748. * Gets the xy component (input)
  58749. */
  58750. get xyIn(): NodeMaterialConnectionPoint;
  58751. /**
  58752. * Gets the x component (input)
  58753. */
  58754. get x(): NodeMaterialConnectionPoint;
  58755. /**
  58756. * Gets the y component (input)
  58757. */
  58758. get y(): NodeMaterialConnectionPoint;
  58759. /**
  58760. * Gets the z component (input)
  58761. */
  58762. get z(): NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the w component (input)
  58765. */
  58766. get w(): NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the xyzw component (output)
  58769. */
  58770. get xyzw(): NodeMaterialConnectionPoint;
  58771. /**
  58772. * Gets the xyz component (output)
  58773. */
  58774. get xyzOut(): NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the xy component (output)
  58777. */
  58778. get xyOut(): NodeMaterialConnectionPoint;
  58779. /**
  58780. * Gets the xy component (output)
  58781. * @deprecated Please use xyOut instead.
  58782. */
  58783. get xy(): NodeMaterialConnectionPoint;
  58784. /**
  58785. * Gets the xyz component (output)
  58786. * @deprecated Please use xyzOut instead.
  58787. */
  58788. get xyz(): NodeMaterialConnectionPoint;
  58789. protected _buildBlock(state: NodeMaterialBuildState): this;
  58790. }
  58791. }
  58792. declare module BABYLON {
  58793. /**
  58794. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58795. */
  58796. export class ColorSplitterBlock extends NodeMaterialBlock {
  58797. /**
  58798. * Create a new ColorSplitterBlock
  58799. * @param name defines the block name
  58800. */
  58801. constructor(name: string);
  58802. /**
  58803. * Gets the current class name
  58804. * @returns the class name
  58805. */
  58806. getClassName(): string;
  58807. /**
  58808. * Gets the rgba component (input)
  58809. */
  58810. get rgba(): NodeMaterialConnectionPoint;
  58811. /**
  58812. * Gets the rgb component (input)
  58813. */
  58814. get rgbIn(): NodeMaterialConnectionPoint;
  58815. /**
  58816. * Gets the rgb component (output)
  58817. */
  58818. get rgbOut(): NodeMaterialConnectionPoint;
  58819. /**
  58820. * Gets the r component (output)
  58821. */
  58822. get r(): NodeMaterialConnectionPoint;
  58823. /**
  58824. * Gets the g component (output)
  58825. */
  58826. get g(): NodeMaterialConnectionPoint;
  58827. /**
  58828. * Gets the b component (output)
  58829. */
  58830. get b(): NodeMaterialConnectionPoint;
  58831. /**
  58832. * Gets the a component (output)
  58833. */
  58834. get a(): NodeMaterialConnectionPoint;
  58835. protected _inputRename(name: string): string;
  58836. protected _outputRename(name: string): string;
  58837. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58843. */
  58844. export class VectorSplitterBlock extends NodeMaterialBlock {
  58845. /**
  58846. * Create a new VectorSplitterBlock
  58847. * @param name defines the block name
  58848. */
  58849. constructor(name: string);
  58850. /**
  58851. * Gets the current class name
  58852. * @returns the class name
  58853. */
  58854. getClassName(): string;
  58855. /**
  58856. * Gets the xyzw component (input)
  58857. */
  58858. get xyzw(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the xyz component (input)
  58861. */
  58862. get xyzIn(): NodeMaterialConnectionPoint;
  58863. /**
  58864. * Gets the xy component (input)
  58865. */
  58866. get xyIn(): NodeMaterialConnectionPoint;
  58867. /**
  58868. * Gets the xyz component (output)
  58869. */
  58870. get xyzOut(): NodeMaterialConnectionPoint;
  58871. /**
  58872. * Gets the xy component (output)
  58873. */
  58874. get xyOut(): NodeMaterialConnectionPoint;
  58875. /**
  58876. * Gets the x component (output)
  58877. */
  58878. get x(): NodeMaterialConnectionPoint;
  58879. /**
  58880. * Gets the y component (output)
  58881. */
  58882. get y(): NodeMaterialConnectionPoint;
  58883. /**
  58884. * Gets the z component (output)
  58885. */
  58886. get z(): NodeMaterialConnectionPoint;
  58887. /**
  58888. * Gets the w component (output)
  58889. */
  58890. get w(): NodeMaterialConnectionPoint;
  58891. protected _inputRename(name: string): string;
  58892. protected _outputRename(name: string): string;
  58893. protected _buildBlock(state: NodeMaterialBuildState): this;
  58894. }
  58895. }
  58896. declare module BABYLON {
  58897. /**
  58898. * Block used to lerp between 2 values
  58899. */
  58900. export class LerpBlock extends NodeMaterialBlock {
  58901. /**
  58902. * Creates a new LerpBlock
  58903. * @param name defines the block name
  58904. */
  58905. constructor(name: string);
  58906. /**
  58907. * Gets the current class name
  58908. * @returns the class name
  58909. */
  58910. getClassName(): string;
  58911. /**
  58912. * Gets the left operand input component
  58913. */
  58914. get left(): NodeMaterialConnectionPoint;
  58915. /**
  58916. * Gets the right operand input component
  58917. */
  58918. get right(): NodeMaterialConnectionPoint;
  58919. /**
  58920. * Gets the gradient operand input component
  58921. */
  58922. get gradient(): NodeMaterialConnectionPoint;
  58923. /**
  58924. * Gets the output component
  58925. */
  58926. get output(): NodeMaterialConnectionPoint;
  58927. protected _buildBlock(state: NodeMaterialBuildState): this;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. /**
  58932. * Block used to divide 2 vectors
  58933. */
  58934. export class DivideBlock extends NodeMaterialBlock {
  58935. /**
  58936. * Creates a new DivideBlock
  58937. * @param name defines the block name
  58938. */
  58939. constructor(name: string);
  58940. /**
  58941. * Gets the current class name
  58942. * @returns the class name
  58943. */
  58944. getClassName(): string;
  58945. /**
  58946. * Gets the left operand input component
  58947. */
  58948. get left(): NodeMaterialConnectionPoint;
  58949. /**
  58950. * Gets the right operand input component
  58951. */
  58952. get right(): NodeMaterialConnectionPoint;
  58953. /**
  58954. * Gets the output component
  58955. */
  58956. get output(): NodeMaterialConnectionPoint;
  58957. protected _buildBlock(state: NodeMaterialBuildState): this;
  58958. }
  58959. }
  58960. declare module BABYLON {
  58961. /**
  58962. * Block used to subtract 2 vectors
  58963. */
  58964. export class SubtractBlock extends NodeMaterialBlock {
  58965. /**
  58966. * Creates a new SubtractBlock
  58967. * @param name defines the block name
  58968. */
  58969. constructor(name: string);
  58970. /**
  58971. * Gets the current class name
  58972. * @returns the class name
  58973. */
  58974. getClassName(): string;
  58975. /**
  58976. * Gets the left operand input component
  58977. */
  58978. get left(): NodeMaterialConnectionPoint;
  58979. /**
  58980. * Gets the right operand input component
  58981. */
  58982. get right(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the output component
  58985. */
  58986. get output(): NodeMaterialConnectionPoint;
  58987. protected _buildBlock(state: NodeMaterialBuildState): this;
  58988. }
  58989. }
  58990. declare module BABYLON {
  58991. /**
  58992. * Block used to step a value
  58993. */
  58994. export class StepBlock extends NodeMaterialBlock {
  58995. /**
  58996. * Creates a new StepBlock
  58997. * @param name defines the block name
  58998. */
  58999. constructor(name: string);
  59000. /**
  59001. * Gets the current class name
  59002. * @returns the class name
  59003. */
  59004. getClassName(): string;
  59005. /**
  59006. * Gets the value operand input component
  59007. */
  59008. get value(): NodeMaterialConnectionPoint;
  59009. /**
  59010. * Gets the edge operand input component
  59011. */
  59012. get edge(): NodeMaterialConnectionPoint;
  59013. /**
  59014. * Gets the output component
  59015. */
  59016. get output(): NodeMaterialConnectionPoint;
  59017. protected _buildBlock(state: NodeMaterialBuildState): this;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Block used to get the opposite (1 - x) of a value
  59023. */
  59024. export class OneMinusBlock extends NodeMaterialBlock {
  59025. /**
  59026. * Creates a new OneMinusBlock
  59027. * @param name defines the block name
  59028. */
  59029. constructor(name: string);
  59030. /**
  59031. * Gets the current class name
  59032. * @returns the class name
  59033. */
  59034. getClassName(): string;
  59035. /**
  59036. * Gets the input component
  59037. */
  59038. get input(): NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the output component
  59041. */
  59042. get output(): NodeMaterialConnectionPoint;
  59043. protected _buildBlock(state: NodeMaterialBuildState): this;
  59044. }
  59045. }
  59046. declare module BABYLON {
  59047. /**
  59048. * Block used to get the view direction
  59049. */
  59050. export class ViewDirectionBlock extends NodeMaterialBlock {
  59051. /**
  59052. * Creates a new ViewDirectionBlock
  59053. * @param name defines the block name
  59054. */
  59055. constructor(name: string);
  59056. /**
  59057. * Gets the current class name
  59058. * @returns the class name
  59059. */
  59060. getClassName(): string;
  59061. /**
  59062. * Gets the world position component
  59063. */
  59064. get worldPosition(): NodeMaterialConnectionPoint;
  59065. /**
  59066. * Gets the camera position component
  59067. */
  59068. get cameraPosition(): NodeMaterialConnectionPoint;
  59069. /**
  59070. * Gets the output component
  59071. */
  59072. get output(): NodeMaterialConnectionPoint;
  59073. autoConfigure(material: NodeMaterial): void;
  59074. protected _buildBlock(state: NodeMaterialBuildState): this;
  59075. }
  59076. }
  59077. declare module BABYLON {
  59078. /**
  59079. * Block used to compute fresnel value
  59080. */
  59081. export class FresnelBlock extends NodeMaterialBlock {
  59082. /**
  59083. * Create a new FresnelBlock
  59084. * @param name defines the block name
  59085. */
  59086. constructor(name: string);
  59087. /**
  59088. * Gets the current class name
  59089. * @returns the class name
  59090. */
  59091. getClassName(): string;
  59092. /**
  59093. * Gets the world normal input component
  59094. */
  59095. get worldNormal(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the view direction input component
  59098. */
  59099. get viewDirection(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the bias input component
  59102. */
  59103. get bias(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the camera (or eye) position component
  59106. */
  59107. get power(): NodeMaterialConnectionPoint;
  59108. /**
  59109. * Gets the fresnel output component
  59110. */
  59111. get fresnel(): NodeMaterialConnectionPoint;
  59112. autoConfigure(material: NodeMaterial): void;
  59113. protected _buildBlock(state: NodeMaterialBuildState): this;
  59114. }
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * Block used to get the max of 2 values
  59119. */
  59120. export class MaxBlock extends NodeMaterialBlock {
  59121. /**
  59122. * Creates a new MaxBlock
  59123. * @param name defines the block name
  59124. */
  59125. constructor(name: string);
  59126. /**
  59127. * Gets the current class name
  59128. * @returns the class name
  59129. */
  59130. getClassName(): string;
  59131. /**
  59132. * Gets the left operand input component
  59133. */
  59134. get left(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the right operand input component
  59137. */
  59138. get right(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the output component
  59141. */
  59142. get output(): NodeMaterialConnectionPoint;
  59143. protected _buildBlock(state: NodeMaterialBuildState): this;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /**
  59148. * Block used to get the min of 2 values
  59149. */
  59150. export class MinBlock extends NodeMaterialBlock {
  59151. /**
  59152. * Creates a new MinBlock
  59153. * @param name defines the block name
  59154. */
  59155. constructor(name: string);
  59156. /**
  59157. * Gets the current class name
  59158. * @returns the class name
  59159. */
  59160. getClassName(): string;
  59161. /**
  59162. * Gets the left operand input component
  59163. */
  59164. get left(): NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the right operand input component
  59167. */
  59168. get right(): NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the output component
  59171. */
  59172. get output(): NodeMaterialConnectionPoint;
  59173. protected _buildBlock(state: NodeMaterialBuildState): this;
  59174. }
  59175. }
  59176. declare module BABYLON {
  59177. /**
  59178. * Block used to get the distance between 2 values
  59179. */
  59180. export class DistanceBlock extends NodeMaterialBlock {
  59181. /**
  59182. * Creates a new DistanceBlock
  59183. * @param name defines the block name
  59184. */
  59185. constructor(name: string);
  59186. /**
  59187. * Gets the current class name
  59188. * @returns the class name
  59189. */
  59190. getClassName(): string;
  59191. /**
  59192. * Gets the left operand input component
  59193. */
  59194. get left(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the right operand input component
  59197. */
  59198. get right(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the output component
  59201. */
  59202. get output(): NodeMaterialConnectionPoint;
  59203. protected _buildBlock(state: NodeMaterialBuildState): this;
  59204. }
  59205. }
  59206. declare module BABYLON {
  59207. /**
  59208. * Block used to get the length of a vector
  59209. */
  59210. export class LengthBlock extends NodeMaterialBlock {
  59211. /**
  59212. * Creates a new LengthBlock
  59213. * @param name defines the block name
  59214. */
  59215. constructor(name: string);
  59216. /**
  59217. * Gets the current class name
  59218. * @returns the class name
  59219. */
  59220. getClassName(): string;
  59221. /**
  59222. * Gets the value input component
  59223. */
  59224. get value(): NodeMaterialConnectionPoint;
  59225. /**
  59226. * Gets the output component
  59227. */
  59228. get output(): NodeMaterialConnectionPoint;
  59229. protected _buildBlock(state: NodeMaterialBuildState): this;
  59230. }
  59231. }
  59232. declare module BABYLON {
  59233. /**
  59234. * Block used to get negative version of a value (i.e. x * -1)
  59235. */
  59236. export class NegateBlock extends NodeMaterialBlock {
  59237. /**
  59238. * Creates a new NegateBlock
  59239. * @param name defines the block name
  59240. */
  59241. constructor(name: string);
  59242. /**
  59243. * Gets the current class name
  59244. * @returns the class name
  59245. */
  59246. getClassName(): string;
  59247. /**
  59248. * Gets the value input component
  59249. */
  59250. get value(): NodeMaterialConnectionPoint;
  59251. /**
  59252. * Gets the output component
  59253. */
  59254. get output(): NodeMaterialConnectionPoint;
  59255. protected _buildBlock(state: NodeMaterialBuildState): this;
  59256. }
  59257. }
  59258. declare module BABYLON {
  59259. /**
  59260. * Block used to get the value of the first parameter raised to the power of the second
  59261. */
  59262. export class PowBlock extends NodeMaterialBlock {
  59263. /**
  59264. * Creates a new PowBlock
  59265. * @param name defines the block name
  59266. */
  59267. constructor(name: string);
  59268. /**
  59269. * Gets the current class name
  59270. * @returns the class name
  59271. */
  59272. getClassName(): string;
  59273. /**
  59274. * Gets the value operand input component
  59275. */
  59276. get value(): NodeMaterialConnectionPoint;
  59277. /**
  59278. * Gets the power operand input component
  59279. */
  59280. get power(): NodeMaterialConnectionPoint;
  59281. /**
  59282. * Gets the output component
  59283. */
  59284. get output(): NodeMaterialConnectionPoint;
  59285. protected _buildBlock(state: NodeMaterialBuildState): this;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /**
  59290. * Block used to get a random number
  59291. */
  59292. export class RandomNumberBlock extends NodeMaterialBlock {
  59293. /**
  59294. * Creates a new RandomNumberBlock
  59295. * @param name defines the block name
  59296. */
  59297. constructor(name: string);
  59298. /**
  59299. * Gets the current class name
  59300. * @returns the class name
  59301. */
  59302. getClassName(): string;
  59303. /**
  59304. * Gets the seed input component
  59305. */
  59306. get seed(): NodeMaterialConnectionPoint;
  59307. /**
  59308. * Gets the output component
  59309. */
  59310. get output(): NodeMaterialConnectionPoint;
  59311. protected _buildBlock(state: NodeMaterialBuildState): this;
  59312. }
  59313. }
  59314. declare module BABYLON {
  59315. /**
  59316. * Block used to compute arc tangent of 2 values
  59317. */
  59318. export class ArcTan2Block extends NodeMaterialBlock {
  59319. /**
  59320. * Creates a new ArcTan2Block
  59321. * @param name defines the block name
  59322. */
  59323. constructor(name: string);
  59324. /**
  59325. * Gets the current class name
  59326. * @returns the class name
  59327. */
  59328. getClassName(): string;
  59329. /**
  59330. * Gets the x operand input component
  59331. */
  59332. get x(): NodeMaterialConnectionPoint;
  59333. /**
  59334. * Gets the y operand input component
  59335. */
  59336. get y(): NodeMaterialConnectionPoint;
  59337. /**
  59338. * Gets the output component
  59339. */
  59340. get output(): NodeMaterialConnectionPoint;
  59341. protected _buildBlock(state: NodeMaterialBuildState): this;
  59342. }
  59343. }
  59344. declare module BABYLON {
  59345. /**
  59346. * Block used to smooth step a value
  59347. */
  59348. export class SmoothStepBlock extends NodeMaterialBlock {
  59349. /**
  59350. * Creates a new SmoothStepBlock
  59351. * @param name defines the block name
  59352. */
  59353. constructor(name: string);
  59354. /**
  59355. * Gets the current class name
  59356. * @returns the class name
  59357. */
  59358. getClassName(): string;
  59359. /**
  59360. * Gets the value operand input component
  59361. */
  59362. get value(): NodeMaterialConnectionPoint;
  59363. /**
  59364. * Gets the first edge operand input component
  59365. */
  59366. get edge0(): NodeMaterialConnectionPoint;
  59367. /**
  59368. * Gets the second edge operand input component
  59369. */
  59370. get edge1(): NodeMaterialConnectionPoint;
  59371. /**
  59372. * Gets the output component
  59373. */
  59374. get output(): NodeMaterialConnectionPoint;
  59375. protected _buildBlock(state: NodeMaterialBuildState): this;
  59376. }
  59377. }
  59378. declare module BABYLON {
  59379. /**
  59380. * Block used to get the reciprocal (1 / x) of a value
  59381. */
  59382. export class ReciprocalBlock extends NodeMaterialBlock {
  59383. /**
  59384. * Creates a new ReciprocalBlock
  59385. * @param name defines the block name
  59386. */
  59387. constructor(name: string);
  59388. /**
  59389. * Gets the current class name
  59390. * @returns the class name
  59391. */
  59392. getClassName(): string;
  59393. /**
  59394. * Gets the input component
  59395. */
  59396. get input(): NodeMaterialConnectionPoint;
  59397. /**
  59398. * Gets the output component
  59399. */
  59400. get output(): NodeMaterialConnectionPoint;
  59401. protected _buildBlock(state: NodeMaterialBuildState): this;
  59402. }
  59403. }
  59404. declare module BABYLON {
  59405. /**
  59406. * Block used to replace a color by another one
  59407. */
  59408. export class ReplaceColorBlock extends NodeMaterialBlock {
  59409. /**
  59410. * Creates a new ReplaceColorBlock
  59411. * @param name defines the block name
  59412. */
  59413. constructor(name: string);
  59414. /**
  59415. * Gets the current class name
  59416. * @returns the class name
  59417. */
  59418. getClassName(): string;
  59419. /**
  59420. * Gets the value input component
  59421. */
  59422. get value(): NodeMaterialConnectionPoint;
  59423. /**
  59424. * Gets the reference input component
  59425. */
  59426. get reference(): NodeMaterialConnectionPoint;
  59427. /**
  59428. * Gets the distance input component
  59429. */
  59430. get distance(): NodeMaterialConnectionPoint;
  59431. /**
  59432. * Gets the replacement input component
  59433. */
  59434. get replacement(): NodeMaterialConnectionPoint;
  59435. /**
  59436. * Gets the output component
  59437. */
  59438. get output(): NodeMaterialConnectionPoint;
  59439. protected _buildBlock(state: NodeMaterialBuildState): this;
  59440. }
  59441. }
  59442. declare module BABYLON {
  59443. /**
  59444. * Block used to posterize a value
  59445. * @see https://en.wikipedia.org/wiki/Posterization
  59446. */
  59447. export class PosterizeBlock extends NodeMaterialBlock {
  59448. /**
  59449. * Creates a new PosterizeBlock
  59450. * @param name defines the block name
  59451. */
  59452. constructor(name: string);
  59453. /**
  59454. * Gets the current class name
  59455. * @returns the class name
  59456. */
  59457. getClassName(): string;
  59458. /**
  59459. * Gets the value input component
  59460. */
  59461. get value(): NodeMaterialConnectionPoint;
  59462. /**
  59463. * Gets the steps input component
  59464. */
  59465. get steps(): NodeMaterialConnectionPoint;
  59466. /**
  59467. * Gets the output component
  59468. */
  59469. get output(): NodeMaterialConnectionPoint;
  59470. protected _buildBlock(state: NodeMaterialBuildState): this;
  59471. }
  59472. }
  59473. declare module BABYLON {
  59474. /**
  59475. * Operations supported by the Wave block
  59476. */
  59477. export enum WaveBlockKind {
  59478. /** SawTooth */
  59479. SawTooth = 0,
  59480. /** Square */
  59481. Square = 1,
  59482. /** Triangle */
  59483. Triangle = 2
  59484. }
  59485. /**
  59486. * Block used to apply wave operation to floats
  59487. */
  59488. export class WaveBlock extends NodeMaterialBlock {
  59489. /**
  59490. * Gets or sets the kibnd of wave to be applied by the block
  59491. */
  59492. kind: WaveBlockKind;
  59493. /**
  59494. * Creates a new WaveBlock
  59495. * @param name defines the block name
  59496. */
  59497. constructor(name: string);
  59498. /**
  59499. * Gets the current class name
  59500. * @returns the class name
  59501. */
  59502. getClassName(): string;
  59503. /**
  59504. * Gets the input component
  59505. */
  59506. get input(): NodeMaterialConnectionPoint;
  59507. /**
  59508. * Gets the output component
  59509. */
  59510. get output(): NodeMaterialConnectionPoint;
  59511. protected _buildBlock(state: NodeMaterialBuildState): this;
  59512. serialize(): any;
  59513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59514. }
  59515. }
  59516. declare module BABYLON {
  59517. /**
  59518. * Class used to store a color step for the GradientBlock
  59519. */
  59520. export class GradientBlockColorStep {
  59521. /**
  59522. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59523. */
  59524. step: number;
  59525. /**
  59526. * Gets or sets the color associated with this step
  59527. */
  59528. color: Color3;
  59529. /**
  59530. * Creates a new GradientBlockColorStep
  59531. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59532. * @param color defines the color associated with this step
  59533. */
  59534. constructor(
  59535. /**
  59536. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59537. */
  59538. step: number,
  59539. /**
  59540. * Gets or sets the color associated with this step
  59541. */
  59542. color: Color3);
  59543. }
  59544. /**
  59545. * Block used to return a color from a gradient based on an input value between 0 and 1
  59546. */
  59547. export class GradientBlock extends NodeMaterialBlock {
  59548. /**
  59549. * Gets or sets the list of color steps
  59550. */
  59551. colorSteps: GradientBlockColorStep[];
  59552. /**
  59553. * Creates a new GradientBlock
  59554. * @param name defines the block name
  59555. */
  59556. constructor(name: string);
  59557. /**
  59558. * Gets the current class name
  59559. * @returns the class name
  59560. */
  59561. getClassName(): string;
  59562. /**
  59563. * Gets the gradient input component
  59564. */
  59565. get gradient(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the output component
  59568. */
  59569. get output(): NodeMaterialConnectionPoint;
  59570. private _writeColorConstant;
  59571. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59572. serialize(): any;
  59573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59574. protected _dumpPropertiesCode(): string;
  59575. }
  59576. }
  59577. declare module BABYLON {
  59578. /**
  59579. * Block used to normalize lerp between 2 values
  59580. */
  59581. export class NLerpBlock extends NodeMaterialBlock {
  59582. /**
  59583. * Creates a new NLerpBlock
  59584. * @param name defines the block name
  59585. */
  59586. constructor(name: string);
  59587. /**
  59588. * Gets the current class name
  59589. * @returns the class name
  59590. */
  59591. getClassName(): string;
  59592. /**
  59593. * Gets the left operand input component
  59594. */
  59595. get left(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the right operand input component
  59598. */
  59599. get right(): NodeMaterialConnectionPoint;
  59600. /**
  59601. * Gets the gradient operand input component
  59602. */
  59603. get gradient(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the output component
  59606. */
  59607. get output(): NodeMaterialConnectionPoint;
  59608. protected _buildBlock(state: NodeMaterialBuildState): this;
  59609. }
  59610. }
  59611. declare module BABYLON {
  59612. /**
  59613. * block used to Generate a Worley Noise 3D Noise Pattern
  59614. */
  59615. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59616. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59617. manhattanDistance: boolean;
  59618. /**
  59619. * Creates a new WorleyNoise3DBlock
  59620. * @param name defines the block name
  59621. */
  59622. constructor(name: string);
  59623. /**
  59624. * Gets the current class name
  59625. * @returns the class name
  59626. */
  59627. getClassName(): string;
  59628. /**
  59629. * Gets the seed input component
  59630. */
  59631. get seed(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the jitter input component
  59634. */
  59635. get jitter(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the output component
  59638. */
  59639. get output(): NodeMaterialConnectionPoint;
  59640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59641. /**
  59642. * Exposes the properties to the UI?
  59643. */
  59644. protected _dumpPropertiesCode(): string;
  59645. /**
  59646. * Exposes the properties to the Seralize?
  59647. */
  59648. serialize(): any;
  59649. /**
  59650. * Exposes the properties to the deseralize?
  59651. */
  59652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59653. }
  59654. }
  59655. declare module BABYLON {
  59656. /**
  59657. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59658. */
  59659. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59660. /**
  59661. * Creates a new SimplexPerlin3DBlock
  59662. * @param name defines the block name
  59663. */
  59664. constructor(name: string);
  59665. /**
  59666. * Gets the current class name
  59667. * @returns the class name
  59668. */
  59669. getClassName(): string;
  59670. /**
  59671. * Gets the seed operand input component
  59672. */
  59673. get seed(): NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the output component
  59676. */
  59677. get output(): NodeMaterialConnectionPoint;
  59678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59679. }
  59680. }
  59681. declare module BABYLON {
  59682. /**
  59683. * Block used to blend normals
  59684. */
  59685. export class NormalBlendBlock extends NodeMaterialBlock {
  59686. /**
  59687. * Creates a new NormalBlendBlock
  59688. * @param name defines the block name
  59689. */
  59690. constructor(name: string);
  59691. /**
  59692. * Gets the current class name
  59693. * @returns the class name
  59694. */
  59695. getClassName(): string;
  59696. /**
  59697. * Gets the first input component
  59698. */
  59699. get normalMap0(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the second input component
  59702. */
  59703. get normalMap1(): NodeMaterialConnectionPoint;
  59704. /**
  59705. * Gets the output component
  59706. */
  59707. get output(): NodeMaterialConnectionPoint;
  59708. protected _buildBlock(state: NodeMaterialBuildState): this;
  59709. }
  59710. }
  59711. declare module BABYLON {
  59712. /**
  59713. * Block used to rotate a 2d vector by a given angle
  59714. */
  59715. export class Rotate2dBlock extends NodeMaterialBlock {
  59716. /**
  59717. * Creates a new Rotate2dBlock
  59718. * @param name defines the block name
  59719. */
  59720. constructor(name: string);
  59721. /**
  59722. * Gets the current class name
  59723. * @returns the class name
  59724. */
  59725. getClassName(): string;
  59726. /**
  59727. * Gets the input vector
  59728. */
  59729. get input(): NodeMaterialConnectionPoint;
  59730. /**
  59731. * Gets the input angle
  59732. */
  59733. get angle(): NodeMaterialConnectionPoint;
  59734. /**
  59735. * Gets the output component
  59736. */
  59737. get output(): NodeMaterialConnectionPoint;
  59738. autoConfigure(material: NodeMaterial): void;
  59739. protected _buildBlock(state: NodeMaterialBuildState): this;
  59740. }
  59741. }
  59742. declare module BABYLON {
  59743. /**
  59744. * Block used to get the reflected vector from a direction and a normal
  59745. */
  59746. export class ReflectBlock extends NodeMaterialBlock {
  59747. /**
  59748. * Creates a new ReflectBlock
  59749. * @param name defines the block name
  59750. */
  59751. constructor(name: string);
  59752. /**
  59753. * Gets the current class name
  59754. * @returns the class name
  59755. */
  59756. getClassName(): string;
  59757. /**
  59758. * Gets the incident component
  59759. */
  59760. get incident(): NodeMaterialConnectionPoint;
  59761. /**
  59762. * Gets the normal component
  59763. */
  59764. get normal(): NodeMaterialConnectionPoint;
  59765. /**
  59766. * Gets the output component
  59767. */
  59768. get output(): NodeMaterialConnectionPoint;
  59769. protected _buildBlock(state: NodeMaterialBuildState): this;
  59770. }
  59771. }
  59772. declare module BABYLON {
  59773. /**
  59774. * Block used to get the refracted vector from a direction and a normal
  59775. */
  59776. export class RefractBlock extends NodeMaterialBlock {
  59777. /**
  59778. * Creates a new RefractBlock
  59779. * @param name defines the block name
  59780. */
  59781. constructor(name: string);
  59782. /**
  59783. * Gets the current class name
  59784. * @returns the class name
  59785. */
  59786. getClassName(): string;
  59787. /**
  59788. * Gets the incident component
  59789. */
  59790. get incident(): NodeMaterialConnectionPoint;
  59791. /**
  59792. * Gets the normal component
  59793. */
  59794. get normal(): NodeMaterialConnectionPoint;
  59795. /**
  59796. * Gets the index of refraction component
  59797. */
  59798. get ior(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the output component
  59801. */
  59802. get output(): NodeMaterialConnectionPoint;
  59803. protected _buildBlock(state: NodeMaterialBuildState): this;
  59804. }
  59805. }
  59806. declare module BABYLON {
  59807. /**
  59808. * Block used to desaturate a color
  59809. */
  59810. export class DesaturateBlock extends NodeMaterialBlock {
  59811. /**
  59812. * Creates a new DesaturateBlock
  59813. * @param name defines the block name
  59814. */
  59815. constructor(name: string);
  59816. /**
  59817. * Gets the current class name
  59818. * @returns the class name
  59819. */
  59820. getClassName(): string;
  59821. /**
  59822. * Gets the color operand input component
  59823. */
  59824. get color(): NodeMaterialConnectionPoint;
  59825. /**
  59826. * Gets the level operand input component
  59827. */
  59828. get level(): NodeMaterialConnectionPoint;
  59829. /**
  59830. * Gets the output component
  59831. */
  59832. get output(): NodeMaterialConnectionPoint;
  59833. protected _buildBlock(state: NodeMaterialBuildState): this;
  59834. }
  59835. }
  59836. declare module BABYLON {
  59837. /**
  59838. * Effect Render Options
  59839. */
  59840. export interface IEffectRendererOptions {
  59841. /**
  59842. * Defines the vertices positions.
  59843. */
  59844. positions?: number[];
  59845. /**
  59846. * Defines the indices.
  59847. */
  59848. indices?: number[];
  59849. }
  59850. /**
  59851. * Helper class to render one or more effects
  59852. */
  59853. export class EffectRenderer {
  59854. private engine;
  59855. private static _DefaultOptions;
  59856. private _vertexBuffers;
  59857. private _indexBuffer;
  59858. private _ringBufferIndex;
  59859. private _ringScreenBuffer;
  59860. private _fullscreenViewport;
  59861. private _getNextFrameBuffer;
  59862. /**
  59863. * Creates an effect renderer
  59864. * @param engine the engine to use for rendering
  59865. * @param options defines the options of the effect renderer
  59866. */
  59867. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59868. /**
  59869. * Sets the current viewport in normalized coordinates 0-1
  59870. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59871. */
  59872. setViewport(viewport?: Viewport): void;
  59873. /**
  59874. * Binds the embedded attributes buffer to the effect.
  59875. * @param effect Defines the effect to bind the attributes for
  59876. */
  59877. bindBuffers(effect: Effect): void;
  59878. /**
  59879. * Sets the current effect wrapper to use during draw.
  59880. * The effect needs to be ready before calling this api.
  59881. * This also sets the default full screen position attribute.
  59882. * @param effectWrapper Defines the effect to draw with
  59883. */
  59884. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59885. /**
  59886. * Draws a full screen quad.
  59887. */
  59888. draw(): void;
  59889. /**
  59890. * renders one or more effects to a specified texture
  59891. * @param effectWrappers list of effects to renderer
  59892. * @param outputTexture texture to draw to, if null it will render to the screen
  59893. */
  59894. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59895. /**
  59896. * Disposes of the effect renderer
  59897. */
  59898. dispose(): void;
  59899. }
  59900. /**
  59901. * Options to create an EffectWrapper
  59902. */
  59903. interface EffectWrapperCreationOptions {
  59904. /**
  59905. * Engine to use to create the effect
  59906. */
  59907. engine: ThinEngine;
  59908. /**
  59909. * Fragment shader for the effect
  59910. */
  59911. fragmentShader: string;
  59912. /**
  59913. * Vertex shader for the effect
  59914. */
  59915. vertexShader?: string;
  59916. /**
  59917. * Attributes to use in the shader
  59918. */
  59919. attributeNames?: Array<string>;
  59920. /**
  59921. * Uniforms to use in the shader
  59922. */
  59923. uniformNames?: Array<string>;
  59924. /**
  59925. * Texture sampler names to use in the shader
  59926. */
  59927. samplerNames?: Array<string>;
  59928. /**
  59929. * The friendly name of the effect displayed in Spector.
  59930. */
  59931. name?: string;
  59932. }
  59933. /**
  59934. * Wraps an effect to be used for rendering
  59935. */
  59936. export class EffectWrapper {
  59937. /**
  59938. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59939. */
  59940. onApplyObservable: Observable<{}>;
  59941. /**
  59942. * The underlying effect
  59943. */
  59944. effect: Effect;
  59945. /**
  59946. * Creates an effect to be renderer
  59947. * @param creationOptions options to create the effect
  59948. */
  59949. constructor(creationOptions: EffectWrapperCreationOptions);
  59950. /**
  59951. * Disposes of the effect wrapper
  59952. */
  59953. dispose(): void;
  59954. }
  59955. }
  59956. declare module BABYLON {
  59957. /**
  59958. * Helper class to push actions to a pool of workers.
  59959. */
  59960. export class WorkerPool implements IDisposable {
  59961. private _workerInfos;
  59962. private _pendingActions;
  59963. /**
  59964. * Constructor
  59965. * @param workers Array of workers to use for actions
  59966. */
  59967. constructor(workers: Array<Worker>);
  59968. /**
  59969. * Terminates all workers and clears any pending actions.
  59970. */
  59971. dispose(): void;
  59972. /**
  59973. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59974. * pended until a worker has completed its action.
  59975. * @param action The action to perform. Call onComplete when the action is complete.
  59976. */
  59977. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59978. private _execute;
  59979. }
  59980. }
  59981. declare module BABYLON {
  59982. /**
  59983. * Configuration for Draco compression
  59984. */
  59985. export interface IDracoCompressionConfiguration {
  59986. /**
  59987. * Configuration for the decoder.
  59988. */
  59989. decoder: {
  59990. /**
  59991. * The url to the WebAssembly module.
  59992. */
  59993. wasmUrl?: string;
  59994. /**
  59995. * The url to the WebAssembly binary.
  59996. */
  59997. wasmBinaryUrl?: string;
  59998. /**
  59999. * The url to the fallback JavaScript module.
  60000. */
  60001. fallbackUrl?: string;
  60002. };
  60003. }
  60004. /**
  60005. * Draco compression (https://google.github.io/draco/)
  60006. *
  60007. * This class wraps the Draco module.
  60008. *
  60009. * **Encoder**
  60010. *
  60011. * The encoder is not currently implemented.
  60012. *
  60013. * **Decoder**
  60014. *
  60015. * 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.
  60016. *
  60017. * To update the configuration, use the following code:
  60018. * ```javascript
  60019. * DracoCompression.Configuration = {
  60020. * decoder: {
  60021. * wasmUrl: "<url to the WebAssembly library>",
  60022. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60023. * fallbackUrl: "<url to the fallback JavaScript library>",
  60024. * }
  60025. * };
  60026. * ```
  60027. *
  60028. * 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.
  60029. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60030. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60031. *
  60032. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60033. * ```javascript
  60034. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60035. * ```
  60036. *
  60037. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60038. */
  60039. export class DracoCompression implements IDisposable {
  60040. private _workerPoolPromise?;
  60041. private _decoderModulePromise?;
  60042. /**
  60043. * The configuration. Defaults to the following urls:
  60044. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60045. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60046. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60047. */
  60048. static Configuration: IDracoCompressionConfiguration;
  60049. /**
  60050. * Returns true if the decoder configuration is available.
  60051. */
  60052. static get DecoderAvailable(): boolean;
  60053. /**
  60054. * Default number of workers to create when creating the draco compression object.
  60055. */
  60056. static DefaultNumWorkers: number;
  60057. private static GetDefaultNumWorkers;
  60058. private static _Default;
  60059. /**
  60060. * Default instance for the draco compression object.
  60061. */
  60062. static get Default(): DracoCompression;
  60063. /**
  60064. * Constructor
  60065. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60066. */
  60067. constructor(numWorkers?: number);
  60068. /**
  60069. * Stop all async operations and release resources.
  60070. */
  60071. dispose(): void;
  60072. /**
  60073. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60074. * @returns a promise that resolves when ready
  60075. */
  60076. whenReadyAsync(): Promise<void>;
  60077. /**
  60078. * Decode Draco compressed mesh data to vertex data.
  60079. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60080. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60081. * @returns A promise that resolves with the decoded vertex data
  60082. */
  60083. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60084. [kind: string]: number;
  60085. }): Promise<VertexData>;
  60086. }
  60087. }
  60088. declare module BABYLON {
  60089. /**
  60090. * Class for building Constructive Solid Geometry
  60091. */
  60092. export class CSG {
  60093. private polygons;
  60094. /**
  60095. * The world matrix
  60096. */
  60097. matrix: Matrix;
  60098. /**
  60099. * Stores the position
  60100. */
  60101. position: Vector3;
  60102. /**
  60103. * Stores the rotation
  60104. */
  60105. rotation: Vector3;
  60106. /**
  60107. * Stores the rotation quaternion
  60108. */
  60109. rotationQuaternion: Nullable<Quaternion>;
  60110. /**
  60111. * Stores the scaling vector
  60112. */
  60113. scaling: Vector3;
  60114. /**
  60115. * Convert the Mesh to CSG
  60116. * @param mesh The Mesh to convert to CSG
  60117. * @returns A new CSG from the Mesh
  60118. */
  60119. static FromMesh(mesh: Mesh): CSG;
  60120. /**
  60121. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60122. * @param polygons Polygons used to construct a CSG solid
  60123. */
  60124. private static FromPolygons;
  60125. /**
  60126. * Clones, or makes a deep copy, of the CSG
  60127. * @returns A new CSG
  60128. */
  60129. clone(): CSG;
  60130. /**
  60131. * Unions this CSG with another CSG
  60132. * @param csg The CSG to union against this CSG
  60133. * @returns The unioned CSG
  60134. */
  60135. union(csg: CSG): CSG;
  60136. /**
  60137. * Unions this CSG with another CSG in place
  60138. * @param csg The CSG to union against this CSG
  60139. */
  60140. unionInPlace(csg: CSG): void;
  60141. /**
  60142. * Subtracts this CSG with another CSG
  60143. * @param csg The CSG to subtract against this CSG
  60144. * @returns A new CSG
  60145. */
  60146. subtract(csg: CSG): CSG;
  60147. /**
  60148. * Subtracts this CSG with another CSG in place
  60149. * @param csg The CSG to subtact against this CSG
  60150. */
  60151. subtractInPlace(csg: CSG): void;
  60152. /**
  60153. * Intersect this CSG with another CSG
  60154. * @param csg The CSG to intersect against this CSG
  60155. * @returns A new CSG
  60156. */
  60157. intersect(csg: CSG): CSG;
  60158. /**
  60159. * Intersects this CSG with another CSG in place
  60160. * @param csg The CSG to intersect against this CSG
  60161. */
  60162. intersectInPlace(csg: CSG): void;
  60163. /**
  60164. * Return a new CSG solid with solid and empty space switched. This solid is
  60165. * not modified.
  60166. * @returns A new CSG solid with solid and empty space switched
  60167. */
  60168. inverse(): CSG;
  60169. /**
  60170. * Inverses the CSG in place
  60171. */
  60172. inverseInPlace(): void;
  60173. /**
  60174. * This is used to keep meshes transformations so they can be restored
  60175. * when we build back a Babylon Mesh
  60176. * NB : All CSG operations are performed in world coordinates
  60177. * @param csg The CSG to copy the transform attributes from
  60178. * @returns This CSG
  60179. */
  60180. copyTransformAttributes(csg: CSG): CSG;
  60181. /**
  60182. * Build Raw mesh from CSG
  60183. * Coordinates here are in world space
  60184. * @param name The name of the mesh geometry
  60185. * @param scene The Scene
  60186. * @param keepSubMeshes Specifies if the submeshes should be kept
  60187. * @returns A new Mesh
  60188. */
  60189. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60190. /**
  60191. * Build Mesh from CSG taking material and transforms into account
  60192. * @param name The name of the Mesh
  60193. * @param material The material of the Mesh
  60194. * @param scene The Scene
  60195. * @param keepSubMeshes Specifies if submeshes should be kept
  60196. * @returns The new Mesh
  60197. */
  60198. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60199. }
  60200. }
  60201. declare module BABYLON {
  60202. /**
  60203. * Class used to create a trail following a mesh
  60204. */
  60205. export class TrailMesh extends Mesh {
  60206. private _generator;
  60207. private _autoStart;
  60208. private _running;
  60209. private _diameter;
  60210. private _length;
  60211. private _sectionPolygonPointsCount;
  60212. private _sectionVectors;
  60213. private _sectionNormalVectors;
  60214. private _beforeRenderObserver;
  60215. /**
  60216. * @constructor
  60217. * @param name The value used by scene.getMeshByName() to do a lookup.
  60218. * @param generator The mesh or transform node to generate a trail.
  60219. * @param scene The scene to add this mesh to.
  60220. * @param diameter Diameter of trailing mesh. Default is 1.
  60221. * @param length Length of trailing mesh. Default is 60.
  60222. * @param autoStart Automatically start trailing mesh. Default true.
  60223. */
  60224. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60225. /**
  60226. * "TrailMesh"
  60227. * @returns "TrailMesh"
  60228. */
  60229. getClassName(): string;
  60230. private _createMesh;
  60231. /**
  60232. * Start trailing mesh.
  60233. */
  60234. start(): void;
  60235. /**
  60236. * Stop trailing mesh.
  60237. */
  60238. stop(): void;
  60239. /**
  60240. * Update trailing mesh geometry.
  60241. */
  60242. update(): void;
  60243. /**
  60244. * Returns a new TrailMesh object.
  60245. * @param name is a string, the name given to the new mesh
  60246. * @param newGenerator use new generator object for cloned trail mesh
  60247. * @returns a new mesh
  60248. */
  60249. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60250. /**
  60251. * Serializes this trail mesh
  60252. * @param serializationObject object to write serialization to
  60253. */
  60254. serialize(serializationObject: any): void;
  60255. /**
  60256. * Parses a serialized trail mesh
  60257. * @param parsedMesh the serialized mesh
  60258. * @param scene the scene to create the trail mesh in
  60259. * @returns the created trail mesh
  60260. */
  60261. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60262. }
  60263. }
  60264. declare module BABYLON {
  60265. /**
  60266. * Class containing static functions to help procedurally build meshes
  60267. */
  60268. export class TiledBoxBuilder {
  60269. /**
  60270. * Creates a box mesh
  60271. * 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)
  60272. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60274. * * 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
  60275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60276. * @param name defines the name of the mesh
  60277. * @param options defines the options used to create the mesh
  60278. * @param scene defines the hosting scene
  60279. * @returns the box mesh
  60280. */
  60281. static CreateTiledBox(name: string, options: {
  60282. pattern?: number;
  60283. width?: number;
  60284. height?: number;
  60285. depth?: number;
  60286. tileSize?: number;
  60287. tileWidth?: number;
  60288. tileHeight?: number;
  60289. alignHorizontal?: number;
  60290. alignVertical?: number;
  60291. faceUV?: Vector4[];
  60292. faceColors?: Color4[];
  60293. sideOrientation?: number;
  60294. updatable?: boolean;
  60295. }, scene?: Nullable<Scene>): Mesh;
  60296. }
  60297. }
  60298. declare module BABYLON {
  60299. /**
  60300. * Class containing static functions to help procedurally build meshes
  60301. */
  60302. export class TorusKnotBuilder {
  60303. /**
  60304. * Creates a torus knot mesh
  60305. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60306. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60307. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60308. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60310. * * 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
  60311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60312. * @param name defines the name of the mesh
  60313. * @param options defines the options used to create the mesh
  60314. * @param scene defines the hosting scene
  60315. * @returns the torus knot mesh
  60316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60317. */
  60318. static CreateTorusKnot(name: string, options: {
  60319. radius?: number;
  60320. tube?: number;
  60321. radialSegments?: number;
  60322. tubularSegments?: number;
  60323. p?: number;
  60324. q?: number;
  60325. updatable?: boolean;
  60326. sideOrientation?: number;
  60327. frontUVs?: Vector4;
  60328. backUVs?: Vector4;
  60329. }, scene: any): Mesh;
  60330. }
  60331. }
  60332. declare module BABYLON {
  60333. /**
  60334. * Polygon
  60335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60336. */
  60337. export class Polygon {
  60338. /**
  60339. * Creates a rectangle
  60340. * @param xmin bottom X coord
  60341. * @param ymin bottom Y coord
  60342. * @param xmax top X coord
  60343. * @param ymax top Y coord
  60344. * @returns points that make the resulting rectation
  60345. */
  60346. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60347. /**
  60348. * Creates a circle
  60349. * @param radius radius of circle
  60350. * @param cx scale in x
  60351. * @param cy scale in y
  60352. * @param numberOfSides number of sides that make up the circle
  60353. * @returns points that make the resulting circle
  60354. */
  60355. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60356. /**
  60357. * Creates a polygon from input string
  60358. * @param input Input polygon data
  60359. * @returns the parsed points
  60360. */
  60361. static Parse(input: string): Vector2[];
  60362. /**
  60363. * Starts building a polygon from x and y coordinates
  60364. * @param x x coordinate
  60365. * @param y y coordinate
  60366. * @returns the started path2
  60367. */
  60368. static StartingAt(x: number, y: number): Path2;
  60369. }
  60370. /**
  60371. * Builds a polygon
  60372. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60373. */
  60374. export class PolygonMeshBuilder {
  60375. private _points;
  60376. private _outlinepoints;
  60377. private _holes;
  60378. private _name;
  60379. private _scene;
  60380. private _epoints;
  60381. private _eholes;
  60382. private _addToepoint;
  60383. /**
  60384. * Babylon reference to the earcut plugin.
  60385. */
  60386. bjsEarcut: any;
  60387. /**
  60388. * Creates a PolygonMeshBuilder
  60389. * @param name name of the builder
  60390. * @param contours Path of the polygon
  60391. * @param scene scene to add to when creating the mesh
  60392. * @param earcutInjection can be used to inject your own earcut reference
  60393. */
  60394. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60395. /**
  60396. * Adds a whole within the polygon
  60397. * @param hole Array of points defining the hole
  60398. * @returns this
  60399. */
  60400. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60401. /**
  60402. * Creates the polygon
  60403. * @param updatable If the mesh should be updatable
  60404. * @param depth The depth of the mesh created
  60405. * @returns the created mesh
  60406. */
  60407. build(updatable?: boolean, depth?: number): Mesh;
  60408. /**
  60409. * Creates the polygon
  60410. * @param depth The depth of the mesh created
  60411. * @returns the created VertexData
  60412. */
  60413. buildVertexData(depth?: number): VertexData;
  60414. /**
  60415. * Adds a side to the polygon
  60416. * @param positions points that make the polygon
  60417. * @param normals normals of the polygon
  60418. * @param uvs uvs of the polygon
  60419. * @param indices indices of the polygon
  60420. * @param bounds bounds of the polygon
  60421. * @param points points of the polygon
  60422. * @param depth depth of the polygon
  60423. * @param flip flip of the polygon
  60424. */
  60425. private addSide;
  60426. }
  60427. }
  60428. declare module BABYLON {
  60429. /**
  60430. * Class containing static functions to help procedurally build meshes
  60431. */
  60432. export class PolygonBuilder {
  60433. /**
  60434. * Creates a polygon mesh
  60435. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60436. * * 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
  60437. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60439. * * 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)
  60440. * * Remember you can only change the shape positions, not their number when updating a polygon
  60441. * @param name defines the name of the mesh
  60442. * @param options defines the options used to create the mesh
  60443. * @param scene defines the hosting scene
  60444. * @param earcutInjection can be used to inject your own earcut reference
  60445. * @returns the polygon mesh
  60446. */
  60447. static CreatePolygon(name: string, options: {
  60448. shape: Vector3[];
  60449. holes?: Vector3[][];
  60450. depth?: number;
  60451. faceUV?: Vector4[];
  60452. faceColors?: Color4[];
  60453. updatable?: boolean;
  60454. sideOrientation?: number;
  60455. frontUVs?: Vector4;
  60456. backUVs?: Vector4;
  60457. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60458. /**
  60459. * Creates an extruded polygon mesh, with depth in the Y direction.
  60460. * * 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)
  60461. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60462. * @param name defines the name of the mesh
  60463. * @param options defines the options used to create the mesh
  60464. * @param scene defines the hosting scene
  60465. * @param earcutInjection can be used to inject your own earcut reference
  60466. * @returns the polygon mesh
  60467. */
  60468. static ExtrudePolygon(name: string, options: {
  60469. shape: Vector3[];
  60470. holes?: Vector3[][];
  60471. depth?: number;
  60472. faceUV?: Vector4[];
  60473. faceColors?: Color4[];
  60474. updatable?: boolean;
  60475. sideOrientation?: number;
  60476. frontUVs?: Vector4;
  60477. backUVs?: Vector4;
  60478. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60479. }
  60480. }
  60481. declare module BABYLON {
  60482. /**
  60483. * Class containing static functions to help procedurally build meshes
  60484. */
  60485. export class LatheBuilder {
  60486. /**
  60487. * Creates lathe mesh.
  60488. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60489. * * 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
  60490. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60491. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60492. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60493. * * 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
  60494. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60495. * * 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
  60496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60497. * * 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
  60498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60500. * @param name defines the name of the mesh
  60501. * @param options defines the options used to create the mesh
  60502. * @param scene defines the hosting scene
  60503. * @returns the lathe mesh
  60504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60505. */
  60506. static CreateLathe(name: string, options: {
  60507. shape: Vector3[];
  60508. radius?: number;
  60509. tessellation?: number;
  60510. clip?: number;
  60511. arc?: number;
  60512. closed?: boolean;
  60513. updatable?: boolean;
  60514. sideOrientation?: number;
  60515. frontUVs?: Vector4;
  60516. backUVs?: Vector4;
  60517. cap?: number;
  60518. invertUV?: boolean;
  60519. }, scene?: Nullable<Scene>): Mesh;
  60520. }
  60521. }
  60522. declare module BABYLON {
  60523. /**
  60524. * Class containing static functions to help procedurally build meshes
  60525. */
  60526. export class TiledPlaneBuilder {
  60527. /**
  60528. * Creates a tiled plane mesh
  60529. * * The parameter `pattern` will, depending on value, do nothing or
  60530. * * * flip (reflect about central vertical) alternate tiles across and up
  60531. * * * flip every tile on alternate rows
  60532. * * * rotate (180 degs) alternate tiles across and up
  60533. * * * rotate every tile on alternate rows
  60534. * * * flip and rotate alternate tiles across and up
  60535. * * * flip and rotate every tile on alternate rows
  60536. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60537. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60538. * * 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
  60539. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60540. * * 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)
  60541. * * 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)
  60542. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60543. * @param name defines the name of the mesh
  60544. * @param options defines the options used to create the mesh
  60545. * @param scene defines the hosting scene
  60546. * @returns the box mesh
  60547. */
  60548. static CreateTiledPlane(name: string, options: {
  60549. pattern?: number;
  60550. tileSize?: number;
  60551. tileWidth?: number;
  60552. tileHeight?: number;
  60553. size?: number;
  60554. width?: number;
  60555. height?: number;
  60556. alignHorizontal?: number;
  60557. alignVertical?: number;
  60558. sideOrientation?: number;
  60559. frontUVs?: Vector4;
  60560. backUVs?: Vector4;
  60561. updatable?: boolean;
  60562. }, scene?: Nullable<Scene>): Mesh;
  60563. }
  60564. }
  60565. declare module BABYLON {
  60566. /**
  60567. * Class containing static functions to help procedurally build meshes
  60568. */
  60569. export class TubeBuilder {
  60570. /**
  60571. * Creates a tube mesh.
  60572. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60573. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60574. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60575. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60576. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60577. * * 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)
  60578. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60579. * * 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
  60580. * * 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
  60581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60582. * * 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
  60583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60585. * @param name defines the name of the mesh
  60586. * @param options defines the options used to create the mesh
  60587. * @param scene defines the hosting scene
  60588. * @returns the tube mesh
  60589. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60590. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60591. */
  60592. static CreateTube(name: string, options: {
  60593. path: Vector3[];
  60594. radius?: number;
  60595. tessellation?: number;
  60596. radiusFunction?: {
  60597. (i: number, distance: number): number;
  60598. };
  60599. cap?: number;
  60600. arc?: number;
  60601. updatable?: boolean;
  60602. sideOrientation?: number;
  60603. frontUVs?: Vector4;
  60604. backUVs?: Vector4;
  60605. instance?: Mesh;
  60606. invertUV?: boolean;
  60607. }, scene?: Nullable<Scene>): Mesh;
  60608. }
  60609. }
  60610. declare module BABYLON {
  60611. /**
  60612. * Class containing static functions to help procedurally build meshes
  60613. */
  60614. export class IcoSphereBuilder {
  60615. /**
  60616. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60617. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60618. * * 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`)
  60619. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60620. * * 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
  60621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60622. * * 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
  60623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60624. * @param name defines the name of the mesh
  60625. * @param options defines the options used to create the mesh
  60626. * @param scene defines the hosting scene
  60627. * @returns the icosahedron mesh
  60628. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60629. */
  60630. static CreateIcoSphere(name: string, options: {
  60631. radius?: number;
  60632. radiusX?: number;
  60633. radiusY?: number;
  60634. radiusZ?: number;
  60635. flat?: boolean;
  60636. subdivisions?: number;
  60637. sideOrientation?: number;
  60638. frontUVs?: Vector4;
  60639. backUVs?: Vector4;
  60640. updatable?: boolean;
  60641. }, scene?: Nullable<Scene>): Mesh;
  60642. }
  60643. }
  60644. declare module BABYLON {
  60645. /**
  60646. * Class containing static functions to help procedurally build meshes
  60647. */
  60648. export class DecalBuilder {
  60649. /**
  60650. * Creates a decal mesh.
  60651. * 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
  60652. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60653. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60654. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60655. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60656. * @param name defines the name of the mesh
  60657. * @param sourceMesh defines the mesh where the decal must be applied
  60658. * @param options defines the options used to create the mesh
  60659. * @param scene defines the hosting scene
  60660. * @returns the decal mesh
  60661. * @see https://doc.babylonjs.com/how_to/decals
  60662. */
  60663. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60664. position?: Vector3;
  60665. normal?: Vector3;
  60666. size?: Vector3;
  60667. angle?: number;
  60668. }): Mesh;
  60669. }
  60670. }
  60671. declare module BABYLON {
  60672. /**
  60673. * Class containing static functions to help procedurally build meshes
  60674. */
  60675. export class MeshBuilder {
  60676. /**
  60677. * Creates a box mesh
  60678. * * The parameter `size` sets the size (float) of each box side (default 1)
  60679. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60680. * * 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)
  60681. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60683. * * 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
  60684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60685. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60686. * @param name defines the name of the mesh
  60687. * @param options defines the options used to create the mesh
  60688. * @param scene defines the hosting scene
  60689. * @returns the box mesh
  60690. */
  60691. static CreateBox(name: string, options: {
  60692. size?: number;
  60693. width?: number;
  60694. height?: number;
  60695. depth?: number;
  60696. faceUV?: Vector4[];
  60697. faceColors?: Color4[];
  60698. sideOrientation?: number;
  60699. frontUVs?: Vector4;
  60700. backUVs?: Vector4;
  60701. updatable?: boolean;
  60702. }, scene?: Nullable<Scene>): Mesh;
  60703. /**
  60704. * Creates a tiled box mesh
  60705. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60707. * @param name defines the name of the mesh
  60708. * @param options defines the options used to create the mesh
  60709. * @param scene defines the hosting scene
  60710. * @returns the tiled box mesh
  60711. */
  60712. static CreateTiledBox(name: string, options: {
  60713. pattern?: number;
  60714. size?: number;
  60715. width?: number;
  60716. height?: number;
  60717. depth: number;
  60718. tileSize?: number;
  60719. tileWidth?: number;
  60720. tileHeight?: number;
  60721. faceUV?: Vector4[];
  60722. faceColors?: Color4[];
  60723. alignHorizontal?: number;
  60724. alignVertical?: number;
  60725. sideOrientation?: number;
  60726. updatable?: boolean;
  60727. }, scene?: Nullable<Scene>): Mesh;
  60728. /**
  60729. * Creates a sphere mesh
  60730. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60731. * * 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`)
  60732. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60733. * * 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
  60734. * * 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)
  60735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60736. * * 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
  60737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60738. * @param name defines the name of the mesh
  60739. * @param options defines the options used to create the mesh
  60740. * @param scene defines the hosting scene
  60741. * @returns the sphere mesh
  60742. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60743. */
  60744. static CreateSphere(name: string, options: {
  60745. segments?: number;
  60746. diameter?: number;
  60747. diameterX?: number;
  60748. diameterY?: number;
  60749. diameterZ?: number;
  60750. arc?: number;
  60751. slice?: number;
  60752. sideOrientation?: number;
  60753. frontUVs?: Vector4;
  60754. backUVs?: Vector4;
  60755. updatable?: boolean;
  60756. }, scene?: Nullable<Scene>): Mesh;
  60757. /**
  60758. * Creates a plane polygonal mesh. By default, this is a disc
  60759. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60760. * * 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
  60761. * * 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
  60762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60763. * * 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
  60764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60765. * @param name defines the name of the mesh
  60766. * @param options defines the options used to create the mesh
  60767. * @param scene defines the hosting scene
  60768. * @returns the plane polygonal mesh
  60769. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60770. */
  60771. static CreateDisc(name: string, options: {
  60772. radius?: number;
  60773. tessellation?: number;
  60774. arc?: number;
  60775. updatable?: boolean;
  60776. sideOrientation?: number;
  60777. frontUVs?: Vector4;
  60778. backUVs?: Vector4;
  60779. }, scene?: Nullable<Scene>): Mesh;
  60780. /**
  60781. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60782. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60783. * * 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`)
  60784. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60785. * * 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
  60786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60787. * * 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
  60788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60789. * @param name defines the name of the mesh
  60790. * @param options defines the options used to create the mesh
  60791. * @param scene defines the hosting scene
  60792. * @returns the icosahedron mesh
  60793. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60794. */
  60795. static CreateIcoSphere(name: string, options: {
  60796. radius?: number;
  60797. radiusX?: number;
  60798. radiusY?: number;
  60799. radiusZ?: number;
  60800. flat?: boolean;
  60801. subdivisions?: number;
  60802. sideOrientation?: number;
  60803. frontUVs?: Vector4;
  60804. backUVs?: Vector4;
  60805. updatable?: boolean;
  60806. }, scene?: Nullable<Scene>): Mesh;
  60807. /**
  60808. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60809. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60810. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60811. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60812. * * 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
  60813. * * 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
  60814. * * 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
  60815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60816. * * 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
  60817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60818. * * 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
  60819. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60820. * * 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
  60821. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60823. * @param name defines the name of the mesh
  60824. * @param options defines the options used to create the mesh
  60825. * @param scene defines the hosting scene
  60826. * @returns the ribbon mesh
  60827. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60828. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60829. */
  60830. static CreateRibbon(name: string, options: {
  60831. pathArray: Vector3[][];
  60832. closeArray?: boolean;
  60833. closePath?: boolean;
  60834. offset?: number;
  60835. updatable?: boolean;
  60836. sideOrientation?: number;
  60837. frontUVs?: Vector4;
  60838. backUVs?: Vector4;
  60839. instance?: Mesh;
  60840. invertUV?: boolean;
  60841. uvs?: Vector2[];
  60842. colors?: Color4[];
  60843. }, scene?: Nullable<Scene>): Mesh;
  60844. /**
  60845. * Creates a cylinder or a cone mesh
  60846. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60847. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60848. * * 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.
  60849. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60850. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60851. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60852. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60853. * * 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).
  60854. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60855. * * 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).
  60856. * * 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
  60857. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60858. * * 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
  60859. * * 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.
  60860. * * If `enclose` is false, a ring surface is one element.
  60861. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60862. * * 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
  60863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60864. * * 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
  60865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60866. * @param name defines the name of the mesh
  60867. * @param options defines the options used to create the mesh
  60868. * @param scene defines the hosting scene
  60869. * @returns the cylinder mesh
  60870. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60871. */
  60872. static CreateCylinder(name: string, options: {
  60873. height?: number;
  60874. diameterTop?: number;
  60875. diameterBottom?: number;
  60876. diameter?: number;
  60877. tessellation?: number;
  60878. subdivisions?: number;
  60879. arc?: number;
  60880. faceColors?: Color4[];
  60881. faceUV?: Vector4[];
  60882. updatable?: boolean;
  60883. hasRings?: boolean;
  60884. enclose?: boolean;
  60885. cap?: number;
  60886. sideOrientation?: number;
  60887. frontUVs?: Vector4;
  60888. backUVs?: Vector4;
  60889. }, scene?: Nullable<Scene>): Mesh;
  60890. /**
  60891. * Creates a torus mesh
  60892. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60893. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60894. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60896. * * 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
  60897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60898. * @param name defines the name of the mesh
  60899. * @param options defines the options used to create the mesh
  60900. * @param scene defines the hosting scene
  60901. * @returns the torus mesh
  60902. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60903. */
  60904. static CreateTorus(name: string, options: {
  60905. diameter?: number;
  60906. thickness?: number;
  60907. tessellation?: number;
  60908. updatable?: boolean;
  60909. sideOrientation?: number;
  60910. frontUVs?: Vector4;
  60911. backUVs?: Vector4;
  60912. }, scene?: Nullable<Scene>): Mesh;
  60913. /**
  60914. * Creates a torus knot mesh
  60915. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60916. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60917. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60918. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60920. * * 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
  60921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60922. * @param name defines the name of the mesh
  60923. * @param options defines the options used to create the mesh
  60924. * @param scene defines the hosting scene
  60925. * @returns the torus knot mesh
  60926. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60927. */
  60928. static CreateTorusKnot(name: string, options: {
  60929. radius?: number;
  60930. tube?: number;
  60931. radialSegments?: number;
  60932. tubularSegments?: number;
  60933. p?: number;
  60934. q?: number;
  60935. updatable?: boolean;
  60936. sideOrientation?: number;
  60937. frontUVs?: Vector4;
  60938. backUVs?: Vector4;
  60939. }, scene?: Nullable<Scene>): Mesh;
  60940. /**
  60941. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60942. * * 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
  60943. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60944. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60945. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60946. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60947. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60948. * * 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
  60949. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60952. * @param name defines the name of the new line system
  60953. * @param options defines the options used to create the line system
  60954. * @param scene defines the hosting scene
  60955. * @returns a new line system mesh
  60956. */
  60957. static CreateLineSystem(name: string, options: {
  60958. lines: Vector3[][];
  60959. updatable?: boolean;
  60960. instance?: Nullable<LinesMesh>;
  60961. colors?: Nullable<Color4[][]>;
  60962. useVertexAlpha?: boolean;
  60963. }, scene: Nullable<Scene>): LinesMesh;
  60964. /**
  60965. * Creates a line mesh
  60966. * 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
  60967. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60968. * * The parameter `points` is an array successive Vector3
  60969. * * 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
  60970. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60971. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60972. * * When updating an instance, remember that only point positions can change, not the number of points
  60973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60975. * @param name defines the name of the new line system
  60976. * @param options defines the options used to create the line system
  60977. * @param scene defines the hosting scene
  60978. * @returns a new line mesh
  60979. */
  60980. static CreateLines(name: string, options: {
  60981. points: Vector3[];
  60982. updatable?: boolean;
  60983. instance?: Nullable<LinesMesh>;
  60984. colors?: Color4[];
  60985. useVertexAlpha?: boolean;
  60986. }, scene?: Nullable<Scene>): LinesMesh;
  60987. /**
  60988. * Creates a dashed line mesh
  60989. * * 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
  60990. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60991. * * The parameter `points` is an array successive Vector3
  60992. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60993. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60994. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60995. * * 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
  60996. * * When updating an instance, remember that only point positions can change, not the number of points
  60997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60998. * @param name defines the name of the mesh
  60999. * @param options defines the options used to create the mesh
  61000. * @param scene defines the hosting scene
  61001. * @returns the dashed line mesh
  61002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61003. */
  61004. static CreateDashedLines(name: string, options: {
  61005. points: Vector3[];
  61006. dashSize?: number;
  61007. gapSize?: number;
  61008. dashNb?: number;
  61009. updatable?: boolean;
  61010. instance?: LinesMesh;
  61011. }, scene?: Nullable<Scene>): LinesMesh;
  61012. /**
  61013. * 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.
  61014. * * 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.
  61015. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61016. * * 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.
  61017. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61018. * * 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
  61019. * * 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
  61020. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61022. * * 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
  61023. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61025. * @param name defines the name of the mesh
  61026. * @param options defines the options used to create the mesh
  61027. * @param scene defines the hosting scene
  61028. * @returns the extruded shape mesh
  61029. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61031. */
  61032. static ExtrudeShape(name: string, options: {
  61033. shape: Vector3[];
  61034. path: Vector3[];
  61035. scale?: number;
  61036. rotation?: number;
  61037. cap?: number;
  61038. updatable?: boolean;
  61039. sideOrientation?: number;
  61040. frontUVs?: Vector4;
  61041. backUVs?: Vector4;
  61042. instance?: Mesh;
  61043. invertUV?: boolean;
  61044. }, scene?: Nullable<Scene>): Mesh;
  61045. /**
  61046. * Creates an custom extruded shape mesh.
  61047. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61048. * * 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.
  61049. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61050. * * 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
  61051. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61052. * * 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
  61053. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61054. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61055. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61056. * * 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
  61057. * * 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
  61058. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61060. * * 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
  61061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61063. * @param name defines the name of the mesh
  61064. * @param options defines the options used to create the mesh
  61065. * @param scene defines the hosting scene
  61066. * @returns the custom extruded shape mesh
  61067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61068. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61070. */
  61071. static ExtrudeShapeCustom(name: string, options: {
  61072. shape: Vector3[];
  61073. path: Vector3[];
  61074. scaleFunction?: any;
  61075. rotationFunction?: any;
  61076. ribbonCloseArray?: boolean;
  61077. ribbonClosePath?: boolean;
  61078. cap?: number;
  61079. updatable?: boolean;
  61080. sideOrientation?: number;
  61081. frontUVs?: Vector4;
  61082. backUVs?: Vector4;
  61083. instance?: Mesh;
  61084. invertUV?: boolean;
  61085. }, scene?: Nullable<Scene>): Mesh;
  61086. /**
  61087. * Creates lathe mesh.
  61088. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61089. * * 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
  61090. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61091. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61092. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61093. * * 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
  61094. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61095. * * 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
  61096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61097. * * 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
  61098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61100. * @param name defines the name of the mesh
  61101. * @param options defines the options used to create the mesh
  61102. * @param scene defines the hosting scene
  61103. * @returns the lathe mesh
  61104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61105. */
  61106. static CreateLathe(name: string, options: {
  61107. shape: Vector3[];
  61108. radius?: number;
  61109. tessellation?: number;
  61110. clip?: number;
  61111. arc?: number;
  61112. closed?: boolean;
  61113. updatable?: boolean;
  61114. sideOrientation?: number;
  61115. frontUVs?: Vector4;
  61116. backUVs?: Vector4;
  61117. cap?: number;
  61118. invertUV?: boolean;
  61119. }, scene?: Nullable<Scene>): Mesh;
  61120. /**
  61121. * Creates a tiled plane mesh
  61122. * * You can set a limited pattern arrangement with the tiles
  61123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61124. * * 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
  61125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61126. * @param name defines the name of the mesh
  61127. * @param options defines the options used to create the mesh
  61128. * @param scene defines the hosting scene
  61129. * @returns the plane mesh
  61130. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61131. */
  61132. static CreateTiledPlane(name: string, options: {
  61133. pattern?: number;
  61134. tileSize?: number;
  61135. tileWidth?: number;
  61136. tileHeight?: number;
  61137. size?: number;
  61138. width?: number;
  61139. height?: number;
  61140. alignHorizontal?: number;
  61141. alignVertical?: number;
  61142. sideOrientation?: number;
  61143. frontUVs?: Vector4;
  61144. backUVs?: Vector4;
  61145. updatable?: boolean;
  61146. }, scene?: Nullable<Scene>): Mesh;
  61147. /**
  61148. * Creates a plane mesh
  61149. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61150. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61151. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61153. * * 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
  61154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61155. * @param name defines the name of the mesh
  61156. * @param options defines the options used to create the mesh
  61157. * @param scene defines the hosting scene
  61158. * @returns the plane mesh
  61159. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61160. */
  61161. static CreatePlane(name: string, options: {
  61162. size?: number;
  61163. width?: number;
  61164. height?: number;
  61165. sideOrientation?: number;
  61166. frontUVs?: Vector4;
  61167. backUVs?: Vector4;
  61168. updatable?: boolean;
  61169. sourcePlane?: Plane;
  61170. }, scene?: Nullable<Scene>): Mesh;
  61171. /**
  61172. * Creates a ground mesh
  61173. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61174. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61176. * @param name defines the name of the mesh
  61177. * @param options defines the options used to create the mesh
  61178. * @param scene defines the hosting scene
  61179. * @returns the ground mesh
  61180. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61181. */
  61182. static CreateGround(name: string, options: {
  61183. width?: number;
  61184. height?: number;
  61185. subdivisions?: number;
  61186. subdivisionsX?: number;
  61187. subdivisionsY?: number;
  61188. updatable?: boolean;
  61189. }, scene?: Nullable<Scene>): Mesh;
  61190. /**
  61191. * Creates a tiled ground mesh
  61192. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61193. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61194. * * 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
  61195. * * 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
  61196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61197. * @param name defines the name of the mesh
  61198. * @param options defines the options used to create the mesh
  61199. * @param scene defines the hosting scene
  61200. * @returns the tiled ground mesh
  61201. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61202. */
  61203. static CreateTiledGround(name: string, options: {
  61204. xmin: number;
  61205. zmin: number;
  61206. xmax: number;
  61207. zmax: number;
  61208. subdivisions?: {
  61209. w: number;
  61210. h: number;
  61211. };
  61212. precision?: {
  61213. w: number;
  61214. h: number;
  61215. };
  61216. updatable?: boolean;
  61217. }, scene?: Nullable<Scene>): Mesh;
  61218. /**
  61219. * Creates a ground mesh from a height map
  61220. * * The parameter `url` sets the URL of the height map image resource.
  61221. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61222. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61223. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61224. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61225. * * 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.
  61226. * * 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).
  61227. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61229. * @param name defines the name of the mesh
  61230. * @param url defines the url to the height map
  61231. * @param options defines the options used to create the mesh
  61232. * @param scene defines the hosting scene
  61233. * @returns the ground mesh
  61234. * @see https://doc.babylonjs.com/babylon101/height_map
  61235. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61236. */
  61237. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61238. width?: number;
  61239. height?: number;
  61240. subdivisions?: number;
  61241. minHeight?: number;
  61242. maxHeight?: number;
  61243. colorFilter?: Color3;
  61244. alphaFilter?: number;
  61245. updatable?: boolean;
  61246. onReady?: (mesh: GroundMesh) => void;
  61247. }, scene?: Nullable<Scene>): GroundMesh;
  61248. /**
  61249. * Creates a polygon mesh
  61250. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61251. * * 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
  61252. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61254. * * 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)
  61255. * * Remember you can only change the shape positions, not their number when updating a polygon
  61256. * @param name defines the name of the mesh
  61257. * @param options defines the options used to create the mesh
  61258. * @param scene defines the hosting scene
  61259. * @param earcutInjection can be used to inject your own earcut reference
  61260. * @returns the polygon mesh
  61261. */
  61262. static CreatePolygon(name: string, options: {
  61263. shape: Vector3[];
  61264. holes?: Vector3[][];
  61265. depth?: number;
  61266. faceUV?: Vector4[];
  61267. faceColors?: Color4[];
  61268. updatable?: boolean;
  61269. sideOrientation?: number;
  61270. frontUVs?: Vector4;
  61271. backUVs?: Vector4;
  61272. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61273. /**
  61274. * Creates an extruded polygon mesh, with depth in the Y direction.
  61275. * * 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)
  61276. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61277. * @param name defines the name of the mesh
  61278. * @param options defines the options used to create the mesh
  61279. * @param scene defines the hosting scene
  61280. * @param earcutInjection can be used to inject your own earcut reference
  61281. * @returns the polygon mesh
  61282. */
  61283. static ExtrudePolygon(name: string, options: {
  61284. shape: Vector3[];
  61285. holes?: Vector3[][];
  61286. depth?: number;
  61287. faceUV?: Vector4[];
  61288. faceColors?: Color4[];
  61289. updatable?: boolean;
  61290. sideOrientation?: number;
  61291. frontUVs?: Vector4;
  61292. backUVs?: Vector4;
  61293. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61294. /**
  61295. * Creates a tube mesh.
  61296. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61297. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61298. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61299. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61300. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61301. * * 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)
  61302. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61303. * * 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
  61304. * * 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
  61305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61306. * * 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
  61307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61309. * @param name defines the name of the mesh
  61310. * @param options defines the options used to create the mesh
  61311. * @param scene defines the hosting scene
  61312. * @returns the tube mesh
  61313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61314. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61315. */
  61316. static CreateTube(name: string, options: {
  61317. path: Vector3[];
  61318. radius?: number;
  61319. tessellation?: number;
  61320. radiusFunction?: {
  61321. (i: number, distance: number): number;
  61322. };
  61323. cap?: number;
  61324. arc?: number;
  61325. updatable?: boolean;
  61326. sideOrientation?: number;
  61327. frontUVs?: Vector4;
  61328. backUVs?: Vector4;
  61329. instance?: Mesh;
  61330. invertUV?: boolean;
  61331. }, scene?: Nullable<Scene>): Mesh;
  61332. /**
  61333. * Creates a polyhedron mesh
  61334. * * 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
  61335. * * The parameter `size` (positive float, default 1) sets the polygon size
  61336. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61337. * * 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`
  61338. * * 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
  61339. * * 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)`)
  61340. * * 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
  61341. * * 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
  61342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61343. * * 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
  61344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61345. * @param name defines the name of the mesh
  61346. * @param options defines the options used to create the mesh
  61347. * @param scene defines the hosting scene
  61348. * @returns the polyhedron mesh
  61349. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61350. */
  61351. static CreatePolyhedron(name: string, options: {
  61352. type?: number;
  61353. size?: number;
  61354. sizeX?: number;
  61355. sizeY?: number;
  61356. sizeZ?: number;
  61357. custom?: any;
  61358. faceUV?: Vector4[];
  61359. faceColors?: Color4[];
  61360. flat?: boolean;
  61361. updatable?: boolean;
  61362. sideOrientation?: number;
  61363. frontUVs?: Vector4;
  61364. backUVs?: Vector4;
  61365. }, scene?: Nullable<Scene>): Mesh;
  61366. /**
  61367. * Creates a decal mesh.
  61368. * 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
  61369. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61370. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61371. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61372. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61373. * @param name defines the name of the mesh
  61374. * @param sourceMesh defines the mesh where the decal must be applied
  61375. * @param options defines the options used to create the mesh
  61376. * @param scene defines the hosting scene
  61377. * @returns the decal mesh
  61378. * @see https://doc.babylonjs.com/how_to/decals
  61379. */
  61380. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61381. position?: Vector3;
  61382. normal?: Vector3;
  61383. size?: Vector3;
  61384. angle?: number;
  61385. }): Mesh;
  61386. }
  61387. }
  61388. declare module BABYLON {
  61389. /**
  61390. * A simplifier interface for future simplification implementations
  61391. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61392. */
  61393. export interface ISimplifier {
  61394. /**
  61395. * Simplification of a given mesh according to the given settings.
  61396. * Since this requires computation, it is assumed that the function runs async.
  61397. * @param settings The settings of the simplification, including quality and distance
  61398. * @param successCallback A callback that will be called after the mesh was simplified.
  61399. * @param errorCallback in case of an error, this callback will be called. optional.
  61400. */
  61401. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61402. }
  61403. /**
  61404. * Expected simplification settings.
  61405. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61406. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61407. */
  61408. export interface ISimplificationSettings {
  61409. /**
  61410. * Gets or sets the expected quality
  61411. */
  61412. quality: number;
  61413. /**
  61414. * Gets or sets the distance when this optimized version should be used
  61415. */
  61416. distance: number;
  61417. /**
  61418. * Gets an already optimized mesh
  61419. */
  61420. optimizeMesh?: boolean;
  61421. }
  61422. /**
  61423. * Class used to specify simplification options
  61424. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61425. */
  61426. export class SimplificationSettings implements ISimplificationSettings {
  61427. /** expected quality */
  61428. quality: number;
  61429. /** distance when this optimized version should be used */
  61430. distance: number;
  61431. /** already optimized mesh */
  61432. optimizeMesh?: boolean | undefined;
  61433. /**
  61434. * Creates a SimplificationSettings
  61435. * @param quality expected quality
  61436. * @param distance distance when this optimized version should be used
  61437. * @param optimizeMesh already optimized mesh
  61438. */
  61439. constructor(
  61440. /** expected quality */
  61441. quality: number,
  61442. /** distance when this optimized version should be used */
  61443. distance: number,
  61444. /** already optimized mesh */
  61445. optimizeMesh?: boolean | undefined);
  61446. }
  61447. /**
  61448. * Interface used to define a simplification task
  61449. */
  61450. export interface ISimplificationTask {
  61451. /**
  61452. * Array of settings
  61453. */
  61454. settings: Array<ISimplificationSettings>;
  61455. /**
  61456. * Simplification type
  61457. */
  61458. simplificationType: SimplificationType;
  61459. /**
  61460. * Mesh to simplify
  61461. */
  61462. mesh: Mesh;
  61463. /**
  61464. * Callback called on success
  61465. */
  61466. successCallback?: () => void;
  61467. /**
  61468. * Defines if parallel processing can be used
  61469. */
  61470. parallelProcessing: boolean;
  61471. }
  61472. /**
  61473. * Queue used to order the simplification tasks
  61474. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61475. */
  61476. export class SimplificationQueue {
  61477. private _simplificationArray;
  61478. /**
  61479. * Gets a boolean indicating that the process is still running
  61480. */
  61481. running: boolean;
  61482. /**
  61483. * Creates a new queue
  61484. */
  61485. constructor();
  61486. /**
  61487. * Adds a new simplification task
  61488. * @param task defines a task to add
  61489. */
  61490. addTask(task: ISimplificationTask): void;
  61491. /**
  61492. * Execute next task
  61493. */
  61494. executeNext(): void;
  61495. /**
  61496. * Execute a simplification task
  61497. * @param task defines the task to run
  61498. */
  61499. runSimplification(task: ISimplificationTask): void;
  61500. private getSimplifier;
  61501. }
  61502. /**
  61503. * The implemented types of simplification
  61504. * At the moment only Quadratic Error Decimation is implemented
  61505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61506. */
  61507. export enum SimplificationType {
  61508. /** Quadratic error decimation */
  61509. QUADRATIC = 0
  61510. }
  61511. }
  61512. declare module BABYLON {
  61513. interface Scene {
  61514. /** @hidden (Backing field) */
  61515. _simplificationQueue: SimplificationQueue;
  61516. /**
  61517. * Gets or sets the simplification queue attached to the scene
  61518. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61519. */
  61520. simplificationQueue: SimplificationQueue;
  61521. }
  61522. interface Mesh {
  61523. /**
  61524. * Simplify the mesh according to the given array of settings.
  61525. * Function will return immediately and will simplify async
  61526. * @param settings a collection of simplification settings
  61527. * @param parallelProcessing should all levels calculate parallel or one after the other
  61528. * @param simplificationType the type of simplification to run
  61529. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61530. * @returns the current mesh
  61531. */
  61532. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61533. }
  61534. /**
  61535. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61536. * created in a scene
  61537. */
  61538. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61539. /**
  61540. * The component name helpfull to identify the component in the list of scene components.
  61541. */
  61542. readonly name: string;
  61543. /**
  61544. * The scene the component belongs to.
  61545. */
  61546. scene: Scene;
  61547. /**
  61548. * Creates a new instance of the component for the given scene
  61549. * @param scene Defines the scene to register the component in
  61550. */
  61551. constructor(scene: Scene);
  61552. /**
  61553. * Registers the component in a given scene
  61554. */
  61555. register(): void;
  61556. /**
  61557. * Rebuilds the elements related to this component in case of
  61558. * context lost for instance.
  61559. */
  61560. rebuild(): void;
  61561. /**
  61562. * Disposes the component and the associated ressources
  61563. */
  61564. dispose(): void;
  61565. private _beforeCameraUpdate;
  61566. }
  61567. }
  61568. declare module BABYLON {
  61569. /**
  61570. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61571. */
  61572. export interface INavigationEnginePlugin {
  61573. /**
  61574. * plugin name
  61575. */
  61576. name: string;
  61577. /**
  61578. * Creates a navigation mesh
  61579. * @param meshes array of all the geometry used to compute the navigatio mesh
  61580. * @param parameters bunch of parameters used to filter geometry
  61581. */
  61582. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61583. /**
  61584. * Create a navigation mesh debug mesh
  61585. * @param scene is where the mesh will be added
  61586. * @returns debug display mesh
  61587. */
  61588. createDebugNavMesh(scene: Scene): Mesh;
  61589. /**
  61590. * Get a navigation mesh constrained position, closest to the parameter position
  61591. * @param position world position
  61592. * @returns the closest point to position constrained by the navigation mesh
  61593. */
  61594. getClosestPoint(position: Vector3): Vector3;
  61595. /**
  61596. * Get a navigation mesh constrained position, within a particular radius
  61597. * @param position world position
  61598. * @param maxRadius the maximum distance to the constrained world position
  61599. * @returns the closest point to position constrained by the navigation mesh
  61600. */
  61601. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61602. /**
  61603. * Compute the final position from a segment made of destination-position
  61604. * @param position world position
  61605. * @param destination world position
  61606. * @returns the resulting point along the navmesh
  61607. */
  61608. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61609. /**
  61610. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61611. * @param start world position
  61612. * @param end world position
  61613. * @returns array containing world position composing the path
  61614. */
  61615. computePath(start: Vector3, end: Vector3): Vector3[];
  61616. /**
  61617. * If this plugin is supported
  61618. * @returns true if plugin is supported
  61619. */
  61620. isSupported(): boolean;
  61621. /**
  61622. * Create a new Crowd so you can add agents
  61623. * @param maxAgents the maximum agent count in the crowd
  61624. * @param maxAgentRadius the maximum radius an agent can have
  61625. * @param scene to attach the crowd to
  61626. * @returns the crowd you can add agents to
  61627. */
  61628. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61629. /**
  61630. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61631. * The queries will try to find a solution within those bounds
  61632. * default is (1,1,1)
  61633. * @param extent x,y,z value that define the extent around the queries point of reference
  61634. */
  61635. setDefaultQueryExtent(extent: Vector3): void;
  61636. /**
  61637. * Get the Bounding box extent specified by setDefaultQueryExtent
  61638. * @returns the box extent values
  61639. */
  61640. getDefaultQueryExtent(): Vector3;
  61641. /**
  61642. * Release all resources
  61643. */
  61644. dispose(): void;
  61645. }
  61646. /**
  61647. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61648. */
  61649. export interface ICrowd {
  61650. /**
  61651. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61652. * You can attach anything to that node. The node position is updated in the scene update tick.
  61653. * @param pos world position that will be constrained by the navigation mesh
  61654. * @param parameters agent parameters
  61655. * @param transform hooked to the agent that will be update by the scene
  61656. * @returns agent index
  61657. */
  61658. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61659. /**
  61660. * Returns the agent position in world space
  61661. * @param index agent index returned by addAgent
  61662. * @returns world space position
  61663. */
  61664. getAgentPosition(index: number): Vector3;
  61665. /**
  61666. * Gets the agent velocity in world space
  61667. * @param index agent index returned by addAgent
  61668. * @returns world space velocity
  61669. */
  61670. getAgentVelocity(index: number): Vector3;
  61671. /**
  61672. * remove a particular agent previously created
  61673. * @param index agent index returned by addAgent
  61674. */
  61675. removeAgent(index: number): void;
  61676. /**
  61677. * get the list of all agents attached to this crowd
  61678. * @returns list of agent indices
  61679. */
  61680. getAgents(): number[];
  61681. /**
  61682. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61683. * @param deltaTime in seconds
  61684. */
  61685. update(deltaTime: number): void;
  61686. /**
  61687. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61688. * @param index agent index returned by addAgent
  61689. * @param destination targeted world position
  61690. */
  61691. agentGoto(index: number, destination: Vector3): void;
  61692. /**
  61693. * Teleport the agent to a new position
  61694. * @param index agent index returned by addAgent
  61695. * @param destination targeted world position
  61696. */
  61697. agentTeleport(index: number, destination: Vector3): void;
  61698. /**
  61699. * Update agent parameters
  61700. * @param index agent index returned by addAgent
  61701. * @param parameters agent parameters
  61702. */
  61703. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61704. /**
  61705. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61706. * The queries will try to find a solution within those bounds
  61707. * default is (1,1,1)
  61708. * @param extent x,y,z value that define the extent around the queries point of reference
  61709. */
  61710. setDefaultQueryExtent(extent: Vector3): void;
  61711. /**
  61712. * Get the Bounding box extent specified by setDefaultQueryExtent
  61713. * @returns the box extent values
  61714. */
  61715. getDefaultQueryExtent(): Vector3;
  61716. /**
  61717. * Release all resources
  61718. */
  61719. dispose(): void;
  61720. }
  61721. /**
  61722. * Configures an agent
  61723. */
  61724. export interface IAgentParameters {
  61725. /**
  61726. * Agent radius. [Limit: >= 0]
  61727. */
  61728. radius: number;
  61729. /**
  61730. * Agent height. [Limit: > 0]
  61731. */
  61732. height: number;
  61733. /**
  61734. * Maximum allowed acceleration. [Limit: >= 0]
  61735. */
  61736. maxAcceleration: number;
  61737. /**
  61738. * Maximum allowed speed. [Limit: >= 0]
  61739. */
  61740. maxSpeed: number;
  61741. /**
  61742. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61743. */
  61744. collisionQueryRange: number;
  61745. /**
  61746. * The path visibility optimization range. [Limit: > 0]
  61747. */
  61748. pathOptimizationRange: number;
  61749. /**
  61750. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61751. */
  61752. separationWeight: number;
  61753. }
  61754. /**
  61755. * Configures the navigation mesh creation
  61756. */
  61757. export interface INavMeshParameters {
  61758. /**
  61759. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61760. */
  61761. cs: number;
  61762. /**
  61763. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61764. */
  61765. ch: number;
  61766. /**
  61767. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61768. */
  61769. walkableSlopeAngle: number;
  61770. /**
  61771. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61772. * be considered walkable. [Limit: >= 3] [Units: vx]
  61773. */
  61774. walkableHeight: number;
  61775. /**
  61776. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61777. */
  61778. walkableClimb: number;
  61779. /**
  61780. * The distance to erode/shrink the walkable area of the heightfield away from
  61781. * obstructions. [Limit: >=0] [Units: vx]
  61782. */
  61783. walkableRadius: number;
  61784. /**
  61785. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61786. */
  61787. maxEdgeLen: number;
  61788. /**
  61789. * The maximum distance a simplfied contour's border edges should deviate
  61790. * the original raw contour. [Limit: >=0] [Units: vx]
  61791. */
  61792. maxSimplificationError: number;
  61793. /**
  61794. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61795. */
  61796. minRegionArea: number;
  61797. /**
  61798. * Any regions with a span count smaller than this value will, if possible,
  61799. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61800. */
  61801. mergeRegionArea: number;
  61802. /**
  61803. * The maximum number of vertices allowed for polygons generated during the
  61804. * contour to polygon conversion process. [Limit: >= 3]
  61805. */
  61806. maxVertsPerPoly: number;
  61807. /**
  61808. * Sets the sampling distance to use when generating the detail mesh.
  61809. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61810. */
  61811. detailSampleDist: number;
  61812. /**
  61813. * The maximum distance the detail mesh surface should deviate from heightfield
  61814. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61815. */
  61816. detailSampleMaxError: number;
  61817. }
  61818. }
  61819. declare module BABYLON {
  61820. /**
  61821. * RecastJS navigation plugin
  61822. */
  61823. export class RecastJSPlugin implements INavigationEnginePlugin {
  61824. /**
  61825. * Reference to the Recast library
  61826. */
  61827. bjsRECAST: any;
  61828. /**
  61829. * plugin name
  61830. */
  61831. name: string;
  61832. /**
  61833. * the first navmesh created. We might extend this to support multiple navmeshes
  61834. */
  61835. navMesh: any;
  61836. /**
  61837. * Initializes the recastJS plugin
  61838. * @param recastInjection can be used to inject your own recast reference
  61839. */
  61840. constructor(recastInjection?: any);
  61841. /**
  61842. * Creates a navigation mesh
  61843. * @param meshes array of all the geometry used to compute the navigatio mesh
  61844. * @param parameters bunch of parameters used to filter geometry
  61845. */
  61846. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61847. /**
  61848. * Create a navigation mesh debug mesh
  61849. * @param scene is where the mesh will be added
  61850. * @returns debug display mesh
  61851. */
  61852. createDebugNavMesh(scene: Scene): Mesh;
  61853. /**
  61854. * Get a navigation mesh constrained position, closest to the parameter position
  61855. * @param position world position
  61856. * @returns the closest point to position constrained by the navigation mesh
  61857. */
  61858. getClosestPoint(position: Vector3): Vector3;
  61859. /**
  61860. * Get a navigation mesh constrained position, within a particular radius
  61861. * @param position world position
  61862. * @param maxRadius the maximum distance to the constrained world position
  61863. * @returns the closest point to position constrained by the navigation mesh
  61864. */
  61865. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61866. /**
  61867. * Compute the final position from a segment made of destination-position
  61868. * @param position world position
  61869. * @param destination world position
  61870. * @returns the resulting point along the navmesh
  61871. */
  61872. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61873. /**
  61874. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61875. * @param start world position
  61876. * @param end world position
  61877. * @returns array containing world position composing the path
  61878. */
  61879. computePath(start: Vector3, end: Vector3): Vector3[];
  61880. /**
  61881. * Create a new Crowd so you can add agents
  61882. * @param maxAgents the maximum agent count in the crowd
  61883. * @param maxAgentRadius the maximum radius an agent can have
  61884. * @param scene to attach the crowd to
  61885. * @returns the crowd you can add agents to
  61886. */
  61887. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61888. /**
  61889. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61890. * The queries will try to find a solution within those bounds
  61891. * default is (1,1,1)
  61892. * @param extent x,y,z value that define the extent around the queries point of reference
  61893. */
  61894. setDefaultQueryExtent(extent: Vector3): void;
  61895. /**
  61896. * Get the Bounding box extent specified by setDefaultQueryExtent
  61897. * @returns the box extent values
  61898. */
  61899. getDefaultQueryExtent(): Vector3;
  61900. /**
  61901. * Disposes
  61902. */
  61903. dispose(): void;
  61904. /**
  61905. * If this plugin is supported
  61906. * @returns true if plugin is supported
  61907. */
  61908. isSupported(): boolean;
  61909. }
  61910. /**
  61911. * Recast detour crowd implementation
  61912. */
  61913. export class RecastJSCrowd implements ICrowd {
  61914. /**
  61915. * Recast/detour plugin
  61916. */
  61917. bjsRECASTPlugin: RecastJSPlugin;
  61918. /**
  61919. * Link to the detour crowd
  61920. */
  61921. recastCrowd: any;
  61922. /**
  61923. * One transform per agent
  61924. */
  61925. transforms: TransformNode[];
  61926. /**
  61927. * All agents created
  61928. */
  61929. agents: number[];
  61930. /**
  61931. * Link to the scene is kept to unregister the crowd from the scene
  61932. */
  61933. private _scene;
  61934. /**
  61935. * Observer for crowd updates
  61936. */
  61937. private _onBeforeAnimationsObserver;
  61938. /**
  61939. * Constructor
  61940. * @param plugin recastJS plugin
  61941. * @param maxAgents the maximum agent count in the crowd
  61942. * @param maxAgentRadius the maximum radius an agent can have
  61943. * @param scene to attach the crowd to
  61944. * @returns the crowd you can add agents to
  61945. */
  61946. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61947. /**
  61948. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61949. * You can attach anything to that node. The node position is updated in the scene update tick.
  61950. * @param pos world position that will be constrained by the navigation mesh
  61951. * @param parameters agent parameters
  61952. * @param transform hooked to the agent that will be update by the scene
  61953. * @returns agent index
  61954. */
  61955. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61956. /**
  61957. * Returns the agent position in world space
  61958. * @param index agent index returned by addAgent
  61959. * @returns world space position
  61960. */
  61961. getAgentPosition(index: number): Vector3;
  61962. /**
  61963. * Returns the agent velocity in world space
  61964. * @param index agent index returned by addAgent
  61965. * @returns world space velocity
  61966. */
  61967. getAgentVelocity(index: number): Vector3;
  61968. /**
  61969. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61970. * @param index agent index returned by addAgent
  61971. * @param destination targeted world position
  61972. */
  61973. agentGoto(index: number, destination: Vector3): void;
  61974. /**
  61975. * Teleport the agent to a new position
  61976. * @param index agent index returned by addAgent
  61977. * @param destination targeted world position
  61978. */
  61979. agentTeleport(index: number, destination: Vector3): void;
  61980. /**
  61981. * Update agent parameters
  61982. * @param index agent index returned by addAgent
  61983. * @param parameters agent parameters
  61984. */
  61985. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61986. /**
  61987. * remove a particular agent previously created
  61988. * @param index agent index returned by addAgent
  61989. */
  61990. removeAgent(index: number): void;
  61991. /**
  61992. * get the list of all agents attached to this crowd
  61993. * @returns list of agent indices
  61994. */
  61995. getAgents(): number[];
  61996. /**
  61997. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61998. * @param deltaTime in seconds
  61999. */
  62000. update(deltaTime: number): void;
  62001. /**
  62002. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62003. * The queries will try to find a solution within those bounds
  62004. * default is (1,1,1)
  62005. * @param extent x,y,z value that define the extent around the queries point of reference
  62006. */
  62007. setDefaultQueryExtent(extent: Vector3): void;
  62008. /**
  62009. * Get the Bounding box extent specified by setDefaultQueryExtent
  62010. * @returns the box extent values
  62011. */
  62012. getDefaultQueryExtent(): Vector3;
  62013. /**
  62014. * Release all resources
  62015. */
  62016. dispose(): void;
  62017. }
  62018. }
  62019. declare module BABYLON {
  62020. /**
  62021. * Class used to enable access to IndexedDB
  62022. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62023. */
  62024. export class Database implements IOfflineProvider {
  62025. private _callbackManifestChecked;
  62026. private _currentSceneUrl;
  62027. private _db;
  62028. private _enableSceneOffline;
  62029. private _enableTexturesOffline;
  62030. private _manifestVersionFound;
  62031. private _mustUpdateRessources;
  62032. private _hasReachedQuota;
  62033. private _isSupported;
  62034. private _idbFactory;
  62035. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62036. private static IsUASupportingBlobStorage;
  62037. /**
  62038. * Gets a boolean indicating if Database storate is enabled (off by default)
  62039. */
  62040. static IDBStorageEnabled: boolean;
  62041. /**
  62042. * Gets a boolean indicating if scene must be saved in the database
  62043. */
  62044. get enableSceneOffline(): boolean;
  62045. /**
  62046. * Gets a boolean indicating if textures must be saved in the database
  62047. */
  62048. get enableTexturesOffline(): boolean;
  62049. /**
  62050. * Creates a new Database
  62051. * @param urlToScene defines the url to load the scene
  62052. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62053. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62054. */
  62055. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62056. private static _ParseURL;
  62057. private static _ReturnFullUrlLocation;
  62058. private _checkManifestFile;
  62059. /**
  62060. * Open the database and make it available
  62061. * @param successCallback defines the callback to call on success
  62062. * @param errorCallback defines the callback to call on error
  62063. */
  62064. open(successCallback: () => void, errorCallback: () => void): void;
  62065. /**
  62066. * Loads an image from the database
  62067. * @param url defines the url to load from
  62068. * @param image defines the target DOM image
  62069. */
  62070. loadImage(url: string, image: HTMLImageElement): void;
  62071. private _loadImageFromDBAsync;
  62072. private _saveImageIntoDBAsync;
  62073. private _checkVersionFromDB;
  62074. private _loadVersionFromDBAsync;
  62075. private _saveVersionIntoDBAsync;
  62076. /**
  62077. * Loads a file from database
  62078. * @param url defines the URL to load from
  62079. * @param sceneLoaded defines a callback to call on success
  62080. * @param progressCallBack defines a callback to call when progress changed
  62081. * @param errorCallback defines a callback to call on error
  62082. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62083. */
  62084. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62085. private _loadFileAsync;
  62086. private _saveFileAsync;
  62087. /**
  62088. * Validates if xhr data is correct
  62089. * @param xhr defines the request to validate
  62090. * @param dataType defines the expected data type
  62091. * @returns true if data is correct
  62092. */
  62093. private static _ValidateXHRData;
  62094. }
  62095. }
  62096. declare module BABYLON {
  62097. /** @hidden */
  62098. export var gpuUpdateParticlesPixelShader: {
  62099. name: string;
  62100. shader: string;
  62101. };
  62102. }
  62103. declare module BABYLON {
  62104. /** @hidden */
  62105. export var gpuUpdateParticlesVertexShader: {
  62106. name: string;
  62107. shader: string;
  62108. };
  62109. }
  62110. declare module BABYLON {
  62111. /** @hidden */
  62112. export var clipPlaneFragmentDeclaration2: {
  62113. name: string;
  62114. shader: string;
  62115. };
  62116. }
  62117. declare module BABYLON {
  62118. /** @hidden */
  62119. export var gpuRenderParticlesPixelShader: {
  62120. name: string;
  62121. shader: string;
  62122. };
  62123. }
  62124. declare module BABYLON {
  62125. /** @hidden */
  62126. export var clipPlaneVertexDeclaration2: {
  62127. name: string;
  62128. shader: string;
  62129. };
  62130. }
  62131. declare module BABYLON {
  62132. /** @hidden */
  62133. export var gpuRenderParticlesVertexShader: {
  62134. name: string;
  62135. shader: string;
  62136. };
  62137. }
  62138. declare module BABYLON {
  62139. /**
  62140. * This represents a GPU particle system in Babylon
  62141. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62142. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62143. */
  62144. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62145. /**
  62146. * The layer mask we are rendering the particles through.
  62147. */
  62148. layerMask: number;
  62149. private _capacity;
  62150. private _activeCount;
  62151. private _currentActiveCount;
  62152. private _accumulatedCount;
  62153. private _renderEffect;
  62154. private _updateEffect;
  62155. private _buffer0;
  62156. private _buffer1;
  62157. private _spriteBuffer;
  62158. private _updateVAO;
  62159. private _renderVAO;
  62160. private _targetIndex;
  62161. private _sourceBuffer;
  62162. private _targetBuffer;
  62163. private _engine;
  62164. private _currentRenderId;
  62165. private _started;
  62166. private _stopped;
  62167. private _timeDelta;
  62168. private _randomTexture;
  62169. private _randomTexture2;
  62170. private _attributesStrideSize;
  62171. private _updateEffectOptions;
  62172. private _randomTextureSize;
  62173. private _actualFrame;
  62174. private readonly _rawTextureWidth;
  62175. /**
  62176. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62177. */
  62178. static get IsSupported(): boolean;
  62179. /**
  62180. * An event triggered when the system is disposed.
  62181. */
  62182. onDisposeObservable: Observable<GPUParticleSystem>;
  62183. /**
  62184. * Gets the maximum number of particles active at the same time.
  62185. * @returns The max number of active particles.
  62186. */
  62187. getCapacity(): number;
  62188. /**
  62189. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62190. * to override the particles.
  62191. */
  62192. forceDepthWrite: boolean;
  62193. /**
  62194. * Gets or set the number of active particles
  62195. */
  62196. get activeParticleCount(): number;
  62197. set activeParticleCount(value: number);
  62198. private _preWarmDone;
  62199. /**
  62200. * Is this system ready to be used/rendered
  62201. * @return true if the system is ready
  62202. */
  62203. isReady(): boolean;
  62204. /**
  62205. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62206. * @returns True if it has been started, otherwise false.
  62207. */
  62208. isStarted(): boolean;
  62209. /**
  62210. * Starts the particle system and begins to emit
  62211. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62212. */
  62213. start(delay?: number): void;
  62214. /**
  62215. * Stops the particle system.
  62216. */
  62217. stop(): void;
  62218. /**
  62219. * Remove all active particles
  62220. */
  62221. reset(): void;
  62222. /**
  62223. * Returns the string "GPUParticleSystem"
  62224. * @returns a string containing the class name
  62225. */
  62226. getClassName(): string;
  62227. private _colorGradientsTexture;
  62228. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62229. /**
  62230. * Adds a new color gradient
  62231. * @param gradient defines the gradient to use (between 0 and 1)
  62232. * @param color1 defines the color to affect to the specified gradient
  62233. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62234. * @returns the current particle system
  62235. */
  62236. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62237. /**
  62238. * Remove a specific color gradient
  62239. * @param gradient defines the gradient to remove
  62240. * @returns the current particle system
  62241. */
  62242. removeColorGradient(gradient: number): GPUParticleSystem;
  62243. private _angularSpeedGradientsTexture;
  62244. private _sizeGradientsTexture;
  62245. private _velocityGradientsTexture;
  62246. private _limitVelocityGradientsTexture;
  62247. private _dragGradientsTexture;
  62248. private _addFactorGradient;
  62249. /**
  62250. * Adds a new size gradient
  62251. * @param gradient defines the gradient to use (between 0 and 1)
  62252. * @param factor defines the size factor to affect to the specified gradient
  62253. * @returns the current particle system
  62254. */
  62255. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62256. /**
  62257. * Remove a specific size gradient
  62258. * @param gradient defines the gradient to remove
  62259. * @returns the current particle system
  62260. */
  62261. removeSizeGradient(gradient: number): GPUParticleSystem;
  62262. /**
  62263. * Adds a new angular speed gradient
  62264. * @param gradient defines the gradient to use (between 0 and 1)
  62265. * @param factor defines the angular speed to affect to the specified gradient
  62266. * @returns the current particle system
  62267. */
  62268. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62269. /**
  62270. * Remove a specific angular speed gradient
  62271. * @param gradient defines the gradient to remove
  62272. * @returns the current particle system
  62273. */
  62274. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62275. /**
  62276. * Adds a new velocity gradient
  62277. * @param gradient defines the gradient to use (between 0 and 1)
  62278. * @param factor defines the velocity to affect to the specified gradient
  62279. * @returns the current particle system
  62280. */
  62281. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62282. /**
  62283. * Remove a specific velocity gradient
  62284. * @param gradient defines the gradient to remove
  62285. * @returns the current particle system
  62286. */
  62287. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62288. /**
  62289. * Adds a new limit velocity gradient
  62290. * @param gradient defines the gradient to use (between 0 and 1)
  62291. * @param factor defines the limit velocity value to affect to the specified gradient
  62292. * @returns the current particle system
  62293. */
  62294. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62295. /**
  62296. * Remove a specific limit velocity gradient
  62297. * @param gradient defines the gradient to remove
  62298. * @returns the current particle system
  62299. */
  62300. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62301. /**
  62302. * Adds a new drag gradient
  62303. * @param gradient defines the gradient to use (between 0 and 1)
  62304. * @param factor defines the drag value to affect to the specified gradient
  62305. * @returns the current particle system
  62306. */
  62307. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62308. /**
  62309. * Remove a specific drag gradient
  62310. * @param gradient defines the gradient to remove
  62311. * @returns the current particle system
  62312. */
  62313. removeDragGradient(gradient: number): GPUParticleSystem;
  62314. /**
  62315. * Not supported by GPUParticleSystem
  62316. * @param gradient defines the gradient to use (between 0 and 1)
  62317. * @param factor defines the emit rate value to affect to the specified gradient
  62318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62319. * @returns the current particle system
  62320. */
  62321. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62322. /**
  62323. * Not supported by GPUParticleSystem
  62324. * @param gradient defines the gradient to remove
  62325. * @returns the current particle system
  62326. */
  62327. removeEmitRateGradient(gradient: number): IParticleSystem;
  62328. /**
  62329. * Not supported by GPUParticleSystem
  62330. * @param gradient defines the gradient to use (between 0 and 1)
  62331. * @param factor defines the start size value to affect to the specified gradient
  62332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62333. * @returns the current particle system
  62334. */
  62335. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62336. /**
  62337. * Not supported by GPUParticleSystem
  62338. * @param gradient defines the gradient to remove
  62339. * @returns the current particle system
  62340. */
  62341. removeStartSizeGradient(gradient: number): IParticleSystem;
  62342. /**
  62343. * Not supported by GPUParticleSystem
  62344. * @param gradient defines the gradient to use (between 0 and 1)
  62345. * @param min defines the color remap minimal range
  62346. * @param max defines the color remap maximal range
  62347. * @returns the current particle system
  62348. */
  62349. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62350. /**
  62351. * Not supported by GPUParticleSystem
  62352. * @param gradient defines the gradient to remove
  62353. * @returns the current particle system
  62354. */
  62355. removeColorRemapGradient(): IParticleSystem;
  62356. /**
  62357. * Not supported by GPUParticleSystem
  62358. * @param gradient defines the gradient to use (between 0 and 1)
  62359. * @param min defines the alpha remap minimal range
  62360. * @param max defines the alpha remap maximal range
  62361. * @returns the current particle system
  62362. */
  62363. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62364. /**
  62365. * Not supported by GPUParticleSystem
  62366. * @param gradient defines the gradient to remove
  62367. * @returns the current particle system
  62368. */
  62369. removeAlphaRemapGradient(): IParticleSystem;
  62370. /**
  62371. * Not supported by GPUParticleSystem
  62372. * @param gradient defines the gradient to use (between 0 and 1)
  62373. * @param color defines the color to affect to the specified gradient
  62374. * @returns the current particle system
  62375. */
  62376. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62377. /**
  62378. * Not supported by GPUParticleSystem
  62379. * @param gradient defines the gradient to remove
  62380. * @returns the current particle system
  62381. */
  62382. removeRampGradient(): IParticleSystem;
  62383. /**
  62384. * Not supported by GPUParticleSystem
  62385. * @returns the list of ramp gradients
  62386. */
  62387. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62388. /**
  62389. * Not supported by GPUParticleSystem
  62390. * Gets or sets a boolean indicating that ramp gradients must be used
  62391. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62392. */
  62393. get useRampGradients(): boolean;
  62394. set useRampGradients(value: boolean);
  62395. /**
  62396. * Not supported by GPUParticleSystem
  62397. * @param gradient defines the gradient to use (between 0 and 1)
  62398. * @param factor defines the life time factor to affect to the specified gradient
  62399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62400. * @returns the current particle system
  62401. */
  62402. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62403. /**
  62404. * Not supported by GPUParticleSystem
  62405. * @param gradient defines the gradient to remove
  62406. * @returns the current particle system
  62407. */
  62408. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62409. /**
  62410. * Instantiates a GPU particle system.
  62411. * 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.
  62412. * @param name The name of the particle system
  62413. * @param options The options used to create the system
  62414. * @param scene The scene the particle system belongs to
  62415. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62416. */
  62417. constructor(name: string, options: Partial<{
  62418. capacity: number;
  62419. randomTextureSize: number;
  62420. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62421. protected _reset(): void;
  62422. private _createUpdateVAO;
  62423. private _createRenderVAO;
  62424. private _initialize;
  62425. /** @hidden */
  62426. _recreateUpdateEffect(): void;
  62427. /** @hidden */
  62428. _recreateRenderEffect(): void;
  62429. /**
  62430. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62431. * @param preWarm defines if we are in the pre-warmimg phase
  62432. */
  62433. animate(preWarm?: boolean): void;
  62434. private _createFactorGradientTexture;
  62435. private _createSizeGradientTexture;
  62436. private _createAngularSpeedGradientTexture;
  62437. private _createVelocityGradientTexture;
  62438. private _createLimitVelocityGradientTexture;
  62439. private _createDragGradientTexture;
  62440. private _createColorGradientTexture;
  62441. /**
  62442. * Renders the particle system in its current state
  62443. * @param preWarm defines if the system should only update the particles but not render them
  62444. * @returns the current number of particles
  62445. */
  62446. render(preWarm?: boolean): number;
  62447. /**
  62448. * Rebuilds the particle system
  62449. */
  62450. rebuild(): void;
  62451. private _releaseBuffers;
  62452. private _releaseVAOs;
  62453. /**
  62454. * Disposes the particle system and free the associated resources
  62455. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62456. */
  62457. dispose(disposeTexture?: boolean): void;
  62458. /**
  62459. * Clones the particle system.
  62460. * @param name The name of the cloned object
  62461. * @param newEmitter The new emitter to use
  62462. * @returns the cloned particle system
  62463. */
  62464. clone(name: string, newEmitter: any): GPUParticleSystem;
  62465. /**
  62466. * Serializes the particle system to a JSON object.
  62467. * @returns the JSON object
  62468. */
  62469. serialize(): any;
  62470. /**
  62471. * Parses a JSON object to create a GPU particle system.
  62472. * @param parsedParticleSystem The JSON object to parse
  62473. * @param scene The scene to create the particle system in
  62474. * @param rootUrl The root url to use to load external dependencies like texture
  62475. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62476. * @returns the parsed GPU particle system
  62477. */
  62478. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62479. }
  62480. }
  62481. declare module BABYLON {
  62482. /**
  62483. * Represents a set of particle systems working together to create a specific effect
  62484. */
  62485. export class ParticleSystemSet implements IDisposable {
  62486. /**
  62487. * Gets or sets base Assets URL
  62488. */
  62489. static BaseAssetsUrl: string;
  62490. private _emitterCreationOptions;
  62491. private _emitterNode;
  62492. /**
  62493. * Gets the particle system list
  62494. */
  62495. systems: IParticleSystem[];
  62496. /**
  62497. * Gets the emitter node used with this set
  62498. */
  62499. get emitterNode(): Nullable<TransformNode>;
  62500. /**
  62501. * Creates a new emitter mesh as a sphere
  62502. * @param options defines the options used to create the sphere
  62503. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62504. * @param scene defines the hosting scene
  62505. */
  62506. setEmitterAsSphere(options: {
  62507. diameter: number;
  62508. segments: number;
  62509. color: Color3;
  62510. }, renderingGroupId: number, scene: Scene): void;
  62511. /**
  62512. * Starts all particle systems of the set
  62513. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62514. */
  62515. start(emitter?: AbstractMesh): void;
  62516. /**
  62517. * Release all associated resources
  62518. */
  62519. dispose(): void;
  62520. /**
  62521. * Serialize the set into a JSON compatible object
  62522. * @returns a JSON compatible representation of the set
  62523. */
  62524. serialize(): any;
  62525. /**
  62526. * Parse a new ParticleSystemSet from a serialized source
  62527. * @param data defines a JSON compatible representation of the set
  62528. * @param scene defines the hosting scene
  62529. * @param gpu defines if we want GPU particles or CPU particles
  62530. * @returns a new ParticleSystemSet
  62531. */
  62532. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62533. }
  62534. }
  62535. declare module BABYLON {
  62536. /**
  62537. * This class is made for on one-liner static method to help creating particle system set.
  62538. */
  62539. export class ParticleHelper {
  62540. /**
  62541. * Gets or sets base Assets URL
  62542. */
  62543. static BaseAssetsUrl: string;
  62544. /**
  62545. * Create a default particle system that you can tweak
  62546. * @param emitter defines the emitter to use
  62547. * @param capacity defines the system capacity (default is 500 particles)
  62548. * @param scene defines the hosting scene
  62549. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62550. * @returns the new Particle system
  62551. */
  62552. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62553. /**
  62554. * This is the main static method (one-liner) of this helper to create different particle systems
  62555. * @param type This string represents the type to the particle system to create
  62556. * @param scene The scene where the particle system should live
  62557. * @param gpu If the system will use gpu
  62558. * @returns the ParticleSystemSet created
  62559. */
  62560. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62561. /**
  62562. * Static function used to export a particle system to a ParticleSystemSet variable.
  62563. * Please note that the emitter shape is not exported
  62564. * @param systems defines the particle systems to export
  62565. * @returns the created particle system set
  62566. */
  62567. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62568. }
  62569. }
  62570. declare module BABYLON {
  62571. interface Engine {
  62572. /**
  62573. * Create an effect to use with particle systems.
  62574. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62575. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62576. * @param uniformsNames defines a list of attribute names
  62577. * @param samplers defines an array of string used to represent textures
  62578. * @param defines defines the string containing the defines to use to compile the shaders
  62579. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62580. * @param onCompiled defines a function to call when the effect creation is successful
  62581. * @param onError defines a function to call when the effect creation has failed
  62582. * @returns the new Effect
  62583. */
  62584. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62585. }
  62586. interface Mesh {
  62587. /**
  62588. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62589. * @returns an array of IParticleSystem
  62590. */
  62591. getEmittedParticleSystems(): IParticleSystem[];
  62592. /**
  62593. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62594. * @returns an array of IParticleSystem
  62595. */
  62596. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62597. }
  62598. /**
  62599. * @hidden
  62600. */
  62601. export var _IDoNeedToBeInTheBuild: number;
  62602. }
  62603. declare module BABYLON {
  62604. /** Defines the 4 color options */
  62605. export enum PointColor {
  62606. /** color value */
  62607. Color = 2,
  62608. /** uv value */
  62609. UV = 1,
  62610. /** random value */
  62611. Random = 0,
  62612. /** stated value */
  62613. Stated = 3
  62614. }
  62615. /**
  62616. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62617. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  62618. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62619. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62620. *
  62621. * Full documentation here : TO BE ENTERED
  62622. */
  62623. export class PointsCloudSystem implements IDisposable {
  62624. /**
  62625. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62626. * Example : var p = SPS.particles[i];
  62627. */
  62628. particles: CloudPoint[];
  62629. /**
  62630. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62631. */
  62632. nbParticles: number;
  62633. /**
  62634. * This a counter for your own usage. It's not set by any SPS functions.
  62635. */
  62636. counter: number;
  62637. /**
  62638. * The PCS name. This name is also given to the underlying mesh.
  62639. */
  62640. name: string;
  62641. /**
  62642. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62643. */
  62644. mesh: Mesh;
  62645. /**
  62646. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62647. * Please read :
  62648. */
  62649. vars: any;
  62650. /**
  62651. * @hidden
  62652. */
  62653. _size: number;
  62654. private _scene;
  62655. private _promises;
  62656. private _positions;
  62657. private _indices;
  62658. private _normals;
  62659. private _colors;
  62660. private _uvs;
  62661. private _indices32;
  62662. private _positions32;
  62663. private _colors32;
  62664. private _uvs32;
  62665. private _updatable;
  62666. private _isVisibilityBoxLocked;
  62667. private _alwaysVisible;
  62668. private _groups;
  62669. private _groupCounter;
  62670. private _computeParticleColor;
  62671. private _computeParticleTexture;
  62672. private _computeParticleRotation;
  62673. private _computeBoundingBox;
  62674. private _isReady;
  62675. /**
  62676. * Creates a PCS (Points Cloud System) object
  62677. * @param name (String) is the PCS name, this will be the underlying mesh name
  62678. * @param pointSize (number) is the size for each point
  62679. * @param scene (Scene) is the scene in which the PCS is added
  62680. * @param options defines the options of the PCS e.g.
  62681. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62682. */
  62683. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62684. updatable?: boolean;
  62685. });
  62686. /**
  62687. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62688. * If no points were added to the PCS, the returned mesh is just a single point.
  62689. * @returns a promise for the created mesh
  62690. */
  62691. buildMeshAsync(): Promise<Mesh>;
  62692. /**
  62693. * @hidden
  62694. */
  62695. private _buildMesh;
  62696. private _addParticle;
  62697. private _randomUnitVector;
  62698. private _getColorIndicesForCoord;
  62699. private _setPointsColorOrUV;
  62700. private _colorFromTexture;
  62701. private _calculateDensity;
  62702. /**
  62703. * Adds points to the PCS in random positions within a unit sphere
  62704. * @param nb (positive integer) the number of particles to be created from this model
  62705. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62706. * @returns the number of groups in the system
  62707. */
  62708. addPoints(nb: number, pointFunction?: any): number;
  62709. /**
  62710. * Adds points to the PCS from the surface of the model shape
  62711. * @param mesh is any Mesh object that will be used as a surface model for the points
  62712. * @param nb (positive integer) the number of particles to be created from this model
  62713. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62714. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62715. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62716. * @returns the number of groups in the system
  62717. */
  62718. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62719. /**
  62720. * Adds points to the PCS inside the model shape
  62721. * @param mesh is any Mesh object that will be used as a surface model for the points
  62722. * @param nb (positive integer) the number of particles to be created from this model
  62723. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62724. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62725. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62726. * @returns the number of groups in the system
  62727. */
  62728. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62729. /**
  62730. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62731. * This method calls `updateParticle()` for each particle of the SPS.
  62732. * For an animated SPS, it is usually called within the render loop.
  62733. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62734. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62735. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62736. * @returns the PCS.
  62737. */
  62738. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62739. /**
  62740. * Disposes the PCS.
  62741. */
  62742. dispose(): void;
  62743. /**
  62744. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62745. * doc :
  62746. * @returns the PCS.
  62747. */
  62748. refreshVisibleSize(): PointsCloudSystem;
  62749. /**
  62750. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62751. * @param size the size (float) of the visibility box
  62752. * note : this doesn't lock the PCS mesh bounding box.
  62753. * doc :
  62754. */
  62755. setVisibilityBox(size: number): void;
  62756. /**
  62757. * Gets whether the PCS is always visible or not
  62758. * doc :
  62759. */
  62760. get isAlwaysVisible(): boolean;
  62761. /**
  62762. * Sets the PCS as always visible or not
  62763. * doc :
  62764. */
  62765. set isAlwaysVisible(val: boolean);
  62766. /**
  62767. * Tells to `setParticles()` to compute the particle rotations or not
  62768. * Default value : false. The PCS is faster when it's set to false
  62769. * Note : particle rotations are only applied to parent particles
  62770. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62771. */
  62772. set computeParticleRotation(val: boolean);
  62773. /**
  62774. * Tells to `setParticles()` to compute the particle colors or not.
  62775. * Default value : true. The PCS is faster when it's set to false.
  62776. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62777. */
  62778. set computeParticleColor(val: boolean);
  62779. set computeParticleTexture(val: boolean);
  62780. /**
  62781. * Gets if `setParticles()` computes the particle colors or not.
  62782. * Default value : false. The PCS is faster when it's set to false.
  62783. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62784. */
  62785. get computeParticleColor(): boolean;
  62786. /**
  62787. * Gets if `setParticles()` computes the particle textures or not.
  62788. * Default value : false. The PCS is faster when it's set to false.
  62789. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62790. */
  62791. get computeParticleTexture(): boolean;
  62792. /**
  62793. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62794. */
  62795. set computeBoundingBox(val: boolean);
  62796. /**
  62797. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62798. */
  62799. get computeBoundingBox(): boolean;
  62800. /**
  62801. * This function does nothing. It may be overwritten to set all the particle first values.
  62802. * The PCS doesn't call this function, you may have to call it by your own.
  62803. * doc :
  62804. */
  62805. initParticles(): void;
  62806. /**
  62807. * This function does nothing. It may be overwritten to recycle a particle
  62808. * The PCS doesn't call this function, you can to call it
  62809. * doc :
  62810. * @param particle The particle to recycle
  62811. * @returns the recycled particle
  62812. */
  62813. recycleParticle(particle: CloudPoint): CloudPoint;
  62814. /**
  62815. * Updates a particle : this function should be overwritten by the user.
  62816. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62817. * doc :
  62818. * @example : just set a particle position or velocity and recycle conditions
  62819. * @param particle The particle to update
  62820. * @returns the updated particle
  62821. */
  62822. updateParticle(particle: CloudPoint): CloudPoint;
  62823. /**
  62824. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62825. * This does nothing and may be overwritten by the user.
  62826. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62827. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62828. * @param update the boolean update value actually passed to setParticles()
  62829. */
  62830. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62831. /**
  62832. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62833. * This will be passed three parameters.
  62834. * This does nothing and may be overwritten by the user.
  62835. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62836. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62837. * @param update the boolean update value actually passed to setParticles()
  62838. */
  62839. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62840. }
  62841. }
  62842. declare module BABYLON {
  62843. /**
  62844. * Represents one particle of a points cloud system.
  62845. */
  62846. export class CloudPoint {
  62847. /**
  62848. * particle global index
  62849. */
  62850. idx: number;
  62851. /**
  62852. * The color of the particle
  62853. */
  62854. color: Nullable<Color4>;
  62855. /**
  62856. * The world space position of the particle.
  62857. */
  62858. position: Vector3;
  62859. /**
  62860. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62861. */
  62862. rotation: Vector3;
  62863. /**
  62864. * The world space rotation quaternion of the particle.
  62865. */
  62866. rotationQuaternion: Nullable<Quaternion>;
  62867. /**
  62868. * The uv of the particle.
  62869. */
  62870. uv: Nullable<Vector2>;
  62871. /**
  62872. * The current speed of the particle.
  62873. */
  62874. velocity: Vector3;
  62875. /**
  62876. * The pivot point in the particle local space.
  62877. */
  62878. pivot: Vector3;
  62879. /**
  62880. * Must the particle be translated from its pivot point in its local space ?
  62881. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62882. * Default : false
  62883. */
  62884. translateFromPivot: boolean;
  62885. /**
  62886. * Index of this particle in the global "positions" array (Internal use)
  62887. * @hidden
  62888. */
  62889. _pos: number;
  62890. /**
  62891. * @hidden Index of this particle in the global "indices" array (Internal use)
  62892. */
  62893. _ind: number;
  62894. /**
  62895. * Group this particle belongs to
  62896. */
  62897. _group: PointsGroup;
  62898. /**
  62899. * Group id of this particle
  62900. */
  62901. groupId: number;
  62902. /**
  62903. * Index of the particle in its group id (Internal use)
  62904. */
  62905. idxInGroup: number;
  62906. /**
  62907. * @hidden Particle BoundingInfo object (Internal use)
  62908. */
  62909. _boundingInfo: BoundingInfo;
  62910. /**
  62911. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62912. */
  62913. _pcs: PointsCloudSystem;
  62914. /**
  62915. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62916. */
  62917. _stillInvisible: boolean;
  62918. /**
  62919. * @hidden Last computed particle rotation matrix
  62920. */
  62921. _rotationMatrix: number[];
  62922. /**
  62923. * Parent particle Id, if any.
  62924. * Default null.
  62925. */
  62926. parentId: Nullable<number>;
  62927. /**
  62928. * @hidden Internal global position in the PCS.
  62929. */
  62930. _globalPosition: Vector3;
  62931. /**
  62932. * Creates a Point Cloud object.
  62933. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62934. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62935. * @param group (PointsGroup) is the group the particle belongs to
  62936. * @param groupId (integer) is the group identifier in the PCS.
  62937. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62938. * @param pcs defines the PCS it is associated to
  62939. */
  62940. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62941. /**
  62942. * get point size
  62943. */
  62944. get size(): Vector3;
  62945. /**
  62946. * Set point size
  62947. */
  62948. set size(scale: Vector3);
  62949. /**
  62950. * Legacy support, changed quaternion to rotationQuaternion
  62951. */
  62952. get quaternion(): Nullable<Quaternion>;
  62953. /**
  62954. * Legacy support, changed quaternion to rotationQuaternion
  62955. */
  62956. set quaternion(q: Nullable<Quaternion>);
  62957. /**
  62958. * Returns a boolean. True if the particle intersects a mesh, else false
  62959. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62960. * @param target is the object (point or mesh) what the intersection is computed against
  62961. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62962. * @returns true if it intersects
  62963. */
  62964. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62965. /**
  62966. * get the rotation matrix of the particle
  62967. * @hidden
  62968. */
  62969. getRotationMatrix(m: Matrix): void;
  62970. }
  62971. /**
  62972. * Represents a group of points in a points cloud system
  62973. * * PCS internal tool, don't use it manually.
  62974. */
  62975. export class PointsGroup {
  62976. /**
  62977. * The group id
  62978. * @hidden
  62979. */
  62980. groupID: number;
  62981. /**
  62982. * image data for group (internal use)
  62983. * @hidden
  62984. */
  62985. _groupImageData: Nullable<ArrayBufferView>;
  62986. /**
  62987. * Image Width (internal use)
  62988. * @hidden
  62989. */
  62990. _groupImgWidth: number;
  62991. /**
  62992. * Image Height (internal use)
  62993. * @hidden
  62994. */
  62995. _groupImgHeight: number;
  62996. /**
  62997. * Custom position function (internal use)
  62998. * @hidden
  62999. */
  63000. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63001. /**
  63002. * density per facet for surface points
  63003. * @hidden
  63004. */
  63005. _groupDensity: number[];
  63006. /**
  63007. * Only when points are colored by texture carries pointer to texture list array
  63008. * @hidden
  63009. */
  63010. _textureNb: number;
  63011. /**
  63012. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63013. * PCS internal tool, don't use it manually.
  63014. * @hidden
  63015. */
  63016. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63017. }
  63018. }
  63019. declare module BABYLON {
  63020. interface Scene {
  63021. /** @hidden (Backing field) */
  63022. _physicsEngine: Nullable<IPhysicsEngine>;
  63023. /** @hidden */
  63024. _physicsTimeAccumulator: number;
  63025. /**
  63026. * Gets the current physics engine
  63027. * @returns a IPhysicsEngine or null if none attached
  63028. */
  63029. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63030. /**
  63031. * Enables physics to the current scene
  63032. * @param gravity defines the scene's gravity for the physics engine
  63033. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63034. * @return a boolean indicating if the physics engine was initialized
  63035. */
  63036. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63037. /**
  63038. * Disables and disposes the physics engine associated with the scene
  63039. */
  63040. disablePhysicsEngine(): void;
  63041. /**
  63042. * Gets a boolean indicating if there is an active physics engine
  63043. * @returns a boolean indicating if there is an active physics engine
  63044. */
  63045. isPhysicsEnabled(): boolean;
  63046. /**
  63047. * Deletes a physics compound impostor
  63048. * @param compound defines the compound to delete
  63049. */
  63050. deleteCompoundImpostor(compound: any): void;
  63051. /**
  63052. * An event triggered when physic simulation is about to be run
  63053. */
  63054. onBeforePhysicsObservable: Observable<Scene>;
  63055. /**
  63056. * An event triggered when physic simulation has been done
  63057. */
  63058. onAfterPhysicsObservable: Observable<Scene>;
  63059. }
  63060. interface AbstractMesh {
  63061. /** @hidden */
  63062. _physicsImpostor: Nullable<PhysicsImpostor>;
  63063. /**
  63064. * Gets or sets impostor used for physic simulation
  63065. * @see http://doc.babylonjs.com/features/physics_engine
  63066. */
  63067. physicsImpostor: Nullable<PhysicsImpostor>;
  63068. /**
  63069. * Gets the current physics impostor
  63070. * @see http://doc.babylonjs.com/features/physics_engine
  63071. * @returns a physics impostor or null
  63072. */
  63073. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63074. /** Apply a physic impulse to the mesh
  63075. * @param force defines the force to apply
  63076. * @param contactPoint defines where to apply the force
  63077. * @returns the current mesh
  63078. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63079. */
  63080. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63081. /**
  63082. * Creates a physic joint between two meshes
  63083. * @param otherMesh defines the other mesh to use
  63084. * @param pivot1 defines the pivot to use on this mesh
  63085. * @param pivot2 defines the pivot to use on the other mesh
  63086. * @param options defines additional options (can be plugin dependent)
  63087. * @returns the current mesh
  63088. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63089. */
  63090. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63091. /** @hidden */
  63092. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63093. }
  63094. /**
  63095. * Defines the physics engine scene component responsible to manage a physics engine
  63096. */
  63097. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63098. /**
  63099. * The component name helpful to identify the component in the list of scene components.
  63100. */
  63101. readonly name: string;
  63102. /**
  63103. * The scene the component belongs to.
  63104. */
  63105. scene: Scene;
  63106. /**
  63107. * Creates a new instance of the component for the given scene
  63108. * @param scene Defines the scene to register the component in
  63109. */
  63110. constructor(scene: Scene);
  63111. /**
  63112. * Registers the component in a given scene
  63113. */
  63114. register(): void;
  63115. /**
  63116. * Rebuilds the elements related to this component in case of
  63117. * context lost for instance.
  63118. */
  63119. rebuild(): void;
  63120. /**
  63121. * Disposes the component and the associated ressources
  63122. */
  63123. dispose(): void;
  63124. }
  63125. }
  63126. declare module BABYLON {
  63127. /**
  63128. * A helper for physics simulations
  63129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63130. */
  63131. export class PhysicsHelper {
  63132. private _scene;
  63133. private _physicsEngine;
  63134. /**
  63135. * Initializes the Physics helper
  63136. * @param scene Babylon.js scene
  63137. */
  63138. constructor(scene: Scene);
  63139. /**
  63140. * Applies a radial explosion impulse
  63141. * @param origin the origin of the explosion
  63142. * @param radiusOrEventOptions the radius or the options of radial explosion
  63143. * @param strength the explosion strength
  63144. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63145. * @returns A physics radial explosion event, or null
  63146. */
  63147. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63148. /**
  63149. * Applies a radial explosion force
  63150. * @param origin the origin of the explosion
  63151. * @param radiusOrEventOptions the radius or the options of radial explosion
  63152. * @param strength the explosion strength
  63153. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63154. * @returns A physics radial explosion event, or null
  63155. */
  63156. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63157. /**
  63158. * Creates a gravitational field
  63159. * @param origin the origin of the explosion
  63160. * @param radiusOrEventOptions the radius or the options of radial explosion
  63161. * @param strength the explosion strength
  63162. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63163. * @returns A physics gravitational field event, or null
  63164. */
  63165. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63166. /**
  63167. * Creates a physics updraft event
  63168. * @param origin the origin of the updraft
  63169. * @param radiusOrEventOptions the radius or the options of the updraft
  63170. * @param strength the strength of the updraft
  63171. * @param height the height of the updraft
  63172. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63173. * @returns A physics updraft event, or null
  63174. */
  63175. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63176. /**
  63177. * Creates a physics vortex event
  63178. * @param origin the of the vortex
  63179. * @param radiusOrEventOptions the radius or the options of the vortex
  63180. * @param strength the strength of the vortex
  63181. * @param height the height of the vortex
  63182. * @returns a Physics vortex event, or null
  63183. * A physics vortex event or null
  63184. */
  63185. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63186. }
  63187. /**
  63188. * Represents a physics radial explosion event
  63189. */
  63190. class PhysicsRadialExplosionEvent {
  63191. private _scene;
  63192. private _options;
  63193. private _sphere;
  63194. private _dataFetched;
  63195. /**
  63196. * Initializes a radial explosioin event
  63197. * @param _scene BabylonJS scene
  63198. * @param _options The options for the vortex event
  63199. */
  63200. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63201. /**
  63202. * Returns the data related to the radial explosion event (sphere).
  63203. * @returns The radial explosion event data
  63204. */
  63205. getData(): PhysicsRadialExplosionEventData;
  63206. /**
  63207. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63208. * @param impostor A physics imposter
  63209. * @param origin the origin of the explosion
  63210. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63211. */
  63212. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63213. /**
  63214. * Triggers affecterd impostors callbacks
  63215. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63216. */
  63217. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63218. /**
  63219. * Disposes the sphere.
  63220. * @param force Specifies if the sphere should be disposed by force
  63221. */
  63222. dispose(force?: boolean): void;
  63223. /*** Helpers ***/
  63224. private _prepareSphere;
  63225. private _intersectsWithSphere;
  63226. }
  63227. /**
  63228. * Represents a gravitational field event
  63229. */
  63230. class PhysicsGravitationalFieldEvent {
  63231. private _physicsHelper;
  63232. private _scene;
  63233. private _origin;
  63234. private _options;
  63235. private _tickCallback;
  63236. private _sphere;
  63237. private _dataFetched;
  63238. /**
  63239. * Initializes the physics gravitational field event
  63240. * @param _physicsHelper A physics helper
  63241. * @param _scene BabylonJS scene
  63242. * @param _origin The origin position of the gravitational field event
  63243. * @param _options The options for the vortex event
  63244. */
  63245. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63246. /**
  63247. * Returns the data related to the gravitational field event (sphere).
  63248. * @returns A gravitational field event
  63249. */
  63250. getData(): PhysicsGravitationalFieldEventData;
  63251. /**
  63252. * Enables the gravitational field.
  63253. */
  63254. enable(): void;
  63255. /**
  63256. * Disables the gravitational field.
  63257. */
  63258. disable(): void;
  63259. /**
  63260. * Disposes the sphere.
  63261. * @param force The force to dispose from the gravitational field event
  63262. */
  63263. dispose(force?: boolean): void;
  63264. private _tick;
  63265. }
  63266. /**
  63267. * Represents a physics updraft event
  63268. */
  63269. class PhysicsUpdraftEvent {
  63270. private _scene;
  63271. private _origin;
  63272. private _options;
  63273. private _physicsEngine;
  63274. private _originTop;
  63275. private _originDirection;
  63276. private _tickCallback;
  63277. private _cylinder;
  63278. private _cylinderPosition;
  63279. private _dataFetched;
  63280. /**
  63281. * Initializes the physics updraft event
  63282. * @param _scene BabylonJS scene
  63283. * @param _origin The origin position of the updraft
  63284. * @param _options The options for the updraft event
  63285. */
  63286. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63287. /**
  63288. * Returns the data related to the updraft event (cylinder).
  63289. * @returns A physics updraft event
  63290. */
  63291. getData(): PhysicsUpdraftEventData;
  63292. /**
  63293. * Enables the updraft.
  63294. */
  63295. enable(): void;
  63296. /**
  63297. * Disables the updraft.
  63298. */
  63299. disable(): void;
  63300. /**
  63301. * Disposes the cylinder.
  63302. * @param force Specifies if the updraft should be disposed by force
  63303. */
  63304. dispose(force?: boolean): void;
  63305. private getImpostorHitData;
  63306. private _tick;
  63307. /*** Helpers ***/
  63308. private _prepareCylinder;
  63309. private _intersectsWithCylinder;
  63310. }
  63311. /**
  63312. * Represents a physics vortex event
  63313. */
  63314. class PhysicsVortexEvent {
  63315. private _scene;
  63316. private _origin;
  63317. private _options;
  63318. private _physicsEngine;
  63319. private _originTop;
  63320. private _tickCallback;
  63321. private _cylinder;
  63322. private _cylinderPosition;
  63323. private _dataFetched;
  63324. /**
  63325. * Initializes the physics vortex event
  63326. * @param _scene The BabylonJS scene
  63327. * @param _origin The origin position of the vortex
  63328. * @param _options The options for the vortex event
  63329. */
  63330. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63331. /**
  63332. * Returns the data related to the vortex event (cylinder).
  63333. * @returns The physics vortex event data
  63334. */
  63335. getData(): PhysicsVortexEventData;
  63336. /**
  63337. * Enables the vortex.
  63338. */
  63339. enable(): void;
  63340. /**
  63341. * Disables the cortex.
  63342. */
  63343. disable(): void;
  63344. /**
  63345. * Disposes the sphere.
  63346. * @param force
  63347. */
  63348. dispose(force?: boolean): void;
  63349. private getImpostorHitData;
  63350. private _tick;
  63351. /*** Helpers ***/
  63352. private _prepareCylinder;
  63353. private _intersectsWithCylinder;
  63354. }
  63355. /**
  63356. * Options fot the radial explosion event
  63357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63358. */
  63359. export class PhysicsRadialExplosionEventOptions {
  63360. /**
  63361. * The radius of the sphere for the radial explosion.
  63362. */
  63363. radius: number;
  63364. /**
  63365. * The strenth of the explosion.
  63366. */
  63367. strength: number;
  63368. /**
  63369. * The strenght of the force in correspondence to the distance of the affected object
  63370. */
  63371. falloff: PhysicsRadialImpulseFalloff;
  63372. /**
  63373. * Sphere options for the radial explosion.
  63374. */
  63375. sphere: {
  63376. segments: number;
  63377. diameter: number;
  63378. };
  63379. /**
  63380. * Sphere options for the radial explosion.
  63381. */
  63382. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63383. }
  63384. /**
  63385. * Options fot the updraft event
  63386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63387. */
  63388. export class PhysicsUpdraftEventOptions {
  63389. /**
  63390. * The radius of the cylinder for the vortex
  63391. */
  63392. radius: number;
  63393. /**
  63394. * The strenth of the updraft.
  63395. */
  63396. strength: number;
  63397. /**
  63398. * The height of the cylinder for the updraft.
  63399. */
  63400. height: number;
  63401. /**
  63402. * The mode for the the updraft.
  63403. */
  63404. updraftMode: PhysicsUpdraftMode;
  63405. }
  63406. /**
  63407. * Options fot the vortex event
  63408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63409. */
  63410. export class PhysicsVortexEventOptions {
  63411. /**
  63412. * The radius of the cylinder for the vortex
  63413. */
  63414. radius: number;
  63415. /**
  63416. * The strenth of the vortex.
  63417. */
  63418. strength: number;
  63419. /**
  63420. * The height of the cylinder for the vortex.
  63421. */
  63422. height: number;
  63423. /**
  63424. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63425. */
  63426. centripetalForceThreshold: number;
  63427. /**
  63428. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63429. */
  63430. centripetalForceMultiplier: number;
  63431. /**
  63432. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63433. */
  63434. centrifugalForceMultiplier: number;
  63435. /**
  63436. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63437. */
  63438. updraftForceMultiplier: number;
  63439. }
  63440. /**
  63441. * The strenght of the force in correspondence to the distance of the affected object
  63442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63443. */
  63444. export enum PhysicsRadialImpulseFalloff {
  63445. /** Defines that impulse is constant in strength across it's whole radius */
  63446. Constant = 0,
  63447. /** Defines that impulse gets weaker if it's further from the origin */
  63448. Linear = 1
  63449. }
  63450. /**
  63451. * The strength of the force in correspondence to the distance of the affected object
  63452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63453. */
  63454. export enum PhysicsUpdraftMode {
  63455. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63456. Center = 0,
  63457. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63458. Perpendicular = 1
  63459. }
  63460. /**
  63461. * Interface for a physics hit data
  63462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63463. */
  63464. export interface PhysicsHitData {
  63465. /**
  63466. * The force applied at the contact point
  63467. */
  63468. force: Vector3;
  63469. /**
  63470. * The contact point
  63471. */
  63472. contactPoint: Vector3;
  63473. /**
  63474. * The distance from the origin to the contact point
  63475. */
  63476. distanceFromOrigin: number;
  63477. }
  63478. /**
  63479. * Interface for radial explosion event data
  63480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63481. */
  63482. export interface PhysicsRadialExplosionEventData {
  63483. /**
  63484. * A sphere used for the radial explosion event
  63485. */
  63486. sphere: Mesh;
  63487. }
  63488. /**
  63489. * Interface for gravitational field event data
  63490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63491. */
  63492. export interface PhysicsGravitationalFieldEventData {
  63493. /**
  63494. * A sphere mesh used for the gravitational field event
  63495. */
  63496. sphere: Mesh;
  63497. }
  63498. /**
  63499. * Interface for updraft event data
  63500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63501. */
  63502. export interface PhysicsUpdraftEventData {
  63503. /**
  63504. * A cylinder used for the updraft event
  63505. */
  63506. cylinder: Mesh;
  63507. }
  63508. /**
  63509. * Interface for vortex event data
  63510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63511. */
  63512. export interface PhysicsVortexEventData {
  63513. /**
  63514. * A cylinder used for the vortex event
  63515. */
  63516. cylinder: Mesh;
  63517. }
  63518. /**
  63519. * Interface for an affected physics impostor
  63520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63521. */
  63522. export interface PhysicsAffectedImpostorWithData {
  63523. /**
  63524. * The impostor affected by the effect
  63525. */
  63526. impostor: PhysicsImpostor;
  63527. /**
  63528. * The data about the hit/horce from the explosion
  63529. */
  63530. hitData: PhysicsHitData;
  63531. }
  63532. }
  63533. declare module BABYLON {
  63534. /** @hidden */
  63535. export var blackAndWhitePixelShader: {
  63536. name: string;
  63537. shader: string;
  63538. };
  63539. }
  63540. declare module BABYLON {
  63541. /**
  63542. * Post process used to render in black and white
  63543. */
  63544. export class BlackAndWhitePostProcess extends PostProcess {
  63545. /**
  63546. * Linear about to convert he result to black and white (default: 1)
  63547. */
  63548. degree: number;
  63549. /**
  63550. * Creates a black and white post process
  63551. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63552. * @param name The name of the effect.
  63553. * @param options The required width/height ratio to downsize to before computing the render pass.
  63554. * @param camera The camera to apply the render pass to.
  63555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63556. * @param engine The engine which the post process will be applied. (default: current engine)
  63557. * @param reusable If the post process can be reused on the same frame. (default: false)
  63558. */
  63559. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63560. }
  63561. }
  63562. declare module BABYLON {
  63563. /**
  63564. * This represents a set of one or more post processes in Babylon.
  63565. * A post process can be used to apply a shader to a texture after it is rendered.
  63566. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63567. */
  63568. export class PostProcessRenderEffect {
  63569. private _postProcesses;
  63570. private _getPostProcesses;
  63571. private _singleInstance;
  63572. private _cameras;
  63573. private _indicesForCamera;
  63574. /**
  63575. * Name of the effect
  63576. * @hidden
  63577. */
  63578. _name: string;
  63579. /**
  63580. * Instantiates a post process render effect.
  63581. * A post process can be used to apply a shader to a texture after it is rendered.
  63582. * @param engine The engine the effect is tied to
  63583. * @param name The name of the effect
  63584. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63585. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63586. */
  63587. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63588. /**
  63589. * Checks if all the post processes in the effect are supported.
  63590. */
  63591. get isSupported(): boolean;
  63592. /**
  63593. * Updates the current state of the effect
  63594. * @hidden
  63595. */
  63596. _update(): void;
  63597. /**
  63598. * Attaches the effect on cameras
  63599. * @param cameras The camera to attach to.
  63600. * @hidden
  63601. */
  63602. _attachCameras(cameras: Camera): void;
  63603. /**
  63604. * Attaches the effect on cameras
  63605. * @param cameras The camera to attach to.
  63606. * @hidden
  63607. */
  63608. _attachCameras(cameras: Camera[]): void;
  63609. /**
  63610. * Detaches the effect on cameras
  63611. * @param cameras The camera to detatch from.
  63612. * @hidden
  63613. */
  63614. _detachCameras(cameras: Camera): void;
  63615. /**
  63616. * Detatches the effect on cameras
  63617. * @param cameras The camera to detatch from.
  63618. * @hidden
  63619. */
  63620. _detachCameras(cameras: Camera[]): void;
  63621. /**
  63622. * Enables the effect on given cameras
  63623. * @param cameras The camera to enable.
  63624. * @hidden
  63625. */
  63626. _enable(cameras: Camera): void;
  63627. /**
  63628. * Enables the effect on given cameras
  63629. * @param cameras The camera to enable.
  63630. * @hidden
  63631. */
  63632. _enable(cameras: Nullable<Camera[]>): void;
  63633. /**
  63634. * Disables the effect on the given cameras
  63635. * @param cameras The camera to disable.
  63636. * @hidden
  63637. */
  63638. _disable(cameras: Camera): void;
  63639. /**
  63640. * Disables the effect on the given cameras
  63641. * @param cameras The camera to disable.
  63642. * @hidden
  63643. */
  63644. _disable(cameras: Nullable<Camera[]>): void;
  63645. /**
  63646. * Gets a list of the post processes contained in the effect.
  63647. * @param camera The camera to get the post processes on.
  63648. * @returns The list of the post processes in the effect.
  63649. */
  63650. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63651. }
  63652. }
  63653. declare module BABYLON {
  63654. /** @hidden */
  63655. export var extractHighlightsPixelShader: {
  63656. name: string;
  63657. shader: string;
  63658. };
  63659. }
  63660. declare module BABYLON {
  63661. /**
  63662. * 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.
  63663. */
  63664. export class ExtractHighlightsPostProcess extends PostProcess {
  63665. /**
  63666. * The luminance threshold, pixels below this value will be set to black.
  63667. */
  63668. threshold: number;
  63669. /** @hidden */
  63670. _exposure: number;
  63671. /**
  63672. * Post process which has the input texture to be used when performing highlight extraction
  63673. * @hidden
  63674. */
  63675. _inputPostProcess: Nullable<PostProcess>;
  63676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63677. }
  63678. }
  63679. declare module BABYLON {
  63680. /** @hidden */
  63681. export var bloomMergePixelShader: {
  63682. name: string;
  63683. shader: string;
  63684. };
  63685. }
  63686. declare module BABYLON {
  63687. /**
  63688. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63689. */
  63690. export class BloomMergePostProcess extends PostProcess {
  63691. /** Weight of the bloom to be added to the original input. */
  63692. weight: number;
  63693. /**
  63694. * Creates a new instance of @see BloomMergePostProcess
  63695. * @param name The name of the effect.
  63696. * @param originalFromInput Post process which's input will be used for the merge.
  63697. * @param blurred Blurred highlights post process which's output will be used.
  63698. * @param weight Weight of the bloom to be added to the original input.
  63699. * @param options The required width/height ratio to downsize to before computing the render pass.
  63700. * @param camera The camera to apply the render pass to.
  63701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63702. * @param engine The engine which the post process will be applied. (default: current engine)
  63703. * @param reusable If the post process can be reused on the same frame. (default: false)
  63704. * @param textureType Type of textures used when performing the post process. (default: 0)
  63705. * @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)
  63706. */
  63707. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63708. /** Weight of the bloom to be added to the original input. */
  63709. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63710. }
  63711. }
  63712. declare module BABYLON {
  63713. /**
  63714. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63715. */
  63716. export class BloomEffect extends PostProcessRenderEffect {
  63717. private bloomScale;
  63718. /**
  63719. * @hidden Internal
  63720. */
  63721. _effects: Array<PostProcess>;
  63722. /**
  63723. * @hidden Internal
  63724. */
  63725. _downscale: ExtractHighlightsPostProcess;
  63726. private _blurX;
  63727. private _blurY;
  63728. private _merge;
  63729. /**
  63730. * The luminance threshold to find bright areas of the image to bloom.
  63731. */
  63732. get threshold(): number;
  63733. set threshold(value: number);
  63734. /**
  63735. * The strength of the bloom.
  63736. */
  63737. get weight(): number;
  63738. set weight(value: number);
  63739. /**
  63740. * Specifies the size of the bloom blur kernel, relative to the final output size
  63741. */
  63742. get kernel(): number;
  63743. set kernel(value: number);
  63744. /**
  63745. * Creates a new instance of @see BloomEffect
  63746. * @param scene The scene the effect belongs to.
  63747. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63748. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63749. * @param bloomWeight The the strength of bloom.
  63750. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63751. * @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)
  63752. */
  63753. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63754. /**
  63755. * Disposes each of the internal effects for a given camera.
  63756. * @param camera The camera to dispose the effect on.
  63757. */
  63758. disposeEffects(camera: Camera): void;
  63759. /**
  63760. * @hidden Internal
  63761. */
  63762. _updateEffects(): void;
  63763. /**
  63764. * Internal
  63765. * @returns if all the contained post processes are ready.
  63766. * @hidden
  63767. */
  63768. _isReady(): boolean;
  63769. }
  63770. }
  63771. declare module BABYLON {
  63772. /** @hidden */
  63773. export var chromaticAberrationPixelShader: {
  63774. name: string;
  63775. shader: string;
  63776. };
  63777. }
  63778. declare module BABYLON {
  63779. /**
  63780. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63781. */
  63782. export class ChromaticAberrationPostProcess extends PostProcess {
  63783. /**
  63784. * The amount of seperation of rgb channels (default: 30)
  63785. */
  63786. aberrationAmount: number;
  63787. /**
  63788. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63789. */
  63790. radialIntensity: number;
  63791. /**
  63792. * 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))
  63793. */
  63794. direction: Vector2;
  63795. /**
  63796. * 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))
  63797. */
  63798. centerPosition: Vector2;
  63799. /**
  63800. * Creates a new instance ChromaticAberrationPostProcess
  63801. * @param name The name of the effect.
  63802. * @param screenWidth The width of the screen to apply the effect on.
  63803. * @param screenHeight The height of the screen to apply the effect on.
  63804. * @param options The required width/height ratio to downsize to before computing the render pass.
  63805. * @param camera The camera to apply the render pass to.
  63806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63807. * @param engine The engine which the post process will be applied. (default: current engine)
  63808. * @param reusable If the post process can be reused on the same frame. (default: false)
  63809. * @param textureType Type of textures used when performing the post process. (default: 0)
  63810. * @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)
  63811. */
  63812. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /** @hidden */
  63817. export var circleOfConfusionPixelShader: {
  63818. name: string;
  63819. shader: string;
  63820. };
  63821. }
  63822. declare module BABYLON {
  63823. /**
  63824. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63825. */
  63826. export class CircleOfConfusionPostProcess extends PostProcess {
  63827. /**
  63828. * 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.
  63829. */
  63830. lensSize: number;
  63831. /**
  63832. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63833. */
  63834. fStop: number;
  63835. /**
  63836. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63837. */
  63838. focusDistance: number;
  63839. /**
  63840. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63841. */
  63842. focalLength: number;
  63843. private _depthTexture;
  63844. /**
  63845. * Creates a new instance CircleOfConfusionPostProcess
  63846. * @param name The name of the effect.
  63847. * @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.
  63848. * @param options The required width/height ratio to downsize to before computing the render pass.
  63849. * @param camera The camera to apply the render pass to.
  63850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63851. * @param engine The engine which the post process will be applied. (default: current engine)
  63852. * @param reusable If the post process can be reused on the same frame. (default: false)
  63853. * @param textureType Type of textures used when performing the post process. (default: 0)
  63854. * @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)
  63855. */
  63856. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63857. /**
  63858. * 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.
  63859. */
  63860. set depthTexture(value: RenderTargetTexture);
  63861. }
  63862. }
  63863. declare module BABYLON {
  63864. /** @hidden */
  63865. export var colorCorrectionPixelShader: {
  63866. name: string;
  63867. shader: string;
  63868. };
  63869. }
  63870. declare module BABYLON {
  63871. /**
  63872. *
  63873. * This post-process allows the modification of rendered colors by using
  63874. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63875. *
  63876. * The object needs to be provided an url to a texture containing the color
  63877. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63878. * Use an image editing software to tweak the LUT to match your needs.
  63879. *
  63880. * For an example of a color LUT, see here:
  63881. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63882. * For explanations on color grading, see here:
  63883. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63884. *
  63885. */
  63886. export class ColorCorrectionPostProcess extends PostProcess {
  63887. private _colorTableTexture;
  63888. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63889. }
  63890. }
  63891. declare module BABYLON {
  63892. /** @hidden */
  63893. export var convolutionPixelShader: {
  63894. name: string;
  63895. shader: string;
  63896. };
  63897. }
  63898. declare module BABYLON {
  63899. /**
  63900. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63901. * input texture to perform effects such as edge detection or sharpening
  63902. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63903. */
  63904. export class ConvolutionPostProcess extends PostProcess {
  63905. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63906. kernel: number[];
  63907. /**
  63908. * Creates a new instance ConvolutionPostProcess
  63909. * @param name The name of the effect.
  63910. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63911. * @param options The required width/height ratio to downsize to before computing the render pass.
  63912. * @param camera The camera to apply the render pass to.
  63913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63914. * @param engine The engine which the post process will be applied. (default: current engine)
  63915. * @param reusable If the post process can be reused on the same frame. (default: false)
  63916. * @param textureType Type of textures used when performing the post process. (default: 0)
  63917. */
  63918. constructor(name: string,
  63919. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63920. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63921. /**
  63922. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63923. */
  63924. static EdgeDetect0Kernel: number[];
  63925. /**
  63926. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63927. */
  63928. static EdgeDetect1Kernel: number[];
  63929. /**
  63930. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63931. */
  63932. static EdgeDetect2Kernel: number[];
  63933. /**
  63934. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63935. */
  63936. static SharpenKernel: number[];
  63937. /**
  63938. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63939. */
  63940. static EmbossKernel: number[];
  63941. /**
  63942. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63943. */
  63944. static GaussianKernel: number[];
  63945. }
  63946. }
  63947. declare module BABYLON {
  63948. /**
  63949. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63950. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63951. * based on samples that have a large difference in distance than the center pixel.
  63952. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63953. */
  63954. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63955. direction: Vector2;
  63956. /**
  63957. * Creates a new instance CircleOfConfusionPostProcess
  63958. * @param name The name of the effect.
  63959. * @param scene The scene the effect belongs to.
  63960. * @param direction The direction the blur should be applied.
  63961. * @param kernel The size of the kernel used to blur.
  63962. * @param options The required width/height ratio to downsize to before computing the render pass.
  63963. * @param camera The camera to apply the render pass to.
  63964. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63965. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63967. * @param engine The engine which the post process will be applied. (default: current engine)
  63968. * @param reusable If the post process can be reused on the same frame. (default: false)
  63969. * @param textureType Type of textures used when performing the post process. (default: 0)
  63970. * @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)
  63971. */
  63972. 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);
  63973. }
  63974. }
  63975. declare module BABYLON {
  63976. /** @hidden */
  63977. export var depthOfFieldMergePixelShader: {
  63978. name: string;
  63979. shader: string;
  63980. };
  63981. }
  63982. declare module BABYLON {
  63983. /**
  63984. * Options to be set when merging outputs from the default pipeline.
  63985. */
  63986. export class DepthOfFieldMergePostProcessOptions {
  63987. /**
  63988. * The original image to merge on top of
  63989. */
  63990. originalFromInput: PostProcess;
  63991. /**
  63992. * Parameters to perform the merge of the depth of field effect
  63993. */
  63994. depthOfField?: {
  63995. circleOfConfusion: PostProcess;
  63996. blurSteps: Array<PostProcess>;
  63997. };
  63998. /**
  63999. * Parameters to perform the merge of bloom effect
  64000. */
  64001. bloom?: {
  64002. blurred: PostProcess;
  64003. weight: number;
  64004. };
  64005. }
  64006. /**
  64007. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64008. */
  64009. export class DepthOfFieldMergePostProcess extends PostProcess {
  64010. private blurSteps;
  64011. /**
  64012. * Creates a new instance of DepthOfFieldMergePostProcess
  64013. * @param name The name of the effect.
  64014. * @param originalFromInput Post process which's input will be used for the merge.
  64015. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64016. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64017. * @param options The required width/height ratio to downsize to before computing the render pass.
  64018. * @param camera The camera to apply the render pass to.
  64019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64020. * @param engine The engine which the post process will be applied. (default: current engine)
  64021. * @param reusable If the post process can be reused on the same frame. (default: false)
  64022. * @param textureType Type of textures used when performing the post process. (default: 0)
  64023. * @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)
  64024. */
  64025. 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);
  64026. /**
  64027. * Updates the effect with the current post process compile time values and recompiles the shader.
  64028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64031. * @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
  64032. * @param onCompiled Called when the shader has been compiled.
  64033. * @param onError Called if there is an error when compiling a shader.
  64034. */
  64035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64036. }
  64037. }
  64038. declare module BABYLON {
  64039. /**
  64040. * Specifies the level of max blur that should be applied when using the depth of field effect
  64041. */
  64042. export enum DepthOfFieldEffectBlurLevel {
  64043. /**
  64044. * Subtle blur
  64045. */
  64046. Low = 0,
  64047. /**
  64048. * Medium blur
  64049. */
  64050. Medium = 1,
  64051. /**
  64052. * Large blur
  64053. */
  64054. High = 2
  64055. }
  64056. /**
  64057. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64058. */
  64059. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64060. private _circleOfConfusion;
  64061. /**
  64062. * @hidden Internal, blurs from high to low
  64063. */
  64064. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64065. private _depthOfFieldBlurY;
  64066. private _dofMerge;
  64067. /**
  64068. * @hidden Internal post processes in depth of field effect
  64069. */
  64070. _effects: Array<PostProcess>;
  64071. /**
  64072. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64073. */
  64074. set focalLength(value: number);
  64075. get focalLength(): number;
  64076. /**
  64077. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64078. */
  64079. set fStop(value: number);
  64080. get fStop(): number;
  64081. /**
  64082. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64083. */
  64084. set focusDistance(value: number);
  64085. get focusDistance(): number;
  64086. /**
  64087. * 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.
  64088. */
  64089. set lensSize(value: number);
  64090. get lensSize(): number;
  64091. /**
  64092. * Creates a new instance DepthOfFieldEffect
  64093. * @param scene The scene the effect belongs to.
  64094. * @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.
  64095. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64096. * @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)
  64097. */
  64098. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64099. /**
  64100. * Get the current class name of the current effet
  64101. * @returns "DepthOfFieldEffect"
  64102. */
  64103. getClassName(): string;
  64104. /**
  64105. * 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.
  64106. */
  64107. set depthTexture(value: RenderTargetTexture);
  64108. /**
  64109. * Disposes each of the internal effects for a given camera.
  64110. * @param camera The camera to dispose the effect on.
  64111. */
  64112. disposeEffects(camera: Camera): void;
  64113. /**
  64114. * @hidden Internal
  64115. */
  64116. _updateEffects(): void;
  64117. /**
  64118. * Internal
  64119. * @returns if all the contained post processes are ready.
  64120. * @hidden
  64121. */
  64122. _isReady(): boolean;
  64123. }
  64124. }
  64125. declare module BABYLON {
  64126. /** @hidden */
  64127. export var displayPassPixelShader: {
  64128. name: string;
  64129. shader: string;
  64130. };
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * DisplayPassPostProcess which produces an output the same as it's input
  64135. */
  64136. export class DisplayPassPostProcess extends PostProcess {
  64137. /**
  64138. * Creates the DisplayPassPostProcess
  64139. * @param name The name of the effect.
  64140. * @param options The required width/height ratio to downsize to before computing the render pass.
  64141. * @param camera The camera to apply the render pass to.
  64142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64143. * @param engine The engine which the post process will be applied. (default: current engine)
  64144. * @param reusable If the post process can be reused on the same frame. (default: false)
  64145. */
  64146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64147. }
  64148. }
  64149. declare module BABYLON {
  64150. /** @hidden */
  64151. export var filterPixelShader: {
  64152. name: string;
  64153. shader: string;
  64154. };
  64155. }
  64156. declare module BABYLON {
  64157. /**
  64158. * Applies a kernel filter to the image
  64159. */
  64160. export class FilterPostProcess extends PostProcess {
  64161. /** The matrix to be applied to the image */
  64162. kernelMatrix: Matrix;
  64163. /**
  64164. *
  64165. * @param name The name of the effect.
  64166. * @param kernelMatrix The matrix to be applied to the image
  64167. * @param options The required width/height ratio to downsize to before computing the render pass.
  64168. * @param camera The camera to apply the render pass to.
  64169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64170. * @param engine The engine which the post process will be applied. (default: current engine)
  64171. * @param reusable If the post process can be reused on the same frame. (default: false)
  64172. */
  64173. constructor(name: string,
  64174. /** The matrix to be applied to the image */
  64175. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64176. }
  64177. }
  64178. declare module BABYLON {
  64179. /** @hidden */
  64180. export var fxaaPixelShader: {
  64181. name: string;
  64182. shader: string;
  64183. };
  64184. }
  64185. declare module BABYLON {
  64186. /** @hidden */
  64187. export var fxaaVertexShader: {
  64188. name: string;
  64189. shader: string;
  64190. };
  64191. }
  64192. declare module BABYLON {
  64193. /**
  64194. * Fxaa post process
  64195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64196. */
  64197. export class FxaaPostProcess extends PostProcess {
  64198. /** @hidden */
  64199. texelWidth: number;
  64200. /** @hidden */
  64201. texelHeight: number;
  64202. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64203. private _getDefines;
  64204. }
  64205. }
  64206. declare module BABYLON {
  64207. /** @hidden */
  64208. export var grainPixelShader: {
  64209. name: string;
  64210. shader: string;
  64211. };
  64212. }
  64213. declare module BABYLON {
  64214. /**
  64215. * The GrainPostProcess adds noise to the image at mid luminance levels
  64216. */
  64217. export class GrainPostProcess extends PostProcess {
  64218. /**
  64219. * The intensity of the grain added (default: 30)
  64220. */
  64221. intensity: number;
  64222. /**
  64223. * If the grain should be randomized on every frame
  64224. */
  64225. animated: boolean;
  64226. /**
  64227. * Creates a new instance of @see GrainPostProcess
  64228. * @param name The name of the effect.
  64229. * @param options The required width/height ratio to downsize to before computing the render pass.
  64230. * @param camera The camera to apply the render pass to.
  64231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64232. * @param engine The engine which the post process will be applied. (default: current engine)
  64233. * @param reusable If the post process can be reused on the same frame. (default: false)
  64234. * @param textureType Type of textures used when performing the post process. (default: 0)
  64235. * @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)
  64236. */
  64237. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /** @hidden */
  64242. export var highlightsPixelShader: {
  64243. name: string;
  64244. shader: string;
  64245. };
  64246. }
  64247. declare module BABYLON {
  64248. /**
  64249. * Extracts highlights from the image
  64250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64251. */
  64252. export class HighlightsPostProcess extends PostProcess {
  64253. /**
  64254. * Extracts highlights from the image
  64255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64256. * @param name The name of the effect.
  64257. * @param options The required width/height ratio to downsize to before computing the render pass.
  64258. * @param camera The camera to apply the render pass to.
  64259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64260. * @param engine The engine which the post process will be applied. (default: current engine)
  64261. * @param reusable If the post process can be reused on the same frame. (default: false)
  64262. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64263. */
  64264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /** @hidden */
  64269. export var mrtFragmentDeclaration: {
  64270. name: string;
  64271. shader: string;
  64272. };
  64273. }
  64274. declare module BABYLON {
  64275. /** @hidden */
  64276. export var geometryPixelShader: {
  64277. name: string;
  64278. shader: string;
  64279. };
  64280. }
  64281. declare module BABYLON {
  64282. /** @hidden */
  64283. export var geometryVertexShader: {
  64284. name: string;
  64285. shader: string;
  64286. };
  64287. }
  64288. declare module BABYLON {
  64289. /** @hidden */
  64290. interface ISavedTransformationMatrix {
  64291. world: Matrix;
  64292. viewProjection: Matrix;
  64293. }
  64294. /**
  64295. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64296. */
  64297. export class GeometryBufferRenderer {
  64298. /**
  64299. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64300. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64301. */
  64302. static readonly POSITION_TEXTURE_TYPE: number;
  64303. /**
  64304. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64305. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64306. */
  64307. static readonly VELOCITY_TEXTURE_TYPE: number;
  64308. /**
  64309. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64310. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64311. */
  64312. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64313. /**
  64314. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64315. * in order to compute objects velocities when enableVelocity is set to "true"
  64316. * @hidden
  64317. */
  64318. _previousTransformationMatrices: {
  64319. [index: number]: ISavedTransformationMatrix;
  64320. };
  64321. /**
  64322. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64323. * in order to compute objects velocities when enableVelocity is set to "true"
  64324. * @hidden
  64325. */
  64326. _previousBonesTransformationMatrices: {
  64327. [index: number]: Float32Array;
  64328. };
  64329. /**
  64330. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64331. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64332. */
  64333. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64334. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64335. renderTransparentMeshes: boolean;
  64336. private _scene;
  64337. private _multiRenderTarget;
  64338. private _ratio;
  64339. private _enablePosition;
  64340. private _enableVelocity;
  64341. private _enableReflectivity;
  64342. private _positionIndex;
  64343. private _velocityIndex;
  64344. private _reflectivityIndex;
  64345. protected _effect: Effect;
  64346. protected _cachedDefines: string;
  64347. /**
  64348. * Set the render list (meshes to be rendered) used in the G buffer.
  64349. */
  64350. set renderList(meshes: Mesh[]);
  64351. /**
  64352. * Gets wether or not G buffer are supported by the running hardware.
  64353. * This requires draw buffer supports
  64354. */
  64355. get isSupported(): boolean;
  64356. /**
  64357. * Returns the index of the given texture type in the G-Buffer textures array
  64358. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64359. * @returns the index of the given texture type in the G-Buffer textures array
  64360. */
  64361. getTextureIndex(textureType: number): number;
  64362. /**
  64363. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64364. */
  64365. get enablePosition(): boolean;
  64366. /**
  64367. * Sets whether or not objects positions are enabled for the G buffer.
  64368. */
  64369. set enablePosition(enable: boolean);
  64370. /**
  64371. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64372. */
  64373. get enableVelocity(): boolean;
  64374. /**
  64375. * Sets wether or not objects velocities are enabled for the G buffer.
  64376. */
  64377. set enableVelocity(enable: boolean);
  64378. /**
  64379. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64380. */
  64381. get enableReflectivity(): boolean;
  64382. /**
  64383. * Sets wether or not objects roughness are enabled for the G buffer.
  64384. */
  64385. set enableReflectivity(enable: boolean);
  64386. /**
  64387. * Gets the scene associated with the buffer.
  64388. */
  64389. get scene(): Scene;
  64390. /**
  64391. * Gets the ratio used by the buffer during its creation.
  64392. * How big is the buffer related to the main canvas.
  64393. */
  64394. get ratio(): number;
  64395. /** @hidden */
  64396. static _SceneComponentInitialization: (scene: Scene) => void;
  64397. /**
  64398. * Creates a new G Buffer for the scene
  64399. * @param scene The scene the buffer belongs to
  64400. * @param ratio How big is the buffer related to the main canvas.
  64401. */
  64402. constructor(scene: Scene, ratio?: number);
  64403. /**
  64404. * Checks wether everything is ready to render a submesh to the G buffer.
  64405. * @param subMesh the submesh to check readiness for
  64406. * @param useInstances is the mesh drawn using instance or not
  64407. * @returns true if ready otherwise false
  64408. */
  64409. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64410. /**
  64411. * Gets the current underlying G Buffer.
  64412. * @returns the buffer
  64413. */
  64414. getGBuffer(): MultiRenderTarget;
  64415. /**
  64416. * Gets the number of samples used to render the buffer (anti aliasing).
  64417. */
  64418. get samples(): number;
  64419. /**
  64420. * Sets the number of samples used to render the buffer (anti aliasing).
  64421. */
  64422. set samples(value: number);
  64423. /**
  64424. * Disposes the renderer and frees up associated resources.
  64425. */
  64426. dispose(): void;
  64427. protected _createRenderTargets(): void;
  64428. private _copyBonesTransformationMatrices;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. interface Scene {
  64433. /** @hidden (Backing field) */
  64434. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64435. /**
  64436. * Gets or Sets the current geometry buffer associated to the scene.
  64437. */
  64438. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64439. /**
  64440. * Enables a GeometryBufferRender and associates it with the scene
  64441. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64442. * @returns the GeometryBufferRenderer
  64443. */
  64444. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64445. /**
  64446. * Disables the GeometryBufferRender associated with the scene
  64447. */
  64448. disableGeometryBufferRenderer(): void;
  64449. }
  64450. /**
  64451. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64452. * in several rendering techniques.
  64453. */
  64454. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64455. /**
  64456. * The component name helpful to identify the component in the list of scene components.
  64457. */
  64458. readonly name: string;
  64459. /**
  64460. * The scene the component belongs to.
  64461. */
  64462. scene: Scene;
  64463. /**
  64464. * Creates a new instance of the component for the given scene
  64465. * @param scene Defines the scene to register the component in
  64466. */
  64467. constructor(scene: Scene);
  64468. /**
  64469. * Registers the component in a given scene
  64470. */
  64471. register(): void;
  64472. /**
  64473. * Rebuilds the elements related to this component in case of
  64474. * context lost for instance.
  64475. */
  64476. rebuild(): void;
  64477. /**
  64478. * Disposes the component and the associated ressources
  64479. */
  64480. dispose(): void;
  64481. private _gatherRenderTargets;
  64482. }
  64483. }
  64484. declare module BABYLON {
  64485. /** @hidden */
  64486. export var motionBlurPixelShader: {
  64487. name: string;
  64488. shader: string;
  64489. };
  64490. }
  64491. declare module BABYLON {
  64492. /**
  64493. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64494. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64495. * As an example, all you have to do is to create the post-process:
  64496. * var mb = new BABYLON.MotionBlurPostProcess(
  64497. * 'mb', // The name of the effect.
  64498. * scene, // The scene containing the objects to blur according to their velocity.
  64499. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64500. * camera // The camera to apply the render pass to.
  64501. * );
  64502. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64503. */
  64504. export class MotionBlurPostProcess extends PostProcess {
  64505. /**
  64506. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64507. */
  64508. motionStrength: number;
  64509. /**
  64510. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64511. */
  64512. get motionBlurSamples(): number;
  64513. /**
  64514. * Sets the number of iterations to be used for motion blur quality
  64515. */
  64516. set motionBlurSamples(samples: number);
  64517. private _motionBlurSamples;
  64518. private _geometryBufferRenderer;
  64519. /**
  64520. * Creates a new instance MotionBlurPostProcess
  64521. * @param name The name of the effect.
  64522. * @param scene The scene containing the objects to blur according to their velocity.
  64523. * @param options The required width/height ratio to downsize to before computing the render pass.
  64524. * @param camera The camera to apply the render pass to.
  64525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64526. * @param engine The engine which the post process will be applied. (default: current engine)
  64527. * @param reusable If the post process can be reused on the same frame. (default: false)
  64528. * @param textureType Type of textures used when performing the post process. (default: 0)
  64529. * @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)
  64530. */
  64531. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64532. /**
  64533. * Excludes the given skinned mesh from computing bones velocities.
  64534. * 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.
  64535. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64536. */
  64537. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64538. /**
  64539. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64540. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64541. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64542. */
  64543. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64544. /**
  64545. * Disposes the post process.
  64546. * @param camera The camera to dispose the post process on.
  64547. */
  64548. dispose(camera?: Camera): void;
  64549. }
  64550. }
  64551. declare module BABYLON {
  64552. /** @hidden */
  64553. export var refractionPixelShader: {
  64554. name: string;
  64555. shader: string;
  64556. };
  64557. }
  64558. declare module BABYLON {
  64559. /**
  64560. * Post process which applies a refractin texture
  64561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64562. */
  64563. export class RefractionPostProcess extends PostProcess {
  64564. /** the base color of the refraction (used to taint the rendering) */
  64565. color: Color3;
  64566. /** simulated refraction depth */
  64567. depth: number;
  64568. /** the coefficient of the base color (0 to remove base color tainting) */
  64569. colorLevel: number;
  64570. private _refTexture;
  64571. private _ownRefractionTexture;
  64572. /**
  64573. * Gets or sets the refraction texture
  64574. * Please note that you are responsible for disposing the texture if you set it manually
  64575. */
  64576. get refractionTexture(): Texture;
  64577. set refractionTexture(value: Texture);
  64578. /**
  64579. * Initializes the RefractionPostProcess
  64580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64581. * @param name The name of the effect.
  64582. * @param refractionTextureUrl Url of the refraction texture to use
  64583. * @param color the base color of the refraction (used to taint the rendering)
  64584. * @param depth simulated refraction depth
  64585. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64586. * @param camera The camera to apply the render pass to.
  64587. * @param options The required width/height ratio to downsize to before computing the render pass.
  64588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64589. * @param engine The engine which the post process will be applied. (default: current engine)
  64590. * @param reusable If the post process can be reused on the same frame. (default: false)
  64591. */
  64592. constructor(name: string, refractionTextureUrl: string,
  64593. /** the base color of the refraction (used to taint the rendering) */
  64594. color: Color3,
  64595. /** simulated refraction depth */
  64596. depth: number,
  64597. /** the coefficient of the base color (0 to remove base color tainting) */
  64598. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64599. /**
  64600. * Disposes of the post process
  64601. * @param camera Camera to dispose post process on
  64602. */
  64603. dispose(camera: Camera): void;
  64604. }
  64605. }
  64606. declare module BABYLON {
  64607. /** @hidden */
  64608. export var sharpenPixelShader: {
  64609. name: string;
  64610. shader: string;
  64611. };
  64612. }
  64613. declare module BABYLON {
  64614. /**
  64615. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64616. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64617. */
  64618. export class SharpenPostProcess extends PostProcess {
  64619. /**
  64620. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64621. */
  64622. colorAmount: number;
  64623. /**
  64624. * How much sharpness should be applied (default: 0.3)
  64625. */
  64626. edgeAmount: number;
  64627. /**
  64628. * Creates a new instance ConvolutionPostProcess
  64629. * @param name The name of the effect.
  64630. * @param options The required width/height ratio to downsize to before computing the render pass.
  64631. * @param camera The camera to apply the render pass to.
  64632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64633. * @param engine The engine which the post process will be applied. (default: current engine)
  64634. * @param reusable If the post process can be reused on the same frame. (default: false)
  64635. * @param textureType Type of textures used when performing the post process. (default: 0)
  64636. * @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)
  64637. */
  64638. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * PostProcessRenderPipeline
  64644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64645. */
  64646. export class PostProcessRenderPipeline {
  64647. private engine;
  64648. private _renderEffects;
  64649. private _renderEffectsForIsolatedPass;
  64650. /**
  64651. * List of inspectable custom properties (used by the Inspector)
  64652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64653. */
  64654. inspectableCustomProperties: IInspectable[];
  64655. /**
  64656. * @hidden
  64657. */
  64658. protected _cameras: Camera[];
  64659. /** @hidden */
  64660. _name: string;
  64661. /**
  64662. * Gets pipeline name
  64663. */
  64664. get name(): string;
  64665. /** Gets the list of attached cameras */
  64666. get cameras(): Camera[];
  64667. /**
  64668. * Initializes a PostProcessRenderPipeline
  64669. * @param engine engine to add the pipeline to
  64670. * @param name name of the pipeline
  64671. */
  64672. constructor(engine: Engine, name: string);
  64673. /**
  64674. * Gets the class name
  64675. * @returns "PostProcessRenderPipeline"
  64676. */
  64677. getClassName(): string;
  64678. /**
  64679. * If all the render effects in the pipeline are supported
  64680. */
  64681. get isSupported(): boolean;
  64682. /**
  64683. * Adds an effect to the pipeline
  64684. * @param renderEffect the effect to add
  64685. */
  64686. addEffect(renderEffect: PostProcessRenderEffect): void;
  64687. /** @hidden */
  64688. _rebuild(): void;
  64689. /** @hidden */
  64690. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64691. /** @hidden */
  64692. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64693. /** @hidden */
  64694. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64695. /** @hidden */
  64696. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64697. /** @hidden */
  64698. _attachCameras(cameras: Camera, unique: boolean): void;
  64699. /** @hidden */
  64700. _attachCameras(cameras: Camera[], unique: boolean): void;
  64701. /** @hidden */
  64702. _detachCameras(cameras: Camera): void;
  64703. /** @hidden */
  64704. _detachCameras(cameras: Nullable<Camera[]>): void;
  64705. /** @hidden */
  64706. _update(): void;
  64707. /** @hidden */
  64708. _reset(): void;
  64709. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64710. /**
  64711. * Disposes of the pipeline
  64712. */
  64713. dispose(): void;
  64714. }
  64715. }
  64716. declare module BABYLON {
  64717. /**
  64718. * PostProcessRenderPipelineManager class
  64719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64720. */
  64721. export class PostProcessRenderPipelineManager {
  64722. private _renderPipelines;
  64723. /**
  64724. * Initializes a PostProcessRenderPipelineManager
  64725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64726. */
  64727. constructor();
  64728. /**
  64729. * Gets the list of supported render pipelines
  64730. */
  64731. get supportedPipelines(): PostProcessRenderPipeline[];
  64732. /**
  64733. * Adds a pipeline to the manager
  64734. * @param renderPipeline The pipeline to add
  64735. */
  64736. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64737. /**
  64738. * Attaches a camera to the pipeline
  64739. * @param renderPipelineName The name of the pipeline to attach to
  64740. * @param cameras the camera to attach
  64741. * @param unique if the camera can be attached multiple times to the pipeline
  64742. */
  64743. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64744. /**
  64745. * Detaches a camera from the pipeline
  64746. * @param renderPipelineName The name of the pipeline to detach from
  64747. * @param cameras the camera to detach
  64748. */
  64749. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64750. /**
  64751. * Enables an effect by name on a pipeline
  64752. * @param renderPipelineName the name of the pipeline to enable the effect in
  64753. * @param renderEffectName the name of the effect to enable
  64754. * @param cameras the cameras that the effect should be enabled on
  64755. */
  64756. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64757. /**
  64758. * Disables an effect by name on a pipeline
  64759. * @param renderPipelineName the name of the pipeline to disable the effect in
  64760. * @param renderEffectName the name of the effect to disable
  64761. * @param cameras the cameras that the effect should be disabled on
  64762. */
  64763. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64764. /**
  64765. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64766. */
  64767. update(): void;
  64768. /** @hidden */
  64769. _rebuild(): void;
  64770. /**
  64771. * Disposes of the manager and pipelines
  64772. */
  64773. dispose(): void;
  64774. }
  64775. }
  64776. declare module BABYLON {
  64777. interface Scene {
  64778. /** @hidden (Backing field) */
  64779. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64780. /**
  64781. * Gets the postprocess render pipeline manager
  64782. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64783. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64784. */
  64785. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64786. }
  64787. /**
  64788. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64789. */
  64790. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64791. /**
  64792. * The component name helpfull to identify the component in the list of scene components.
  64793. */
  64794. readonly name: string;
  64795. /**
  64796. * The scene the component belongs to.
  64797. */
  64798. scene: Scene;
  64799. /**
  64800. * Creates a new instance of the component for the given scene
  64801. * @param scene Defines the scene to register the component in
  64802. */
  64803. constructor(scene: Scene);
  64804. /**
  64805. * Registers the component in a given scene
  64806. */
  64807. register(): void;
  64808. /**
  64809. * Rebuilds the elements related to this component in case of
  64810. * context lost for instance.
  64811. */
  64812. rebuild(): void;
  64813. /**
  64814. * Disposes the component and the associated ressources
  64815. */
  64816. dispose(): void;
  64817. private _gatherRenderTargets;
  64818. }
  64819. }
  64820. declare module BABYLON {
  64821. /**
  64822. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64823. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64824. */
  64825. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64826. private _scene;
  64827. private _camerasToBeAttached;
  64828. /**
  64829. * ID of the sharpen post process,
  64830. */
  64831. private readonly SharpenPostProcessId;
  64832. /**
  64833. * @ignore
  64834. * ID of the image processing post process;
  64835. */
  64836. readonly ImageProcessingPostProcessId: string;
  64837. /**
  64838. * @ignore
  64839. * ID of the Fast Approximate Anti-Aliasing post process;
  64840. */
  64841. readonly FxaaPostProcessId: string;
  64842. /**
  64843. * ID of the chromatic aberration post process,
  64844. */
  64845. private readonly ChromaticAberrationPostProcessId;
  64846. /**
  64847. * ID of the grain post process
  64848. */
  64849. private readonly GrainPostProcessId;
  64850. /**
  64851. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64852. */
  64853. sharpen: SharpenPostProcess;
  64854. private _sharpenEffect;
  64855. private bloom;
  64856. /**
  64857. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64858. */
  64859. depthOfField: DepthOfFieldEffect;
  64860. /**
  64861. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64862. */
  64863. fxaa: FxaaPostProcess;
  64864. /**
  64865. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64866. */
  64867. imageProcessing: ImageProcessingPostProcess;
  64868. /**
  64869. * Chromatic aberration post process which will shift rgb colors in the image
  64870. */
  64871. chromaticAberration: ChromaticAberrationPostProcess;
  64872. private _chromaticAberrationEffect;
  64873. /**
  64874. * Grain post process which add noise to the image
  64875. */
  64876. grain: GrainPostProcess;
  64877. private _grainEffect;
  64878. /**
  64879. * Glow post process which adds a glow to emissive areas of the image
  64880. */
  64881. private _glowLayer;
  64882. /**
  64883. * Animations which can be used to tweak settings over a period of time
  64884. */
  64885. animations: Animation[];
  64886. private _imageProcessingConfigurationObserver;
  64887. private _sharpenEnabled;
  64888. private _bloomEnabled;
  64889. private _depthOfFieldEnabled;
  64890. private _depthOfFieldBlurLevel;
  64891. private _fxaaEnabled;
  64892. private _imageProcessingEnabled;
  64893. private _defaultPipelineTextureType;
  64894. private _bloomScale;
  64895. private _chromaticAberrationEnabled;
  64896. private _grainEnabled;
  64897. private _buildAllowed;
  64898. /**
  64899. * Gets active scene
  64900. */
  64901. get scene(): Scene;
  64902. /**
  64903. * Enable or disable the sharpen process from the pipeline
  64904. */
  64905. set sharpenEnabled(enabled: boolean);
  64906. get sharpenEnabled(): boolean;
  64907. private _resizeObserver;
  64908. private _hardwareScaleLevel;
  64909. private _bloomKernel;
  64910. /**
  64911. * Specifies the size of the bloom blur kernel, relative to the final output size
  64912. */
  64913. get bloomKernel(): number;
  64914. set bloomKernel(value: number);
  64915. /**
  64916. * Specifies the weight of the bloom in the final rendering
  64917. */
  64918. private _bloomWeight;
  64919. /**
  64920. * Specifies the luma threshold for the area that will be blurred by the bloom
  64921. */
  64922. private _bloomThreshold;
  64923. private _hdr;
  64924. /**
  64925. * The strength of the bloom.
  64926. */
  64927. set bloomWeight(value: number);
  64928. get bloomWeight(): number;
  64929. /**
  64930. * The strength of the bloom.
  64931. */
  64932. set bloomThreshold(value: number);
  64933. get bloomThreshold(): number;
  64934. /**
  64935. * The scale of the bloom, lower value will provide better performance.
  64936. */
  64937. set bloomScale(value: number);
  64938. get bloomScale(): number;
  64939. /**
  64940. * Enable or disable the bloom from the pipeline
  64941. */
  64942. set bloomEnabled(enabled: boolean);
  64943. get bloomEnabled(): boolean;
  64944. private _rebuildBloom;
  64945. /**
  64946. * If the depth of field is enabled.
  64947. */
  64948. get depthOfFieldEnabled(): boolean;
  64949. set depthOfFieldEnabled(enabled: boolean);
  64950. /**
  64951. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64952. */
  64953. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  64954. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  64955. /**
  64956. * If the anti aliasing is enabled.
  64957. */
  64958. set fxaaEnabled(enabled: boolean);
  64959. get fxaaEnabled(): boolean;
  64960. private _samples;
  64961. /**
  64962. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64963. */
  64964. set samples(sampleCount: number);
  64965. get samples(): number;
  64966. /**
  64967. * If image processing is enabled.
  64968. */
  64969. set imageProcessingEnabled(enabled: boolean);
  64970. get imageProcessingEnabled(): boolean;
  64971. /**
  64972. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64973. */
  64974. set glowLayerEnabled(enabled: boolean);
  64975. get glowLayerEnabled(): boolean;
  64976. /**
  64977. * Gets the glow layer (or null if not defined)
  64978. */
  64979. get glowLayer(): Nullable<GlowLayer>;
  64980. /**
  64981. * Enable or disable the chromaticAberration process from the pipeline
  64982. */
  64983. set chromaticAberrationEnabled(enabled: boolean);
  64984. get chromaticAberrationEnabled(): boolean;
  64985. /**
  64986. * Enable or disable the grain process from the pipeline
  64987. */
  64988. set grainEnabled(enabled: boolean);
  64989. get grainEnabled(): boolean;
  64990. /**
  64991. * @constructor
  64992. * @param name - The rendering pipeline name (default: "")
  64993. * @param hdr - If high dynamic range textures should be used (default: true)
  64994. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64995. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64996. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64997. */
  64998. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64999. /**
  65000. * Get the class name
  65001. * @returns "DefaultRenderingPipeline"
  65002. */
  65003. getClassName(): string;
  65004. /**
  65005. * Force the compilation of the entire pipeline.
  65006. */
  65007. prepare(): void;
  65008. private _hasCleared;
  65009. private _prevPostProcess;
  65010. private _prevPrevPostProcess;
  65011. private _setAutoClearAndTextureSharing;
  65012. private _depthOfFieldSceneObserver;
  65013. private _buildPipeline;
  65014. private _disposePostProcesses;
  65015. /**
  65016. * Adds a camera to the pipeline
  65017. * @param camera the camera to be added
  65018. */
  65019. addCamera(camera: Camera): void;
  65020. /**
  65021. * Removes a camera from the pipeline
  65022. * @param camera the camera to remove
  65023. */
  65024. removeCamera(camera: Camera): void;
  65025. /**
  65026. * Dispose of the pipeline and stop all post processes
  65027. */
  65028. dispose(): void;
  65029. /**
  65030. * Serialize the rendering pipeline (Used when exporting)
  65031. * @returns the serialized object
  65032. */
  65033. serialize(): any;
  65034. /**
  65035. * Parse the serialized pipeline
  65036. * @param source Source pipeline.
  65037. * @param scene The scene to load the pipeline to.
  65038. * @param rootUrl The URL of the serialized pipeline.
  65039. * @returns An instantiated pipeline from the serialized object.
  65040. */
  65041. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65042. }
  65043. }
  65044. declare module BABYLON {
  65045. /** @hidden */
  65046. export var lensHighlightsPixelShader: {
  65047. name: string;
  65048. shader: string;
  65049. };
  65050. }
  65051. declare module BABYLON {
  65052. /** @hidden */
  65053. export var depthOfFieldPixelShader: {
  65054. name: string;
  65055. shader: string;
  65056. };
  65057. }
  65058. declare module BABYLON {
  65059. /**
  65060. * BABYLON.JS Chromatic Aberration GLSL Shader
  65061. * Author: Olivier Guyot
  65062. * Separates very slightly R, G and B colors on the edges of the screen
  65063. * Inspired by Francois Tarlier & Martins Upitis
  65064. */
  65065. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65066. /**
  65067. * @ignore
  65068. * The chromatic aberration PostProcess id in the pipeline
  65069. */
  65070. LensChromaticAberrationEffect: string;
  65071. /**
  65072. * @ignore
  65073. * The highlights enhancing PostProcess id in the pipeline
  65074. */
  65075. HighlightsEnhancingEffect: string;
  65076. /**
  65077. * @ignore
  65078. * The depth-of-field PostProcess id in the pipeline
  65079. */
  65080. LensDepthOfFieldEffect: string;
  65081. private _scene;
  65082. private _depthTexture;
  65083. private _grainTexture;
  65084. private _chromaticAberrationPostProcess;
  65085. private _highlightsPostProcess;
  65086. private _depthOfFieldPostProcess;
  65087. private _edgeBlur;
  65088. private _grainAmount;
  65089. private _chromaticAberration;
  65090. private _distortion;
  65091. private _highlightsGain;
  65092. private _highlightsThreshold;
  65093. private _dofDistance;
  65094. private _dofAperture;
  65095. private _dofDarken;
  65096. private _dofPentagon;
  65097. private _blurNoise;
  65098. /**
  65099. * @constructor
  65100. *
  65101. * Effect parameters are as follow:
  65102. * {
  65103. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65104. * edge_blur: number; // from 0 to x (1 for realism)
  65105. * distortion: number; // from 0 to x (1 for realism)
  65106. * grain_amount: number; // from 0 to 1
  65107. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65108. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65109. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65110. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65111. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65112. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65113. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65114. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65115. * }
  65116. * Note: if an effect parameter is unset, effect is disabled
  65117. *
  65118. * @param name The rendering pipeline name
  65119. * @param parameters - An object containing all parameters (see above)
  65120. * @param scene The scene linked to this pipeline
  65121. * @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)
  65122. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65123. */
  65124. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65125. /**
  65126. * Get the class name
  65127. * @returns "LensRenderingPipeline"
  65128. */
  65129. getClassName(): string;
  65130. /**
  65131. * Gets associated scene
  65132. */
  65133. get scene(): Scene;
  65134. /**
  65135. * Gets or sets the edge blur
  65136. */
  65137. get edgeBlur(): number;
  65138. set edgeBlur(value: number);
  65139. /**
  65140. * Gets or sets the grain amount
  65141. */
  65142. get grainAmount(): number;
  65143. set grainAmount(value: number);
  65144. /**
  65145. * Gets or sets the chromatic aberration amount
  65146. */
  65147. get chromaticAberration(): number;
  65148. set chromaticAberration(value: number);
  65149. /**
  65150. * Gets or sets the depth of field aperture
  65151. */
  65152. get dofAperture(): number;
  65153. set dofAperture(value: number);
  65154. /**
  65155. * Gets or sets the edge distortion
  65156. */
  65157. get edgeDistortion(): number;
  65158. set edgeDistortion(value: number);
  65159. /**
  65160. * Gets or sets the depth of field distortion
  65161. */
  65162. get dofDistortion(): number;
  65163. set dofDistortion(value: number);
  65164. /**
  65165. * Gets or sets the darken out of focus amount
  65166. */
  65167. get darkenOutOfFocus(): number;
  65168. set darkenOutOfFocus(value: number);
  65169. /**
  65170. * Gets or sets a boolean indicating if blur noise is enabled
  65171. */
  65172. get blurNoise(): boolean;
  65173. set blurNoise(value: boolean);
  65174. /**
  65175. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65176. */
  65177. get pentagonBokeh(): boolean;
  65178. set pentagonBokeh(value: boolean);
  65179. /**
  65180. * Gets or sets the highlight grain amount
  65181. */
  65182. get highlightsGain(): number;
  65183. set highlightsGain(value: number);
  65184. /**
  65185. * Gets or sets the highlight threshold
  65186. */
  65187. get highlightsThreshold(): number;
  65188. set highlightsThreshold(value: number);
  65189. /**
  65190. * Sets the amount of blur at the edges
  65191. * @param amount blur amount
  65192. */
  65193. setEdgeBlur(amount: number): void;
  65194. /**
  65195. * Sets edge blur to 0
  65196. */
  65197. disableEdgeBlur(): void;
  65198. /**
  65199. * Sets the amout of grain
  65200. * @param amount Amount of grain
  65201. */
  65202. setGrainAmount(amount: number): void;
  65203. /**
  65204. * Set grain amount to 0
  65205. */
  65206. disableGrain(): void;
  65207. /**
  65208. * Sets the chromatic aberration amount
  65209. * @param amount amount of chromatic aberration
  65210. */
  65211. setChromaticAberration(amount: number): void;
  65212. /**
  65213. * Sets chromatic aberration amount to 0
  65214. */
  65215. disableChromaticAberration(): void;
  65216. /**
  65217. * Sets the EdgeDistortion amount
  65218. * @param amount amount of EdgeDistortion
  65219. */
  65220. setEdgeDistortion(amount: number): void;
  65221. /**
  65222. * Sets edge distortion to 0
  65223. */
  65224. disableEdgeDistortion(): void;
  65225. /**
  65226. * Sets the FocusDistance amount
  65227. * @param amount amount of FocusDistance
  65228. */
  65229. setFocusDistance(amount: number): void;
  65230. /**
  65231. * Disables depth of field
  65232. */
  65233. disableDepthOfField(): void;
  65234. /**
  65235. * Sets the Aperture amount
  65236. * @param amount amount of Aperture
  65237. */
  65238. setAperture(amount: number): void;
  65239. /**
  65240. * Sets the DarkenOutOfFocus amount
  65241. * @param amount amount of DarkenOutOfFocus
  65242. */
  65243. setDarkenOutOfFocus(amount: number): void;
  65244. private _pentagonBokehIsEnabled;
  65245. /**
  65246. * Creates a pentagon bokeh effect
  65247. */
  65248. enablePentagonBokeh(): void;
  65249. /**
  65250. * Disables the pentagon bokeh effect
  65251. */
  65252. disablePentagonBokeh(): void;
  65253. /**
  65254. * Enables noise blur
  65255. */
  65256. enableNoiseBlur(): void;
  65257. /**
  65258. * Disables noise blur
  65259. */
  65260. disableNoiseBlur(): void;
  65261. /**
  65262. * Sets the HighlightsGain amount
  65263. * @param amount amount of HighlightsGain
  65264. */
  65265. setHighlightsGain(amount: number): void;
  65266. /**
  65267. * Sets the HighlightsThreshold amount
  65268. * @param amount amount of HighlightsThreshold
  65269. */
  65270. setHighlightsThreshold(amount: number): void;
  65271. /**
  65272. * Disables highlights
  65273. */
  65274. disableHighlights(): void;
  65275. /**
  65276. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65277. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65278. */
  65279. dispose(disableDepthRender?: boolean): void;
  65280. private _createChromaticAberrationPostProcess;
  65281. private _createHighlightsPostProcess;
  65282. private _createDepthOfFieldPostProcess;
  65283. private _createGrainTexture;
  65284. }
  65285. }
  65286. declare module BABYLON {
  65287. /** @hidden */
  65288. export var ssao2PixelShader: {
  65289. name: string;
  65290. shader: string;
  65291. };
  65292. }
  65293. declare module BABYLON {
  65294. /** @hidden */
  65295. export var ssaoCombinePixelShader: {
  65296. name: string;
  65297. shader: string;
  65298. };
  65299. }
  65300. declare module BABYLON {
  65301. /**
  65302. * Render pipeline to produce ssao effect
  65303. */
  65304. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65305. /**
  65306. * @ignore
  65307. * The PassPostProcess id in the pipeline that contains the original scene color
  65308. */
  65309. SSAOOriginalSceneColorEffect: string;
  65310. /**
  65311. * @ignore
  65312. * The SSAO PostProcess id in the pipeline
  65313. */
  65314. SSAORenderEffect: string;
  65315. /**
  65316. * @ignore
  65317. * The horizontal blur PostProcess id in the pipeline
  65318. */
  65319. SSAOBlurHRenderEffect: string;
  65320. /**
  65321. * @ignore
  65322. * The vertical blur PostProcess id in the pipeline
  65323. */
  65324. SSAOBlurVRenderEffect: string;
  65325. /**
  65326. * @ignore
  65327. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65328. */
  65329. SSAOCombineRenderEffect: string;
  65330. /**
  65331. * The output strength of the SSAO post-process. Default value is 1.0.
  65332. */
  65333. totalStrength: number;
  65334. /**
  65335. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65336. */
  65337. maxZ: number;
  65338. /**
  65339. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65340. */
  65341. minZAspect: number;
  65342. private _samples;
  65343. /**
  65344. * Number of samples used for the SSAO calculations. Default value is 8
  65345. */
  65346. set samples(n: number);
  65347. get samples(): number;
  65348. private _textureSamples;
  65349. /**
  65350. * Number of samples to use for antialiasing
  65351. */
  65352. set textureSamples(n: number);
  65353. get textureSamples(): number;
  65354. /**
  65355. * Ratio object used for SSAO ratio and blur ratio
  65356. */
  65357. private _ratio;
  65358. /**
  65359. * Dynamically generated sphere sampler.
  65360. */
  65361. private _sampleSphere;
  65362. /**
  65363. * Blur filter offsets
  65364. */
  65365. private _samplerOffsets;
  65366. private _expensiveBlur;
  65367. /**
  65368. * If bilateral blur should be used
  65369. */
  65370. set expensiveBlur(b: boolean);
  65371. get expensiveBlur(): boolean;
  65372. /**
  65373. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65374. */
  65375. radius: number;
  65376. /**
  65377. * The base color of the SSAO post-process
  65378. * The final result is "base + ssao" between [0, 1]
  65379. */
  65380. base: number;
  65381. /**
  65382. * Support test.
  65383. */
  65384. static get IsSupported(): boolean;
  65385. private _scene;
  65386. private _depthTexture;
  65387. private _normalTexture;
  65388. private _randomTexture;
  65389. private _originalColorPostProcess;
  65390. private _ssaoPostProcess;
  65391. private _blurHPostProcess;
  65392. private _blurVPostProcess;
  65393. private _ssaoCombinePostProcess;
  65394. /**
  65395. * Gets active scene
  65396. */
  65397. get scene(): Scene;
  65398. /**
  65399. * @constructor
  65400. * @param name The rendering pipeline name
  65401. * @param scene The scene linked to this pipeline
  65402. * @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 }
  65403. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65404. */
  65405. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65406. /**
  65407. * Get the class name
  65408. * @returns "SSAO2RenderingPipeline"
  65409. */
  65410. getClassName(): string;
  65411. /**
  65412. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65413. */
  65414. dispose(disableGeometryBufferRenderer?: boolean): void;
  65415. private _createBlurPostProcess;
  65416. /** @hidden */
  65417. _rebuild(): void;
  65418. private _bits;
  65419. private _radicalInverse_VdC;
  65420. private _hammersley;
  65421. private _hemisphereSample_uniform;
  65422. private _generateHemisphere;
  65423. private _createSSAOPostProcess;
  65424. private _createSSAOCombinePostProcess;
  65425. private _createRandomTexture;
  65426. /**
  65427. * Serialize the rendering pipeline (Used when exporting)
  65428. * @returns the serialized object
  65429. */
  65430. serialize(): any;
  65431. /**
  65432. * Parse the serialized pipeline
  65433. * @param source Source pipeline.
  65434. * @param scene The scene to load the pipeline to.
  65435. * @param rootUrl The URL of the serialized pipeline.
  65436. * @returns An instantiated pipeline from the serialized object.
  65437. */
  65438. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65439. }
  65440. }
  65441. declare module BABYLON {
  65442. /** @hidden */
  65443. export var ssaoPixelShader: {
  65444. name: string;
  65445. shader: string;
  65446. };
  65447. }
  65448. declare module BABYLON {
  65449. /**
  65450. * Render pipeline to produce ssao effect
  65451. */
  65452. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65453. /**
  65454. * @ignore
  65455. * The PassPostProcess id in the pipeline that contains the original scene color
  65456. */
  65457. SSAOOriginalSceneColorEffect: string;
  65458. /**
  65459. * @ignore
  65460. * The SSAO PostProcess id in the pipeline
  65461. */
  65462. SSAORenderEffect: string;
  65463. /**
  65464. * @ignore
  65465. * The horizontal blur PostProcess id in the pipeline
  65466. */
  65467. SSAOBlurHRenderEffect: string;
  65468. /**
  65469. * @ignore
  65470. * The vertical blur PostProcess id in the pipeline
  65471. */
  65472. SSAOBlurVRenderEffect: string;
  65473. /**
  65474. * @ignore
  65475. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65476. */
  65477. SSAOCombineRenderEffect: string;
  65478. /**
  65479. * The output strength of the SSAO post-process. Default value is 1.0.
  65480. */
  65481. totalStrength: number;
  65482. /**
  65483. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65484. */
  65485. radius: number;
  65486. /**
  65487. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65488. * Must not be equal to fallOff and superior to fallOff.
  65489. * Default value is 0.0075
  65490. */
  65491. area: number;
  65492. /**
  65493. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65494. * Must not be equal to area and inferior to area.
  65495. * Default value is 0.000001
  65496. */
  65497. fallOff: number;
  65498. /**
  65499. * The base color of the SSAO post-process
  65500. * The final result is "base + ssao" between [0, 1]
  65501. */
  65502. base: number;
  65503. private _scene;
  65504. private _depthTexture;
  65505. private _randomTexture;
  65506. private _originalColorPostProcess;
  65507. private _ssaoPostProcess;
  65508. private _blurHPostProcess;
  65509. private _blurVPostProcess;
  65510. private _ssaoCombinePostProcess;
  65511. private _firstUpdate;
  65512. /**
  65513. * Gets active scene
  65514. */
  65515. get scene(): Scene;
  65516. /**
  65517. * @constructor
  65518. * @param name - The rendering pipeline name
  65519. * @param scene - The scene linked to this pipeline
  65520. * @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 }
  65521. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65522. */
  65523. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65524. /**
  65525. * Get the class name
  65526. * @returns "SSAORenderingPipeline"
  65527. */
  65528. getClassName(): string;
  65529. /**
  65530. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65531. */
  65532. dispose(disableDepthRender?: boolean): void;
  65533. private _createBlurPostProcess;
  65534. /** @hidden */
  65535. _rebuild(): void;
  65536. private _createSSAOPostProcess;
  65537. private _createSSAOCombinePostProcess;
  65538. private _createRandomTexture;
  65539. }
  65540. }
  65541. declare module BABYLON {
  65542. /** @hidden */
  65543. export var screenSpaceReflectionPixelShader: {
  65544. name: string;
  65545. shader: string;
  65546. };
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65551. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65552. */
  65553. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65554. /**
  65555. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65556. */
  65557. threshold: number;
  65558. /**
  65559. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65560. */
  65561. strength: number;
  65562. /**
  65563. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65564. */
  65565. reflectionSpecularFalloffExponent: number;
  65566. /**
  65567. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  65568. */
  65569. step: number;
  65570. /**
  65571. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65572. */
  65573. roughnessFactor: number;
  65574. private _geometryBufferRenderer;
  65575. private _enableSmoothReflections;
  65576. private _reflectionSamples;
  65577. private _smoothSteps;
  65578. /**
  65579. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65580. * @param name The name of the effect.
  65581. * @param scene The scene containing the objects to calculate reflections.
  65582. * @param options The required width/height ratio to downsize to before computing the render pass.
  65583. * @param camera The camera to apply the render pass to.
  65584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65585. * @param engine The engine which the post process will be applied. (default: current engine)
  65586. * @param reusable If the post process can be reused on the same frame. (default: false)
  65587. * @param textureType Type of textures used when performing the post process. (default: 0)
  65588. * @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)
  65589. */
  65590. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65591. /**
  65592. * Gets wether or not smoothing reflections is enabled.
  65593. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65594. */
  65595. get enableSmoothReflections(): boolean;
  65596. /**
  65597. * Sets wether or not smoothing reflections is enabled.
  65598. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65599. */
  65600. set enableSmoothReflections(enabled: boolean);
  65601. /**
  65602. * Gets the number of samples taken while computing reflections. More samples count is high,
  65603. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65604. */
  65605. get reflectionSamples(): number;
  65606. /**
  65607. * Sets the number of samples taken while computing reflections. More samples count is high,
  65608. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65609. */
  65610. set reflectionSamples(samples: number);
  65611. /**
  65612. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65613. * more the post-process will require GPU power and can generate a drop in FPS.
  65614. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65615. */
  65616. get smoothSteps(): number;
  65617. set smoothSteps(steps: number);
  65618. private _updateEffectDefines;
  65619. }
  65620. }
  65621. declare module BABYLON {
  65622. /** @hidden */
  65623. export var standardPixelShader: {
  65624. name: string;
  65625. shader: string;
  65626. };
  65627. }
  65628. declare module BABYLON {
  65629. /**
  65630. * Standard rendering pipeline
  65631. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65632. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65633. */
  65634. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65635. /**
  65636. * Public members
  65637. */
  65638. /**
  65639. * Post-process which contains the original scene color before the pipeline applies all the effects
  65640. */
  65641. originalPostProcess: Nullable<PostProcess>;
  65642. /**
  65643. * Post-process used to down scale an image x4
  65644. */
  65645. downSampleX4PostProcess: Nullable<PostProcess>;
  65646. /**
  65647. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65648. */
  65649. brightPassPostProcess: Nullable<PostProcess>;
  65650. /**
  65651. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65652. */
  65653. blurHPostProcesses: PostProcess[];
  65654. /**
  65655. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65656. */
  65657. blurVPostProcesses: PostProcess[];
  65658. /**
  65659. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65660. */
  65661. textureAdderPostProcess: Nullable<PostProcess>;
  65662. /**
  65663. * Post-process used to create volumetric lighting effect
  65664. */
  65665. volumetricLightPostProcess: Nullable<PostProcess>;
  65666. /**
  65667. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65668. */
  65669. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65670. /**
  65671. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65672. */
  65673. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65674. /**
  65675. * Post-process used to merge the volumetric light effect and the real scene color
  65676. */
  65677. volumetricLightMergePostProces: Nullable<PostProcess>;
  65678. /**
  65679. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65680. */
  65681. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65682. /**
  65683. * Base post-process used to calculate the average luminance of the final image for HDR
  65684. */
  65685. luminancePostProcess: Nullable<PostProcess>;
  65686. /**
  65687. * Post-processes used to create down sample post-processes in order to get
  65688. * the average luminance of the final image for HDR
  65689. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65690. */
  65691. luminanceDownSamplePostProcesses: PostProcess[];
  65692. /**
  65693. * Post-process used to create a HDR effect (light adaptation)
  65694. */
  65695. hdrPostProcess: Nullable<PostProcess>;
  65696. /**
  65697. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65698. */
  65699. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65700. /**
  65701. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65702. */
  65703. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65704. /**
  65705. * Post-process used to merge the final HDR post-process and the real scene color
  65706. */
  65707. hdrFinalPostProcess: Nullable<PostProcess>;
  65708. /**
  65709. * Post-process used to create a lens flare effect
  65710. */
  65711. lensFlarePostProcess: Nullable<PostProcess>;
  65712. /**
  65713. * Post-process that merges the result of the lens flare post-process and the real scene color
  65714. */
  65715. lensFlareComposePostProcess: Nullable<PostProcess>;
  65716. /**
  65717. * Post-process used to create a motion blur effect
  65718. */
  65719. motionBlurPostProcess: Nullable<PostProcess>;
  65720. /**
  65721. * Post-process used to create a depth of field effect
  65722. */
  65723. depthOfFieldPostProcess: Nullable<PostProcess>;
  65724. /**
  65725. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65726. */
  65727. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65728. /**
  65729. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65730. */
  65731. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65732. /**
  65733. * Represents the brightness threshold in order to configure the illuminated surfaces
  65734. */
  65735. brightThreshold: number;
  65736. /**
  65737. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65738. */
  65739. blurWidth: number;
  65740. /**
  65741. * Sets if the blur for highlighted surfaces must be only horizontal
  65742. */
  65743. horizontalBlur: boolean;
  65744. /**
  65745. * Gets the overall exposure used by the pipeline
  65746. */
  65747. get exposure(): number;
  65748. /**
  65749. * Sets the overall exposure used by the pipeline
  65750. */
  65751. set exposure(value: number);
  65752. /**
  65753. * Texture used typically to simulate "dirty" on camera lens
  65754. */
  65755. lensTexture: Nullable<Texture>;
  65756. /**
  65757. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65758. */
  65759. volumetricLightCoefficient: number;
  65760. /**
  65761. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65762. */
  65763. volumetricLightPower: number;
  65764. /**
  65765. * Used the set the blur intensity to smooth the volumetric lights
  65766. */
  65767. volumetricLightBlurScale: number;
  65768. /**
  65769. * Light (spot or directional) used to generate the volumetric lights rays
  65770. * The source light must have a shadow generate so the pipeline can get its
  65771. * depth map
  65772. */
  65773. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65774. /**
  65775. * For eye adaptation, represents the minimum luminance the eye can see
  65776. */
  65777. hdrMinimumLuminance: number;
  65778. /**
  65779. * For eye adaptation, represents the decrease luminance speed
  65780. */
  65781. hdrDecreaseRate: number;
  65782. /**
  65783. * For eye adaptation, represents the increase luminance speed
  65784. */
  65785. hdrIncreaseRate: number;
  65786. /**
  65787. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65788. */
  65789. get hdrAutoExposure(): boolean;
  65790. /**
  65791. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65792. */
  65793. set hdrAutoExposure(value: boolean);
  65794. /**
  65795. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65796. */
  65797. lensColorTexture: Nullable<Texture>;
  65798. /**
  65799. * The overall strengh for the lens flare effect
  65800. */
  65801. lensFlareStrength: number;
  65802. /**
  65803. * Dispersion coefficient for lens flare ghosts
  65804. */
  65805. lensFlareGhostDispersal: number;
  65806. /**
  65807. * Main lens flare halo width
  65808. */
  65809. lensFlareHaloWidth: number;
  65810. /**
  65811. * Based on the lens distortion effect, defines how much the lens flare result
  65812. * is distorted
  65813. */
  65814. lensFlareDistortionStrength: number;
  65815. /**
  65816. * Configures the blur intensity used for for lens flare (halo)
  65817. */
  65818. lensFlareBlurWidth: number;
  65819. /**
  65820. * Lens star texture must be used to simulate rays on the flares and is available
  65821. * in the documentation
  65822. */
  65823. lensStarTexture: Nullable<Texture>;
  65824. /**
  65825. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65826. * flare effect by taking account of the dirt texture
  65827. */
  65828. lensFlareDirtTexture: Nullable<Texture>;
  65829. /**
  65830. * Represents the focal length for the depth of field effect
  65831. */
  65832. depthOfFieldDistance: number;
  65833. /**
  65834. * Represents the blur intensity for the blurred part of the depth of field effect
  65835. */
  65836. depthOfFieldBlurWidth: number;
  65837. /**
  65838. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65839. */
  65840. get motionStrength(): number;
  65841. /**
  65842. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65843. */
  65844. set motionStrength(strength: number);
  65845. /**
  65846. * Gets wether or not the motion blur post-process is object based or screen based.
  65847. */
  65848. get objectBasedMotionBlur(): boolean;
  65849. /**
  65850. * Sets wether or not the motion blur post-process should be object based or screen based
  65851. */
  65852. set objectBasedMotionBlur(value: boolean);
  65853. /**
  65854. * List of animations for the pipeline (IAnimatable implementation)
  65855. */
  65856. animations: Animation[];
  65857. /**
  65858. * Private members
  65859. */
  65860. private _scene;
  65861. private _currentDepthOfFieldSource;
  65862. private _basePostProcess;
  65863. private _fixedExposure;
  65864. private _currentExposure;
  65865. private _hdrAutoExposure;
  65866. private _hdrCurrentLuminance;
  65867. private _motionStrength;
  65868. private _isObjectBasedMotionBlur;
  65869. private _floatTextureType;
  65870. private _camerasToBeAttached;
  65871. private _ratio;
  65872. private _bloomEnabled;
  65873. private _depthOfFieldEnabled;
  65874. private _vlsEnabled;
  65875. private _lensFlareEnabled;
  65876. private _hdrEnabled;
  65877. private _motionBlurEnabled;
  65878. private _fxaaEnabled;
  65879. private _screenSpaceReflectionsEnabled;
  65880. private _motionBlurSamples;
  65881. private _volumetricLightStepsCount;
  65882. private _samples;
  65883. /**
  65884. * @ignore
  65885. * Specifies if the bloom pipeline is enabled
  65886. */
  65887. get BloomEnabled(): boolean;
  65888. set BloomEnabled(enabled: boolean);
  65889. /**
  65890. * @ignore
  65891. * Specifies if the depth of field pipeline is enabed
  65892. */
  65893. get DepthOfFieldEnabled(): boolean;
  65894. set DepthOfFieldEnabled(enabled: boolean);
  65895. /**
  65896. * @ignore
  65897. * Specifies if the lens flare pipeline is enabed
  65898. */
  65899. get LensFlareEnabled(): boolean;
  65900. set LensFlareEnabled(enabled: boolean);
  65901. /**
  65902. * @ignore
  65903. * Specifies if the HDR pipeline is enabled
  65904. */
  65905. get HDREnabled(): boolean;
  65906. set HDREnabled(enabled: boolean);
  65907. /**
  65908. * @ignore
  65909. * Specifies if the volumetric lights scattering effect is enabled
  65910. */
  65911. get VLSEnabled(): boolean;
  65912. set VLSEnabled(enabled: boolean);
  65913. /**
  65914. * @ignore
  65915. * Specifies if the motion blur effect is enabled
  65916. */
  65917. get MotionBlurEnabled(): boolean;
  65918. set MotionBlurEnabled(enabled: boolean);
  65919. /**
  65920. * Specifies if anti-aliasing is enabled
  65921. */
  65922. get fxaaEnabled(): boolean;
  65923. set fxaaEnabled(enabled: boolean);
  65924. /**
  65925. * Specifies if screen space reflections are enabled.
  65926. */
  65927. get screenSpaceReflectionsEnabled(): boolean;
  65928. set screenSpaceReflectionsEnabled(enabled: boolean);
  65929. /**
  65930. * Specifies the number of steps used to calculate the volumetric lights
  65931. * Typically in interval [50, 200]
  65932. */
  65933. get volumetricLightStepsCount(): number;
  65934. set volumetricLightStepsCount(count: number);
  65935. /**
  65936. * Specifies the number of samples used for the motion blur effect
  65937. * Typically in interval [16, 64]
  65938. */
  65939. get motionBlurSamples(): number;
  65940. set motionBlurSamples(samples: number);
  65941. /**
  65942. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65943. */
  65944. get samples(): number;
  65945. set samples(sampleCount: number);
  65946. /**
  65947. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65948. * @constructor
  65949. * @param name The rendering pipeline name
  65950. * @param scene The scene linked to this pipeline
  65951. * @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)
  65952. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65953. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65954. */
  65955. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65956. private _buildPipeline;
  65957. private _createDownSampleX4PostProcess;
  65958. private _createBrightPassPostProcess;
  65959. private _createBlurPostProcesses;
  65960. private _createTextureAdderPostProcess;
  65961. private _createVolumetricLightPostProcess;
  65962. private _createLuminancePostProcesses;
  65963. private _createHdrPostProcess;
  65964. private _createLensFlarePostProcess;
  65965. private _createDepthOfFieldPostProcess;
  65966. private _createMotionBlurPostProcess;
  65967. private _getDepthTexture;
  65968. private _disposePostProcesses;
  65969. /**
  65970. * Dispose of the pipeline and stop all post processes
  65971. */
  65972. dispose(): void;
  65973. /**
  65974. * Serialize the rendering pipeline (Used when exporting)
  65975. * @returns the serialized object
  65976. */
  65977. serialize(): any;
  65978. /**
  65979. * Parse the serialized pipeline
  65980. * @param source Source pipeline.
  65981. * @param scene The scene to load the pipeline to.
  65982. * @param rootUrl The URL of the serialized pipeline.
  65983. * @returns An instantiated pipeline from the serialized object.
  65984. */
  65985. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65986. /**
  65987. * Luminance steps
  65988. */
  65989. static LuminanceSteps: number;
  65990. }
  65991. }
  65992. declare module BABYLON {
  65993. /** @hidden */
  65994. export var tonemapPixelShader: {
  65995. name: string;
  65996. shader: string;
  65997. };
  65998. }
  65999. declare module BABYLON {
  66000. /** Defines operator used for tonemapping */
  66001. export enum TonemappingOperator {
  66002. /** Hable */
  66003. Hable = 0,
  66004. /** Reinhard */
  66005. Reinhard = 1,
  66006. /** HejiDawson */
  66007. HejiDawson = 2,
  66008. /** Photographic */
  66009. Photographic = 3
  66010. }
  66011. /**
  66012. * Defines a post process to apply tone mapping
  66013. */
  66014. export class TonemapPostProcess extends PostProcess {
  66015. private _operator;
  66016. /** Defines the required exposure adjustement */
  66017. exposureAdjustment: number;
  66018. /**
  66019. * Creates a new TonemapPostProcess
  66020. * @param name defines the name of the postprocess
  66021. * @param _operator defines the operator to use
  66022. * @param exposureAdjustment defines the required exposure adjustement
  66023. * @param camera defines the camera to use (can be null)
  66024. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66025. * @param engine defines the hosting engine (can be ignore if camera is set)
  66026. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66027. */
  66028. constructor(name: string, _operator: TonemappingOperator,
  66029. /** Defines the required exposure adjustement */
  66030. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66031. }
  66032. }
  66033. declare module BABYLON {
  66034. /** @hidden */
  66035. export var volumetricLightScatteringPixelShader: {
  66036. name: string;
  66037. shader: string;
  66038. };
  66039. }
  66040. declare module BABYLON {
  66041. /** @hidden */
  66042. export var volumetricLightScatteringPassVertexShader: {
  66043. name: string;
  66044. shader: string;
  66045. };
  66046. }
  66047. declare module BABYLON {
  66048. /** @hidden */
  66049. export var volumetricLightScatteringPassPixelShader: {
  66050. name: string;
  66051. shader: string;
  66052. };
  66053. }
  66054. declare module BABYLON {
  66055. /**
  66056. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66057. */
  66058. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66059. private _volumetricLightScatteringPass;
  66060. private _volumetricLightScatteringRTT;
  66061. private _viewPort;
  66062. private _screenCoordinates;
  66063. private _cachedDefines;
  66064. /**
  66065. * If not undefined, the mesh position is computed from the attached node position
  66066. */
  66067. attachedNode: {
  66068. position: Vector3;
  66069. };
  66070. /**
  66071. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66072. */
  66073. customMeshPosition: Vector3;
  66074. /**
  66075. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66076. */
  66077. useCustomMeshPosition: boolean;
  66078. /**
  66079. * If the post-process should inverse the light scattering direction
  66080. */
  66081. invert: boolean;
  66082. /**
  66083. * The internal mesh used by the post-process
  66084. */
  66085. mesh: Mesh;
  66086. /**
  66087. * @hidden
  66088. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66089. */
  66090. get useDiffuseColor(): boolean;
  66091. set useDiffuseColor(useDiffuseColor: boolean);
  66092. /**
  66093. * Array containing the excluded meshes not rendered in the internal pass
  66094. */
  66095. excludedMeshes: AbstractMesh[];
  66096. /**
  66097. * Controls the overall intensity of the post-process
  66098. */
  66099. exposure: number;
  66100. /**
  66101. * Dissipates each sample's contribution in range [0, 1]
  66102. */
  66103. decay: number;
  66104. /**
  66105. * Controls the overall intensity of each sample
  66106. */
  66107. weight: number;
  66108. /**
  66109. * Controls the density of each sample
  66110. */
  66111. density: number;
  66112. /**
  66113. * @constructor
  66114. * @param name The post-process name
  66115. * @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)
  66116. * @param camera The camera that the post-process will be attached to
  66117. * @param mesh The mesh used to create the light scattering
  66118. * @param samples The post-process quality, default 100
  66119. * @param samplingModeThe post-process filtering mode
  66120. * @param engine The babylon engine
  66121. * @param reusable If the post-process is reusable
  66122. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66123. */
  66124. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66125. /**
  66126. * Returns the string "VolumetricLightScatteringPostProcess"
  66127. * @returns "VolumetricLightScatteringPostProcess"
  66128. */
  66129. getClassName(): string;
  66130. private _isReady;
  66131. /**
  66132. * Sets the new light position for light scattering effect
  66133. * @param position The new custom light position
  66134. */
  66135. setCustomMeshPosition(position: Vector3): void;
  66136. /**
  66137. * Returns the light position for light scattering effect
  66138. * @return Vector3 The custom light position
  66139. */
  66140. getCustomMeshPosition(): Vector3;
  66141. /**
  66142. * Disposes the internal assets and detaches the post-process from the camera
  66143. */
  66144. dispose(camera: Camera): void;
  66145. /**
  66146. * Returns the render target texture used by the post-process
  66147. * @return the render target texture used by the post-process
  66148. */
  66149. getPass(): RenderTargetTexture;
  66150. private _meshExcluded;
  66151. private _createPass;
  66152. private _updateMeshScreenCoordinates;
  66153. /**
  66154. * Creates a default mesh for the Volumeric Light Scattering post-process
  66155. * @param name The mesh name
  66156. * @param scene The scene where to create the mesh
  66157. * @return the default mesh
  66158. */
  66159. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66160. }
  66161. }
  66162. declare module BABYLON {
  66163. interface Scene {
  66164. /** @hidden (Backing field) */
  66165. _boundingBoxRenderer: BoundingBoxRenderer;
  66166. /** @hidden (Backing field) */
  66167. _forceShowBoundingBoxes: boolean;
  66168. /**
  66169. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66170. */
  66171. forceShowBoundingBoxes: boolean;
  66172. /**
  66173. * Gets the bounding box renderer associated with the scene
  66174. * @returns a BoundingBoxRenderer
  66175. */
  66176. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66177. }
  66178. interface AbstractMesh {
  66179. /** @hidden (Backing field) */
  66180. _showBoundingBox: boolean;
  66181. /**
  66182. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66183. */
  66184. showBoundingBox: boolean;
  66185. }
  66186. /**
  66187. * Component responsible of rendering the bounding box of the meshes in a scene.
  66188. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66189. */
  66190. export class BoundingBoxRenderer implements ISceneComponent {
  66191. /**
  66192. * The component name helpfull to identify the component in the list of scene components.
  66193. */
  66194. readonly name: string;
  66195. /**
  66196. * The scene the component belongs to.
  66197. */
  66198. scene: Scene;
  66199. /**
  66200. * Color of the bounding box lines placed in front of an object
  66201. */
  66202. frontColor: Color3;
  66203. /**
  66204. * Color of the bounding box lines placed behind an object
  66205. */
  66206. backColor: Color3;
  66207. /**
  66208. * Defines if the renderer should show the back lines or not
  66209. */
  66210. showBackLines: boolean;
  66211. /**
  66212. * @hidden
  66213. */
  66214. renderList: SmartArray<BoundingBox>;
  66215. private _colorShader;
  66216. private _vertexBuffers;
  66217. private _indexBuffer;
  66218. private _fillIndexBuffer;
  66219. private _fillIndexData;
  66220. /**
  66221. * Instantiates a new bounding box renderer in a scene.
  66222. * @param scene the scene the renderer renders in
  66223. */
  66224. constructor(scene: Scene);
  66225. /**
  66226. * Registers the component in a given scene
  66227. */
  66228. register(): void;
  66229. private _evaluateSubMesh;
  66230. private _activeMesh;
  66231. private _prepareRessources;
  66232. private _createIndexBuffer;
  66233. /**
  66234. * Rebuilds the elements related to this component in case of
  66235. * context lost for instance.
  66236. */
  66237. rebuild(): void;
  66238. /**
  66239. * @hidden
  66240. */
  66241. reset(): void;
  66242. /**
  66243. * Render the bounding boxes of a specific rendering group
  66244. * @param renderingGroupId defines the rendering group to render
  66245. */
  66246. render(renderingGroupId: number): void;
  66247. /**
  66248. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66249. * @param mesh Define the mesh to render the occlusion bounding box for
  66250. */
  66251. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66252. /**
  66253. * Dispose and release the resources attached to this renderer.
  66254. */
  66255. dispose(): void;
  66256. }
  66257. }
  66258. declare module BABYLON {
  66259. interface Scene {
  66260. /** @hidden (Backing field) */
  66261. _depthRenderer: {
  66262. [id: string]: DepthRenderer;
  66263. };
  66264. /**
  66265. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66266. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66267. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66268. * @returns the created depth renderer
  66269. */
  66270. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66271. /**
  66272. * Disables a depth renderer for a given camera
  66273. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66274. */
  66275. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66276. }
  66277. /**
  66278. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66279. * in several rendering techniques.
  66280. */
  66281. export class DepthRendererSceneComponent implements ISceneComponent {
  66282. /**
  66283. * The component name helpfull to identify the component in the list of scene components.
  66284. */
  66285. readonly name: string;
  66286. /**
  66287. * The scene the component belongs to.
  66288. */
  66289. scene: Scene;
  66290. /**
  66291. * Creates a new instance of the component for the given scene
  66292. * @param scene Defines the scene to register the component in
  66293. */
  66294. constructor(scene: Scene);
  66295. /**
  66296. * Registers the component in a given scene
  66297. */
  66298. register(): void;
  66299. /**
  66300. * Rebuilds the elements related to this component in case of
  66301. * context lost for instance.
  66302. */
  66303. rebuild(): void;
  66304. /**
  66305. * Disposes the component and the associated ressources
  66306. */
  66307. dispose(): void;
  66308. private _gatherRenderTargets;
  66309. private _gatherActiveCameraRenderTargets;
  66310. }
  66311. }
  66312. declare module BABYLON {
  66313. /** @hidden */
  66314. export var outlinePixelShader: {
  66315. name: string;
  66316. shader: string;
  66317. };
  66318. }
  66319. declare module BABYLON {
  66320. /** @hidden */
  66321. export var outlineVertexShader: {
  66322. name: string;
  66323. shader: string;
  66324. };
  66325. }
  66326. declare module BABYLON {
  66327. interface Scene {
  66328. /** @hidden */
  66329. _outlineRenderer: OutlineRenderer;
  66330. /**
  66331. * Gets the outline renderer associated with the scene
  66332. * @returns a OutlineRenderer
  66333. */
  66334. getOutlineRenderer(): OutlineRenderer;
  66335. }
  66336. interface AbstractMesh {
  66337. /** @hidden (Backing field) */
  66338. _renderOutline: boolean;
  66339. /**
  66340. * Gets or sets a boolean indicating if the outline must be rendered as well
  66341. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66342. */
  66343. renderOutline: boolean;
  66344. /** @hidden (Backing field) */
  66345. _renderOverlay: boolean;
  66346. /**
  66347. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66348. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66349. */
  66350. renderOverlay: boolean;
  66351. }
  66352. /**
  66353. * This class is responsible to draw bothe outline/overlay of meshes.
  66354. * It should not be used directly but through the available method on mesh.
  66355. */
  66356. export class OutlineRenderer implements ISceneComponent {
  66357. /**
  66358. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66359. */
  66360. private static _StencilReference;
  66361. /**
  66362. * The name of the component. Each component must have a unique name.
  66363. */
  66364. name: string;
  66365. /**
  66366. * The scene the component belongs to.
  66367. */
  66368. scene: Scene;
  66369. /**
  66370. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66371. */
  66372. zOffset: number;
  66373. private _engine;
  66374. private _effect;
  66375. private _cachedDefines;
  66376. private _savedDepthWrite;
  66377. /**
  66378. * Instantiates a new outline renderer. (There could be only one per scene).
  66379. * @param scene Defines the scene it belongs to
  66380. */
  66381. constructor(scene: Scene);
  66382. /**
  66383. * Register the component to one instance of a scene.
  66384. */
  66385. register(): void;
  66386. /**
  66387. * Rebuilds the elements related to this component in case of
  66388. * context lost for instance.
  66389. */
  66390. rebuild(): void;
  66391. /**
  66392. * Disposes the component and the associated ressources.
  66393. */
  66394. dispose(): void;
  66395. /**
  66396. * Renders the outline in the canvas.
  66397. * @param subMesh Defines the sumesh to render
  66398. * @param batch Defines the batch of meshes in case of instances
  66399. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66400. */
  66401. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66402. /**
  66403. * Returns whether or not the outline renderer is ready for a given submesh.
  66404. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66405. * @param subMesh Defines the submesh to check readyness for
  66406. * @param useInstances Defines wheter wee are trying to render instances or not
  66407. * @returns true if ready otherwise false
  66408. */
  66409. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66410. private _beforeRenderingMesh;
  66411. private _afterRenderingMesh;
  66412. }
  66413. }
  66414. declare module BABYLON {
  66415. /**
  66416. * Defines the basic options interface of a Sprite Frame Source Size.
  66417. */
  66418. export interface ISpriteJSONSpriteSourceSize {
  66419. /**
  66420. * number of the original width of the Frame
  66421. */
  66422. w: number;
  66423. /**
  66424. * number of the original height of the Frame
  66425. */
  66426. h: number;
  66427. }
  66428. /**
  66429. * Defines the basic options interface of a Sprite Frame Data.
  66430. */
  66431. export interface ISpriteJSONSpriteFrameData {
  66432. /**
  66433. * number of the x offset of the Frame
  66434. */
  66435. x: number;
  66436. /**
  66437. * number of the y offset of the Frame
  66438. */
  66439. y: number;
  66440. /**
  66441. * number of the width of the Frame
  66442. */
  66443. w: number;
  66444. /**
  66445. * number of the height of the Frame
  66446. */
  66447. h: number;
  66448. }
  66449. /**
  66450. * Defines the basic options interface of a JSON Sprite.
  66451. */
  66452. export interface ISpriteJSONSprite {
  66453. /**
  66454. * string name of the Frame
  66455. */
  66456. filename: string;
  66457. /**
  66458. * ISpriteJSONSpriteFrame basic object of the frame data
  66459. */
  66460. frame: ISpriteJSONSpriteFrameData;
  66461. /**
  66462. * boolean to flag is the frame was rotated.
  66463. */
  66464. rotated: boolean;
  66465. /**
  66466. * boolean to flag is the frame was trimmed.
  66467. */
  66468. trimmed: boolean;
  66469. /**
  66470. * ISpriteJSONSpriteFrame basic object of the source data
  66471. */
  66472. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66473. /**
  66474. * ISpriteJSONSpriteFrame basic object of the source data
  66475. */
  66476. sourceSize: ISpriteJSONSpriteSourceSize;
  66477. }
  66478. /**
  66479. * Defines the basic options interface of a JSON atlas.
  66480. */
  66481. export interface ISpriteJSONAtlas {
  66482. /**
  66483. * Array of objects that contain the frame data.
  66484. */
  66485. frames: Array<ISpriteJSONSprite>;
  66486. /**
  66487. * object basic object containing the sprite meta data.
  66488. */
  66489. meta?: object;
  66490. }
  66491. }
  66492. declare module BABYLON {
  66493. /** @hidden */
  66494. export var spriteMapPixelShader: {
  66495. name: string;
  66496. shader: string;
  66497. };
  66498. }
  66499. declare module BABYLON {
  66500. /** @hidden */
  66501. export var spriteMapVertexShader: {
  66502. name: string;
  66503. shader: string;
  66504. };
  66505. }
  66506. declare module BABYLON {
  66507. /**
  66508. * Defines the basic options interface of a SpriteMap
  66509. */
  66510. export interface ISpriteMapOptions {
  66511. /**
  66512. * Vector2 of the number of cells in the grid.
  66513. */
  66514. stageSize?: Vector2;
  66515. /**
  66516. * Vector2 of the size of the output plane in World Units.
  66517. */
  66518. outputSize?: Vector2;
  66519. /**
  66520. * Vector3 of the position of the output plane in World Units.
  66521. */
  66522. outputPosition?: Vector3;
  66523. /**
  66524. * Vector3 of the rotation of the output plane.
  66525. */
  66526. outputRotation?: Vector3;
  66527. /**
  66528. * number of layers that the system will reserve in resources.
  66529. */
  66530. layerCount?: number;
  66531. /**
  66532. * number of max animation frames a single cell will reserve in resources.
  66533. */
  66534. maxAnimationFrames?: number;
  66535. /**
  66536. * number cell index of the base tile when the system compiles.
  66537. */
  66538. baseTile?: number;
  66539. /**
  66540. * boolean flip the sprite after its been repositioned by the framing data.
  66541. */
  66542. flipU?: boolean;
  66543. /**
  66544. * Vector3 scalar of the global RGB values of the SpriteMap.
  66545. */
  66546. colorMultiply?: Vector3;
  66547. }
  66548. /**
  66549. * Defines the IDisposable interface in order to be cleanable from resources.
  66550. */
  66551. export interface ISpriteMap extends IDisposable {
  66552. /**
  66553. * String name of the SpriteMap.
  66554. */
  66555. name: string;
  66556. /**
  66557. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66558. */
  66559. atlasJSON: ISpriteJSONAtlas;
  66560. /**
  66561. * Texture of the SpriteMap.
  66562. */
  66563. spriteSheet: Texture;
  66564. /**
  66565. * The parameters to initialize the SpriteMap with.
  66566. */
  66567. options: ISpriteMapOptions;
  66568. }
  66569. /**
  66570. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66571. */
  66572. export class SpriteMap implements ISpriteMap {
  66573. /** The Name of the spriteMap */
  66574. name: string;
  66575. /** The JSON file with the frame and meta data */
  66576. atlasJSON: ISpriteJSONAtlas;
  66577. /** The systems Sprite Sheet Texture */
  66578. spriteSheet: Texture;
  66579. /** Arguments passed with the Constructor */
  66580. options: ISpriteMapOptions;
  66581. /** Public Sprite Storage array, parsed from atlasJSON */
  66582. sprites: Array<ISpriteJSONSprite>;
  66583. /** Returns the Number of Sprites in the System */
  66584. get spriteCount(): number;
  66585. /** Returns the Position of Output Plane*/
  66586. get position(): Vector3;
  66587. /** Returns the Position of Output Plane*/
  66588. set position(v: Vector3);
  66589. /** Returns the Rotation of Output Plane*/
  66590. get rotation(): Vector3;
  66591. /** Returns the Rotation of Output Plane*/
  66592. set rotation(v: Vector3);
  66593. /** Sets the AnimationMap*/
  66594. get animationMap(): RawTexture;
  66595. /** Sets the AnimationMap*/
  66596. set animationMap(v: RawTexture);
  66597. /** Scene that the SpriteMap was created in */
  66598. private _scene;
  66599. /** Texture Buffer of Float32 that holds tile frame data*/
  66600. private _frameMap;
  66601. /** Texture Buffers of Float32 that holds tileMap data*/
  66602. private _tileMaps;
  66603. /** Texture Buffer of Float32 that holds Animation Data*/
  66604. private _animationMap;
  66605. /** Custom ShaderMaterial Central to the System*/
  66606. private _material;
  66607. /** Custom ShaderMaterial Central to the System*/
  66608. private _output;
  66609. /** Systems Time Ticker*/
  66610. private _time;
  66611. /**
  66612. * Creates a new SpriteMap
  66613. * @param name defines the SpriteMaps Name
  66614. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66615. * @param spriteSheet is the Texture that the Sprites are on.
  66616. * @param options a basic deployment configuration
  66617. * @param scene The Scene that the map is deployed on
  66618. */
  66619. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66620. /**
  66621. * Returns tileID location
  66622. * @returns Vector2 the cell position ID
  66623. */
  66624. getTileID(): Vector2;
  66625. /**
  66626. * Gets the UV location of the mouse over the SpriteMap.
  66627. * @returns Vector2 the UV position of the mouse interaction
  66628. */
  66629. getMousePosition(): Vector2;
  66630. /**
  66631. * Creates the "frame" texture Buffer
  66632. * -------------------------------------
  66633. * Structure of frames
  66634. * "filename": "Falling-Water-2.png",
  66635. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66636. * "rotated": true,
  66637. * "trimmed": true,
  66638. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66639. * "sourceSize": {"w":32,"h":32}
  66640. * @returns RawTexture of the frameMap
  66641. */
  66642. private _createFrameBuffer;
  66643. /**
  66644. * Creates the tileMap texture Buffer
  66645. * @param buffer normally and array of numbers, or a false to generate from scratch
  66646. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66647. * @returns RawTexture of the tileMap
  66648. */
  66649. private _createTileBuffer;
  66650. /**
  66651. * Modifies the data of the tileMaps
  66652. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66653. * @param pos is the iVector2 Coordinates of the Tile
  66654. * @param tile The SpriteIndex of the new Tile
  66655. */
  66656. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66657. /**
  66658. * Creates the animationMap texture Buffer
  66659. * @param buffer normally and array of numbers, or a false to generate from scratch
  66660. * @returns RawTexture of the animationMap
  66661. */
  66662. private _createTileAnimationBuffer;
  66663. /**
  66664. * Modifies the data of the animationMap
  66665. * @param cellID is the Index of the Sprite
  66666. * @param _frame is the target Animation frame
  66667. * @param toCell is the Target Index of the next frame of the animation
  66668. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66669. * @param speed is a global scalar of the time variable on the map.
  66670. */
  66671. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66672. /**
  66673. * Exports the .tilemaps file
  66674. */
  66675. saveTileMaps(): void;
  66676. /**
  66677. * Imports the .tilemaps file
  66678. * @param url of the .tilemaps file
  66679. */
  66680. loadTileMaps(url: string): void;
  66681. /**
  66682. * Release associated resources
  66683. */
  66684. dispose(): void;
  66685. }
  66686. }
  66687. declare module BABYLON {
  66688. /**
  66689. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66690. * @see http://doc.babylonjs.com/babylon101/sprites
  66691. */
  66692. export class SpritePackedManager extends SpriteManager {
  66693. /** defines the packed manager's name */
  66694. name: string;
  66695. /**
  66696. * Creates a new sprite manager from a packed sprite sheet
  66697. * @param name defines the manager's name
  66698. * @param imgUrl defines the sprite sheet url
  66699. * @param capacity defines the maximum allowed number of sprites
  66700. * @param scene defines the hosting scene
  66701. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66702. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66703. * @param samplingMode defines the smapling mode to use with spritesheet
  66704. * @param fromPacked set to true; do not alter
  66705. */
  66706. constructor(
  66707. /** defines the packed manager's name */
  66708. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66709. }
  66710. }
  66711. declare module BABYLON {
  66712. /**
  66713. * Defines the list of states available for a task inside a AssetsManager
  66714. */
  66715. export enum AssetTaskState {
  66716. /**
  66717. * Initialization
  66718. */
  66719. INIT = 0,
  66720. /**
  66721. * Running
  66722. */
  66723. RUNNING = 1,
  66724. /**
  66725. * Done
  66726. */
  66727. DONE = 2,
  66728. /**
  66729. * Error
  66730. */
  66731. ERROR = 3
  66732. }
  66733. /**
  66734. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66735. */
  66736. export abstract class AbstractAssetTask {
  66737. /**
  66738. * Task name
  66739. */ name: string;
  66740. /**
  66741. * Callback called when the task is successful
  66742. */
  66743. onSuccess: (task: any) => void;
  66744. /**
  66745. * Callback called when the task is not successful
  66746. */
  66747. onError: (task: any, message?: string, exception?: any) => void;
  66748. /**
  66749. * Creates a new AssetsManager
  66750. * @param name defines the name of the task
  66751. */
  66752. constructor(
  66753. /**
  66754. * Task name
  66755. */ name: string);
  66756. private _isCompleted;
  66757. private _taskState;
  66758. private _errorObject;
  66759. /**
  66760. * Get if the task is completed
  66761. */
  66762. get isCompleted(): boolean;
  66763. /**
  66764. * Gets the current state of the task
  66765. */
  66766. get taskState(): AssetTaskState;
  66767. /**
  66768. * Gets the current error object (if task is in error)
  66769. */
  66770. get errorObject(): {
  66771. message?: string;
  66772. exception?: any;
  66773. };
  66774. /**
  66775. * Internal only
  66776. * @hidden
  66777. */
  66778. _setErrorObject(message?: string, exception?: any): void;
  66779. /**
  66780. * Execute the current task
  66781. * @param scene defines the scene where you want your assets to be loaded
  66782. * @param onSuccess is a callback called when the task is successfully executed
  66783. * @param onError is a callback called if an error occurs
  66784. */
  66785. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66786. /**
  66787. * Execute the current task
  66788. * @param scene defines the scene where you want your assets to be loaded
  66789. * @param onSuccess is a callback called when the task is successfully executed
  66790. * @param onError is a callback called if an error occurs
  66791. */
  66792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66793. /**
  66794. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66795. * This can be used with failed tasks that have the reason for failure fixed.
  66796. */
  66797. reset(): void;
  66798. private onErrorCallback;
  66799. private onDoneCallback;
  66800. }
  66801. /**
  66802. * Define the interface used by progress events raised during assets loading
  66803. */
  66804. export interface IAssetsProgressEvent {
  66805. /**
  66806. * Defines the number of remaining tasks to process
  66807. */
  66808. remainingCount: number;
  66809. /**
  66810. * Defines the total number of tasks
  66811. */
  66812. totalCount: number;
  66813. /**
  66814. * Defines the task that was just processed
  66815. */
  66816. task: AbstractAssetTask;
  66817. }
  66818. /**
  66819. * Class used to share progress information about assets loading
  66820. */
  66821. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66822. /**
  66823. * Defines the number of remaining tasks to process
  66824. */
  66825. remainingCount: number;
  66826. /**
  66827. * Defines the total number of tasks
  66828. */
  66829. totalCount: number;
  66830. /**
  66831. * Defines the task that was just processed
  66832. */
  66833. task: AbstractAssetTask;
  66834. /**
  66835. * Creates a AssetsProgressEvent
  66836. * @param remainingCount defines the number of remaining tasks to process
  66837. * @param totalCount defines the total number of tasks
  66838. * @param task defines the task that was just processed
  66839. */
  66840. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66841. }
  66842. /**
  66843. * Define a task used by AssetsManager to load meshes
  66844. */
  66845. export class MeshAssetTask extends AbstractAssetTask {
  66846. /**
  66847. * Defines the name of the task
  66848. */
  66849. name: string;
  66850. /**
  66851. * Defines the list of mesh's names you want to load
  66852. */
  66853. meshesNames: any;
  66854. /**
  66855. * Defines the root url to use as a base to load your meshes and associated resources
  66856. */
  66857. rootUrl: string;
  66858. /**
  66859. * Defines the filename of the scene to load from
  66860. */
  66861. sceneFilename: string;
  66862. /**
  66863. * Gets the list of loaded meshes
  66864. */
  66865. loadedMeshes: Array<AbstractMesh>;
  66866. /**
  66867. * Gets the list of loaded particle systems
  66868. */
  66869. loadedParticleSystems: Array<IParticleSystem>;
  66870. /**
  66871. * Gets the list of loaded skeletons
  66872. */
  66873. loadedSkeletons: Array<Skeleton>;
  66874. /**
  66875. * Gets the list of loaded animation groups
  66876. */
  66877. loadedAnimationGroups: Array<AnimationGroup>;
  66878. /**
  66879. * Callback called when the task is successful
  66880. */
  66881. onSuccess: (task: MeshAssetTask) => void;
  66882. /**
  66883. * Callback called when the task is successful
  66884. */
  66885. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66886. /**
  66887. * Creates a new MeshAssetTask
  66888. * @param name defines the name of the task
  66889. * @param meshesNames defines the list of mesh's names you want to load
  66890. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66891. * @param sceneFilename defines the filename of the scene to load from
  66892. */
  66893. constructor(
  66894. /**
  66895. * Defines the name of the task
  66896. */
  66897. name: string,
  66898. /**
  66899. * Defines the list of mesh's names you want to load
  66900. */
  66901. meshesNames: any,
  66902. /**
  66903. * Defines the root url to use as a base to load your meshes and associated resources
  66904. */
  66905. rootUrl: string,
  66906. /**
  66907. * Defines the filename of the scene to load from
  66908. */
  66909. sceneFilename: string);
  66910. /**
  66911. * Execute the current task
  66912. * @param scene defines the scene where you want your assets to be loaded
  66913. * @param onSuccess is a callback called when the task is successfully executed
  66914. * @param onError is a callback called if an error occurs
  66915. */
  66916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66917. }
  66918. /**
  66919. * Define a task used by AssetsManager to load text content
  66920. */
  66921. export class TextFileAssetTask extends AbstractAssetTask {
  66922. /**
  66923. * Defines the name of the task
  66924. */
  66925. name: string;
  66926. /**
  66927. * Defines the location of the file to load
  66928. */
  66929. url: string;
  66930. /**
  66931. * Gets the loaded text string
  66932. */
  66933. text: string;
  66934. /**
  66935. * Callback called when the task is successful
  66936. */
  66937. onSuccess: (task: TextFileAssetTask) => void;
  66938. /**
  66939. * Callback called when the task is successful
  66940. */
  66941. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66942. /**
  66943. * Creates a new TextFileAssetTask object
  66944. * @param name defines the name of the task
  66945. * @param url defines the location of the file to load
  66946. */
  66947. constructor(
  66948. /**
  66949. * Defines the name of the task
  66950. */
  66951. name: string,
  66952. /**
  66953. * Defines the location of the file to load
  66954. */
  66955. url: string);
  66956. /**
  66957. * Execute the current task
  66958. * @param scene defines the scene where you want your assets to be loaded
  66959. * @param onSuccess is a callback called when the task is successfully executed
  66960. * @param onError is a callback called if an error occurs
  66961. */
  66962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66963. }
  66964. /**
  66965. * Define a task used by AssetsManager to load binary data
  66966. */
  66967. export class BinaryFileAssetTask extends AbstractAssetTask {
  66968. /**
  66969. * Defines the name of the task
  66970. */
  66971. name: string;
  66972. /**
  66973. * Defines the location of the file to load
  66974. */
  66975. url: string;
  66976. /**
  66977. * Gets the lodaded data (as an array buffer)
  66978. */
  66979. data: ArrayBuffer;
  66980. /**
  66981. * Callback called when the task is successful
  66982. */
  66983. onSuccess: (task: BinaryFileAssetTask) => void;
  66984. /**
  66985. * Callback called when the task is successful
  66986. */
  66987. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66988. /**
  66989. * Creates a new BinaryFileAssetTask object
  66990. * @param name defines the name of the new task
  66991. * @param url defines the location of the file to load
  66992. */
  66993. constructor(
  66994. /**
  66995. * Defines the name of the task
  66996. */
  66997. name: string,
  66998. /**
  66999. * Defines the location of the file to load
  67000. */
  67001. url: string);
  67002. /**
  67003. * Execute the current task
  67004. * @param scene defines the scene where you want your assets to be loaded
  67005. * @param onSuccess is a callback called when the task is successfully executed
  67006. * @param onError is a callback called if an error occurs
  67007. */
  67008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67009. }
  67010. /**
  67011. * Define a task used by AssetsManager to load images
  67012. */
  67013. export class ImageAssetTask extends AbstractAssetTask {
  67014. /**
  67015. * Defines the name of the task
  67016. */
  67017. name: string;
  67018. /**
  67019. * Defines the location of the image to load
  67020. */
  67021. url: string;
  67022. /**
  67023. * Gets the loaded images
  67024. */
  67025. image: HTMLImageElement;
  67026. /**
  67027. * Callback called when the task is successful
  67028. */
  67029. onSuccess: (task: ImageAssetTask) => void;
  67030. /**
  67031. * Callback called when the task is successful
  67032. */
  67033. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67034. /**
  67035. * Creates a new ImageAssetTask
  67036. * @param name defines the name of the task
  67037. * @param url defines the location of the image to load
  67038. */
  67039. constructor(
  67040. /**
  67041. * Defines the name of the task
  67042. */
  67043. name: string,
  67044. /**
  67045. * Defines the location of the image to load
  67046. */
  67047. url: string);
  67048. /**
  67049. * Execute the current task
  67050. * @param scene defines the scene where you want your assets to be loaded
  67051. * @param onSuccess is a callback called when the task is successfully executed
  67052. * @param onError is a callback called if an error occurs
  67053. */
  67054. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67055. }
  67056. /**
  67057. * Defines the interface used by texture loading tasks
  67058. */
  67059. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67060. /**
  67061. * Gets the loaded texture
  67062. */
  67063. texture: TEX;
  67064. }
  67065. /**
  67066. * Define a task used by AssetsManager to load 2D textures
  67067. */
  67068. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67069. /**
  67070. * Defines the name of the task
  67071. */
  67072. name: string;
  67073. /**
  67074. * Defines the location of the file to load
  67075. */
  67076. url: string;
  67077. /**
  67078. * Defines if mipmap should not be generated (default is false)
  67079. */
  67080. noMipmap?: boolean | undefined;
  67081. /**
  67082. * Defines if texture must be inverted on Y axis (default is false)
  67083. */
  67084. invertY?: boolean | undefined;
  67085. /**
  67086. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67087. */
  67088. samplingMode: number;
  67089. /**
  67090. * Gets the loaded texture
  67091. */
  67092. texture: Texture;
  67093. /**
  67094. * Callback called when the task is successful
  67095. */
  67096. onSuccess: (task: TextureAssetTask) => void;
  67097. /**
  67098. * Callback called when the task is successful
  67099. */
  67100. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67101. /**
  67102. * Creates a new TextureAssetTask object
  67103. * @param name defines the name of the task
  67104. * @param url defines the location of the file to load
  67105. * @param noMipmap defines if mipmap should not be generated (default is false)
  67106. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67107. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67108. */
  67109. constructor(
  67110. /**
  67111. * Defines the name of the task
  67112. */
  67113. name: string,
  67114. /**
  67115. * Defines the location of the file to load
  67116. */
  67117. url: string,
  67118. /**
  67119. * Defines if mipmap should not be generated (default is false)
  67120. */
  67121. noMipmap?: boolean | undefined,
  67122. /**
  67123. * Defines if texture must be inverted on Y axis (default is false)
  67124. */
  67125. invertY?: boolean | undefined,
  67126. /**
  67127. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67128. */
  67129. samplingMode?: number);
  67130. /**
  67131. * Execute the current task
  67132. * @param scene defines the scene where you want your assets to be loaded
  67133. * @param onSuccess is a callback called when the task is successfully executed
  67134. * @param onError is a callback called if an error occurs
  67135. */
  67136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67137. }
  67138. /**
  67139. * Define a task used by AssetsManager to load cube textures
  67140. */
  67141. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67142. /**
  67143. * Defines the name of the task
  67144. */
  67145. name: string;
  67146. /**
  67147. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67148. */
  67149. url: string;
  67150. /**
  67151. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67152. */
  67153. extensions?: string[] | undefined;
  67154. /**
  67155. * Defines if mipmaps should not be generated (default is false)
  67156. */
  67157. noMipmap?: boolean | undefined;
  67158. /**
  67159. * Defines the explicit list of files (undefined by default)
  67160. */
  67161. files?: string[] | undefined;
  67162. /**
  67163. * Gets the loaded texture
  67164. */
  67165. texture: CubeTexture;
  67166. /**
  67167. * Callback called when the task is successful
  67168. */
  67169. onSuccess: (task: CubeTextureAssetTask) => void;
  67170. /**
  67171. * Callback called when the task is successful
  67172. */
  67173. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67174. /**
  67175. * Creates a new CubeTextureAssetTask
  67176. * @param name defines the name of the task
  67177. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67178. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67179. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67180. * @param files defines the explicit list of files (undefined by default)
  67181. */
  67182. constructor(
  67183. /**
  67184. * Defines the name of the task
  67185. */
  67186. name: string,
  67187. /**
  67188. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67189. */
  67190. url: string,
  67191. /**
  67192. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67193. */
  67194. extensions?: string[] | undefined,
  67195. /**
  67196. * Defines if mipmaps should not be generated (default is false)
  67197. */
  67198. noMipmap?: boolean | undefined,
  67199. /**
  67200. * Defines the explicit list of files (undefined by default)
  67201. */
  67202. files?: string[] | undefined);
  67203. /**
  67204. * Execute the current task
  67205. * @param scene defines the scene where you want your assets to be loaded
  67206. * @param onSuccess is a callback called when the task is successfully executed
  67207. * @param onError is a callback called if an error occurs
  67208. */
  67209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67210. }
  67211. /**
  67212. * Define a task used by AssetsManager to load HDR cube textures
  67213. */
  67214. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67215. /**
  67216. * Defines the name of the task
  67217. */
  67218. name: string;
  67219. /**
  67220. * Defines the location of the file to load
  67221. */
  67222. url: string;
  67223. /**
  67224. * Defines the desired size (the more it increases the longer the generation will be)
  67225. */
  67226. size: number;
  67227. /**
  67228. * Defines if mipmaps should not be generated (default is false)
  67229. */
  67230. noMipmap: boolean;
  67231. /**
  67232. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67233. */
  67234. generateHarmonics: boolean;
  67235. /**
  67236. * 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)
  67237. */
  67238. gammaSpace: boolean;
  67239. /**
  67240. * Internal Use Only
  67241. */
  67242. reserved: boolean;
  67243. /**
  67244. * Gets the loaded texture
  67245. */
  67246. texture: HDRCubeTexture;
  67247. /**
  67248. * Callback called when the task is successful
  67249. */
  67250. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67251. /**
  67252. * Callback called when the task is successful
  67253. */
  67254. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67255. /**
  67256. * Creates a new HDRCubeTextureAssetTask object
  67257. * @param name defines the name of the task
  67258. * @param url defines the location of the file to load
  67259. * @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.
  67260. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67261. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67262. * @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)
  67263. * @param reserved Internal use only
  67264. */
  67265. constructor(
  67266. /**
  67267. * Defines the name of the task
  67268. */
  67269. name: string,
  67270. /**
  67271. * Defines the location of the file to load
  67272. */
  67273. url: string,
  67274. /**
  67275. * Defines the desired size (the more it increases the longer the generation will be)
  67276. */
  67277. size: number,
  67278. /**
  67279. * Defines if mipmaps should not be generated (default is false)
  67280. */
  67281. noMipmap?: boolean,
  67282. /**
  67283. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67284. */
  67285. generateHarmonics?: boolean,
  67286. /**
  67287. * 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)
  67288. */
  67289. gammaSpace?: boolean,
  67290. /**
  67291. * Internal Use Only
  67292. */
  67293. reserved?: boolean);
  67294. /**
  67295. * Execute the current task
  67296. * @param scene defines the scene where you want your assets to be loaded
  67297. * @param onSuccess is a callback called when the task is successfully executed
  67298. * @param onError is a callback called if an error occurs
  67299. */
  67300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67301. }
  67302. /**
  67303. * Define a task used by AssetsManager to load Equirectangular cube textures
  67304. */
  67305. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67306. /**
  67307. * Defines the name of the task
  67308. */
  67309. name: string;
  67310. /**
  67311. * Defines the location of the file to load
  67312. */
  67313. url: string;
  67314. /**
  67315. * Defines the desired size (the more it increases the longer the generation will be)
  67316. */
  67317. size: number;
  67318. /**
  67319. * Defines if mipmaps should not be generated (default is false)
  67320. */
  67321. noMipmap: boolean;
  67322. /**
  67323. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67324. * but the standard material would require them in Gamma space) (default is true)
  67325. */
  67326. gammaSpace: boolean;
  67327. /**
  67328. * Gets the loaded texture
  67329. */
  67330. texture: EquiRectangularCubeTexture;
  67331. /**
  67332. * Callback called when the task is successful
  67333. */
  67334. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67335. /**
  67336. * Callback called when the task is successful
  67337. */
  67338. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67339. /**
  67340. * Creates a new EquiRectangularCubeTextureAssetTask object
  67341. * @param name defines the name of the task
  67342. * @param url defines the location of the file to load
  67343. * @param size defines the desired size (the more it increases the longer the generation will be)
  67344. * If the size is omitted this implies you are using a preprocessed cubemap.
  67345. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67346. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67347. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67348. * (default is true)
  67349. */
  67350. constructor(
  67351. /**
  67352. * Defines the name of the task
  67353. */
  67354. name: string,
  67355. /**
  67356. * Defines the location of the file to load
  67357. */
  67358. url: string,
  67359. /**
  67360. * Defines the desired size (the more it increases the longer the generation will be)
  67361. */
  67362. size: number,
  67363. /**
  67364. * Defines if mipmaps should not be generated (default is false)
  67365. */
  67366. noMipmap?: boolean,
  67367. /**
  67368. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67369. * but the standard material would require them in Gamma space) (default is true)
  67370. */
  67371. gammaSpace?: boolean);
  67372. /**
  67373. * Execute the current task
  67374. * @param scene defines the scene where you want your assets to be loaded
  67375. * @param onSuccess is a callback called when the task is successfully executed
  67376. * @param onError is a callback called if an error occurs
  67377. */
  67378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67379. }
  67380. /**
  67381. * This class can be used to easily import assets into a scene
  67382. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67383. */
  67384. export class AssetsManager {
  67385. private _scene;
  67386. private _isLoading;
  67387. protected _tasks: AbstractAssetTask[];
  67388. protected _waitingTasksCount: number;
  67389. protected _totalTasksCount: number;
  67390. /**
  67391. * Callback called when all tasks are processed
  67392. */
  67393. onFinish: (tasks: AbstractAssetTask[]) => void;
  67394. /**
  67395. * Callback called when a task is successful
  67396. */
  67397. onTaskSuccess: (task: AbstractAssetTask) => void;
  67398. /**
  67399. * Callback called when a task had an error
  67400. */
  67401. onTaskError: (task: AbstractAssetTask) => void;
  67402. /**
  67403. * Callback called when a task is done (whatever the result is)
  67404. */
  67405. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67406. /**
  67407. * Observable called when all tasks are processed
  67408. */
  67409. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67410. /**
  67411. * Observable called when a task had an error
  67412. */
  67413. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67414. /**
  67415. * Observable called when all tasks were executed
  67416. */
  67417. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67418. /**
  67419. * Observable called when a task is done (whatever the result is)
  67420. */
  67421. onProgressObservable: Observable<IAssetsProgressEvent>;
  67422. /**
  67423. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67424. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67425. */
  67426. useDefaultLoadingScreen: boolean;
  67427. /**
  67428. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67429. * when all assets have been downloaded.
  67430. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67431. */
  67432. autoHideLoadingUI: boolean;
  67433. /**
  67434. * Creates a new AssetsManager
  67435. * @param scene defines the scene to work on
  67436. */
  67437. constructor(scene: Scene);
  67438. /**
  67439. * Add a MeshAssetTask to the list of active tasks
  67440. * @param taskName defines the name of the new task
  67441. * @param meshesNames defines the name of meshes to load
  67442. * @param rootUrl defines the root url to use to locate files
  67443. * @param sceneFilename defines the filename of the scene file
  67444. * @returns a new MeshAssetTask object
  67445. */
  67446. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67447. /**
  67448. * Add a TextFileAssetTask to the list of active tasks
  67449. * @param taskName defines the name of the new task
  67450. * @param url defines the url of the file to load
  67451. * @returns a new TextFileAssetTask object
  67452. */
  67453. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67454. /**
  67455. * Add a BinaryFileAssetTask to the list of active tasks
  67456. * @param taskName defines the name of the new task
  67457. * @param url defines the url of the file to load
  67458. * @returns a new BinaryFileAssetTask object
  67459. */
  67460. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67461. /**
  67462. * Add a ImageAssetTask to the list of active tasks
  67463. * @param taskName defines the name of the new task
  67464. * @param url defines the url of the file to load
  67465. * @returns a new ImageAssetTask object
  67466. */
  67467. addImageTask(taskName: string, url: string): ImageAssetTask;
  67468. /**
  67469. * Add a TextureAssetTask to the list of active tasks
  67470. * @param taskName defines the name of the new task
  67471. * @param url defines the url of the file to load
  67472. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67473. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67474. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67475. * @returns a new TextureAssetTask object
  67476. */
  67477. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67478. /**
  67479. * Add a CubeTextureAssetTask to the list of active tasks
  67480. * @param taskName defines the name of the new task
  67481. * @param url defines the url of the file to load
  67482. * @param extensions defines the extension to use to load the cube map (can be null)
  67483. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67484. * @param files defines the list of files to load (can be null)
  67485. * @returns a new CubeTextureAssetTask object
  67486. */
  67487. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67488. /**
  67489. *
  67490. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67491. * @param taskName defines the name of the new task
  67492. * @param url defines the url of the file to load
  67493. * @param size defines the size you want for the cubemap (can be null)
  67494. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67495. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67496. * @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)
  67497. * @param reserved Internal use only
  67498. * @returns a new HDRCubeTextureAssetTask object
  67499. */
  67500. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67501. /**
  67502. *
  67503. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67504. * @param taskName defines the name of the new task
  67505. * @param url defines the url of the file to load
  67506. * @param size defines the size you want for the cubemap (can be null)
  67507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67508. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67509. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67510. * @returns a new EquiRectangularCubeTextureAssetTask object
  67511. */
  67512. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67513. /**
  67514. * Remove a task from the assets manager.
  67515. * @param task the task to remove
  67516. */
  67517. removeTask(task: AbstractAssetTask): void;
  67518. private _decreaseWaitingTasksCount;
  67519. private _runTask;
  67520. /**
  67521. * Reset the AssetsManager and remove all tasks
  67522. * @return the current instance of the AssetsManager
  67523. */
  67524. reset(): AssetsManager;
  67525. /**
  67526. * Start the loading process
  67527. * @return the current instance of the AssetsManager
  67528. */
  67529. load(): AssetsManager;
  67530. /**
  67531. * Start the loading process as an async operation
  67532. * @return a promise returning the list of failed tasks
  67533. */
  67534. loadAsync(): Promise<void>;
  67535. }
  67536. }
  67537. declare module BABYLON {
  67538. /**
  67539. * Wrapper class for promise with external resolve and reject.
  67540. */
  67541. export class Deferred<T> {
  67542. /**
  67543. * The promise associated with this deferred object.
  67544. */
  67545. readonly promise: Promise<T>;
  67546. private _resolve;
  67547. private _reject;
  67548. /**
  67549. * The resolve method of the promise associated with this deferred object.
  67550. */
  67551. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67552. /**
  67553. * The reject method of the promise associated with this deferred object.
  67554. */
  67555. get reject(): (reason?: any) => void;
  67556. /**
  67557. * Constructor for this deferred object.
  67558. */
  67559. constructor();
  67560. }
  67561. }
  67562. declare module BABYLON {
  67563. /**
  67564. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67565. */
  67566. export class MeshExploder {
  67567. private _centerMesh;
  67568. private _meshes;
  67569. private _meshesOrigins;
  67570. private _toCenterVectors;
  67571. private _scaledDirection;
  67572. private _newPosition;
  67573. private _centerPosition;
  67574. /**
  67575. * Explodes meshes from a center mesh.
  67576. * @param meshes The meshes to explode.
  67577. * @param centerMesh The mesh to be center of explosion.
  67578. */
  67579. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67580. private _setCenterMesh;
  67581. /**
  67582. * Get class name
  67583. * @returns "MeshExploder"
  67584. */
  67585. getClassName(): string;
  67586. /**
  67587. * "Exploded meshes"
  67588. * @returns Array of meshes with the centerMesh at index 0.
  67589. */
  67590. getMeshes(): Array<Mesh>;
  67591. /**
  67592. * Explodes meshes giving a specific direction
  67593. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67594. */
  67595. explode(direction?: number): void;
  67596. }
  67597. }
  67598. declare module BABYLON {
  67599. /**
  67600. * Class used to help managing file picking and drag'n'drop
  67601. */
  67602. export class FilesInput {
  67603. /**
  67604. * List of files ready to be loaded
  67605. */
  67606. static get FilesToLoad(): {
  67607. [key: string]: File;
  67608. };
  67609. /**
  67610. * Callback called when a file is processed
  67611. */
  67612. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67613. private _engine;
  67614. private _currentScene;
  67615. private _sceneLoadedCallback;
  67616. private _progressCallback;
  67617. private _additionalRenderLoopLogicCallback;
  67618. private _textureLoadingCallback;
  67619. private _startingProcessingFilesCallback;
  67620. private _onReloadCallback;
  67621. private _errorCallback;
  67622. private _elementToMonitor;
  67623. private _sceneFileToLoad;
  67624. private _filesToLoad;
  67625. /**
  67626. * Creates a new FilesInput
  67627. * @param engine defines the rendering engine
  67628. * @param scene defines the hosting scene
  67629. * @param sceneLoadedCallback callback called when scene is loaded
  67630. * @param progressCallback callback called to track progress
  67631. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67632. * @param textureLoadingCallback callback called when a texture is loading
  67633. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67634. * @param onReloadCallback callback called when a reload is requested
  67635. * @param errorCallback callback call if an error occurs
  67636. */
  67637. 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);
  67638. private _dragEnterHandler;
  67639. private _dragOverHandler;
  67640. private _dropHandler;
  67641. /**
  67642. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67643. * @param elementToMonitor defines the DOM element to track
  67644. */
  67645. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67646. /**
  67647. * Release all associated resources
  67648. */
  67649. dispose(): void;
  67650. private renderFunction;
  67651. private drag;
  67652. private drop;
  67653. private _traverseFolder;
  67654. private _processFiles;
  67655. /**
  67656. * Load files from a drop event
  67657. * @param event defines the drop event to use as source
  67658. */
  67659. loadFiles(event: any): void;
  67660. private _processReload;
  67661. /**
  67662. * Reload the current scene from the loaded files
  67663. */
  67664. reload(): void;
  67665. }
  67666. }
  67667. declare module BABYLON {
  67668. /**
  67669. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67671. */
  67672. export class SceneOptimization {
  67673. /**
  67674. * Defines the priority of this optimization (0 by default which means first in the list)
  67675. */
  67676. priority: number;
  67677. /**
  67678. * Gets a string describing the action executed by the current optimization
  67679. * @returns description string
  67680. */
  67681. getDescription(): string;
  67682. /**
  67683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67684. * @param scene defines the current scene where to apply this optimization
  67685. * @param optimizer defines the current optimizer
  67686. * @returns true if everything that can be done was applied
  67687. */
  67688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67689. /**
  67690. * Creates the SceneOptimization object
  67691. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67692. * @param desc defines the description associated with the optimization
  67693. */
  67694. constructor(
  67695. /**
  67696. * Defines the priority of this optimization (0 by default which means first in the list)
  67697. */
  67698. priority?: number);
  67699. }
  67700. /**
  67701. * Defines an optimization used to reduce the size of render target textures
  67702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67703. */
  67704. export class TextureOptimization extends SceneOptimization {
  67705. /**
  67706. * Defines the priority of this optimization (0 by default which means first in the list)
  67707. */
  67708. priority: number;
  67709. /**
  67710. * 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
  67711. */
  67712. maximumSize: number;
  67713. /**
  67714. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67715. */
  67716. step: number;
  67717. /**
  67718. * Gets a string describing the action executed by the current optimization
  67719. * @returns description string
  67720. */
  67721. getDescription(): string;
  67722. /**
  67723. * Creates the TextureOptimization object
  67724. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67725. * @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
  67726. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67727. */
  67728. constructor(
  67729. /**
  67730. * Defines the priority of this optimization (0 by default which means first in the list)
  67731. */
  67732. priority?: number,
  67733. /**
  67734. * 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
  67735. */
  67736. maximumSize?: number,
  67737. /**
  67738. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67739. */
  67740. step?: number);
  67741. /**
  67742. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67743. * @param scene defines the current scene where to apply this optimization
  67744. * @param optimizer defines the current optimizer
  67745. * @returns true if everything that can be done was applied
  67746. */
  67747. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67748. }
  67749. /**
  67750. * Defines an optimization used to increase or decrease the rendering resolution
  67751. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67752. */
  67753. export class HardwareScalingOptimization extends SceneOptimization {
  67754. /**
  67755. * Defines the priority of this optimization (0 by default which means first in the list)
  67756. */
  67757. priority: number;
  67758. /**
  67759. * Defines the maximum scale to use (2 by default)
  67760. */
  67761. maximumScale: number;
  67762. /**
  67763. * Defines the step to use between two passes (0.5 by default)
  67764. */
  67765. step: number;
  67766. private _currentScale;
  67767. private _directionOffset;
  67768. /**
  67769. * Gets a string describing the action executed by the current optimization
  67770. * @return description string
  67771. */
  67772. getDescription(): string;
  67773. /**
  67774. * Creates the HardwareScalingOptimization object
  67775. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67776. * @param maximumScale defines the maximum scale to use (2 by default)
  67777. * @param step defines the step to use between two passes (0.5 by default)
  67778. */
  67779. constructor(
  67780. /**
  67781. * Defines the priority of this optimization (0 by default which means first in the list)
  67782. */
  67783. priority?: number,
  67784. /**
  67785. * Defines the maximum scale to use (2 by default)
  67786. */
  67787. maximumScale?: number,
  67788. /**
  67789. * Defines the step to use between two passes (0.5 by default)
  67790. */
  67791. step?: number);
  67792. /**
  67793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67794. * @param scene defines the current scene where to apply this optimization
  67795. * @param optimizer defines the current optimizer
  67796. * @returns true if everything that can be done was applied
  67797. */
  67798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67799. }
  67800. /**
  67801. * Defines an optimization used to remove shadows
  67802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67803. */
  67804. export class ShadowsOptimization extends SceneOptimization {
  67805. /**
  67806. * Gets a string describing the action executed by the current optimization
  67807. * @return description string
  67808. */
  67809. getDescription(): string;
  67810. /**
  67811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67812. * @param scene defines the current scene where to apply this optimization
  67813. * @param optimizer defines the current optimizer
  67814. * @returns true if everything that can be done was applied
  67815. */
  67816. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67817. }
  67818. /**
  67819. * Defines an optimization used to turn post-processes off
  67820. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67821. */
  67822. export class PostProcessesOptimization extends SceneOptimization {
  67823. /**
  67824. * Gets a string describing the action executed by the current optimization
  67825. * @return description string
  67826. */
  67827. getDescription(): string;
  67828. /**
  67829. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67830. * @param scene defines the current scene where to apply this optimization
  67831. * @param optimizer defines the current optimizer
  67832. * @returns true if everything that can be done was applied
  67833. */
  67834. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67835. }
  67836. /**
  67837. * Defines an optimization used to turn lens flares off
  67838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67839. */
  67840. export class LensFlaresOptimization extends SceneOptimization {
  67841. /**
  67842. * Gets a string describing the action executed by the current optimization
  67843. * @return description string
  67844. */
  67845. getDescription(): string;
  67846. /**
  67847. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67848. * @param scene defines the current scene where to apply this optimization
  67849. * @param optimizer defines the current optimizer
  67850. * @returns true if everything that can be done was applied
  67851. */
  67852. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67853. }
  67854. /**
  67855. * Defines an optimization based on user defined callback.
  67856. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67857. */
  67858. export class CustomOptimization extends SceneOptimization {
  67859. /**
  67860. * Callback called to apply the custom optimization.
  67861. */
  67862. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67863. /**
  67864. * Callback called to get custom description
  67865. */
  67866. onGetDescription: () => string;
  67867. /**
  67868. * Gets a string describing the action executed by the current optimization
  67869. * @returns description string
  67870. */
  67871. getDescription(): string;
  67872. /**
  67873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67874. * @param scene defines the current scene where to apply this optimization
  67875. * @param optimizer defines the current optimizer
  67876. * @returns true if everything that can be done was applied
  67877. */
  67878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67879. }
  67880. /**
  67881. * Defines an optimization used to turn particles off
  67882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67883. */
  67884. export class ParticlesOptimization extends SceneOptimization {
  67885. /**
  67886. * Gets a string describing the action executed by the current optimization
  67887. * @return description string
  67888. */
  67889. getDescription(): string;
  67890. /**
  67891. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67892. * @param scene defines the current scene where to apply this optimization
  67893. * @param optimizer defines the current optimizer
  67894. * @returns true if everything that can be done was applied
  67895. */
  67896. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67897. }
  67898. /**
  67899. * Defines an optimization used to turn render targets off
  67900. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67901. */
  67902. export class RenderTargetsOptimization extends SceneOptimization {
  67903. /**
  67904. * Gets a string describing the action executed by the current optimization
  67905. * @return description string
  67906. */
  67907. getDescription(): string;
  67908. /**
  67909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67910. * @param scene defines the current scene where to apply this optimization
  67911. * @param optimizer defines the current optimizer
  67912. * @returns true if everything that can be done was applied
  67913. */
  67914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67915. }
  67916. /**
  67917. * Defines an optimization used to merge meshes with compatible materials
  67918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67919. */
  67920. export class MergeMeshesOptimization extends SceneOptimization {
  67921. private static _UpdateSelectionTree;
  67922. /**
  67923. * Gets or sets a boolean which defines if optimization octree has to be updated
  67924. */
  67925. static get UpdateSelectionTree(): boolean;
  67926. /**
  67927. * Gets or sets a boolean which defines if optimization octree has to be updated
  67928. */
  67929. static set UpdateSelectionTree(value: boolean);
  67930. /**
  67931. * Gets a string describing the action executed by the current optimization
  67932. * @return description string
  67933. */
  67934. getDescription(): string;
  67935. private _canBeMerged;
  67936. /**
  67937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67938. * @param scene defines the current scene where to apply this optimization
  67939. * @param optimizer defines the current optimizer
  67940. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67941. * @returns true if everything that can be done was applied
  67942. */
  67943. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67944. }
  67945. /**
  67946. * Defines a list of options used by SceneOptimizer
  67947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67948. */
  67949. export class SceneOptimizerOptions {
  67950. /**
  67951. * Defines the target frame rate to reach (60 by default)
  67952. */
  67953. targetFrameRate: number;
  67954. /**
  67955. * Defines the interval between two checkes (2000ms by default)
  67956. */
  67957. trackerDuration: number;
  67958. /**
  67959. * Gets the list of optimizations to apply
  67960. */
  67961. optimizations: SceneOptimization[];
  67962. /**
  67963. * Creates a new list of options used by SceneOptimizer
  67964. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67965. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67966. */
  67967. constructor(
  67968. /**
  67969. * Defines the target frame rate to reach (60 by default)
  67970. */
  67971. targetFrameRate?: number,
  67972. /**
  67973. * Defines the interval between two checkes (2000ms by default)
  67974. */
  67975. trackerDuration?: number);
  67976. /**
  67977. * Add a new optimization
  67978. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67979. * @returns the current SceneOptimizerOptions
  67980. */
  67981. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67982. /**
  67983. * Add a new custom optimization
  67984. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67985. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67986. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67987. * @returns the current SceneOptimizerOptions
  67988. */
  67989. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67990. /**
  67991. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67992. * @param targetFrameRate defines the target frame rate (60 by default)
  67993. * @returns a SceneOptimizerOptions object
  67994. */
  67995. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67996. /**
  67997. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67998. * @param targetFrameRate defines the target frame rate (60 by default)
  67999. * @returns a SceneOptimizerOptions object
  68000. */
  68001. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68002. /**
  68003. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68004. * @param targetFrameRate defines the target frame rate (60 by default)
  68005. * @returns a SceneOptimizerOptions object
  68006. */
  68007. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68008. }
  68009. /**
  68010. * Class used to run optimizations in order to reach a target frame rate
  68011. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68012. */
  68013. export class SceneOptimizer implements IDisposable {
  68014. private _isRunning;
  68015. private _options;
  68016. private _scene;
  68017. private _currentPriorityLevel;
  68018. private _targetFrameRate;
  68019. private _trackerDuration;
  68020. private _currentFrameRate;
  68021. private _sceneDisposeObserver;
  68022. private _improvementMode;
  68023. /**
  68024. * Defines an observable called when the optimizer reaches the target frame rate
  68025. */
  68026. onSuccessObservable: Observable<SceneOptimizer>;
  68027. /**
  68028. * Defines an observable called when the optimizer enables an optimization
  68029. */
  68030. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68031. /**
  68032. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68033. */
  68034. onFailureObservable: Observable<SceneOptimizer>;
  68035. /**
  68036. * Gets a boolean indicating if the optimizer is in improvement mode
  68037. */
  68038. get isInImprovementMode(): boolean;
  68039. /**
  68040. * Gets the current priority level (0 at start)
  68041. */
  68042. get currentPriorityLevel(): number;
  68043. /**
  68044. * Gets the current frame rate checked by the SceneOptimizer
  68045. */
  68046. get currentFrameRate(): number;
  68047. /**
  68048. * Gets or sets the current target frame rate (60 by default)
  68049. */
  68050. get targetFrameRate(): number;
  68051. /**
  68052. * Gets or sets the current target frame rate (60 by default)
  68053. */
  68054. set targetFrameRate(value: number);
  68055. /**
  68056. * Gets or sets the current interval between two checks (every 2000ms by default)
  68057. */
  68058. get trackerDuration(): number;
  68059. /**
  68060. * Gets or sets the current interval between two checks (every 2000ms by default)
  68061. */
  68062. set trackerDuration(value: number);
  68063. /**
  68064. * Gets the list of active optimizations
  68065. */
  68066. get optimizations(): SceneOptimization[];
  68067. /**
  68068. * Creates a new SceneOptimizer
  68069. * @param scene defines the scene to work on
  68070. * @param options defines the options to use with the SceneOptimizer
  68071. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68072. * @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)
  68073. */
  68074. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68075. /**
  68076. * Stops the current optimizer
  68077. */
  68078. stop(): void;
  68079. /**
  68080. * Reset the optimizer to initial step (current priority level = 0)
  68081. */
  68082. reset(): void;
  68083. /**
  68084. * Start the optimizer. By default it will try to reach a specific framerate
  68085. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68086. */
  68087. start(): void;
  68088. private _checkCurrentState;
  68089. /**
  68090. * Release all resources
  68091. */
  68092. dispose(): void;
  68093. /**
  68094. * Helper function to create a SceneOptimizer with one single line of code
  68095. * @param scene defines the scene to work on
  68096. * @param options defines the options to use with the SceneOptimizer
  68097. * @param onSuccess defines a callback to call on success
  68098. * @param onFailure defines a callback to call on failure
  68099. * @returns the new SceneOptimizer object
  68100. */
  68101. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68102. }
  68103. }
  68104. declare module BABYLON {
  68105. /**
  68106. * Class used to serialize a scene into a string
  68107. */
  68108. export class SceneSerializer {
  68109. /**
  68110. * Clear cache used by a previous serialization
  68111. */
  68112. static ClearCache(): void;
  68113. /**
  68114. * Serialize a scene into a JSON compatible object
  68115. * @param scene defines the scene to serialize
  68116. * @returns a JSON compatible object
  68117. */
  68118. static Serialize(scene: Scene): any;
  68119. /**
  68120. * Serialize a mesh into a JSON compatible object
  68121. * @param toSerialize defines the mesh to serialize
  68122. * @param withParents defines if parents must be serialized as well
  68123. * @param withChildren defines if children must be serialized as well
  68124. * @returns a JSON compatible object
  68125. */
  68126. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68127. }
  68128. }
  68129. declare module BABYLON {
  68130. /**
  68131. * Class used to host texture specific utilities
  68132. */
  68133. export class TextureTools {
  68134. /**
  68135. * Uses the GPU to create a copy texture rescaled at a given size
  68136. * @param texture Texture to copy from
  68137. * @param width defines the desired width
  68138. * @param height defines the desired height
  68139. * @param useBilinearMode defines if bilinear mode has to be used
  68140. * @return the generated texture
  68141. */
  68142. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68143. }
  68144. }
  68145. declare module BABYLON {
  68146. /**
  68147. * This represents the different options available for the video capture.
  68148. */
  68149. export interface VideoRecorderOptions {
  68150. /** Defines the mime type of the video. */
  68151. mimeType: string;
  68152. /** Defines the FPS the video should be recorded at. */
  68153. fps: number;
  68154. /** Defines the chunk size for the recording data. */
  68155. recordChunckSize: number;
  68156. /** The audio tracks to attach to the recording. */
  68157. audioTracks?: MediaStreamTrack[];
  68158. }
  68159. /**
  68160. * This can help with recording videos from BabylonJS.
  68161. * This is based on the available WebRTC functionalities of the browser.
  68162. *
  68163. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68164. */
  68165. export class VideoRecorder {
  68166. private static readonly _defaultOptions;
  68167. /**
  68168. * Returns whether or not the VideoRecorder is available in your browser.
  68169. * @param engine Defines the Babylon Engine.
  68170. * @returns true if supported otherwise false.
  68171. */
  68172. static IsSupported(engine: Engine): boolean;
  68173. private readonly _options;
  68174. private _canvas;
  68175. private _mediaRecorder;
  68176. private _recordedChunks;
  68177. private _fileName;
  68178. private _resolve;
  68179. private _reject;
  68180. /**
  68181. * True when a recording is already in progress.
  68182. */
  68183. get isRecording(): boolean;
  68184. /**
  68185. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68186. * @param engine Defines the BabylonJS Engine you wish to record.
  68187. * @param options Defines options that can be used to customize the capture.
  68188. */
  68189. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68190. /**
  68191. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68192. */
  68193. stopRecording(): void;
  68194. /**
  68195. * Starts recording the canvas for a max duration specified in parameters.
  68196. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68197. * If null no automatic download will start and you can rely on the promise to get the data back.
  68198. * @param maxDuration Defines the maximum recording time in seconds.
  68199. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68200. * @return A promise callback at the end of the recording with the video data in Blob.
  68201. */
  68202. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68203. /**
  68204. * Releases internal resources used during the recording.
  68205. */
  68206. dispose(): void;
  68207. private _handleDataAvailable;
  68208. private _handleError;
  68209. private _handleStop;
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /**
  68214. * Class containing a set of static utilities functions for screenshots
  68215. */
  68216. export class ScreenshotTools {
  68217. /**
  68218. * Captures a screenshot of the current rendering
  68219. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68220. * @param engine defines the rendering engine
  68221. * @param camera defines the source camera
  68222. * @param size This parameter can be set to a single number or to an object with the
  68223. * following (optional) properties: precision, width, height. If a single number is passed,
  68224. * it will be used for both width and height. If an object is passed, the screenshot size
  68225. * will be derived from the parameters. The precision property is a multiplier allowing
  68226. * rendering at a higher or lower resolution
  68227. * @param successCallback defines the callback receives a single parameter which contains the
  68228. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68229. * src parameter of an <img> to display it
  68230. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68231. * Check your browser for supported MIME types
  68232. */
  68233. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68234. /**
  68235. * Captures a screenshot of the current rendering
  68236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68237. * @param engine defines the rendering engine
  68238. * @param camera defines the source camera
  68239. * @param size This parameter can be set to a single number or to an object with the
  68240. * following (optional) properties: precision, width, height. If a single number is passed,
  68241. * it will be used for both width and height. If an object is passed, the screenshot size
  68242. * will be derived from the parameters. The precision property is a multiplier allowing
  68243. * rendering at a higher or lower resolution
  68244. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68245. * Check your browser for supported MIME types
  68246. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68247. * to the src parameter of an <img> to display it
  68248. */
  68249. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68250. /**
  68251. * Generates an image screenshot from the specified camera.
  68252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68253. * @param engine The engine to use for rendering
  68254. * @param camera The camera to use for rendering
  68255. * @param size This parameter can be set to a single number or to an object with the
  68256. * following (optional) properties: precision, width, height. If a single number is passed,
  68257. * it will be used for both width and height. If an object is passed, the screenshot size
  68258. * will be derived from the parameters. The precision property is a multiplier allowing
  68259. * rendering at a higher or lower resolution
  68260. * @param successCallback The callback receives a single parameter which contains the
  68261. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68262. * src parameter of an <img> to display it
  68263. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68264. * Check your browser for supported MIME types
  68265. * @param samples Texture samples (default: 1)
  68266. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68267. * @param fileName A name for for the downloaded file.
  68268. */
  68269. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68270. /**
  68271. * Generates an image screenshot from the specified camera.
  68272. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68273. * @param engine The engine to use for rendering
  68274. * @param camera The camera to use for rendering
  68275. * @param size This parameter can be set to a single number or to an object with the
  68276. * following (optional) properties: precision, width, height. If a single number is passed,
  68277. * it will be used for both width and height. If an object is passed, the screenshot size
  68278. * will be derived from the parameters. The precision property is a multiplier allowing
  68279. * rendering at a higher or lower resolution
  68280. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68281. * Check your browser for supported MIME types
  68282. * @param samples Texture samples (default: 1)
  68283. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68284. * @param fileName A name for for the downloaded file.
  68285. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68286. * to the src parameter of an <img> to display it
  68287. */
  68288. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68289. /**
  68290. * Gets height and width for screenshot size
  68291. * @private
  68292. */
  68293. private static _getScreenshotSize;
  68294. }
  68295. }
  68296. declare module BABYLON {
  68297. /**
  68298. * Interface for a data buffer
  68299. */
  68300. export interface IDataBuffer {
  68301. /**
  68302. * Reads bytes from the data buffer.
  68303. * @param byteOffset The byte offset to read
  68304. * @param byteLength The byte length to read
  68305. * @returns A promise that resolves when the bytes are read
  68306. */
  68307. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68308. /**
  68309. * The byte length of the buffer.
  68310. */
  68311. readonly byteLength: number;
  68312. }
  68313. /**
  68314. * Utility class for reading from a data buffer
  68315. */
  68316. export class DataReader {
  68317. /**
  68318. * The data buffer associated with this data reader.
  68319. */
  68320. readonly buffer: IDataBuffer;
  68321. /**
  68322. * The current byte offset from the beginning of the data buffer.
  68323. */
  68324. byteOffset: number;
  68325. private _dataView;
  68326. private _dataByteOffset;
  68327. /**
  68328. * Constructor
  68329. * @param buffer The buffer to read
  68330. */
  68331. constructor(buffer: IDataBuffer);
  68332. /**
  68333. * Loads the given byte length.
  68334. * @param byteLength The byte length to load
  68335. * @returns A promise that resolves when the load is complete
  68336. */
  68337. loadAsync(byteLength: number): Promise<void>;
  68338. /**
  68339. * Read a unsigned 32-bit integer from the currently loaded data range.
  68340. * @returns The 32-bit integer read
  68341. */
  68342. readUint32(): number;
  68343. /**
  68344. * Read a byte array from the currently loaded data range.
  68345. * @param byteLength The byte length to read
  68346. * @returns The byte array read
  68347. */
  68348. readUint8Array(byteLength: number): Uint8Array;
  68349. /**
  68350. * Read a string from the currently loaded data range.
  68351. * @param byteLength The byte length to read
  68352. * @returns The string read
  68353. */
  68354. readString(byteLength: number): string;
  68355. /**
  68356. * Skips the given byte length the currently loaded data range.
  68357. * @param byteLength The byte length to skip
  68358. */
  68359. skipBytes(byteLength: number): void;
  68360. }
  68361. }
  68362. declare module BABYLON {
  68363. /**
  68364. * Options used for hit testing
  68365. */
  68366. export interface IWebXRHitTestOptions {
  68367. /**
  68368. * Only test when user interacted with the scene. Default - hit test every frame
  68369. */
  68370. testOnPointerDownOnly?: boolean;
  68371. /**
  68372. * The node to use to transform the local results to world coordinates
  68373. */
  68374. worldParentNode?: TransformNode;
  68375. }
  68376. /**
  68377. * Interface defining the babylon result of raycasting/hit-test
  68378. */
  68379. export interface IWebXRHitResult {
  68380. /**
  68381. * The native hit test result
  68382. */
  68383. xrHitResult: XRHitResult;
  68384. /**
  68385. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68386. */
  68387. transformationMatrix: Matrix;
  68388. }
  68389. /**
  68390. * The currently-working hit-test module.
  68391. * Hit test (or raycasting) is used to interact with the real world.
  68392. * For further information read here - https://github.com/immersive-web/hit-test
  68393. */
  68394. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68395. /**
  68396. * options to use when constructing this feature
  68397. */
  68398. readonly options: IWebXRHitTestOptions;
  68399. /**
  68400. * The module's name
  68401. */
  68402. static readonly Name: string;
  68403. /**
  68404. * The (Babylon) version of this module.
  68405. * This is an integer representing the implementation version.
  68406. * This number does not correspond to the webxr specs version
  68407. */
  68408. static readonly Version: number;
  68409. /**
  68410. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68411. * @param event the (select) event to use to select with
  68412. * @param referenceSpace the reference space to use for this hit test
  68413. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68414. */
  68415. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68416. /**
  68417. * execute a hit test with an XR Ray
  68418. *
  68419. * @param xrSession a native xrSession that will execute this hit test
  68420. * @param xrRay the ray (position and direction) to use for raycasting
  68421. * @param referenceSpace native XR reference space to use for the hit-test
  68422. * @param filter filter function that will filter the results
  68423. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68424. */
  68425. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68426. /**
  68427. * Triggered when new babylon (transformed) hit test results are available
  68428. */
  68429. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68430. private _onSelectEnabled;
  68431. /**
  68432. * Creates a new instance of the (legacy version) hit test feature
  68433. * @param _xrSessionManager an instance of WebXRSessionManager
  68434. * @param options options to use when constructing this feature
  68435. */
  68436. constructor(_xrSessionManager: WebXRSessionManager,
  68437. /**
  68438. * options to use when constructing this feature
  68439. */
  68440. options?: IWebXRHitTestOptions);
  68441. /**
  68442. * Populated with the last native XR Hit Results
  68443. */
  68444. lastNativeXRHitResults: XRHitResult[];
  68445. /**
  68446. * attach this feature
  68447. * Will usually be called by the features manager
  68448. *
  68449. * @returns true if successful.
  68450. */
  68451. attach(): boolean;
  68452. /**
  68453. * detach this feature.
  68454. * Will usually be called by the features manager
  68455. *
  68456. * @returns true if successful.
  68457. */
  68458. detach(): boolean;
  68459. private _onHitTestResults;
  68460. private _origin;
  68461. private _direction;
  68462. private _mat;
  68463. protected _onXRFrame(frame: XRFrame): void;
  68464. private _onSelect;
  68465. /**
  68466. * Dispose this feature and all of the resources attached
  68467. */
  68468. dispose(): void;
  68469. }
  68470. }
  68471. declare module BABYLON {
  68472. /**
  68473. * Options used in the plane detector module
  68474. */
  68475. export interface IWebXRPlaneDetectorOptions {
  68476. /**
  68477. * The node to use to transform the local results to world coordinates
  68478. */
  68479. worldParentNode?: TransformNode;
  68480. }
  68481. /**
  68482. * A babylon interface for a webxr plane.
  68483. * A Plane is actually a polygon, built from N points in space
  68484. *
  68485. * Supported in chrome 79, not supported in canary 81 ATM
  68486. */
  68487. export interface IWebXRPlane {
  68488. /**
  68489. * a babylon-assigned ID for this polygon
  68490. */
  68491. id: number;
  68492. /**
  68493. * the native xr-plane object
  68494. */
  68495. xrPlane: XRPlane;
  68496. /**
  68497. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68498. */
  68499. polygonDefinition: Array<Vector3>;
  68500. /**
  68501. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68502. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68503. */
  68504. transformationMatrix: Matrix;
  68505. }
  68506. /**
  68507. * The plane detector is used to detect planes in the real world when in AR
  68508. * For more information see https://github.com/immersive-web/real-world-geometry/
  68509. */
  68510. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68511. private _options;
  68512. /**
  68513. * The module's name
  68514. */
  68515. static readonly Name: string;
  68516. /**
  68517. * The (Babylon) version of this module.
  68518. * This is an integer representing the implementation version.
  68519. * This number does not correspond to the webxr specs version
  68520. */
  68521. static readonly Version: number;
  68522. /**
  68523. * Observers registered here will be executed when a new plane was added to the session
  68524. */
  68525. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68526. /**
  68527. * Observers registered here will be executed when a plane is no longer detected in the session
  68528. */
  68529. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68530. /**
  68531. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68532. * This can execute N times every frame
  68533. */
  68534. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68535. private _enabled;
  68536. private _detectedPlanes;
  68537. private _lastFrameDetected;
  68538. /**
  68539. * construct a new Plane Detector
  68540. * @param _xrSessionManager an instance of xr Session manager
  68541. * @param _options configuration to use when constructing this feature
  68542. */
  68543. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68544. private _init;
  68545. protected _onXRFrame(frame: XRFrame): void;
  68546. /**
  68547. * Dispose this feature and all of the resources attached
  68548. */
  68549. dispose(): void;
  68550. private _updatePlaneWithXRPlane;
  68551. /**
  68552. * avoiding using Array.find for global support.
  68553. * @param xrPlane the plane to find in the array
  68554. */
  68555. private findIndexInPlaneArray;
  68556. }
  68557. }
  68558. declare module BABYLON {
  68559. /**
  68560. * Configuration options of the anchor system
  68561. */
  68562. export interface IWebXRAnchorSystemOptions {
  68563. /**
  68564. * a node that will be used to convert local to world coordinates
  68565. */
  68566. worldParentNode?: TransformNode;
  68567. /**
  68568. * should the anchor system use plane detection.
  68569. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68570. */
  68571. usePlaneDetection?: boolean;
  68572. /**
  68573. * Should a new anchor be added every time a select event is triggered
  68574. */
  68575. addAnchorOnSelect?: boolean;
  68576. }
  68577. /**
  68578. * A babylon container for an XR Anchor
  68579. */
  68580. export interface IWebXRAnchor {
  68581. /**
  68582. * A babylon-assigned ID for this anchor
  68583. */
  68584. id: number;
  68585. /**
  68586. * The native anchor object
  68587. */
  68588. xrAnchor: XRAnchor;
  68589. /**
  68590. * Transformation matrix to apply to an object attached to this anchor
  68591. */
  68592. transformationMatrix: Matrix;
  68593. }
  68594. /**
  68595. * An implementation of the anchor system of WebXR.
  68596. * Note that the current documented implementation is not available in any browser. Future implementations
  68597. * will use the frame to create an anchor and not the session or a detected plane
  68598. * For further information see https://github.com/immersive-web/anchors/
  68599. */
  68600. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68601. private _options;
  68602. /**
  68603. * The module's name
  68604. */
  68605. static readonly Name: string;
  68606. /**
  68607. * The (Babylon) version of this module.
  68608. * This is an integer representing the implementation version.
  68609. * This number does not correspond to the webxr specs version
  68610. */
  68611. static readonly Version: number;
  68612. /**
  68613. * Observers registered here will be executed when a new anchor was added to the session
  68614. */
  68615. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68616. /**
  68617. * Observers registered here will be executed when an existing anchor updates
  68618. * This can execute N times every frame
  68619. */
  68620. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68621. /**
  68622. * Observers registered here will be executed when an anchor was removed from the session
  68623. */
  68624. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68625. private _planeDetector;
  68626. private _hitTestModule;
  68627. private _enabled;
  68628. private _trackedAnchors;
  68629. private _lastFrameDetected;
  68630. /**
  68631. * constructs a new anchor system
  68632. * @param _xrSessionManager an instance of WebXRSessionManager
  68633. * @param _options configuration object for this feature
  68634. */
  68635. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68636. /**
  68637. * set the plane detector to use in order to create anchors from frames
  68638. * @param planeDetector the plane-detector module to use
  68639. * @param enable enable plane-anchors. default is true
  68640. */
  68641. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68642. /**
  68643. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68644. * @param hitTestModule the hit-test module to use.
  68645. */
  68646. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68647. /**
  68648. * attach this feature
  68649. * Will usually be called by the features manager
  68650. *
  68651. * @returns true if successful.
  68652. */
  68653. attach(): boolean;
  68654. /**
  68655. * detach this feature.
  68656. * Will usually be called by the features manager
  68657. *
  68658. * @returns true if successful.
  68659. */
  68660. detach(): boolean;
  68661. /**
  68662. * Dispose this feature and all of the resources attached
  68663. */
  68664. dispose(): void;
  68665. protected _onXRFrame(frame: XRFrame): void;
  68666. private _onSelect;
  68667. /**
  68668. * Add anchor at a specific XR point.
  68669. *
  68670. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68671. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68672. * @returns a promise the fulfills when the anchor was created
  68673. */
  68674. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68675. private _updateAnchorWithXRFrame;
  68676. /**
  68677. * avoiding using Array.find for global support.
  68678. * @param xrAnchor the plane to find in the array
  68679. */
  68680. private _findIndexInAnchorArray;
  68681. }
  68682. }
  68683. declare module BABYLON {
  68684. /**
  68685. * Options interface for the background remover plugin
  68686. */
  68687. export interface IWebXRBackgroundRemoverOptions {
  68688. /**
  68689. * don't disable the environment helper
  68690. */
  68691. ignoreEnvironmentHelper?: boolean;
  68692. /**
  68693. * flags to configure the removal of the environment helper.
  68694. * If not set, the entire background will be removed. If set, flags should be set as well.
  68695. */
  68696. environmentHelperRemovalFlags?: {
  68697. /**
  68698. * Should the skybox be removed (default false)
  68699. */
  68700. skyBox?: boolean;
  68701. /**
  68702. * Should the ground be removed (default false)
  68703. */
  68704. ground?: boolean;
  68705. };
  68706. /**
  68707. * Further background meshes to disable when entering AR
  68708. */
  68709. backgroundMeshes?: AbstractMesh[];
  68710. }
  68711. /**
  68712. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68713. */
  68714. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68715. /**
  68716. * read-only options to be used in this module
  68717. */
  68718. readonly options: IWebXRBackgroundRemoverOptions;
  68719. /**
  68720. * The module's name
  68721. */
  68722. static readonly Name: string;
  68723. /**
  68724. * The (Babylon) version of this module.
  68725. * This is an integer representing the implementation version.
  68726. * This number does not correspond to the webxr specs version
  68727. */
  68728. static readonly Version: number;
  68729. /**
  68730. * registered observers will be triggered when the background state changes
  68731. */
  68732. onBackgroundStateChangedObservable: Observable<boolean>;
  68733. /**
  68734. * constructs a new background remover module
  68735. * @param _xrSessionManager the session manager for this module
  68736. * @param options read-only options to be used in this module
  68737. */
  68738. constructor(_xrSessionManager: WebXRSessionManager,
  68739. /**
  68740. * read-only options to be used in this module
  68741. */
  68742. options?: IWebXRBackgroundRemoverOptions);
  68743. /**
  68744. * attach this feature
  68745. * Will usually be called by the features manager
  68746. *
  68747. * @returns true if successful.
  68748. */
  68749. attach(): boolean;
  68750. /**
  68751. * detach this feature.
  68752. * Will usually be called by the features manager
  68753. *
  68754. * @returns true if successful.
  68755. */
  68756. detach(): boolean;
  68757. private _setBackgroundState;
  68758. /**
  68759. * Dispose this feature and all of the resources attached
  68760. */
  68761. dispose(): void;
  68762. protected _onXRFrame(_xrFrame: XRFrame): void;
  68763. }
  68764. }
  68765. declare module BABYLON {
  68766. /**
  68767. * Options for the controller physics feature
  68768. */
  68769. export class IWebXRControllerPhysicsOptions {
  68770. /**
  68771. * the xr input to use with this pointer selection
  68772. */
  68773. xrInput: WebXRInput;
  68774. /**
  68775. * The physics properties of the future impostors
  68776. */
  68777. physicsProperties?: {
  68778. /**
  68779. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  68780. * Note that this requires a physics engine that supports mesh impostors!
  68781. */
  68782. useControllerMesh?: boolean;
  68783. /**
  68784. * The type of impostor to create. Default is sphere
  68785. */
  68786. impostorType?: number;
  68787. /**
  68788. * the size of the impostor. Defaults to 10cm
  68789. */
  68790. impostorSize?: number | {
  68791. width: number;
  68792. height: number;
  68793. depth: number;
  68794. };
  68795. /**
  68796. * Friction definitions
  68797. */
  68798. friction?: number;
  68799. /**
  68800. * Restitution
  68801. */
  68802. restitution?: number;
  68803. };
  68804. }
  68805. /**
  68806. * Add physics impostor to your webxr controllers,
  68807. * including naive calculation of their linear and angular velocity
  68808. */
  68809. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  68810. private readonly _options;
  68811. /**
  68812. * The module's name
  68813. */
  68814. static readonly Name: string;
  68815. /**
  68816. * The (Babylon) version of this module.
  68817. * This is an integer representing the implementation version.
  68818. * This number does not correspond to the webxr specs version
  68819. */
  68820. static readonly Version: number;
  68821. private _lastTimestamp;
  68822. private _delta;
  68823. private _controllers;
  68824. private _tmpVector;
  68825. private _tmpQuaternion;
  68826. /**
  68827. * Construct a new Controller Physics Feature
  68828. * @param _xrSessionManager the corresponding xr session manager
  68829. * @param _options options to create this feature with
  68830. */
  68831. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  68832. /**
  68833. * Update the physics properties provided in the constructor
  68834. * @param newProperties the new properties object
  68835. */
  68836. setPhysicsProperties(newProperties: {
  68837. impostorType?: number;
  68838. impostorSize?: number | {
  68839. width: number;
  68840. height: number;
  68841. depth: number;
  68842. };
  68843. friction?: number;
  68844. restitution?: number;
  68845. }): void;
  68846. /**
  68847. * attach this feature
  68848. * Will usually be called by the features manager
  68849. *
  68850. * @returns true if successful.
  68851. */
  68852. attach(): boolean;
  68853. /**
  68854. * detach this feature.
  68855. * Will usually be called by the features manager
  68856. *
  68857. * @returns true if successful.
  68858. */
  68859. detach(): boolean;
  68860. /**
  68861. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  68862. * @param xrController the controller to add
  68863. */
  68864. addController(xrController: WebXRInputSource): void;
  68865. private _debugMode;
  68866. /**
  68867. * @hidden
  68868. * enable debugging - will show console outputs and the impostor mesh
  68869. */
  68870. _enablePhysicsDebug(): void;
  68871. private _attachController;
  68872. private _detachController;
  68873. protected _onXRFrame(_xrFrame: any): void;
  68874. }
  68875. }
  68876. declare module BABYLON {
  68877. /**
  68878. * The motion controller class for all microsoft mixed reality controllers
  68879. */
  68880. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  68881. /**
  68882. * The base url used to load the left and right controller models
  68883. */
  68884. static MODEL_BASE_URL: string;
  68885. /**
  68886. * The name of the left controller model file
  68887. */
  68888. static MODEL_LEFT_FILENAME: string;
  68889. /**
  68890. * The name of the right controller model file
  68891. */
  68892. static MODEL_RIGHT_FILENAME: string;
  68893. profileId: string;
  68894. protected readonly _mapping: {
  68895. defaultButton: {
  68896. "valueNodeName": string;
  68897. "unpressedNodeName": string;
  68898. "pressedNodeName": string;
  68899. };
  68900. defaultAxis: {
  68901. "valueNodeName": string;
  68902. "minNodeName": string;
  68903. "maxNodeName": string;
  68904. };
  68905. buttons: {
  68906. "xr-standard-trigger": {
  68907. "rootNodeName": string;
  68908. "componentProperty": string;
  68909. "states": string[];
  68910. };
  68911. "xr-standard-squeeze": {
  68912. "rootNodeName": string;
  68913. "componentProperty": string;
  68914. "states": string[];
  68915. };
  68916. "xr-standard-touchpad": {
  68917. "rootNodeName": string;
  68918. "labelAnchorNodeName": string;
  68919. "touchPointNodeName": string;
  68920. };
  68921. "xr-standard-thumbstick": {
  68922. "rootNodeName": string;
  68923. "componentProperty": string;
  68924. "states": string[];
  68925. };
  68926. };
  68927. axes: {
  68928. "xr-standard-touchpad": {
  68929. "x-axis": {
  68930. "rootNodeName": string;
  68931. };
  68932. "y-axis": {
  68933. "rootNodeName": string;
  68934. };
  68935. };
  68936. "xr-standard-thumbstick": {
  68937. "x-axis": {
  68938. "rootNodeName": string;
  68939. };
  68940. "y-axis": {
  68941. "rootNodeName": string;
  68942. };
  68943. };
  68944. };
  68945. };
  68946. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  68947. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  68948. protected _getFilenameAndPath(): {
  68949. filename: string;
  68950. path: string;
  68951. };
  68952. protected _updateModel(): void;
  68953. protected _getModelLoadingConstraints(): boolean;
  68954. protected _setRootMesh(meshes: AbstractMesh[]): void;
  68955. }
  68956. }
  68957. declare module BABYLON {
  68958. /**
  68959. * The motion controller class for oculus touch (quest, rift).
  68960. * This class supports legacy mapping as well the standard xr mapping
  68961. */
  68962. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  68963. private _forceLegacyControllers;
  68964. /**
  68965. * The base url used to load the left and right controller models
  68966. */
  68967. static MODEL_BASE_URL: string;
  68968. /**
  68969. * The name of the left controller model file
  68970. */
  68971. static MODEL_LEFT_FILENAME: string;
  68972. /**
  68973. * The name of the right controller model file
  68974. */
  68975. static MODEL_RIGHT_FILENAME: string;
  68976. /**
  68977. * Base Url for the Quest controller model.
  68978. */
  68979. static QUEST_MODEL_BASE_URL: string;
  68980. profileId: string;
  68981. private _modelRootNode;
  68982. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  68983. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  68984. protected _getFilenameAndPath(): {
  68985. filename: string;
  68986. path: string;
  68987. };
  68988. /**
  68989. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  68990. * between the touch and touch 2.
  68991. */
  68992. private _isQuest;
  68993. protected _updateModel(): void;
  68994. protected _getModelLoadingConstraints(): boolean;
  68995. protected _setRootMesh(meshes: AbstractMesh[]): void;
  68996. }
  68997. }
  68998. declare module BABYLON {
  68999. /**
  69000. * The motion controller class for the standard HTC-Vive controllers
  69001. */
  69002. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69003. /**
  69004. * The base url used to load the left and right controller models
  69005. */
  69006. static MODEL_BASE_URL: string;
  69007. /**
  69008. * File name for the controller model.
  69009. */
  69010. static MODEL_FILENAME: string;
  69011. profileId: string;
  69012. private _modelRootNode;
  69013. /**
  69014. * Create a new Vive motion controller object
  69015. * @param scene the scene to use to create this controller
  69016. * @param gamepadObject the corresponding gamepad object
  69017. * @param handness the handness of the controller
  69018. */
  69019. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69020. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69021. protected _getFilenameAndPath(): {
  69022. filename: string;
  69023. path: string;
  69024. };
  69025. protected _updateModel(): void;
  69026. protected _getModelLoadingConstraints(): boolean;
  69027. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /**
  69032. * A cursor which tracks a point on a path
  69033. */
  69034. export class PathCursor {
  69035. private path;
  69036. /**
  69037. * Stores path cursor callbacks for when an onchange event is triggered
  69038. */
  69039. private _onchange;
  69040. /**
  69041. * The value of the path cursor
  69042. */
  69043. value: number;
  69044. /**
  69045. * The animation array of the path cursor
  69046. */
  69047. animations: Animation[];
  69048. /**
  69049. * Initializes the path cursor
  69050. * @param path The path to track
  69051. */
  69052. constructor(path: Path2);
  69053. /**
  69054. * Gets the cursor point on the path
  69055. * @returns A point on the path cursor at the cursor location
  69056. */
  69057. getPoint(): Vector3;
  69058. /**
  69059. * Moves the cursor ahead by the step amount
  69060. * @param step The amount to move the cursor forward
  69061. * @returns This path cursor
  69062. */
  69063. moveAhead(step?: number): PathCursor;
  69064. /**
  69065. * Moves the cursor behind by the step amount
  69066. * @param step The amount to move the cursor back
  69067. * @returns This path cursor
  69068. */
  69069. moveBack(step?: number): PathCursor;
  69070. /**
  69071. * Moves the cursor by the step amount
  69072. * If the step amount is greater than one, an exception is thrown
  69073. * @param step The amount to move the cursor
  69074. * @returns This path cursor
  69075. */
  69076. move(step: number): PathCursor;
  69077. /**
  69078. * Ensures that the value is limited between zero and one
  69079. * @returns This path cursor
  69080. */
  69081. private ensureLimits;
  69082. /**
  69083. * Runs onchange callbacks on change (used by the animation engine)
  69084. * @returns This path cursor
  69085. */
  69086. private raiseOnChange;
  69087. /**
  69088. * Executes a function on change
  69089. * @param f A path cursor onchange callback
  69090. * @returns This path cursor
  69091. */
  69092. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69093. }
  69094. }
  69095. declare module BABYLON {
  69096. /** @hidden */
  69097. export var blurPixelShader: {
  69098. name: string;
  69099. shader: string;
  69100. };
  69101. }
  69102. declare module BABYLON {
  69103. /** @hidden */
  69104. export var pointCloudVertexDeclaration: {
  69105. name: string;
  69106. shader: string;
  69107. };
  69108. }
  69109. // Mixins
  69110. interface Window {
  69111. mozIndexedDB: IDBFactory;
  69112. webkitIndexedDB: IDBFactory;
  69113. msIndexedDB: IDBFactory;
  69114. webkitURL: typeof URL;
  69115. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69116. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69117. WebGLRenderingContext: WebGLRenderingContext;
  69118. MSGesture: MSGesture;
  69119. CANNON: any;
  69120. AudioContext: AudioContext;
  69121. webkitAudioContext: AudioContext;
  69122. PointerEvent: any;
  69123. Math: Math;
  69124. Uint8Array: Uint8ArrayConstructor;
  69125. Float32Array: Float32ArrayConstructor;
  69126. mozURL: typeof URL;
  69127. msURL: typeof URL;
  69128. VRFrameData: any; // WebVR, from specs 1.1
  69129. DracoDecoderModule: any;
  69130. setImmediate(handler: (...args: any[]) => void): number;
  69131. }
  69132. interface HTMLCanvasElement {
  69133. requestPointerLock(): void;
  69134. msRequestPointerLock?(): void;
  69135. mozRequestPointerLock?(): void;
  69136. webkitRequestPointerLock?(): void;
  69137. /** Track wether a record is in progress */
  69138. isRecording: boolean;
  69139. /** Capture Stream method defined by some browsers */
  69140. captureStream(fps?: number): MediaStream;
  69141. }
  69142. interface CanvasRenderingContext2D {
  69143. msImageSmoothingEnabled: boolean;
  69144. }
  69145. interface MouseEvent {
  69146. mozMovementX: number;
  69147. mozMovementY: number;
  69148. webkitMovementX: number;
  69149. webkitMovementY: number;
  69150. msMovementX: number;
  69151. msMovementY: number;
  69152. }
  69153. interface Navigator {
  69154. mozGetVRDevices: (any: any) => any;
  69155. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69156. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69157. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69158. webkitGetGamepads(): Gamepad[];
  69159. msGetGamepads(): Gamepad[];
  69160. webkitGamepads(): Gamepad[];
  69161. }
  69162. interface HTMLVideoElement {
  69163. mozSrcObject: any;
  69164. }
  69165. interface Math {
  69166. fround(x: number): number;
  69167. imul(a: number, b: number): number;
  69168. }
  69169. interface WebGLRenderingContext {
  69170. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69171. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69172. vertexAttribDivisor(index: number, divisor: number): void;
  69173. createVertexArray(): any;
  69174. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69175. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69176. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69177. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69178. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69179. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69180. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69181. // Queries
  69182. createQuery(): WebGLQuery;
  69183. deleteQuery(query: WebGLQuery): void;
  69184. beginQuery(target: number, query: WebGLQuery): void;
  69185. endQuery(target: number): void;
  69186. getQueryParameter(query: WebGLQuery, pname: number): any;
  69187. getQuery(target: number, pname: number): any;
  69188. MAX_SAMPLES: number;
  69189. RGBA8: number;
  69190. READ_FRAMEBUFFER: number;
  69191. DRAW_FRAMEBUFFER: number;
  69192. UNIFORM_BUFFER: number;
  69193. HALF_FLOAT_OES: number;
  69194. RGBA16F: number;
  69195. RGBA32F: number;
  69196. R32F: number;
  69197. RG32F: number;
  69198. RGB32F: number;
  69199. R16F: number;
  69200. RG16F: number;
  69201. RGB16F: number;
  69202. RED: number;
  69203. RG: number;
  69204. R8: number;
  69205. RG8: number;
  69206. UNSIGNED_INT_24_8: number;
  69207. DEPTH24_STENCIL8: number;
  69208. MIN: number;
  69209. MAX: number;
  69210. /* Multiple Render Targets */
  69211. drawBuffers(buffers: number[]): void;
  69212. readBuffer(src: number): void;
  69213. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69214. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69215. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69216. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69217. // Occlusion Query
  69218. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69219. ANY_SAMPLES_PASSED: number;
  69220. QUERY_RESULT_AVAILABLE: number;
  69221. QUERY_RESULT: number;
  69222. }
  69223. interface WebGLProgram {
  69224. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69225. }
  69226. interface EXT_disjoint_timer_query {
  69227. QUERY_COUNTER_BITS_EXT: number;
  69228. TIME_ELAPSED_EXT: number;
  69229. TIMESTAMP_EXT: number;
  69230. GPU_DISJOINT_EXT: number;
  69231. QUERY_RESULT_EXT: number;
  69232. QUERY_RESULT_AVAILABLE_EXT: number;
  69233. queryCounterEXT(query: WebGLQuery, target: number): void;
  69234. createQueryEXT(): WebGLQuery;
  69235. beginQueryEXT(target: number, query: WebGLQuery): void;
  69236. endQueryEXT(target: number): void;
  69237. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69238. deleteQueryEXT(query: WebGLQuery): void;
  69239. }
  69240. interface WebGLUniformLocation {
  69241. _currentState: any;
  69242. }
  69243. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69244. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69245. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69246. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69247. interface WebGLRenderingContext {
  69248. readonly RASTERIZER_DISCARD: number;
  69249. readonly DEPTH_COMPONENT24: number;
  69250. readonly TEXTURE_3D: number;
  69251. readonly TEXTURE_2D_ARRAY: number;
  69252. readonly TEXTURE_COMPARE_FUNC: number;
  69253. readonly TEXTURE_COMPARE_MODE: number;
  69254. readonly COMPARE_REF_TO_TEXTURE: number;
  69255. readonly TEXTURE_WRAP_R: number;
  69256. readonly HALF_FLOAT: number;
  69257. readonly RGB8: number;
  69258. readonly RED_INTEGER: number;
  69259. readonly RG_INTEGER: number;
  69260. readonly RGB_INTEGER: number;
  69261. readonly RGBA_INTEGER: number;
  69262. readonly R8_SNORM: number;
  69263. readonly RG8_SNORM: number;
  69264. readonly RGB8_SNORM: number;
  69265. readonly RGBA8_SNORM: number;
  69266. readonly R8I: number;
  69267. readonly RG8I: number;
  69268. readonly RGB8I: number;
  69269. readonly RGBA8I: number;
  69270. readonly R8UI: number;
  69271. readonly RG8UI: number;
  69272. readonly RGB8UI: number;
  69273. readonly RGBA8UI: number;
  69274. readonly R16I: number;
  69275. readonly RG16I: number;
  69276. readonly RGB16I: number;
  69277. readonly RGBA16I: number;
  69278. readonly R16UI: number;
  69279. readonly RG16UI: number;
  69280. readonly RGB16UI: number;
  69281. readonly RGBA16UI: number;
  69282. readonly R32I: number;
  69283. readonly RG32I: number;
  69284. readonly RGB32I: number;
  69285. readonly RGBA32I: number;
  69286. readonly R32UI: number;
  69287. readonly RG32UI: number;
  69288. readonly RGB32UI: number;
  69289. readonly RGBA32UI: number;
  69290. readonly RGB10_A2UI: number;
  69291. readonly R11F_G11F_B10F: number;
  69292. readonly RGB9_E5: number;
  69293. readonly RGB10_A2: number;
  69294. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69295. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69296. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69297. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69298. readonly DEPTH_COMPONENT32F: number;
  69299. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69300. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69301. 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;
  69302. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69303. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69304. readonly TRANSFORM_FEEDBACK: number;
  69305. readonly INTERLEAVED_ATTRIBS: number;
  69306. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69307. createTransformFeedback(): WebGLTransformFeedback;
  69308. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69309. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69310. beginTransformFeedback(primitiveMode: number): void;
  69311. endTransformFeedback(): void;
  69312. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69313. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69314. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69315. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69316. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69317. }
  69318. interface ImageBitmap {
  69319. readonly width: number;
  69320. readonly height: number;
  69321. close(): void;
  69322. }
  69323. interface WebGLQuery extends WebGLObject {
  69324. }
  69325. declare var WebGLQuery: {
  69326. prototype: WebGLQuery;
  69327. new(): WebGLQuery;
  69328. };
  69329. interface WebGLSampler extends WebGLObject {
  69330. }
  69331. declare var WebGLSampler: {
  69332. prototype: WebGLSampler;
  69333. new(): WebGLSampler;
  69334. };
  69335. interface WebGLSync extends WebGLObject {
  69336. }
  69337. declare var WebGLSync: {
  69338. prototype: WebGLSync;
  69339. new(): WebGLSync;
  69340. };
  69341. interface WebGLTransformFeedback extends WebGLObject {
  69342. }
  69343. declare var WebGLTransformFeedback: {
  69344. prototype: WebGLTransformFeedback;
  69345. new(): WebGLTransformFeedback;
  69346. };
  69347. interface WebGLVertexArrayObject extends WebGLObject {
  69348. }
  69349. declare var WebGLVertexArrayObject: {
  69350. prototype: WebGLVertexArrayObject;
  69351. new(): WebGLVertexArrayObject;
  69352. };
  69353. // Type definitions for WebVR API
  69354. // Project: https://w3c.github.io/webvr/
  69355. // Definitions by: six a <https://github.com/lostfictions>
  69356. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69357. interface VRDisplay extends EventTarget {
  69358. /**
  69359. * Dictionary of capabilities describing the VRDisplay.
  69360. */
  69361. readonly capabilities: VRDisplayCapabilities;
  69362. /**
  69363. * z-depth defining the far plane of the eye view frustum
  69364. * enables mapping of values in the render target depth
  69365. * attachment to scene coordinates. Initially set to 10000.0.
  69366. */
  69367. depthFar: number;
  69368. /**
  69369. * z-depth defining the near plane of the eye view frustum
  69370. * enables mapping of values in the render target depth
  69371. * attachment to scene coordinates. Initially set to 0.01.
  69372. */
  69373. depthNear: number;
  69374. /**
  69375. * An identifier for this distinct VRDisplay. Used as an
  69376. * association point in the Gamepad API.
  69377. */
  69378. readonly displayId: number;
  69379. /**
  69380. * A display name, a user-readable name identifying it.
  69381. */
  69382. readonly displayName: string;
  69383. readonly isConnected: boolean;
  69384. readonly isPresenting: boolean;
  69385. /**
  69386. * If this VRDisplay supports room-scale experiences, the optional
  69387. * stage attribute contains details on the room-scale parameters.
  69388. */
  69389. readonly stageParameters: VRStageParameters | null;
  69390. /**
  69391. * Passing the value returned by `requestAnimationFrame` to
  69392. * `cancelAnimationFrame` will unregister the callback.
  69393. * @param handle Define the hanle of the request to cancel
  69394. */
  69395. cancelAnimationFrame(handle: number): void;
  69396. /**
  69397. * Stops presenting to the VRDisplay.
  69398. * @returns a promise to know when it stopped
  69399. */
  69400. exitPresent(): Promise<void>;
  69401. /**
  69402. * Return the current VREyeParameters for the given eye.
  69403. * @param whichEye Define the eye we want the parameter for
  69404. * @returns the eye parameters
  69405. */
  69406. getEyeParameters(whichEye: string): VREyeParameters;
  69407. /**
  69408. * Populates the passed VRFrameData with the information required to render
  69409. * the current frame.
  69410. * @param frameData Define the data structure to populate
  69411. * @returns true if ok otherwise false
  69412. */
  69413. getFrameData(frameData: VRFrameData): boolean;
  69414. /**
  69415. * Get the layers currently being presented.
  69416. * @returns the list of VR layers
  69417. */
  69418. getLayers(): VRLayer[];
  69419. /**
  69420. * Return a VRPose containing the future predicted pose of the VRDisplay
  69421. * when the current frame will be presented. The value returned will not
  69422. * change until JavaScript has returned control to the browser.
  69423. *
  69424. * The VRPose will contain the position, orientation, velocity,
  69425. * and acceleration of each of these properties.
  69426. * @returns the pose object
  69427. */
  69428. getPose(): VRPose;
  69429. /**
  69430. * Return the current instantaneous pose of the VRDisplay, with no
  69431. * prediction applied.
  69432. * @returns the current instantaneous pose
  69433. */
  69434. getImmediatePose(): VRPose;
  69435. /**
  69436. * The callback passed to `requestAnimationFrame` will be called
  69437. * any time a new frame should be rendered. When the VRDisplay is
  69438. * presenting the callback will be called at the native refresh
  69439. * rate of the HMD. When not presenting this function acts
  69440. * identically to how window.requestAnimationFrame acts. Content should
  69441. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69442. * asynchronously from other displays and at differing refresh rates.
  69443. * @param callback Define the eaction to run next frame
  69444. * @returns the request handle it
  69445. */
  69446. requestAnimationFrame(callback: FrameRequestCallback): number;
  69447. /**
  69448. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69449. * Repeat calls while already presenting will update the VRLayers being displayed.
  69450. * @param layers Define the list of layer to present
  69451. * @returns a promise to know when the request has been fulfilled
  69452. */
  69453. requestPresent(layers: VRLayer[]): Promise<void>;
  69454. /**
  69455. * Reset the pose for this display, treating its current position and
  69456. * orientation as the "origin/zero" values. VRPose.position,
  69457. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69458. * updated when calling resetPose(). This should be called in only
  69459. * sitting-space experiences.
  69460. */
  69461. resetPose(): void;
  69462. /**
  69463. * The VRLayer provided to the VRDisplay will be captured and presented
  69464. * in the HMD. Calling this function has the same effect on the source
  69465. * canvas as any other operation that uses its source image, and canvases
  69466. * created without preserveDrawingBuffer set to true will be cleared.
  69467. * @param pose Define the pose to submit
  69468. */
  69469. submitFrame(pose?: VRPose): void;
  69470. }
  69471. declare var VRDisplay: {
  69472. prototype: VRDisplay;
  69473. new(): VRDisplay;
  69474. };
  69475. interface VRLayer {
  69476. leftBounds?: number[] | Float32Array | null;
  69477. rightBounds?: number[] | Float32Array | null;
  69478. source?: HTMLCanvasElement | null;
  69479. }
  69480. interface VRDisplayCapabilities {
  69481. readonly canPresent: boolean;
  69482. readonly hasExternalDisplay: boolean;
  69483. readonly hasOrientation: boolean;
  69484. readonly hasPosition: boolean;
  69485. readonly maxLayers: number;
  69486. }
  69487. interface VREyeParameters {
  69488. /** @deprecated */
  69489. readonly fieldOfView: VRFieldOfView;
  69490. readonly offset: Float32Array;
  69491. readonly renderHeight: number;
  69492. readonly renderWidth: number;
  69493. }
  69494. interface VRFieldOfView {
  69495. readonly downDegrees: number;
  69496. readonly leftDegrees: number;
  69497. readonly rightDegrees: number;
  69498. readonly upDegrees: number;
  69499. }
  69500. interface VRFrameData {
  69501. readonly leftProjectionMatrix: Float32Array;
  69502. readonly leftViewMatrix: Float32Array;
  69503. readonly pose: VRPose;
  69504. readonly rightProjectionMatrix: Float32Array;
  69505. readonly rightViewMatrix: Float32Array;
  69506. readonly timestamp: number;
  69507. }
  69508. interface VRPose {
  69509. readonly angularAcceleration: Float32Array | null;
  69510. readonly angularVelocity: Float32Array | null;
  69511. readonly linearAcceleration: Float32Array | null;
  69512. readonly linearVelocity: Float32Array | null;
  69513. readonly orientation: Float32Array | null;
  69514. readonly position: Float32Array | null;
  69515. readonly timestamp: number;
  69516. }
  69517. interface VRStageParameters {
  69518. sittingToStandingTransform?: Float32Array;
  69519. sizeX?: number;
  69520. sizeY?: number;
  69521. }
  69522. interface Navigator {
  69523. getVRDisplays(): Promise<VRDisplay[]>;
  69524. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69525. }
  69526. interface Window {
  69527. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69528. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69529. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69530. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69531. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69532. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69533. }
  69534. interface Gamepad {
  69535. readonly displayId: number;
  69536. }
  69537. type XRSessionMode =
  69538. | "inline"
  69539. | "immersive-vr"
  69540. | "immersive-ar";
  69541. type XRReferenceSpaceType =
  69542. | "viewer"
  69543. | "local"
  69544. | "local-floor"
  69545. | "bounded-floor"
  69546. | "unbounded";
  69547. type XREnvironmentBlendMode =
  69548. | "opaque"
  69549. | "additive"
  69550. | "alpha-blend";
  69551. type XRVisibilityState =
  69552. | "visible"
  69553. | "visible-blurred"
  69554. | "hidden";
  69555. type XRHandedness =
  69556. | "none"
  69557. | "left"
  69558. | "right";
  69559. type XRTargetRayMode =
  69560. | "gaze"
  69561. | "tracked-pointer"
  69562. | "screen";
  69563. type XREye =
  69564. | "none"
  69565. | "left"
  69566. | "right";
  69567. interface XRSpace extends EventTarget {
  69568. }
  69569. interface XRRenderState {
  69570. depthNear?: number;
  69571. depthFar?: number;
  69572. inlineVerticalFieldOfView?: number;
  69573. baseLayer?: XRWebGLLayer;
  69574. }
  69575. interface XRInputSource {
  69576. handedness: XRHandedness;
  69577. targetRayMode: XRTargetRayMode;
  69578. targetRaySpace: XRSpace;
  69579. gripSpace: XRSpace | undefined;
  69580. gamepad: Gamepad | undefined;
  69581. profiles: Array<string>;
  69582. }
  69583. interface XRSessionInit {
  69584. optionalFeatures?: XRReferenceSpaceType[];
  69585. requiredFeatures?: XRReferenceSpaceType[];
  69586. }
  69587. interface XRSession extends XRAnchorCreator {
  69588. addEventListener: Function;
  69589. removeEventListener: Function;
  69590. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69591. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69592. requestAnimationFrame: Function;
  69593. end(): Promise<void>;
  69594. renderState: XRRenderState;
  69595. inputSources: Array<XRInputSource>;
  69596. // AR hit test
  69597. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69598. updateWorldTrackingState(options: {
  69599. planeDetectionState?: { enabled: boolean; }
  69600. }): void;
  69601. }
  69602. interface XRReferenceSpace extends XRSpace {
  69603. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69604. onreset: any;
  69605. }
  69606. type XRPlaneSet = Set<XRPlane>;
  69607. type XRAnchorSet = Set<XRAnchor>;
  69608. interface XRFrame {
  69609. session: XRSession;
  69610. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69611. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69612. // Anchors
  69613. trackedAnchors?: XRAnchorSet;
  69614. // Planes
  69615. worldInformation: {
  69616. detectedPlanes?: XRPlaneSet;
  69617. };
  69618. }
  69619. interface XRViewerPose extends XRPose {
  69620. views: Array<XRView>;
  69621. }
  69622. interface XRPose {
  69623. transform: XRRigidTransform;
  69624. emulatedPosition: boolean;
  69625. }
  69626. interface XRWebGLLayerOptions {
  69627. antialias?: boolean;
  69628. depth?: boolean;
  69629. stencil?: boolean;
  69630. alpha?: boolean;
  69631. multiview?: boolean;
  69632. framebufferScaleFactor?: number;
  69633. }
  69634. declare var XRWebGLLayer: {
  69635. prototype: XRWebGLLayer;
  69636. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69637. };
  69638. interface XRWebGLLayer {
  69639. framebuffer: WebGLFramebuffer;
  69640. framebufferWidth: number;
  69641. framebufferHeight: number;
  69642. getViewport: Function;
  69643. }
  69644. declare class XRRigidTransform {
  69645. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69646. position: DOMPointReadOnly;
  69647. orientation: DOMPointReadOnly;
  69648. matrix: Float32Array;
  69649. inverse: XRRigidTransform;
  69650. }
  69651. interface XRView {
  69652. eye: XREye;
  69653. projectionMatrix: Float32Array;
  69654. transform: XRRigidTransform;
  69655. }
  69656. interface XRInputSourceChangeEvent {
  69657. session: XRSession;
  69658. removed: Array<XRInputSource>;
  69659. added: Array<XRInputSource>;
  69660. }
  69661. interface XRInputSourceEvent extends Event {
  69662. readonly frame: XRFrame;
  69663. readonly inputSource: XRInputSource;
  69664. }
  69665. // Experimental(er) features
  69666. declare class XRRay {
  69667. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69668. origin: DOMPointReadOnly;
  69669. direction: DOMPointReadOnly;
  69670. matrix: Float32Array;
  69671. }
  69672. interface XRHitResult {
  69673. hitMatrix: Float32Array;
  69674. }
  69675. interface XRAnchor {
  69676. // remove?
  69677. id?: string;
  69678. anchorSpace: XRSpace;
  69679. lastChangedTime: number;
  69680. detach(): void;
  69681. }
  69682. interface XRPlane extends XRAnchorCreator {
  69683. orientation: "Horizontal" | "Vertical";
  69684. planeSpace: XRSpace;
  69685. polygon: Array<DOMPointReadOnly>;
  69686. lastChangedTime: number;
  69687. }
  69688. interface XRAnchorCreator {
  69689. // AR Anchors
  69690. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69691. }
  69692. /**
  69693. * @ignore
  69694. */
  69695. declare module BABYLON.GLTF2.Exporter {
  69696. }
  69697. /**
  69698. * @ignore
  69699. */
  69700. declare module BABYLON.GLTF1 {
  69701. }
  69702. declare module BABYLON.GUI {
  69703. /**
  69704. * Class used to specific a value and its associated unit
  69705. */
  69706. export class ValueAndUnit {
  69707. /** defines the unit to store */
  69708. unit: number;
  69709. /** defines a boolean indicating if the value can be negative */
  69710. negativeValueAllowed: boolean;
  69711. private _value;
  69712. private _originalUnit;
  69713. /**
  69714. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69715. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69716. */
  69717. ignoreAdaptiveScaling: boolean;
  69718. /**
  69719. * Creates a new ValueAndUnit
  69720. * @param value defines the value to store
  69721. * @param unit defines the unit to store
  69722. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69723. */
  69724. constructor(value: number,
  69725. /** defines the unit to store */
  69726. unit?: number,
  69727. /** defines a boolean indicating if the value can be negative */
  69728. negativeValueAllowed?: boolean);
  69729. /** Gets a boolean indicating if the value is a percentage */
  69730. get isPercentage(): boolean;
  69731. /** Gets a boolean indicating if the value is store as pixel */
  69732. get isPixel(): boolean;
  69733. /** Gets direct internal value */
  69734. get internalValue(): number;
  69735. /**
  69736. * Gets value as pixel
  69737. * @param host defines the root host
  69738. * @param refValue defines the reference value for percentages
  69739. * @returns the value as pixel
  69740. */
  69741. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  69742. /**
  69743. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  69744. * @param value defines the value to store
  69745. * @param unit defines the unit to store
  69746. * @returns the current ValueAndUnit
  69747. */
  69748. updateInPlace(value: number, unit?: number): ValueAndUnit;
  69749. /**
  69750. * Gets the value accordingly to its unit
  69751. * @param host defines the root host
  69752. * @returns the value
  69753. */
  69754. getValue(host: AdvancedDynamicTexture): number;
  69755. /**
  69756. * Gets a string representation of the value
  69757. * @param host defines the root host
  69758. * @param decimals defines an optional number of decimals to display
  69759. * @returns a string
  69760. */
  69761. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  69762. /**
  69763. * Store a value parsed from a string
  69764. * @param source defines the source string
  69765. * @returns true if the value was successfully parsed
  69766. */
  69767. fromString(source: string | number): boolean;
  69768. private static _Regex;
  69769. private static _UNITMODE_PERCENTAGE;
  69770. private static _UNITMODE_PIXEL;
  69771. /** UNITMODE_PERCENTAGE */
  69772. static get UNITMODE_PERCENTAGE(): number;
  69773. /** UNITMODE_PIXEL */
  69774. static get UNITMODE_PIXEL(): number;
  69775. }
  69776. }
  69777. declare module BABYLON.GUI {
  69778. /**
  69779. * Define a style used by control to automatically setup properties based on a template.
  69780. * Only support font related properties so far
  69781. */
  69782. export class Style implements BABYLON.IDisposable {
  69783. private _fontFamily;
  69784. private _fontStyle;
  69785. private _fontWeight;
  69786. /** @hidden */
  69787. _host: AdvancedDynamicTexture;
  69788. /** @hidden */
  69789. _fontSize: ValueAndUnit;
  69790. /**
  69791. * BABYLON.Observable raised when the style values are changed
  69792. */
  69793. onChangedObservable: BABYLON.Observable<Style>;
  69794. /**
  69795. * Creates a new style object
  69796. * @param host defines the AdvancedDynamicTexture which hosts this style
  69797. */
  69798. constructor(host: AdvancedDynamicTexture);
  69799. /**
  69800. * Gets or sets the font size
  69801. */
  69802. get fontSize(): string | number;
  69803. set fontSize(value: string | number);
  69804. /**
  69805. * Gets or sets the font family
  69806. */
  69807. get fontFamily(): string;
  69808. set fontFamily(value: string);
  69809. /**
  69810. * Gets or sets the font style
  69811. */
  69812. get fontStyle(): string;
  69813. set fontStyle(value: string);
  69814. /** Gets or sets font weight */
  69815. get fontWeight(): string;
  69816. set fontWeight(value: string);
  69817. /** Dispose all associated resources */
  69818. dispose(): void;
  69819. }
  69820. }
  69821. declare module BABYLON.GUI {
  69822. /**
  69823. * Class used to transport BABYLON.Vector2 information for pointer events
  69824. */
  69825. export class Vector2WithInfo extends BABYLON.Vector2 {
  69826. /** defines the current mouse button index */
  69827. buttonIndex: number;
  69828. /**
  69829. * Creates a new Vector2WithInfo
  69830. * @param source defines the vector2 data to transport
  69831. * @param buttonIndex defines the current mouse button index
  69832. */
  69833. constructor(source: BABYLON.Vector2,
  69834. /** defines the current mouse button index */
  69835. buttonIndex?: number);
  69836. }
  69837. /** Class used to provide 2D matrix features */
  69838. export class Matrix2D {
  69839. /** Gets the internal array of 6 floats used to store matrix data */
  69840. m: Float32Array;
  69841. /**
  69842. * Creates a new matrix
  69843. * @param m00 defines value for (0, 0)
  69844. * @param m01 defines value for (0, 1)
  69845. * @param m10 defines value for (1, 0)
  69846. * @param m11 defines value for (1, 1)
  69847. * @param m20 defines value for (2, 0)
  69848. * @param m21 defines value for (2, 1)
  69849. */
  69850. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  69851. /**
  69852. * Fills the matrix from direct values
  69853. * @param m00 defines value for (0, 0)
  69854. * @param m01 defines value for (0, 1)
  69855. * @param m10 defines value for (1, 0)
  69856. * @param m11 defines value for (1, 1)
  69857. * @param m20 defines value for (2, 0)
  69858. * @param m21 defines value for (2, 1)
  69859. * @returns the current modified matrix
  69860. */
  69861. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  69862. /**
  69863. * Gets matrix determinant
  69864. * @returns the determinant
  69865. */
  69866. determinant(): number;
  69867. /**
  69868. * Inverses the matrix and stores it in a target matrix
  69869. * @param result defines the target matrix
  69870. * @returns the current matrix
  69871. */
  69872. invertToRef(result: Matrix2D): Matrix2D;
  69873. /**
  69874. * Multiplies the current matrix with another one
  69875. * @param other defines the second operand
  69876. * @param result defines the target matrix
  69877. * @returns the current matrix
  69878. */
  69879. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  69880. /**
  69881. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  69882. * @param x defines the x coordinate to transform
  69883. * @param y defines the x coordinate to transform
  69884. * @param result defines the target vector2
  69885. * @returns the current matrix
  69886. */
  69887. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  69888. /**
  69889. * Creates an identity matrix
  69890. * @returns a new matrix
  69891. */
  69892. static Identity(): Matrix2D;
  69893. /**
  69894. * Creates a translation matrix and stores it in a target matrix
  69895. * @param x defines the x coordinate of the translation
  69896. * @param y defines the y coordinate of the translation
  69897. * @param result defines the target matrix
  69898. */
  69899. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  69900. /**
  69901. * Creates a scaling matrix and stores it in a target matrix
  69902. * @param x defines the x coordinate of the scaling
  69903. * @param y defines the y coordinate of the scaling
  69904. * @param result defines the target matrix
  69905. */
  69906. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  69907. /**
  69908. * Creates a rotation matrix and stores it in a target matrix
  69909. * @param angle defines the rotation angle
  69910. * @param result defines the target matrix
  69911. */
  69912. static RotationToRef(angle: number, result: Matrix2D): void;
  69913. private static _TempPreTranslationMatrix;
  69914. private static _TempPostTranslationMatrix;
  69915. private static _TempRotationMatrix;
  69916. private static _TempScalingMatrix;
  69917. private static _TempCompose0;
  69918. private static _TempCompose1;
  69919. private static _TempCompose2;
  69920. /**
  69921. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  69922. * @param tx defines the x coordinate of the translation
  69923. * @param ty defines the y coordinate of the translation
  69924. * @param angle defines the rotation angle
  69925. * @param scaleX defines the x coordinate of the scaling
  69926. * @param scaleY defines the y coordinate of the scaling
  69927. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  69928. * @param result defines the target matrix
  69929. */
  69930. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  69931. }
  69932. }
  69933. declare module BABYLON.GUI {
  69934. /**
  69935. * Class used to store 2D control sizes
  69936. */
  69937. export class Measure {
  69938. /** defines left coordinate */
  69939. left: number;
  69940. /** defines top coordinate */
  69941. top: number;
  69942. /** defines width dimension */
  69943. width: number;
  69944. /** defines height dimension */
  69945. height: number;
  69946. /**
  69947. * Creates a new measure
  69948. * @param left defines left coordinate
  69949. * @param top defines top coordinate
  69950. * @param width defines width dimension
  69951. * @param height defines height dimension
  69952. */
  69953. constructor(
  69954. /** defines left coordinate */
  69955. left: number,
  69956. /** defines top coordinate */
  69957. top: number,
  69958. /** defines width dimension */
  69959. width: number,
  69960. /** defines height dimension */
  69961. height: number);
  69962. /**
  69963. * Copy from another measure
  69964. * @param other defines the other measure to copy from
  69965. */
  69966. copyFrom(other: Measure): void;
  69967. /**
  69968. * Copy from a group of 4 floats
  69969. * @param left defines left coordinate
  69970. * @param top defines top coordinate
  69971. * @param width defines width dimension
  69972. * @param height defines height dimension
  69973. */
  69974. copyFromFloats(left: number, top: number, width: number, height: number): void;
  69975. /**
  69976. * Computes the axis aligned bounding box measure for two given measures
  69977. * @param a Input measure
  69978. * @param b Input measure
  69979. * @param result the resulting bounding measure
  69980. */
  69981. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  69982. /**
  69983. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  69984. * @param transform the matrix to transform the measure before computing the AABB
  69985. * @param result the resulting AABB
  69986. */
  69987. transformToRef(transform: Matrix2D, result: Measure): void;
  69988. /**
  69989. * Check equality between this measure and another one
  69990. * @param other defines the other measures
  69991. * @returns true if both measures are equals
  69992. */
  69993. isEqualsTo(other: Measure): boolean;
  69994. /**
  69995. * Creates an empty measure
  69996. * @returns a new measure
  69997. */
  69998. static Empty(): Measure;
  69999. }
  70000. }
  70001. declare module BABYLON.GUI {
  70002. /**
  70003. * Interface used to define a control that can receive focus
  70004. */
  70005. export interface IFocusableControl {
  70006. /**
  70007. * Function called when the control receives the focus
  70008. */
  70009. onFocus(): void;
  70010. /**
  70011. * Function called when the control loses the focus
  70012. */
  70013. onBlur(): void;
  70014. /**
  70015. * Function called to let the control handle keyboard events
  70016. * @param evt defines the current keyboard event
  70017. */
  70018. processKeyboard(evt: KeyboardEvent): void;
  70019. /**
  70020. * Function called to get the list of controls that should not steal the focus from this control
  70021. * @returns an array of controls
  70022. */
  70023. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70024. }
  70025. /**
  70026. * Class used to create texture to support 2D GUI elements
  70027. * @see http://doc.babylonjs.com/how_to/gui
  70028. */
  70029. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70030. private _isDirty;
  70031. private _renderObserver;
  70032. private _resizeObserver;
  70033. private _preKeyboardObserver;
  70034. private _pointerMoveObserver;
  70035. private _pointerObserver;
  70036. private _canvasPointerOutObserver;
  70037. private _background;
  70038. /** @hidden */
  70039. _rootContainer: Container;
  70040. /** @hidden */
  70041. _lastPickedControl: Control;
  70042. /** @hidden */
  70043. _lastControlOver: {
  70044. [pointerId: number]: Control;
  70045. };
  70046. /** @hidden */
  70047. _lastControlDown: {
  70048. [pointerId: number]: Control;
  70049. };
  70050. /** @hidden */
  70051. _capturingControl: {
  70052. [pointerId: number]: Control;
  70053. };
  70054. /** @hidden */
  70055. _shouldBlockPointer: boolean;
  70056. /** @hidden */
  70057. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70058. /** @hidden */
  70059. _linkedControls: Control[];
  70060. private _isFullscreen;
  70061. private _fullscreenViewport;
  70062. private _idealWidth;
  70063. private _idealHeight;
  70064. private _useSmallestIdeal;
  70065. private _renderAtIdealSize;
  70066. private _focusedControl;
  70067. private _blockNextFocusCheck;
  70068. private _renderScale;
  70069. private _rootElement;
  70070. private _cursorChanged;
  70071. /** @hidden */
  70072. _numLayoutCalls: number;
  70073. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70074. get numLayoutCalls(): number;
  70075. /** @hidden */
  70076. _numRenderCalls: number;
  70077. /** Gets the number of render calls made the last time the ADT has been rendered */
  70078. get numRenderCalls(): number;
  70079. /**
  70080. * Define type to string to ensure compatibility across browsers
  70081. * Safari doesn't support DataTransfer constructor
  70082. */
  70083. private _clipboardData;
  70084. /**
  70085. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70086. */
  70087. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70088. /**
  70089. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70090. */
  70091. onControlPickedObservable: BABYLON.Observable<Control>;
  70092. /**
  70093. * BABYLON.Observable event triggered before layout is evaluated
  70094. */
  70095. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70096. /**
  70097. * BABYLON.Observable event triggered after the layout was evaluated
  70098. */
  70099. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70100. /**
  70101. * BABYLON.Observable event triggered before the texture is rendered
  70102. */
  70103. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70104. /**
  70105. * BABYLON.Observable event triggered after the texture was rendered
  70106. */
  70107. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70108. /**
  70109. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70110. */
  70111. premulAlpha: boolean;
  70112. /**
  70113. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70114. * Useful when you want more antialiasing
  70115. */
  70116. get renderScale(): number;
  70117. set renderScale(value: number);
  70118. /** Gets or sets the background color */
  70119. get background(): string;
  70120. set background(value: string);
  70121. /**
  70122. * Gets or sets the ideal width used to design controls.
  70123. * The GUI will then rescale everything accordingly
  70124. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70125. */
  70126. get idealWidth(): number;
  70127. set idealWidth(value: number);
  70128. /**
  70129. * Gets or sets the ideal height used to design controls.
  70130. * The GUI will then rescale everything accordingly
  70131. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70132. */
  70133. get idealHeight(): number;
  70134. set idealHeight(value: number);
  70135. /**
  70136. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70137. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70138. */
  70139. get useSmallestIdeal(): boolean;
  70140. set useSmallestIdeal(value: boolean);
  70141. /**
  70142. * Gets or sets a boolean indicating if adaptive scaling must be used
  70143. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70144. */
  70145. get renderAtIdealSize(): boolean;
  70146. set renderAtIdealSize(value: boolean);
  70147. /**
  70148. * Gets the ratio used when in "ideal mode"
  70149. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70150. * */
  70151. get idealRatio(): number;
  70152. /**
  70153. * Gets the underlying layer used to render the texture when in fullscreen mode
  70154. */
  70155. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70156. /**
  70157. * Gets the root container control
  70158. */
  70159. get rootContainer(): Container;
  70160. /**
  70161. * Returns an array containing the root container.
  70162. * This is mostly used to let the Inspector introspects the ADT
  70163. * @returns an array containing the rootContainer
  70164. */
  70165. getChildren(): Array<Container>;
  70166. /**
  70167. * Will return all controls that are inside this texture
  70168. * @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
  70169. * @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
  70170. * @return all child controls
  70171. */
  70172. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70173. /**
  70174. * Gets or sets the current focused control
  70175. */
  70176. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70177. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70178. /**
  70179. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70180. */
  70181. get isForeground(): boolean;
  70182. set isForeground(value: boolean);
  70183. /**
  70184. * Gets or set information about clipboardData
  70185. */
  70186. get clipboardData(): string;
  70187. set clipboardData(value: string);
  70188. /**
  70189. * Creates a new AdvancedDynamicTexture
  70190. * @param name defines the name of the texture
  70191. * @param width defines the width of the texture
  70192. * @param height defines the height of the texture
  70193. * @param scene defines the hosting scene
  70194. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70195. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70196. */
  70197. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70198. /**
  70199. * Get the current class name of the texture useful for serialization or dynamic coding.
  70200. * @returns "AdvancedDynamicTexture"
  70201. */
  70202. getClassName(): string;
  70203. /**
  70204. * Function used to execute a function on all controls
  70205. * @param func defines the function to execute
  70206. * @param container defines the container where controls belong. If null the root container will be used
  70207. */
  70208. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70209. private _useInvalidateRectOptimization;
  70210. /**
  70211. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70212. */
  70213. get useInvalidateRectOptimization(): boolean;
  70214. set useInvalidateRectOptimization(value: boolean);
  70215. private _invalidatedRectangle;
  70216. /**
  70217. * Invalidates a rectangle area on the gui texture
  70218. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70219. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70220. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70221. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70222. */
  70223. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70224. /**
  70225. * Marks the texture as dirty forcing a complete update
  70226. */
  70227. markAsDirty(): void;
  70228. /**
  70229. * Helper function used to create a new style
  70230. * @returns a new style
  70231. * @see http://doc.babylonjs.com/how_to/gui#styles
  70232. */
  70233. createStyle(): Style;
  70234. /**
  70235. * Adds a new control to the root container
  70236. * @param control defines the control to add
  70237. * @returns the current texture
  70238. */
  70239. addControl(control: Control): AdvancedDynamicTexture;
  70240. /**
  70241. * Removes a control from the root container
  70242. * @param control defines the control to remove
  70243. * @returns the current texture
  70244. */
  70245. removeControl(control: Control): AdvancedDynamicTexture;
  70246. /**
  70247. * Release all resources
  70248. */
  70249. dispose(): void;
  70250. private _onResize;
  70251. /** @hidden */
  70252. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70253. /**
  70254. * Get screen coordinates for a vector3
  70255. * @param position defines the position to project
  70256. * @param worldMatrix defines the world matrix to use
  70257. * @returns the projected position
  70258. */
  70259. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70260. private _checkUpdate;
  70261. private _clearMeasure;
  70262. private _render;
  70263. /** @hidden */
  70264. _changeCursor(cursor: string): void;
  70265. /** @hidden */
  70266. _registerLastControlDown(control: Control, pointerId: number): void;
  70267. private _doPicking;
  70268. /** @hidden */
  70269. _cleanControlAfterRemovalFromList(list: {
  70270. [pointerId: number]: Control;
  70271. }, control: Control): void;
  70272. /** @hidden */
  70273. _cleanControlAfterRemoval(control: Control): void;
  70274. /** Attach to all scene events required to support pointer events */
  70275. attach(): void;
  70276. /** @hidden */
  70277. private onClipboardCopy;
  70278. /** @hidden */
  70279. private onClipboardCut;
  70280. /** @hidden */
  70281. private onClipboardPaste;
  70282. /**
  70283. * Register the clipboard Events onto the canvas
  70284. */
  70285. registerClipboardEvents(): void;
  70286. /**
  70287. * Unregister the clipboard Events from the canvas
  70288. */
  70289. unRegisterClipboardEvents(): void;
  70290. /**
  70291. * Connect the texture to a hosting mesh to enable interactions
  70292. * @param mesh defines the mesh to attach to
  70293. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70294. */
  70295. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70296. /**
  70297. * Move the focus to a specific control
  70298. * @param control defines the control which will receive the focus
  70299. */
  70300. moveFocusToControl(control: IFocusableControl): void;
  70301. private _manageFocus;
  70302. private _attachToOnPointerOut;
  70303. /**
  70304. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70305. * @param mesh defines the mesh which will receive the texture
  70306. * @param width defines the texture width (1024 by default)
  70307. * @param height defines the texture height (1024 by default)
  70308. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70309. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70310. * @returns a new AdvancedDynamicTexture
  70311. */
  70312. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70313. /**
  70314. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70315. * In this mode the texture will rely on a layer for its rendering.
  70316. * This allows it to be treated like any other layer.
  70317. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70318. * LayerMask is set through advancedTexture.layer.layerMask
  70319. * @param name defines name for the texture
  70320. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70321. * @param scene defines the hsoting scene
  70322. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70323. * @returns a new AdvancedDynamicTexture
  70324. */
  70325. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70326. }
  70327. }
  70328. declare module BABYLON.GUI {
  70329. /**
  70330. * Root class used for all 2D controls
  70331. * @see http://doc.babylonjs.com/how_to/gui#controls
  70332. */
  70333. export class Control {
  70334. /** defines the name of the control */
  70335. name?: string | undefined;
  70336. /**
  70337. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70338. */
  70339. static AllowAlphaInheritance: boolean;
  70340. private _alpha;
  70341. private _alphaSet;
  70342. private _zIndex;
  70343. /** @hidden */
  70344. _host: AdvancedDynamicTexture;
  70345. /** Gets or sets the control parent */
  70346. parent: BABYLON.Nullable<Container>;
  70347. /** @hidden */
  70348. _currentMeasure: Measure;
  70349. private _fontFamily;
  70350. private _fontStyle;
  70351. private _fontWeight;
  70352. private _fontSize;
  70353. private _font;
  70354. /** @hidden */
  70355. _width: ValueAndUnit;
  70356. /** @hidden */
  70357. _height: ValueAndUnit;
  70358. /** @hidden */
  70359. protected _fontOffset: {
  70360. ascent: number;
  70361. height: number;
  70362. descent: number;
  70363. };
  70364. private _color;
  70365. private _style;
  70366. private _styleObserver;
  70367. /** @hidden */
  70368. protected _horizontalAlignment: number;
  70369. /** @hidden */
  70370. protected _verticalAlignment: number;
  70371. /** @hidden */
  70372. protected _isDirty: boolean;
  70373. /** @hidden */
  70374. protected _wasDirty: boolean;
  70375. /** @hidden */
  70376. _tempParentMeasure: Measure;
  70377. /** @hidden */
  70378. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70379. /** @hidden */
  70380. protected _cachedParentMeasure: Measure;
  70381. private _paddingLeft;
  70382. private _paddingRight;
  70383. private _paddingTop;
  70384. private _paddingBottom;
  70385. /** @hidden */
  70386. _left: ValueAndUnit;
  70387. /** @hidden */
  70388. _top: ValueAndUnit;
  70389. private _scaleX;
  70390. private _scaleY;
  70391. private _rotation;
  70392. private _transformCenterX;
  70393. private _transformCenterY;
  70394. /** @hidden */
  70395. _transformMatrix: Matrix2D;
  70396. /** @hidden */
  70397. protected _invertTransformMatrix: Matrix2D;
  70398. /** @hidden */
  70399. protected _transformedPosition: BABYLON.Vector2;
  70400. private _isMatrixDirty;
  70401. private _cachedOffsetX;
  70402. private _cachedOffsetY;
  70403. private _isVisible;
  70404. private _isHighlighted;
  70405. /** @hidden */
  70406. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70407. private _fontSet;
  70408. private _dummyVector2;
  70409. private _downCount;
  70410. private _enterCount;
  70411. private _doNotRender;
  70412. private _downPointerIds;
  70413. protected _isEnabled: boolean;
  70414. protected _disabledColor: string;
  70415. /** @hidden */
  70416. protected _rebuildLayout: boolean;
  70417. /** @hidden */
  70418. _customData: any;
  70419. /** @hidden */
  70420. _isClipped: boolean;
  70421. /** @hidden */
  70422. _automaticSize: boolean;
  70423. /** @hidden */
  70424. _tag: any;
  70425. /**
  70426. * 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
  70427. */
  70428. uniqueId: number;
  70429. /**
  70430. * Gets or sets an object used to store user defined information for the node
  70431. */
  70432. metadata: any;
  70433. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70434. isHitTestVisible: boolean;
  70435. /** Gets or sets a boolean indicating if the control can block pointer events */
  70436. isPointerBlocker: boolean;
  70437. /** Gets or sets a boolean indicating if the control can be focusable */
  70438. isFocusInvisible: boolean;
  70439. /**
  70440. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70441. * 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
  70442. */
  70443. clipChildren: boolean;
  70444. /**
  70445. * Gets or sets a boolean indicating that control content must be clipped
  70446. * 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
  70447. */
  70448. clipContent: boolean;
  70449. /**
  70450. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70451. */
  70452. useBitmapCache: boolean;
  70453. private _cacheData;
  70454. private _shadowOffsetX;
  70455. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70456. get shadowOffsetX(): number;
  70457. set shadowOffsetX(value: number);
  70458. private _shadowOffsetY;
  70459. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70460. get shadowOffsetY(): number;
  70461. set shadowOffsetY(value: number);
  70462. private _shadowBlur;
  70463. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70464. get shadowBlur(): number;
  70465. set shadowBlur(value: number);
  70466. private _shadowColor;
  70467. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70468. get shadowColor(): string;
  70469. set shadowColor(value: string);
  70470. /** Gets or sets the cursor to use when the control is hovered */
  70471. hoverCursor: string;
  70472. /** @hidden */
  70473. protected _linkOffsetX: ValueAndUnit;
  70474. /** @hidden */
  70475. protected _linkOffsetY: ValueAndUnit;
  70476. /** Gets the control type name */
  70477. get typeName(): string;
  70478. /**
  70479. * Get the current class name of the control.
  70480. * @returns current class name
  70481. */
  70482. getClassName(): string;
  70483. /**
  70484. * An event triggered when the pointer move over the control.
  70485. */
  70486. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70487. /**
  70488. * An event triggered when the pointer move out of the control.
  70489. */
  70490. onPointerOutObservable: BABYLON.Observable<Control>;
  70491. /**
  70492. * An event triggered when the pointer taps the control
  70493. */
  70494. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70495. /**
  70496. * An event triggered when pointer up
  70497. */
  70498. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70499. /**
  70500. * An event triggered when a control is clicked on
  70501. */
  70502. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70503. /**
  70504. * An event triggered when pointer enters the control
  70505. */
  70506. onPointerEnterObservable: BABYLON.Observable<Control>;
  70507. /**
  70508. * An event triggered when the control is marked as dirty
  70509. */
  70510. onDirtyObservable: BABYLON.Observable<Control>;
  70511. /**
  70512. * An event triggered before drawing the control
  70513. */
  70514. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70515. /**
  70516. * An event triggered after the control was drawn
  70517. */
  70518. onAfterDrawObservable: BABYLON.Observable<Control>;
  70519. /**
  70520. * Get the hosting AdvancedDynamicTexture
  70521. */
  70522. get host(): AdvancedDynamicTexture;
  70523. /** Gets or set information about font offsets (used to render and align text) */
  70524. get fontOffset(): {
  70525. ascent: number;
  70526. height: number;
  70527. descent: number;
  70528. };
  70529. set fontOffset(offset: {
  70530. ascent: number;
  70531. height: number;
  70532. descent: number;
  70533. });
  70534. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70535. get alpha(): number;
  70536. set alpha(value: number);
  70537. /**
  70538. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70539. */
  70540. get isHighlighted(): boolean;
  70541. set isHighlighted(value: boolean);
  70542. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70543. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70544. */
  70545. get scaleX(): number;
  70546. set scaleX(value: number);
  70547. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70548. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70549. */
  70550. get scaleY(): number;
  70551. set scaleY(value: number);
  70552. /** Gets or sets the rotation angle (0 by default)
  70553. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70554. */
  70555. get rotation(): number;
  70556. set rotation(value: number);
  70557. /** Gets or sets the transformation center on Y axis (0 by default)
  70558. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70559. */
  70560. get transformCenterY(): number;
  70561. set transformCenterY(value: number);
  70562. /** Gets or sets the transformation center on X axis (0 by default)
  70563. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70564. */
  70565. get transformCenterX(): number;
  70566. set transformCenterX(value: number);
  70567. /**
  70568. * Gets or sets the horizontal alignment
  70569. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70570. */
  70571. get horizontalAlignment(): number;
  70572. set horizontalAlignment(value: number);
  70573. /**
  70574. * Gets or sets the vertical alignment
  70575. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70576. */
  70577. get verticalAlignment(): number;
  70578. set verticalAlignment(value: number);
  70579. /**
  70580. * Gets or sets control width
  70581. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70582. */
  70583. get width(): string | number;
  70584. set width(value: string | number);
  70585. /**
  70586. * Gets or sets the control width in pixel
  70587. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70588. */
  70589. get widthInPixels(): number;
  70590. set widthInPixels(value: number);
  70591. /**
  70592. * Gets or sets control height
  70593. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70594. */
  70595. get height(): string | number;
  70596. set height(value: string | number);
  70597. /**
  70598. * Gets or sets control height in pixel
  70599. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70600. */
  70601. get heightInPixels(): number;
  70602. set heightInPixels(value: number);
  70603. /** Gets or set font family */
  70604. get fontFamily(): string;
  70605. set fontFamily(value: string);
  70606. /** Gets or sets font style */
  70607. get fontStyle(): string;
  70608. set fontStyle(value: string);
  70609. /** Gets or sets font weight */
  70610. get fontWeight(): string;
  70611. set fontWeight(value: string);
  70612. /**
  70613. * Gets or sets style
  70614. * @see http://doc.babylonjs.com/how_to/gui#styles
  70615. */
  70616. get style(): BABYLON.Nullable<Style>;
  70617. set style(value: BABYLON.Nullable<Style>);
  70618. /** @hidden */
  70619. get _isFontSizeInPercentage(): boolean;
  70620. /** Gets or sets font size in pixels */
  70621. get fontSizeInPixels(): number;
  70622. set fontSizeInPixels(value: number);
  70623. /** Gets or sets font size */
  70624. get fontSize(): string | number;
  70625. set fontSize(value: string | number);
  70626. /** Gets or sets foreground color */
  70627. get color(): string;
  70628. set color(value: string);
  70629. /** Gets or sets z index which is used to reorder controls on the z axis */
  70630. get zIndex(): number;
  70631. set zIndex(value: number);
  70632. /** Gets or sets a boolean indicating if the control can be rendered */
  70633. get notRenderable(): boolean;
  70634. set notRenderable(value: boolean);
  70635. /** Gets or sets a boolean indicating if the control is visible */
  70636. get isVisible(): boolean;
  70637. set isVisible(value: boolean);
  70638. /** Gets a boolean indicating that the control needs to update its rendering */
  70639. get isDirty(): boolean;
  70640. /**
  70641. * Gets the current linked mesh (or null if none)
  70642. */
  70643. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70644. /**
  70645. * Gets or sets a value indicating the padding to use on the left of the control
  70646. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70647. */
  70648. get paddingLeft(): string | number;
  70649. set paddingLeft(value: string | number);
  70650. /**
  70651. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70652. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70653. */
  70654. get paddingLeftInPixels(): number;
  70655. set paddingLeftInPixels(value: number);
  70656. /**
  70657. * Gets or sets a value indicating the padding to use on the right of the control
  70658. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70659. */
  70660. get paddingRight(): string | number;
  70661. set paddingRight(value: string | number);
  70662. /**
  70663. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70664. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70665. */
  70666. get paddingRightInPixels(): number;
  70667. set paddingRightInPixels(value: number);
  70668. /**
  70669. * Gets or sets a value indicating the padding to use on the top of the control
  70670. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70671. */
  70672. get paddingTop(): string | number;
  70673. set paddingTop(value: string | number);
  70674. /**
  70675. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70676. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70677. */
  70678. get paddingTopInPixels(): number;
  70679. set paddingTopInPixels(value: number);
  70680. /**
  70681. * Gets or sets a value indicating the padding to use on the bottom of the control
  70682. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70683. */
  70684. get paddingBottom(): string | number;
  70685. set paddingBottom(value: string | number);
  70686. /**
  70687. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70688. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70689. */
  70690. get paddingBottomInPixels(): number;
  70691. set paddingBottomInPixels(value: number);
  70692. /**
  70693. * Gets or sets a value indicating the left coordinate of the control
  70694. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70695. */
  70696. get left(): string | number;
  70697. set left(value: string | number);
  70698. /**
  70699. * Gets or sets a value indicating the left coordinate in pixels of the control
  70700. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70701. */
  70702. get leftInPixels(): number;
  70703. set leftInPixels(value: number);
  70704. /**
  70705. * Gets or sets a value indicating the top coordinate of the control
  70706. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70707. */
  70708. get top(): string | number;
  70709. set top(value: string | number);
  70710. /**
  70711. * Gets or sets a value indicating the top coordinate in pixels of the control
  70712. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70713. */
  70714. get topInPixels(): number;
  70715. set topInPixels(value: number);
  70716. /**
  70717. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70718. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70719. */
  70720. get linkOffsetX(): string | number;
  70721. set linkOffsetX(value: string | number);
  70722. /**
  70723. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70724. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70725. */
  70726. get linkOffsetXInPixels(): number;
  70727. set linkOffsetXInPixels(value: number);
  70728. /**
  70729. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70730. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70731. */
  70732. get linkOffsetY(): string | number;
  70733. set linkOffsetY(value: string | number);
  70734. /**
  70735. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70736. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70737. */
  70738. get linkOffsetYInPixels(): number;
  70739. set linkOffsetYInPixels(value: number);
  70740. /** Gets the center coordinate on X axis */
  70741. get centerX(): number;
  70742. /** Gets the center coordinate on Y axis */
  70743. get centerY(): number;
  70744. /** Gets or sets if control is Enabled*/
  70745. get isEnabled(): boolean;
  70746. set isEnabled(value: boolean);
  70747. /** Gets or sets background color of control if it's disabled*/
  70748. get disabledColor(): string;
  70749. set disabledColor(value: string);
  70750. /**
  70751. * Creates a new control
  70752. * @param name defines the name of the control
  70753. */
  70754. constructor(
  70755. /** defines the name of the control */
  70756. name?: string | undefined);
  70757. /** @hidden */
  70758. protected _getTypeName(): string;
  70759. /**
  70760. * Gets the first ascendant in the hierarchy of the given type
  70761. * @param className defines the required type
  70762. * @returns the ascendant or null if not found
  70763. */
  70764. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  70765. /** @hidden */
  70766. _resetFontCache(): void;
  70767. /**
  70768. * Determines if a container is an ascendant of the current control
  70769. * @param container defines the container to look for
  70770. * @returns true if the container is one of the ascendant of the control
  70771. */
  70772. isAscendant(container: Control): boolean;
  70773. /**
  70774. * Gets coordinates in local control space
  70775. * @param globalCoordinates defines the coordinates to transform
  70776. * @returns the new coordinates in local space
  70777. */
  70778. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70779. /**
  70780. * Gets coordinates in local control space
  70781. * @param globalCoordinates defines the coordinates to transform
  70782. * @param result defines the target vector2 where to store the result
  70783. * @returns the current control
  70784. */
  70785. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  70786. /**
  70787. * Gets coordinates in parent local control space
  70788. * @param globalCoordinates defines the coordinates to transform
  70789. * @returns the new coordinates in parent local space
  70790. */
  70791. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70792. /**
  70793. * Move the current control to a vector3 position projected onto the screen.
  70794. * @param position defines the target position
  70795. * @param scene defines the hosting scene
  70796. */
  70797. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  70798. /**
  70799. * Will store all controls that have this control as ascendant in a given array
  70800. * @param results defines the array where to store the descendants
  70801. * @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
  70802. * @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
  70803. */
  70804. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70805. /**
  70806. * Will return all controls that have this control as ascendant
  70807. * @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
  70808. * @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
  70809. * @return all child controls
  70810. */
  70811. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70812. /**
  70813. * Link current control with a target mesh
  70814. * @param mesh defines the mesh to link with
  70815. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70816. */
  70817. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  70818. /** @hidden */
  70819. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  70820. /** @hidden */
  70821. _offsetLeft(offset: number): void;
  70822. /** @hidden */
  70823. _offsetTop(offset: number): void;
  70824. /** @hidden */
  70825. _markMatrixAsDirty(): void;
  70826. /** @hidden */
  70827. _flagDescendantsAsMatrixDirty(): void;
  70828. /** @hidden */
  70829. _intersectsRect(rect: Measure): boolean;
  70830. /** @hidden */
  70831. protected invalidateRect(): void;
  70832. /** @hidden */
  70833. _markAsDirty(force?: boolean): void;
  70834. /** @hidden */
  70835. _markAllAsDirty(): void;
  70836. /** @hidden */
  70837. _link(host: AdvancedDynamicTexture): void;
  70838. /** @hidden */
  70839. protected _transform(context?: CanvasRenderingContext2D): void;
  70840. /** @hidden */
  70841. _renderHighlight(context: CanvasRenderingContext2D): void;
  70842. /** @hidden */
  70843. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70844. /** @hidden */
  70845. protected _applyStates(context: CanvasRenderingContext2D): void;
  70846. /** @hidden */
  70847. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70848. /** @hidden */
  70849. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70850. protected _evaluateClippingState(parentMeasure: Measure): void;
  70851. /** @hidden */
  70852. _measure(): void;
  70853. /** @hidden */
  70854. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70855. /** @hidden */
  70856. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70857. /** @hidden */
  70858. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70859. /** @hidden */
  70860. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70861. private static _ClipMeasure;
  70862. private _tmpMeasureA;
  70863. private _clip;
  70864. /** @hidden */
  70865. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  70866. /** @hidden */
  70867. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70868. /**
  70869. * Tests if a given coordinates belong to the current control
  70870. * @param x defines x coordinate to test
  70871. * @param y defines y coordinate to test
  70872. * @returns true if the coordinates are inside the control
  70873. */
  70874. contains(x: number, y: number): boolean;
  70875. /** @hidden */
  70876. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70877. /** @hidden */
  70878. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70879. /** @hidden */
  70880. _onPointerEnter(target: Control): boolean;
  70881. /** @hidden */
  70882. _onPointerOut(target: Control, force?: boolean): void;
  70883. /** @hidden */
  70884. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70885. /** @hidden */
  70886. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70887. /** @hidden */
  70888. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70889. /** @hidden */
  70890. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  70891. private _prepareFont;
  70892. /** Releases associated resources */
  70893. dispose(): void;
  70894. private static _HORIZONTAL_ALIGNMENT_LEFT;
  70895. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  70896. private static _HORIZONTAL_ALIGNMENT_CENTER;
  70897. private static _VERTICAL_ALIGNMENT_TOP;
  70898. private static _VERTICAL_ALIGNMENT_BOTTOM;
  70899. private static _VERTICAL_ALIGNMENT_CENTER;
  70900. /** HORIZONTAL_ALIGNMENT_LEFT */
  70901. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  70902. /** HORIZONTAL_ALIGNMENT_RIGHT */
  70903. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  70904. /** HORIZONTAL_ALIGNMENT_CENTER */
  70905. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  70906. /** VERTICAL_ALIGNMENT_TOP */
  70907. static get VERTICAL_ALIGNMENT_TOP(): number;
  70908. /** VERTICAL_ALIGNMENT_BOTTOM */
  70909. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  70910. /** VERTICAL_ALIGNMENT_CENTER */
  70911. static get VERTICAL_ALIGNMENT_CENTER(): number;
  70912. private static _FontHeightSizes;
  70913. /** @hidden */
  70914. static _GetFontOffset(font: string): {
  70915. ascent: number;
  70916. height: number;
  70917. descent: number;
  70918. };
  70919. /**
  70920. * Creates a stack panel that can be used to render headers
  70921. * @param control defines the control to associate with the header
  70922. * @param text defines the text of the header
  70923. * @param size defines the size of the header
  70924. * @param options defines options used to configure the header
  70925. * @returns a new StackPanel
  70926. * @ignore
  70927. * @hidden
  70928. */
  70929. static AddHeader: (control: Control, text: string, size: string | number, options: {
  70930. isHorizontal: boolean;
  70931. controlFirst: boolean;
  70932. }) => any;
  70933. /** @hidden */
  70934. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  70935. }
  70936. }
  70937. declare module BABYLON.GUI {
  70938. /**
  70939. * Root class for 2D containers
  70940. * @see http://doc.babylonjs.com/how_to/gui#containers
  70941. */
  70942. export class Container extends Control {
  70943. name?: string | undefined;
  70944. /** @hidden */
  70945. _children: Control[];
  70946. /** @hidden */
  70947. protected _measureForChildren: Measure;
  70948. /** @hidden */
  70949. protected _background: string;
  70950. /** @hidden */
  70951. protected _adaptWidthToChildren: boolean;
  70952. /** @hidden */
  70953. protected _adaptHeightToChildren: boolean;
  70954. /**
  70955. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  70956. */
  70957. logLayoutCycleErrors: boolean;
  70958. /**
  70959. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  70960. */
  70961. maxLayoutCycle: number;
  70962. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  70963. get adaptHeightToChildren(): boolean;
  70964. set adaptHeightToChildren(value: boolean);
  70965. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  70966. get adaptWidthToChildren(): boolean;
  70967. set adaptWidthToChildren(value: boolean);
  70968. /** Gets or sets background color */
  70969. get background(): string;
  70970. set background(value: string);
  70971. /** Gets the list of children */
  70972. get children(): Control[];
  70973. /**
  70974. * Creates a new Container
  70975. * @param name defines the name of the container
  70976. */
  70977. constructor(name?: string | undefined);
  70978. protected _getTypeName(): string;
  70979. _flagDescendantsAsMatrixDirty(): void;
  70980. /**
  70981. * Gets a child using its name
  70982. * @param name defines the child name to look for
  70983. * @returns the child control if found
  70984. */
  70985. getChildByName(name: string): BABYLON.Nullable<Control>;
  70986. /**
  70987. * Gets a child using its type and its name
  70988. * @param name defines the child name to look for
  70989. * @param type defines the child type to look for
  70990. * @returns the child control if found
  70991. */
  70992. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  70993. /**
  70994. * Search for a specific control in children
  70995. * @param control defines the control to look for
  70996. * @returns true if the control is in child list
  70997. */
  70998. containsControl(control: Control): boolean;
  70999. /**
  71000. * Adds a new control to the current container
  71001. * @param control defines the control to add
  71002. * @returns the current container
  71003. */
  71004. addControl(control: BABYLON.Nullable<Control>): Container;
  71005. /**
  71006. * Removes all controls from the current container
  71007. * @returns the current container
  71008. */
  71009. clearControls(): Container;
  71010. /**
  71011. * Removes a control from the current container
  71012. * @param control defines the control to remove
  71013. * @returns the current container
  71014. */
  71015. removeControl(control: Control): Container;
  71016. /** @hidden */
  71017. _reOrderControl(control: Control): void;
  71018. /** @hidden */
  71019. _offsetLeft(offset: number): void;
  71020. /** @hidden */
  71021. _offsetTop(offset: number): void;
  71022. /** @hidden */
  71023. _markAllAsDirty(): void;
  71024. /** @hidden */
  71025. protected _localDraw(context: CanvasRenderingContext2D): void;
  71026. /** @hidden */
  71027. _link(host: AdvancedDynamicTexture): void;
  71028. /** @hidden */
  71029. protected _beforeLayout(): void;
  71030. /** @hidden */
  71031. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71032. /** @hidden */
  71033. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71034. protected _postMeasure(): void;
  71035. /** @hidden */
  71036. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71037. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71038. /** @hidden */
  71039. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71040. /** @hidden */
  71041. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71042. /** Releases associated resources */
  71043. dispose(): void;
  71044. }
  71045. }
  71046. declare module BABYLON.GUI {
  71047. /** Class used to create rectangle container */
  71048. export class Rectangle extends Container {
  71049. name?: string | undefined;
  71050. private _thickness;
  71051. private _cornerRadius;
  71052. /** Gets or sets border thickness */
  71053. get thickness(): number;
  71054. set thickness(value: number);
  71055. /** Gets or sets the corner radius angle */
  71056. get cornerRadius(): number;
  71057. set cornerRadius(value: number);
  71058. /**
  71059. * Creates a new Rectangle
  71060. * @param name defines the control name
  71061. */
  71062. constructor(name?: string | undefined);
  71063. protected _getTypeName(): string;
  71064. protected _localDraw(context: CanvasRenderingContext2D): void;
  71065. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71066. private _drawRoundedRect;
  71067. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71068. }
  71069. }
  71070. declare module BABYLON.GUI {
  71071. /**
  71072. * Enum that determines the text-wrapping mode to use.
  71073. */
  71074. export enum TextWrapping {
  71075. /**
  71076. * Clip the text when it's larger than Control.width; this is the default mode.
  71077. */
  71078. Clip = 0,
  71079. /**
  71080. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71081. */
  71082. WordWrap = 1,
  71083. /**
  71084. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71085. */
  71086. Ellipsis = 2
  71087. }
  71088. /**
  71089. * Class used to create text block control
  71090. */
  71091. export class TextBlock extends Control {
  71092. /**
  71093. * Defines the name of the control
  71094. */
  71095. name?: string | undefined;
  71096. private _text;
  71097. private _textWrapping;
  71098. private _textHorizontalAlignment;
  71099. private _textVerticalAlignment;
  71100. private _lines;
  71101. private _resizeToFit;
  71102. private _lineSpacing;
  71103. private _outlineWidth;
  71104. private _outlineColor;
  71105. /**
  71106. * An event triggered after the text is changed
  71107. */
  71108. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71109. /**
  71110. * An event triggered after the text was broken up into lines
  71111. */
  71112. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71113. /**
  71114. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71115. */
  71116. get lines(): any[];
  71117. /**
  71118. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71119. */
  71120. get resizeToFit(): boolean;
  71121. /**
  71122. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71123. */
  71124. set resizeToFit(value: boolean);
  71125. /**
  71126. * Gets or sets a boolean indicating if text must be wrapped
  71127. */
  71128. get textWrapping(): TextWrapping | boolean;
  71129. /**
  71130. * Gets or sets a boolean indicating if text must be wrapped
  71131. */
  71132. set textWrapping(value: TextWrapping | boolean);
  71133. /**
  71134. * Gets or sets text to display
  71135. */
  71136. get text(): string;
  71137. /**
  71138. * Gets or sets text to display
  71139. */
  71140. set text(value: string);
  71141. /**
  71142. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71143. */
  71144. get textHorizontalAlignment(): number;
  71145. /**
  71146. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71147. */
  71148. set textHorizontalAlignment(value: number);
  71149. /**
  71150. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71151. */
  71152. get textVerticalAlignment(): number;
  71153. /**
  71154. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71155. */
  71156. set textVerticalAlignment(value: number);
  71157. /**
  71158. * Gets or sets line spacing value
  71159. */
  71160. set lineSpacing(value: string | number);
  71161. /**
  71162. * Gets or sets line spacing value
  71163. */
  71164. get lineSpacing(): string | number;
  71165. /**
  71166. * Gets or sets outlineWidth of the text to display
  71167. */
  71168. get outlineWidth(): number;
  71169. /**
  71170. * Gets or sets outlineWidth of the text to display
  71171. */
  71172. set outlineWidth(value: number);
  71173. /**
  71174. * Gets or sets outlineColor of the text to display
  71175. */
  71176. get outlineColor(): string;
  71177. /**
  71178. * Gets or sets outlineColor of the text to display
  71179. */
  71180. set outlineColor(value: string);
  71181. /**
  71182. * Creates a new TextBlock object
  71183. * @param name defines the name of the control
  71184. * @param text defines the text to display (emptry string by default)
  71185. */
  71186. constructor(
  71187. /**
  71188. * Defines the name of the control
  71189. */
  71190. name?: string | undefined, text?: string);
  71191. protected _getTypeName(): string;
  71192. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71193. private _drawText;
  71194. /** @hidden */
  71195. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71196. protected _applyStates(context: CanvasRenderingContext2D): void;
  71197. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71198. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71199. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71200. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71201. protected _renderLines(context: CanvasRenderingContext2D): void;
  71202. /**
  71203. * Given a width constraint applied on the text block, find the expected height
  71204. * @returns expected height
  71205. */
  71206. computeExpectedHeight(): number;
  71207. dispose(): void;
  71208. }
  71209. }
  71210. declare module BABYLON.GUI {
  71211. /**
  71212. * Class used to create 2D images
  71213. */
  71214. export class Image extends Control {
  71215. name?: string | undefined;
  71216. private _workingCanvas;
  71217. private _domImage;
  71218. private _imageWidth;
  71219. private _imageHeight;
  71220. private _loaded;
  71221. private _stretch;
  71222. private _source;
  71223. private _autoScale;
  71224. private _sourceLeft;
  71225. private _sourceTop;
  71226. private _sourceWidth;
  71227. private _sourceHeight;
  71228. private _svgAttributesComputationCompleted;
  71229. private _isSVG;
  71230. private _cellWidth;
  71231. private _cellHeight;
  71232. private _cellId;
  71233. private _populateNinePatchSlicesFromImage;
  71234. private _sliceLeft;
  71235. private _sliceRight;
  71236. private _sliceTop;
  71237. private _sliceBottom;
  71238. private _detectPointerOnOpaqueOnly;
  71239. /**
  71240. * BABYLON.Observable notified when the content is loaded
  71241. */
  71242. onImageLoadedObservable: BABYLON.Observable<Image>;
  71243. /**
  71244. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71245. */
  71246. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71247. /**
  71248. * Gets a boolean indicating that the content is loaded
  71249. */
  71250. get isLoaded(): boolean;
  71251. /**
  71252. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71253. */
  71254. get populateNinePatchSlicesFromImage(): boolean;
  71255. set populateNinePatchSlicesFromImage(value: boolean);
  71256. /**
  71257. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71258. * Beware using this as this will comsume more memory as the image has to be stored twice
  71259. */
  71260. get detectPointerOnOpaqueOnly(): boolean;
  71261. set detectPointerOnOpaqueOnly(value: boolean);
  71262. /**
  71263. * Gets or sets the left value for slicing (9-patch)
  71264. */
  71265. get sliceLeft(): number;
  71266. set sliceLeft(value: number);
  71267. /**
  71268. * Gets or sets the right value for slicing (9-patch)
  71269. */
  71270. get sliceRight(): number;
  71271. set sliceRight(value: number);
  71272. /**
  71273. * Gets or sets the top value for slicing (9-patch)
  71274. */
  71275. get sliceTop(): number;
  71276. set sliceTop(value: number);
  71277. /**
  71278. * Gets or sets the bottom value for slicing (9-patch)
  71279. */
  71280. get sliceBottom(): number;
  71281. set sliceBottom(value: number);
  71282. /**
  71283. * Gets or sets the left coordinate in the source image
  71284. */
  71285. get sourceLeft(): number;
  71286. set sourceLeft(value: number);
  71287. /**
  71288. * Gets or sets the top coordinate in the source image
  71289. */
  71290. get sourceTop(): number;
  71291. set sourceTop(value: number);
  71292. /**
  71293. * Gets or sets the width to capture in the source image
  71294. */
  71295. get sourceWidth(): number;
  71296. set sourceWidth(value: number);
  71297. /**
  71298. * Gets or sets the height to capture in the source image
  71299. */
  71300. get sourceHeight(): number;
  71301. set sourceHeight(value: number);
  71302. /** Indicates if the format of the image is SVG */
  71303. get isSVG(): boolean;
  71304. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71305. get svgAttributesComputationCompleted(): boolean;
  71306. /**
  71307. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71308. * @see http://doc.babylonjs.com/how_to/gui#image
  71309. */
  71310. get autoScale(): boolean;
  71311. set autoScale(value: boolean);
  71312. /** Gets or sets the streching mode used by the image */
  71313. get stretch(): number;
  71314. set stretch(value: number);
  71315. /** @hidden */
  71316. _rotate90(n: number, preserveProperties?: boolean): Image;
  71317. private _handleRotationForSVGImage;
  71318. private _rotate90SourceProperties;
  71319. /**
  71320. * Gets or sets the internal DOM image used to render the control
  71321. */
  71322. set domImage(value: HTMLImageElement);
  71323. get domImage(): HTMLImageElement;
  71324. private _onImageLoaded;
  71325. private _extractNinePatchSliceDataFromImage;
  71326. /**
  71327. * Gets or sets image source url
  71328. */
  71329. set source(value: BABYLON.Nullable<string>);
  71330. /**
  71331. * Checks for svg document with icon id present
  71332. */
  71333. private _svgCheck;
  71334. /**
  71335. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71336. * given external svg file and icon id
  71337. */
  71338. private _getSVGAttribs;
  71339. /**
  71340. * Gets or sets the cell width to use when animation sheet is enabled
  71341. * @see http://doc.babylonjs.com/how_to/gui#image
  71342. */
  71343. get cellWidth(): number;
  71344. set cellWidth(value: number);
  71345. /**
  71346. * Gets or sets the cell height to use when animation sheet is enabled
  71347. * @see http://doc.babylonjs.com/how_to/gui#image
  71348. */
  71349. get cellHeight(): number;
  71350. set cellHeight(value: number);
  71351. /**
  71352. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71353. * @see http://doc.babylonjs.com/how_to/gui#image
  71354. */
  71355. get cellId(): number;
  71356. set cellId(value: number);
  71357. /**
  71358. * Creates a new Image
  71359. * @param name defines the control name
  71360. * @param url defines the image url
  71361. */
  71362. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71363. /**
  71364. * Tests if a given coordinates belong to the current control
  71365. * @param x defines x coordinate to test
  71366. * @param y defines y coordinate to test
  71367. * @returns true if the coordinates are inside the control
  71368. */
  71369. contains(x: number, y: number): boolean;
  71370. protected _getTypeName(): string;
  71371. /** Force the control to synchronize with its content */
  71372. synchronizeSizeWithContent(): void;
  71373. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71374. private _prepareWorkingCanvasForOpaqueDetection;
  71375. private _drawImage;
  71376. _draw(context: CanvasRenderingContext2D): void;
  71377. private _renderCornerPatch;
  71378. private _renderNinePatch;
  71379. dispose(): void;
  71380. /** STRETCH_NONE */
  71381. static readonly STRETCH_NONE: number;
  71382. /** STRETCH_FILL */
  71383. static readonly STRETCH_FILL: number;
  71384. /** STRETCH_UNIFORM */
  71385. static readonly STRETCH_UNIFORM: number;
  71386. /** STRETCH_EXTEND */
  71387. static readonly STRETCH_EXTEND: number;
  71388. /** NINE_PATCH */
  71389. static readonly STRETCH_NINE_PATCH: number;
  71390. }
  71391. }
  71392. declare module BABYLON.GUI {
  71393. /**
  71394. * Class used to create 2D buttons
  71395. */
  71396. export class Button extends Rectangle {
  71397. name?: string | undefined;
  71398. /**
  71399. * Function called to generate a pointer enter animation
  71400. */
  71401. pointerEnterAnimation: () => void;
  71402. /**
  71403. * Function called to generate a pointer out animation
  71404. */
  71405. pointerOutAnimation: () => void;
  71406. /**
  71407. * Function called to generate a pointer down animation
  71408. */
  71409. pointerDownAnimation: () => void;
  71410. /**
  71411. * Function called to generate a pointer up animation
  71412. */
  71413. pointerUpAnimation: () => void;
  71414. /**
  71415. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71416. */
  71417. delegatePickingToChildren: boolean;
  71418. private _image;
  71419. /**
  71420. * Returns the image part of the button (if any)
  71421. */
  71422. get image(): BABYLON.Nullable<Image>;
  71423. private _textBlock;
  71424. /**
  71425. * Returns the image part of the button (if any)
  71426. */
  71427. get textBlock(): BABYLON.Nullable<TextBlock>;
  71428. /**
  71429. * Creates a new Button
  71430. * @param name defines the name of the button
  71431. */
  71432. constructor(name?: string | undefined);
  71433. protected _getTypeName(): string;
  71434. /** @hidden */
  71435. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71436. /** @hidden */
  71437. _onPointerEnter(target: Control): boolean;
  71438. /** @hidden */
  71439. _onPointerOut(target: Control, force?: boolean): void;
  71440. /** @hidden */
  71441. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71442. /** @hidden */
  71443. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71444. /**
  71445. * Creates a new button made with an image and a text
  71446. * @param name defines the name of the button
  71447. * @param text defines the text of the button
  71448. * @param imageUrl defines the url of the image
  71449. * @returns a new Button
  71450. */
  71451. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71452. /**
  71453. * Creates a new button made with an image
  71454. * @param name defines the name of the button
  71455. * @param imageUrl defines the url of the image
  71456. * @returns a new Button
  71457. */
  71458. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71459. /**
  71460. * Creates a new button made with a text
  71461. * @param name defines the name of the button
  71462. * @param text defines the text of the button
  71463. * @returns a new Button
  71464. */
  71465. static CreateSimpleButton(name: string, text: string): Button;
  71466. /**
  71467. * Creates a new button made with an image and a centered text
  71468. * @param name defines the name of the button
  71469. * @param text defines the text of the button
  71470. * @param imageUrl defines the url of the image
  71471. * @returns a new Button
  71472. */
  71473. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71474. }
  71475. }
  71476. declare module BABYLON.GUI {
  71477. /**
  71478. * Class used to create a 2D stack panel container
  71479. */
  71480. export class StackPanel extends Container {
  71481. name?: string | undefined;
  71482. private _isVertical;
  71483. private _manualWidth;
  71484. private _manualHeight;
  71485. private _doNotTrackManualChanges;
  71486. /**
  71487. * Gets or sets a boolean indicating that layou warnings should be ignored
  71488. */
  71489. ignoreLayoutWarnings: boolean;
  71490. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71491. get isVertical(): boolean;
  71492. set isVertical(value: boolean);
  71493. /**
  71494. * Gets or sets panel width.
  71495. * This value should not be set when in horizontal mode as it will be computed automatically
  71496. */
  71497. set width(value: string | number);
  71498. get width(): string | number;
  71499. /**
  71500. * Gets or sets panel height.
  71501. * This value should not be set when in vertical mode as it will be computed automatically
  71502. */
  71503. set height(value: string | number);
  71504. get height(): string | number;
  71505. /**
  71506. * Creates a new StackPanel
  71507. * @param name defines control name
  71508. */
  71509. constructor(name?: string | undefined);
  71510. protected _getTypeName(): string;
  71511. /** @hidden */
  71512. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71513. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71514. protected _postMeasure(): void;
  71515. }
  71516. }
  71517. declare module BABYLON.GUI {
  71518. /**
  71519. * Class used to represent a 2D checkbox
  71520. */
  71521. export class Checkbox extends Control {
  71522. name?: string | undefined;
  71523. private _isChecked;
  71524. private _background;
  71525. private _checkSizeRatio;
  71526. private _thickness;
  71527. /** Gets or sets border thickness */
  71528. get thickness(): number;
  71529. set thickness(value: number);
  71530. /**
  71531. * BABYLON.Observable raised when isChecked property changes
  71532. */
  71533. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71534. /** Gets or sets a value indicating the ratio between overall size and check size */
  71535. get checkSizeRatio(): number;
  71536. set checkSizeRatio(value: number);
  71537. /** Gets or sets background color */
  71538. get background(): string;
  71539. set background(value: string);
  71540. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71541. get isChecked(): boolean;
  71542. set isChecked(value: boolean);
  71543. /**
  71544. * Creates a new CheckBox
  71545. * @param name defines the control name
  71546. */
  71547. constructor(name?: string | undefined);
  71548. protected _getTypeName(): string;
  71549. /** @hidden */
  71550. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71551. /** @hidden */
  71552. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71553. /**
  71554. * Utility function to easily create a checkbox with a header
  71555. * @param title defines the label to use for the header
  71556. * @param onValueChanged defines the callback to call when value changes
  71557. * @returns a StackPanel containing the checkbox and a textBlock
  71558. */
  71559. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71560. }
  71561. }
  71562. declare module BABYLON.GUI {
  71563. /**
  71564. * Class used to store key control properties
  71565. */
  71566. export class KeyPropertySet {
  71567. /** Width */
  71568. width?: string;
  71569. /** Height */
  71570. height?: string;
  71571. /** Left padding */
  71572. paddingLeft?: string;
  71573. /** Right padding */
  71574. paddingRight?: string;
  71575. /** Top padding */
  71576. paddingTop?: string;
  71577. /** Bottom padding */
  71578. paddingBottom?: string;
  71579. /** Foreground color */
  71580. color?: string;
  71581. /** Background color */
  71582. background?: string;
  71583. }
  71584. /**
  71585. * Class used to create virtual keyboard
  71586. */
  71587. export class VirtualKeyboard extends StackPanel {
  71588. /** BABYLON.Observable raised when a key is pressed */
  71589. onKeyPressObservable: BABYLON.Observable<string>;
  71590. /** Gets or sets default key button width */
  71591. defaultButtonWidth: string;
  71592. /** Gets or sets default key button height */
  71593. defaultButtonHeight: string;
  71594. /** Gets or sets default key button left padding */
  71595. defaultButtonPaddingLeft: string;
  71596. /** Gets or sets default key button right padding */
  71597. defaultButtonPaddingRight: string;
  71598. /** Gets or sets default key button top padding */
  71599. defaultButtonPaddingTop: string;
  71600. /** Gets or sets default key button bottom padding */
  71601. defaultButtonPaddingBottom: string;
  71602. /** Gets or sets default key button foreground color */
  71603. defaultButtonColor: string;
  71604. /** Gets or sets default key button background color */
  71605. defaultButtonBackground: string;
  71606. /** Gets or sets shift button foreground color */
  71607. shiftButtonColor: string;
  71608. /** Gets or sets shift button thickness*/
  71609. selectedShiftThickness: number;
  71610. /** Gets shift key state */
  71611. shiftState: number;
  71612. protected _getTypeName(): string;
  71613. private _createKey;
  71614. /**
  71615. * Adds a new row of keys
  71616. * @param keys defines the list of keys to add
  71617. * @param propertySets defines the associated property sets
  71618. */
  71619. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71620. /**
  71621. * Set the shift key to a specific state
  71622. * @param shiftState defines the new shift state
  71623. */
  71624. applyShiftState(shiftState: number): void;
  71625. private _currentlyConnectedInputText;
  71626. private _connectedInputTexts;
  71627. private _onKeyPressObserver;
  71628. /** Gets the input text control currently attached to the keyboard */
  71629. get connectedInputText(): BABYLON.Nullable<InputText>;
  71630. /**
  71631. * Connects the keyboard with an input text control
  71632. *
  71633. * @param input defines the target control
  71634. */
  71635. connect(input: InputText): void;
  71636. /**
  71637. * Disconnects the keyboard from connected InputText controls
  71638. *
  71639. * @param input optionally defines a target control, otherwise all are disconnected
  71640. */
  71641. disconnect(input?: InputText): void;
  71642. private _removeConnectedInputObservables;
  71643. /**
  71644. * Release all resources
  71645. */
  71646. dispose(): void;
  71647. /**
  71648. * Creates a new keyboard using a default layout
  71649. *
  71650. * @param name defines control name
  71651. * @returns a new VirtualKeyboard
  71652. */
  71653. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71654. }
  71655. }
  71656. declare module BABYLON.GUI {
  71657. /**
  71658. * Class used to create input text control
  71659. */
  71660. export class InputText extends Control implements IFocusableControl {
  71661. name?: string | undefined;
  71662. private _text;
  71663. private _placeholderText;
  71664. private _background;
  71665. private _focusedBackground;
  71666. private _focusedColor;
  71667. private _placeholderColor;
  71668. private _thickness;
  71669. private _margin;
  71670. private _autoStretchWidth;
  71671. private _maxWidth;
  71672. private _isFocused;
  71673. private _blinkTimeout;
  71674. private _blinkIsEven;
  71675. private _cursorOffset;
  71676. private _scrollLeft;
  71677. private _textWidth;
  71678. private _clickedCoordinate;
  71679. private _deadKey;
  71680. private _addKey;
  71681. private _currentKey;
  71682. private _isTextHighlightOn;
  71683. private _textHighlightColor;
  71684. private _highligherOpacity;
  71685. private _highlightedText;
  71686. private _startHighlightIndex;
  71687. private _endHighlightIndex;
  71688. private _cursorIndex;
  71689. private _onFocusSelectAll;
  71690. private _isPointerDown;
  71691. private _onClipboardObserver;
  71692. private _onPointerDblTapObserver;
  71693. /** @hidden */
  71694. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71695. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71696. promptMessage: string;
  71697. /** Force disable prompt on mobile device */
  71698. disableMobilePrompt: boolean;
  71699. /** BABYLON.Observable raised when the text changes */
  71700. onTextChangedObservable: BABYLON.Observable<InputText>;
  71701. /** BABYLON.Observable raised just before an entered character is to be added */
  71702. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71703. /** BABYLON.Observable raised when the control gets the focus */
  71704. onFocusObservable: BABYLON.Observable<InputText>;
  71705. /** BABYLON.Observable raised when the control loses the focus */
  71706. onBlurObservable: BABYLON.Observable<InputText>;
  71707. /**Observable raised when the text is highlighted */
  71708. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71709. /**Observable raised when copy event is triggered */
  71710. onTextCopyObservable: BABYLON.Observable<InputText>;
  71711. /** BABYLON.Observable raised when cut event is triggered */
  71712. onTextCutObservable: BABYLON.Observable<InputText>;
  71713. /** BABYLON.Observable raised when paste event is triggered */
  71714. onTextPasteObservable: BABYLON.Observable<InputText>;
  71715. /** BABYLON.Observable raised when a key event was processed */
  71716. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71717. /** Gets or sets the maximum width allowed by the control */
  71718. get maxWidth(): string | number;
  71719. /** Gets the maximum width allowed by the control in pixels */
  71720. get maxWidthInPixels(): number;
  71721. set maxWidth(value: string | number);
  71722. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71723. get highligherOpacity(): number;
  71724. set highligherOpacity(value: number);
  71725. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71726. get onFocusSelectAll(): boolean;
  71727. set onFocusSelectAll(value: boolean);
  71728. /** Gets or sets the text hightlight color */
  71729. get textHighlightColor(): string;
  71730. set textHighlightColor(value: string);
  71731. /** Gets or sets control margin */
  71732. get margin(): string;
  71733. /** Gets control margin in pixels */
  71734. get marginInPixels(): number;
  71735. set margin(value: string);
  71736. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71737. get autoStretchWidth(): boolean;
  71738. set autoStretchWidth(value: boolean);
  71739. /** Gets or sets border thickness */
  71740. get thickness(): number;
  71741. set thickness(value: number);
  71742. /** Gets or sets the background color when focused */
  71743. get focusedBackground(): string;
  71744. set focusedBackground(value: string);
  71745. /** Gets or sets the background color when focused */
  71746. get focusedColor(): string;
  71747. set focusedColor(value: string);
  71748. /** Gets or sets the background color */
  71749. get background(): string;
  71750. set background(value: string);
  71751. /** Gets or sets the placeholder color */
  71752. get placeholderColor(): string;
  71753. set placeholderColor(value: string);
  71754. /** Gets or sets the text displayed when the control is empty */
  71755. get placeholderText(): string;
  71756. set placeholderText(value: string);
  71757. /** Gets or sets the dead key flag */
  71758. get deadKey(): boolean;
  71759. set deadKey(flag: boolean);
  71760. /** Gets or sets the highlight text */
  71761. get highlightedText(): string;
  71762. set highlightedText(text: string);
  71763. /** Gets or sets if the current key should be added */
  71764. get addKey(): boolean;
  71765. set addKey(flag: boolean);
  71766. /** Gets or sets the value of the current key being entered */
  71767. get currentKey(): string;
  71768. set currentKey(key: string);
  71769. /** Gets or sets the text displayed in the control */
  71770. get text(): string;
  71771. set text(value: string);
  71772. /** Gets or sets control width */
  71773. get width(): string | number;
  71774. set width(value: string | number);
  71775. /**
  71776. * Creates a new InputText
  71777. * @param name defines the control name
  71778. * @param text defines the text of the control
  71779. */
  71780. constructor(name?: string | undefined, text?: string);
  71781. /** @hidden */
  71782. onBlur(): void;
  71783. /** @hidden */
  71784. onFocus(): void;
  71785. protected _getTypeName(): string;
  71786. /**
  71787. * Function called to get the list of controls that should not steal the focus from this control
  71788. * @returns an array of controls
  71789. */
  71790. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71791. /** @hidden */
  71792. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  71793. /** @hidden */
  71794. private _updateValueFromCursorIndex;
  71795. /** @hidden */
  71796. private _processDblClick;
  71797. /** @hidden */
  71798. private _selectAllText;
  71799. /**
  71800. * Handles the keyboard event
  71801. * @param evt Defines the KeyboardEvent
  71802. */
  71803. processKeyboard(evt: KeyboardEvent): void;
  71804. /** @hidden */
  71805. private _onCopyText;
  71806. /** @hidden */
  71807. private _onCutText;
  71808. /** @hidden */
  71809. private _onPasteText;
  71810. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71811. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71812. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71813. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71814. protected _beforeRenderText(text: string): string;
  71815. dispose(): void;
  71816. }
  71817. }
  71818. declare module BABYLON.GUI {
  71819. /**
  71820. * Class used to create a 2D grid container
  71821. */
  71822. export class Grid extends Container {
  71823. name?: string | undefined;
  71824. private _rowDefinitions;
  71825. private _columnDefinitions;
  71826. private _cells;
  71827. private _childControls;
  71828. /**
  71829. * Gets the number of columns
  71830. */
  71831. get columnCount(): number;
  71832. /**
  71833. * Gets the number of rows
  71834. */
  71835. get rowCount(): number;
  71836. /** Gets the list of children */
  71837. get children(): Control[];
  71838. /** Gets the list of cells (e.g. the containers) */
  71839. get cells(): {
  71840. [key: string]: Container;
  71841. };
  71842. /**
  71843. * Gets the definition of a specific row
  71844. * @param index defines the index of the row
  71845. * @returns the row definition
  71846. */
  71847. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71848. /**
  71849. * Gets the definition of a specific column
  71850. * @param index defines the index of the column
  71851. * @returns the column definition
  71852. */
  71853. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71854. /**
  71855. * Adds a new row to the grid
  71856. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71857. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  71858. * @returns the current grid
  71859. */
  71860. addRowDefinition(height: number, isPixel?: boolean): Grid;
  71861. /**
  71862. * Adds a new column to the grid
  71863. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71864. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71865. * @returns the current grid
  71866. */
  71867. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  71868. /**
  71869. * Update a row definition
  71870. * @param index defines the index of the row to update
  71871. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71872. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  71873. * @returns the current grid
  71874. */
  71875. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  71876. /**
  71877. * Update a column definition
  71878. * @param index defines the index of the column to update
  71879. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71880. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71881. * @returns the current grid
  71882. */
  71883. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  71884. /**
  71885. * Gets the list of children stored in a specific cell
  71886. * @param row defines the row to check
  71887. * @param column defines the column to check
  71888. * @returns the list of controls
  71889. */
  71890. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  71891. /**
  71892. * Gets a string representing the child cell info (row x column)
  71893. * @param child defines the control to get info from
  71894. * @returns a string containing the child cell info (row x column)
  71895. */
  71896. getChildCellInfo(child: Control): string;
  71897. private _removeCell;
  71898. private _offsetCell;
  71899. /**
  71900. * Remove a column definition at specified index
  71901. * @param index defines the index of the column to remove
  71902. * @returns the current grid
  71903. */
  71904. removeColumnDefinition(index: number): Grid;
  71905. /**
  71906. * Remove a row definition at specified index
  71907. * @param index defines the index of the row to remove
  71908. * @returns the current grid
  71909. */
  71910. removeRowDefinition(index: number): Grid;
  71911. /**
  71912. * Adds a new control to the current grid
  71913. * @param control defines the control to add
  71914. * @param row defines the row where to add the control (0 by default)
  71915. * @param column defines the column where to add the control (0 by default)
  71916. * @returns the current grid
  71917. */
  71918. addControl(control: Control, row?: number, column?: number): Grid;
  71919. /**
  71920. * Removes a control from the current container
  71921. * @param control defines the control to remove
  71922. * @returns the current container
  71923. */
  71924. removeControl(control: Control): Container;
  71925. /**
  71926. * Creates a new Grid
  71927. * @param name defines control name
  71928. */
  71929. constructor(name?: string | undefined);
  71930. protected _getTypeName(): string;
  71931. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  71932. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71933. _flagDescendantsAsMatrixDirty(): void;
  71934. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71935. /** Releases associated resources */
  71936. dispose(): void;
  71937. }
  71938. }
  71939. declare module BABYLON.GUI {
  71940. /** Class used to create color pickers */
  71941. export class ColorPicker extends Control {
  71942. name?: string | undefined;
  71943. private static _Epsilon;
  71944. private _colorWheelCanvas;
  71945. private _value;
  71946. private _tmpColor;
  71947. private _pointerStartedOnSquare;
  71948. private _pointerStartedOnWheel;
  71949. private _squareLeft;
  71950. private _squareTop;
  71951. private _squareSize;
  71952. private _h;
  71953. private _s;
  71954. private _v;
  71955. private _lastPointerDownID;
  71956. /**
  71957. * BABYLON.Observable raised when the value changes
  71958. */
  71959. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  71960. /** Gets or sets the color of the color picker */
  71961. get value(): BABYLON.Color3;
  71962. set value(value: BABYLON.Color3);
  71963. /**
  71964. * Gets or sets control width
  71965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71966. */
  71967. get width(): string | number;
  71968. set width(value: string | number);
  71969. /**
  71970. * Gets or sets control height
  71971. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71972. */
  71973. get height(): string | number;
  71974. /** Gets or sets control height */
  71975. set height(value: string | number);
  71976. /** Gets or sets control size */
  71977. get size(): string | number;
  71978. set size(value: string | number);
  71979. /**
  71980. * Creates a new ColorPicker
  71981. * @param name defines the control name
  71982. */
  71983. constructor(name?: string | undefined);
  71984. protected _getTypeName(): string;
  71985. /** @hidden */
  71986. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71987. private _updateSquareProps;
  71988. private _drawGradientSquare;
  71989. private _drawCircle;
  71990. private _createColorWheelCanvas;
  71991. /** @hidden */
  71992. _draw(context: CanvasRenderingContext2D): void;
  71993. private _pointerIsDown;
  71994. private _updateValueFromPointer;
  71995. private _isPointOnSquare;
  71996. private _isPointOnWheel;
  71997. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71998. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71999. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72000. /**
  72001. * This function expands the color picker by creating a color picker dialog with manual
  72002. * color value input and the ability to save colors into an array to be used later in
  72003. * subsequent launches of the dialogue.
  72004. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72005. * @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.
  72006. * @returns picked color as a hex string and the saved colors array as hex strings.
  72007. */
  72008. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72009. pickerWidth?: string;
  72010. pickerHeight?: string;
  72011. headerHeight?: string;
  72012. lastColor?: string;
  72013. swatchLimit?: number;
  72014. numSwatchesPerLine?: number;
  72015. savedColors?: Array<string>;
  72016. }): Promise<{
  72017. savedColors?: string[];
  72018. pickedColor: string;
  72019. }>;
  72020. }
  72021. }
  72022. declare module BABYLON.GUI {
  72023. /** Class used to create 2D ellipse containers */
  72024. export class Ellipse extends Container {
  72025. name?: string | undefined;
  72026. private _thickness;
  72027. /** Gets or sets border thickness */
  72028. get thickness(): number;
  72029. set thickness(value: number);
  72030. /**
  72031. * Creates a new Ellipse
  72032. * @param name defines the control name
  72033. */
  72034. constructor(name?: string | undefined);
  72035. protected _getTypeName(): string;
  72036. protected _localDraw(context: CanvasRenderingContext2D): void;
  72037. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72038. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72039. }
  72040. }
  72041. declare module BABYLON.GUI {
  72042. /**
  72043. * Class used to create a password control
  72044. */
  72045. export class InputPassword extends InputText {
  72046. protected _beforeRenderText(text: string): string;
  72047. }
  72048. }
  72049. declare module BABYLON.GUI {
  72050. /** Class used to render 2D lines */
  72051. export class Line extends Control {
  72052. name?: string | undefined;
  72053. private _lineWidth;
  72054. private _x1;
  72055. private _y1;
  72056. private _x2;
  72057. private _y2;
  72058. private _dash;
  72059. private _connectedControl;
  72060. private _connectedControlDirtyObserver;
  72061. /** Gets or sets the dash pattern */
  72062. get dash(): Array<number>;
  72063. set dash(value: Array<number>);
  72064. /** Gets or sets the control connected with the line end */
  72065. get connectedControl(): Control;
  72066. set connectedControl(value: Control);
  72067. /** Gets or sets start coordinates on X axis */
  72068. get x1(): string | number;
  72069. set x1(value: string | number);
  72070. /** Gets or sets start coordinates on Y axis */
  72071. get y1(): string | number;
  72072. set y1(value: string | number);
  72073. /** Gets or sets end coordinates on X axis */
  72074. get x2(): string | number;
  72075. set x2(value: string | number);
  72076. /** Gets or sets end coordinates on Y axis */
  72077. get y2(): string | number;
  72078. set y2(value: string | number);
  72079. /** Gets or sets line width */
  72080. get lineWidth(): number;
  72081. set lineWidth(value: number);
  72082. /** Gets or sets horizontal alignment */
  72083. set horizontalAlignment(value: number);
  72084. /** Gets or sets vertical alignment */
  72085. set verticalAlignment(value: number);
  72086. private get _effectiveX2();
  72087. private get _effectiveY2();
  72088. /**
  72089. * Creates a new Line
  72090. * @param name defines the control name
  72091. */
  72092. constructor(name?: string | undefined);
  72093. protected _getTypeName(): string;
  72094. _draw(context: CanvasRenderingContext2D): void;
  72095. _measure(): void;
  72096. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72097. /**
  72098. * Move one end of the line given 3D cartesian coordinates.
  72099. * @param position Targeted world position
  72100. * @param scene BABYLON.Scene
  72101. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72102. */
  72103. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72104. /**
  72105. * Move one end of the line to a position in screen absolute space.
  72106. * @param projectedPosition Position in screen absolute space (X, Y)
  72107. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72108. */
  72109. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72110. }
  72111. }
  72112. declare module BABYLON.GUI {
  72113. /**
  72114. * Class used to store a point for a MultiLine object.
  72115. * The point can be pure 2D coordinates, a mesh or a control
  72116. */
  72117. export class MultiLinePoint {
  72118. private _multiLine;
  72119. private _x;
  72120. private _y;
  72121. private _control;
  72122. private _mesh;
  72123. private _controlObserver;
  72124. private _meshObserver;
  72125. /** @hidden */
  72126. _point: BABYLON.Vector2;
  72127. /**
  72128. * Creates a new MultiLinePoint
  72129. * @param multiLine defines the source MultiLine object
  72130. */
  72131. constructor(multiLine: MultiLine);
  72132. /** Gets or sets x coordinate */
  72133. get x(): string | number;
  72134. set x(value: string | number);
  72135. /** Gets or sets y coordinate */
  72136. get y(): string | number;
  72137. set y(value: string | number);
  72138. /** Gets or sets the control associated with this point */
  72139. get control(): BABYLON.Nullable<Control>;
  72140. set control(value: BABYLON.Nullable<Control>);
  72141. /** Gets or sets the mesh associated with this point */
  72142. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72143. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72144. /** Resets links */
  72145. resetLinks(): void;
  72146. /**
  72147. * Gets a translation vector
  72148. * @returns the translation vector
  72149. */
  72150. translate(): BABYLON.Vector2;
  72151. private _translatePoint;
  72152. /** Release associated resources */
  72153. dispose(): void;
  72154. }
  72155. }
  72156. declare module BABYLON.GUI {
  72157. /**
  72158. * Class used to create multi line control
  72159. */
  72160. export class MultiLine extends Control {
  72161. name?: string | undefined;
  72162. private _lineWidth;
  72163. private _dash;
  72164. private _points;
  72165. private _minX;
  72166. private _minY;
  72167. private _maxX;
  72168. private _maxY;
  72169. /**
  72170. * Creates a new MultiLine
  72171. * @param name defines the control name
  72172. */
  72173. constructor(name?: string | undefined);
  72174. /** Gets or sets dash pattern */
  72175. get dash(): Array<number>;
  72176. set dash(value: Array<number>);
  72177. /**
  72178. * Gets point stored at specified index
  72179. * @param index defines the index to look for
  72180. * @returns the requested point if found
  72181. */
  72182. getAt(index: number): MultiLinePoint;
  72183. /** Function called when a point is updated */
  72184. onPointUpdate: () => void;
  72185. /**
  72186. * Adds new points to the point collection
  72187. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72188. * @returns the list of created MultiLinePoint
  72189. */
  72190. add(...items: (AbstractMesh | Control | {
  72191. x: string | number;
  72192. y: string | number;
  72193. })[]): MultiLinePoint[];
  72194. /**
  72195. * Adds a new point to the point collection
  72196. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72197. * @returns the created MultiLinePoint
  72198. */
  72199. push(item?: (AbstractMesh | Control | {
  72200. x: string | number;
  72201. y: string | number;
  72202. })): MultiLinePoint;
  72203. /**
  72204. * Remove a specific value or point from the active point collection
  72205. * @param value defines the value or point to remove
  72206. */
  72207. remove(value: number | MultiLinePoint): void;
  72208. /**
  72209. * Resets this object to initial state (no point)
  72210. */
  72211. reset(): void;
  72212. /**
  72213. * Resets all links
  72214. */
  72215. resetLinks(): void;
  72216. /** Gets or sets line width */
  72217. get lineWidth(): number;
  72218. set lineWidth(value: number);
  72219. set horizontalAlignment(value: number);
  72220. set verticalAlignment(value: number);
  72221. protected _getTypeName(): string;
  72222. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72223. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72224. _measure(): void;
  72225. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72226. dispose(): void;
  72227. }
  72228. }
  72229. declare module BABYLON.GUI {
  72230. /**
  72231. * Class used to create radio button controls
  72232. */
  72233. export class RadioButton extends Control {
  72234. name?: string | undefined;
  72235. private _isChecked;
  72236. private _background;
  72237. private _checkSizeRatio;
  72238. private _thickness;
  72239. /** Gets or sets border thickness */
  72240. get thickness(): number;
  72241. set thickness(value: number);
  72242. /** Gets or sets group name */
  72243. group: string;
  72244. /** BABYLON.Observable raised when isChecked is changed */
  72245. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72246. /** Gets or sets a value indicating the ratio between overall size and check size */
  72247. get checkSizeRatio(): number;
  72248. set checkSizeRatio(value: number);
  72249. /** Gets or sets background color */
  72250. get background(): string;
  72251. set background(value: string);
  72252. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72253. get isChecked(): boolean;
  72254. set isChecked(value: boolean);
  72255. /**
  72256. * Creates a new RadioButton
  72257. * @param name defines the control name
  72258. */
  72259. constructor(name?: string | undefined);
  72260. protected _getTypeName(): string;
  72261. _draw(context: CanvasRenderingContext2D): void;
  72262. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72263. /**
  72264. * Utility function to easily create a radio button with a header
  72265. * @param title defines the label to use for the header
  72266. * @param group defines the group to use for the radio button
  72267. * @param isChecked defines the initial state of the radio button
  72268. * @param onValueChanged defines the callback to call when value changes
  72269. * @returns a StackPanel containing the radio button and a textBlock
  72270. */
  72271. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72272. }
  72273. }
  72274. declare module BABYLON.GUI {
  72275. /**
  72276. * Class used to create slider controls
  72277. */
  72278. export class BaseSlider extends Control {
  72279. name?: string | undefined;
  72280. protected _thumbWidth: ValueAndUnit;
  72281. private _minimum;
  72282. private _maximum;
  72283. private _value;
  72284. private _isVertical;
  72285. protected _barOffset: ValueAndUnit;
  72286. private _isThumbClamped;
  72287. protected _displayThumb: boolean;
  72288. private _step;
  72289. private _lastPointerDownID;
  72290. protected _effectiveBarOffset: number;
  72291. protected _renderLeft: number;
  72292. protected _renderTop: number;
  72293. protected _renderWidth: number;
  72294. protected _renderHeight: number;
  72295. protected _backgroundBoxLength: number;
  72296. protected _backgroundBoxThickness: number;
  72297. protected _effectiveThumbThickness: number;
  72298. /** BABYLON.Observable raised when the sldier value changes */
  72299. onValueChangedObservable: BABYLON.Observable<number>;
  72300. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72301. get displayThumb(): boolean;
  72302. set displayThumb(value: boolean);
  72303. /** Gets or sets a step to apply to values (0 by default) */
  72304. get step(): number;
  72305. set step(value: number);
  72306. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72307. get barOffset(): string | number;
  72308. /** Gets main bar offset in pixels*/
  72309. get barOffsetInPixels(): number;
  72310. set barOffset(value: string | number);
  72311. /** Gets or sets thumb width */
  72312. get thumbWidth(): string | number;
  72313. /** Gets thumb width in pixels */
  72314. get thumbWidthInPixels(): number;
  72315. set thumbWidth(value: string | number);
  72316. /** Gets or sets minimum value */
  72317. get minimum(): number;
  72318. set minimum(value: number);
  72319. /** Gets or sets maximum value */
  72320. get maximum(): number;
  72321. set maximum(value: number);
  72322. /** Gets or sets current value */
  72323. get value(): number;
  72324. set value(value: number);
  72325. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72326. get isVertical(): boolean;
  72327. set isVertical(value: boolean);
  72328. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72329. get isThumbClamped(): boolean;
  72330. set isThumbClamped(value: boolean);
  72331. /**
  72332. * Creates a new BaseSlider
  72333. * @param name defines the control name
  72334. */
  72335. constructor(name?: string | undefined);
  72336. protected _getTypeName(): string;
  72337. protected _getThumbPosition(): number;
  72338. protected _getThumbThickness(type: string): number;
  72339. protected _prepareRenderingData(type: string): void;
  72340. private _pointerIsDown;
  72341. /** @hidden */
  72342. protected _updateValueFromPointer(x: number, y: number): void;
  72343. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72344. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72345. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72346. }
  72347. }
  72348. declare module BABYLON.GUI {
  72349. /**
  72350. * Class used to create slider controls
  72351. */
  72352. export class Slider extends BaseSlider {
  72353. name?: string | undefined;
  72354. private _background;
  72355. private _borderColor;
  72356. private _isThumbCircle;
  72357. protected _displayValueBar: boolean;
  72358. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72359. get displayValueBar(): boolean;
  72360. set displayValueBar(value: boolean);
  72361. /** Gets or sets border color */
  72362. get borderColor(): string;
  72363. set borderColor(value: string);
  72364. /** Gets or sets background color */
  72365. get background(): string;
  72366. set background(value: string);
  72367. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72368. get isThumbCircle(): boolean;
  72369. set isThumbCircle(value: boolean);
  72370. /**
  72371. * Creates a new Slider
  72372. * @param name defines the control name
  72373. */
  72374. constructor(name?: string | undefined);
  72375. protected _getTypeName(): string;
  72376. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72377. }
  72378. }
  72379. declare module BABYLON.GUI {
  72380. /** Class used to create a RadioGroup
  72381. * which contains groups of radio buttons
  72382. */
  72383. export class SelectorGroup {
  72384. /** name of SelectorGroup */
  72385. name: string;
  72386. private _groupPanel;
  72387. private _selectors;
  72388. private _groupHeader;
  72389. /**
  72390. * Creates a new SelectorGroup
  72391. * @param name of group, used as a group heading
  72392. */
  72393. constructor(
  72394. /** name of SelectorGroup */
  72395. name: string);
  72396. /** Gets the groupPanel of the SelectorGroup */
  72397. get groupPanel(): StackPanel;
  72398. /** Gets the selectors array */
  72399. get selectors(): StackPanel[];
  72400. /** Gets and sets the group header */
  72401. get header(): string;
  72402. set header(label: string);
  72403. /** @hidden */
  72404. private _addGroupHeader;
  72405. /** @hidden*/
  72406. _getSelector(selectorNb: number): StackPanel | undefined;
  72407. /** Removes the selector at the given position
  72408. * @param selectorNb the position of the selector within the group
  72409. */
  72410. removeSelector(selectorNb: number): void;
  72411. }
  72412. /** Class used to create a CheckboxGroup
  72413. * which contains groups of checkbox buttons
  72414. */
  72415. export class CheckboxGroup extends SelectorGroup {
  72416. /** Adds a checkbox as a control
  72417. * @param text is the label for the selector
  72418. * @param func is the function called when the Selector is checked
  72419. * @param checked is true when Selector is checked
  72420. */
  72421. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72422. /** @hidden */
  72423. _setSelectorLabel(selectorNb: number, label: string): void;
  72424. /** @hidden */
  72425. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72426. /** @hidden */
  72427. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72428. /** @hidden */
  72429. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72430. }
  72431. /** Class used to create a RadioGroup
  72432. * which contains groups of radio buttons
  72433. */
  72434. export class RadioGroup extends SelectorGroup {
  72435. private _selectNb;
  72436. /** Adds a radio button as a control
  72437. * @param label is the label for the selector
  72438. * @param func is the function called when the Selector is checked
  72439. * @param checked is true when Selector is checked
  72440. */
  72441. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72442. /** @hidden */
  72443. _setSelectorLabel(selectorNb: number, label: string): void;
  72444. /** @hidden */
  72445. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72446. /** @hidden */
  72447. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72448. /** @hidden */
  72449. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72450. }
  72451. /** Class used to create a SliderGroup
  72452. * which contains groups of slider buttons
  72453. */
  72454. export class SliderGroup extends SelectorGroup {
  72455. /**
  72456. * Adds a slider to the SelectorGroup
  72457. * @param label is the label for the SliderBar
  72458. * @param func is the function called when the Slider moves
  72459. * @param unit is a string describing the units used, eg degrees or metres
  72460. * @param min is the minimum value for the Slider
  72461. * @param max is the maximum value for the Slider
  72462. * @param value is the start value for the Slider between min and max
  72463. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72464. */
  72465. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72466. /** @hidden */
  72467. _setSelectorLabel(selectorNb: number, label: string): void;
  72468. /** @hidden */
  72469. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72470. /** @hidden */
  72471. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72472. /** @hidden */
  72473. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72474. }
  72475. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72476. * @see http://doc.babylonjs.com/how_to/selector
  72477. */
  72478. export class SelectionPanel extends Rectangle {
  72479. /** name of SelectionPanel */
  72480. name: string;
  72481. /** an array of SelectionGroups */
  72482. groups: SelectorGroup[];
  72483. private _panel;
  72484. private _buttonColor;
  72485. private _buttonBackground;
  72486. private _headerColor;
  72487. private _barColor;
  72488. private _barHeight;
  72489. private _spacerHeight;
  72490. private _labelColor;
  72491. private _groups;
  72492. private _bars;
  72493. /**
  72494. * Creates a new SelectionPanel
  72495. * @param name of SelectionPanel
  72496. * @param groups is an array of SelectionGroups
  72497. */
  72498. constructor(
  72499. /** name of SelectionPanel */
  72500. name: string,
  72501. /** an array of SelectionGroups */
  72502. groups?: SelectorGroup[]);
  72503. protected _getTypeName(): string;
  72504. /** Gets or sets the headerColor */
  72505. get headerColor(): string;
  72506. set headerColor(color: string);
  72507. private _setHeaderColor;
  72508. /** Gets or sets the button color */
  72509. get buttonColor(): string;
  72510. set buttonColor(color: string);
  72511. private _setbuttonColor;
  72512. /** Gets or sets the label color */
  72513. get labelColor(): string;
  72514. set labelColor(color: string);
  72515. private _setLabelColor;
  72516. /** Gets or sets the button background */
  72517. get buttonBackground(): string;
  72518. set buttonBackground(color: string);
  72519. private _setButtonBackground;
  72520. /** Gets or sets the color of separator bar */
  72521. get barColor(): string;
  72522. set barColor(color: string);
  72523. private _setBarColor;
  72524. /** Gets or sets the height of separator bar */
  72525. get barHeight(): string;
  72526. set barHeight(value: string);
  72527. private _setBarHeight;
  72528. /** Gets or sets the height of spacers*/
  72529. get spacerHeight(): string;
  72530. set spacerHeight(value: string);
  72531. private _setSpacerHeight;
  72532. /** Adds a bar between groups */
  72533. private _addSpacer;
  72534. /** Add a group to the selection panel
  72535. * @param group is the selector group to add
  72536. */
  72537. addGroup(group: SelectorGroup): void;
  72538. /** Remove the group from the given position
  72539. * @param groupNb is the position of the group in the list
  72540. */
  72541. removeGroup(groupNb: number): void;
  72542. /** Change a group header label
  72543. * @param label is the new group header label
  72544. * @param groupNb is the number of the group to relabel
  72545. * */
  72546. setHeaderName(label: string, groupNb: number): void;
  72547. /** Change selector label to the one given
  72548. * @param label is the new selector label
  72549. * @param groupNb is the number of the groupcontaining the selector
  72550. * @param selectorNb is the number of the selector within a group to relabel
  72551. * */
  72552. relabel(label: string, groupNb: number, selectorNb: number): void;
  72553. /** For a given group position remove the selector at the given position
  72554. * @param groupNb is the number of the group to remove the selector from
  72555. * @param selectorNb is the number of the selector within the group
  72556. */
  72557. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72558. /** For a given group position of correct type add a checkbox button
  72559. * @param groupNb is the number of the group to remove the selector from
  72560. * @param label is the label for the selector
  72561. * @param func is the function called when the Selector is checked
  72562. * @param checked is true when Selector is checked
  72563. */
  72564. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72565. /** For a given group position of correct type add a radio button
  72566. * @param groupNb is the number of the group to remove the selector from
  72567. * @param label is the label for the selector
  72568. * @param func is the function called when the Selector is checked
  72569. * @param checked is true when Selector is checked
  72570. */
  72571. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72572. /**
  72573. * For a given slider group add a slider
  72574. * @param groupNb is the number of the group to add the slider to
  72575. * @param label is the label for the Slider
  72576. * @param func is the function called when the Slider moves
  72577. * @param unit is a string describing the units used, eg degrees or metres
  72578. * @param min is the minimum value for the Slider
  72579. * @param max is the maximum value for the Slider
  72580. * @param value is the start value for the Slider between min and max
  72581. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72582. */
  72583. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72584. }
  72585. }
  72586. declare module BABYLON.GUI {
  72587. /**
  72588. * Class used to hold a the container for ScrollViewer
  72589. * @hidden
  72590. */
  72591. export class _ScrollViewerWindow extends Container {
  72592. parentClientWidth: number;
  72593. parentClientHeight: number;
  72594. private _freezeControls;
  72595. private _parentMeasure;
  72596. private _oldLeft;
  72597. private _oldTop;
  72598. get freezeControls(): boolean;
  72599. set freezeControls(value: boolean);
  72600. private _bucketWidth;
  72601. private _bucketHeight;
  72602. private _buckets;
  72603. private _bucketLen;
  72604. get bucketWidth(): number;
  72605. get bucketHeight(): number;
  72606. setBucketSizes(width: number, height: number): void;
  72607. private _useBuckets;
  72608. private _makeBuckets;
  72609. private _dispatchInBuckets;
  72610. private _updateMeasures;
  72611. private _updateChildrenMeasures;
  72612. /**
  72613. * Creates a new ScrollViewerWindow
  72614. * @param name of ScrollViewerWindow
  72615. */
  72616. constructor(name?: string);
  72617. protected _getTypeName(): string;
  72618. /** @hidden */
  72619. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72620. /** @hidden */
  72621. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72622. private _scrollChildren;
  72623. private _scrollChildrenWithBuckets;
  72624. /** @hidden */
  72625. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72626. protected _postMeasure(): void;
  72627. }
  72628. }
  72629. declare module BABYLON.GUI {
  72630. /**
  72631. * Class used to create slider controls
  72632. */
  72633. export class ScrollBar extends BaseSlider {
  72634. name?: string | undefined;
  72635. private _background;
  72636. private _borderColor;
  72637. private _tempMeasure;
  72638. /** Gets or sets border color */
  72639. get borderColor(): string;
  72640. set borderColor(value: string);
  72641. /** Gets or sets background color */
  72642. get background(): string;
  72643. set background(value: string);
  72644. /**
  72645. * Creates a new Slider
  72646. * @param name defines the control name
  72647. */
  72648. constructor(name?: string | undefined);
  72649. protected _getTypeName(): string;
  72650. protected _getThumbThickness(): number;
  72651. _draw(context: CanvasRenderingContext2D): void;
  72652. private _first;
  72653. private _originX;
  72654. private _originY;
  72655. /** @hidden */
  72656. protected _updateValueFromPointer(x: number, y: number): void;
  72657. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72658. }
  72659. }
  72660. declare module BABYLON.GUI {
  72661. /**
  72662. * Class used to create slider controls
  72663. */
  72664. export class ImageScrollBar extends BaseSlider {
  72665. name?: string | undefined;
  72666. private _backgroundBaseImage;
  72667. private _backgroundImage;
  72668. private _thumbImage;
  72669. private _thumbBaseImage;
  72670. private _thumbLength;
  72671. private _thumbHeight;
  72672. private _barImageHeight;
  72673. private _tempMeasure;
  72674. /**
  72675. * Gets or sets the image used to render the background for horizontal bar
  72676. */
  72677. get backgroundImage(): Image;
  72678. set backgroundImage(value: Image);
  72679. /**
  72680. * Gets or sets the image used to render the thumb
  72681. */
  72682. get thumbImage(): Image;
  72683. set thumbImage(value: Image);
  72684. /**
  72685. * Gets or sets the length of the thumb
  72686. */
  72687. get thumbLength(): number;
  72688. set thumbLength(value: number);
  72689. /**
  72690. * Gets or sets the height of the thumb
  72691. */
  72692. get thumbHeight(): number;
  72693. set thumbHeight(value: number);
  72694. /**
  72695. * Gets or sets the height of the bar image
  72696. */
  72697. get barImageHeight(): number;
  72698. set barImageHeight(value: number);
  72699. /**
  72700. * Creates a new ImageScrollBar
  72701. * @param name defines the control name
  72702. */
  72703. constructor(name?: string | undefined);
  72704. protected _getTypeName(): string;
  72705. protected _getThumbThickness(): number;
  72706. _draw(context: CanvasRenderingContext2D): void;
  72707. private _first;
  72708. private _originX;
  72709. private _originY;
  72710. /** @hidden */
  72711. protected _updateValueFromPointer(x: number, y: number): void;
  72712. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72713. }
  72714. }
  72715. declare module BABYLON.GUI {
  72716. /**
  72717. * Class used to hold a viewer window and sliders in a grid
  72718. */
  72719. export class ScrollViewer extends Rectangle {
  72720. private _grid;
  72721. private _horizontalBarSpace;
  72722. private _verticalBarSpace;
  72723. private _dragSpace;
  72724. private _horizontalBar;
  72725. private _verticalBar;
  72726. private _barColor;
  72727. private _barBackground;
  72728. private _barImage;
  72729. private _horizontalBarImage;
  72730. private _verticalBarImage;
  72731. private _barBackgroundImage;
  72732. private _horizontalBarBackgroundImage;
  72733. private _verticalBarBackgroundImage;
  72734. private _barSize;
  72735. private _window;
  72736. private _pointerIsOver;
  72737. private _wheelPrecision;
  72738. private _onPointerObserver;
  72739. private _clientWidth;
  72740. private _clientHeight;
  72741. private _useImageBar;
  72742. private _thumbLength;
  72743. private _thumbHeight;
  72744. private _barImageHeight;
  72745. private _horizontalBarImageHeight;
  72746. private _verticalBarImageHeight;
  72747. /**
  72748. * Gets the horizontal scrollbar
  72749. */
  72750. get horizontalBar(): ScrollBar | ImageScrollBar;
  72751. /**
  72752. * Gets the vertical scrollbar
  72753. */
  72754. get verticalBar(): ScrollBar | ImageScrollBar;
  72755. /**
  72756. * Adds a new control to the current container
  72757. * @param control defines the control to add
  72758. * @returns the current container
  72759. */
  72760. addControl(control: BABYLON.Nullable<Control>): Container;
  72761. /**
  72762. * Removes a control from the current container
  72763. * @param control defines the control to remove
  72764. * @returns the current container
  72765. */
  72766. removeControl(control: Control): Container;
  72767. /** Gets the list of children */
  72768. get children(): Control[];
  72769. _flagDescendantsAsMatrixDirty(): void;
  72770. /**
  72771. * Freezes or unfreezes the controls in the window.
  72772. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  72773. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  72774. */
  72775. get freezeControls(): boolean;
  72776. set freezeControls(value: boolean);
  72777. /** Gets the bucket width */
  72778. get bucketWidth(): number;
  72779. /** Gets the bucket height */
  72780. get bucketHeight(): number;
  72781. /**
  72782. * Sets the bucket sizes.
  72783. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  72784. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  72785. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  72786. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  72787. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  72788. * used), that's why it is not enabled by default.
  72789. * @param width width of the bucket
  72790. * @param height height of the bucket
  72791. */
  72792. setBucketSizes(width: number, height: number): void;
  72793. private _forceHorizontalBar;
  72794. private _forceVerticalBar;
  72795. /**
  72796. * Forces the horizontal scroll bar to be displayed
  72797. */
  72798. get forceHorizontalBar(): boolean;
  72799. set forceHorizontalBar(value: boolean);
  72800. /**
  72801. * Forces the vertical scroll bar to be displayed
  72802. */
  72803. get forceVerticalBar(): boolean;
  72804. set forceVerticalBar(value: boolean);
  72805. /**
  72806. * Creates a new ScrollViewer
  72807. * @param name of ScrollViewer
  72808. */
  72809. constructor(name?: string, isImageBased?: boolean);
  72810. /** Reset the scroll viewer window to initial size */
  72811. resetWindow(): void;
  72812. protected _getTypeName(): string;
  72813. private _buildClientSizes;
  72814. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72815. protected _postMeasure(): void;
  72816. /**
  72817. * Gets or sets the mouse wheel precision
  72818. * from 0 to 1 with a default value of 0.05
  72819. * */
  72820. get wheelPrecision(): number;
  72821. set wheelPrecision(value: number);
  72822. /** Gets or sets the scroll bar container background color */
  72823. get scrollBackground(): string;
  72824. set scrollBackground(color: string);
  72825. /** Gets or sets the bar color */
  72826. get barColor(): string;
  72827. set barColor(color: string);
  72828. /** Gets or sets the bar image */
  72829. get thumbImage(): Image;
  72830. set thumbImage(value: Image);
  72831. /** Gets or sets the horizontal bar image */
  72832. get horizontalThumbImage(): Image;
  72833. set horizontalThumbImage(value: Image);
  72834. /** Gets or sets the vertical bar image */
  72835. get verticalThumbImage(): Image;
  72836. set verticalThumbImage(value: Image);
  72837. /** Gets or sets the size of the bar */
  72838. get barSize(): number;
  72839. set barSize(value: number);
  72840. /** Gets or sets the length of the thumb */
  72841. get thumbLength(): number;
  72842. set thumbLength(value: number);
  72843. /** Gets or sets the height of the thumb */
  72844. get thumbHeight(): number;
  72845. set thumbHeight(value: number);
  72846. /** Gets or sets the height of the bar image */
  72847. get barImageHeight(): number;
  72848. set barImageHeight(value: number);
  72849. /** Gets or sets the height of the horizontal bar image */
  72850. get horizontalBarImageHeight(): number;
  72851. set horizontalBarImageHeight(value: number);
  72852. /** Gets or sets the height of the vertical bar image */
  72853. get verticalBarImageHeight(): number;
  72854. set verticalBarImageHeight(value: number);
  72855. /** Gets or sets the bar background */
  72856. get barBackground(): string;
  72857. set barBackground(color: string);
  72858. /** Gets or sets the bar background image */
  72859. get barImage(): Image;
  72860. set barImage(value: Image);
  72861. /** Gets or sets the horizontal bar background image */
  72862. get horizontalBarImage(): Image;
  72863. set horizontalBarImage(value: Image);
  72864. /** Gets or sets the vertical bar background image */
  72865. get verticalBarImage(): Image;
  72866. set verticalBarImage(value: Image);
  72867. private _setWindowPosition;
  72868. /** @hidden */
  72869. private _updateScroller;
  72870. _link(host: AdvancedDynamicTexture): void;
  72871. /** @hidden */
  72872. private _addBar;
  72873. /** @hidden */
  72874. private _attachWheel;
  72875. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72876. /** Releases associated resources */
  72877. dispose(): void;
  72878. }
  72879. }
  72880. declare module BABYLON.GUI {
  72881. /** Class used to render a grid */
  72882. export class DisplayGrid extends Control {
  72883. name?: string | undefined;
  72884. private _cellWidth;
  72885. private _cellHeight;
  72886. private _minorLineTickness;
  72887. private _minorLineColor;
  72888. private _majorLineTickness;
  72889. private _majorLineColor;
  72890. private _majorLineFrequency;
  72891. private _background;
  72892. private _displayMajorLines;
  72893. private _displayMinorLines;
  72894. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  72895. get displayMinorLines(): boolean;
  72896. set displayMinorLines(value: boolean);
  72897. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  72898. get displayMajorLines(): boolean;
  72899. set displayMajorLines(value: boolean);
  72900. /** Gets or sets background color (Black by default) */
  72901. get background(): string;
  72902. set background(value: string);
  72903. /** Gets or sets the width of each cell (20 by default) */
  72904. get cellWidth(): number;
  72905. set cellWidth(value: number);
  72906. /** Gets or sets the height of each cell (20 by default) */
  72907. get cellHeight(): number;
  72908. set cellHeight(value: number);
  72909. /** Gets or sets the tickness of minor lines (1 by default) */
  72910. get minorLineTickness(): number;
  72911. set minorLineTickness(value: number);
  72912. /** Gets or sets the color of minor lines (DarkGray by default) */
  72913. get minorLineColor(): string;
  72914. set minorLineColor(value: string);
  72915. /** Gets or sets the tickness of major lines (2 by default) */
  72916. get majorLineTickness(): number;
  72917. set majorLineTickness(value: number);
  72918. /** Gets or sets the color of major lines (White by default) */
  72919. get majorLineColor(): string;
  72920. set majorLineColor(value: string);
  72921. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  72922. get majorLineFrequency(): number;
  72923. set majorLineFrequency(value: number);
  72924. /**
  72925. * Creates a new GridDisplayRectangle
  72926. * @param name defines the control name
  72927. */
  72928. constructor(name?: string | undefined);
  72929. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72930. protected _getTypeName(): string;
  72931. }
  72932. }
  72933. declare module BABYLON.GUI {
  72934. /**
  72935. * Class used to create slider controls based on images
  72936. */
  72937. export class ImageBasedSlider extends BaseSlider {
  72938. name?: string | undefined;
  72939. private _backgroundImage;
  72940. private _thumbImage;
  72941. private _valueBarImage;
  72942. private _tempMeasure;
  72943. get displayThumb(): boolean;
  72944. set displayThumb(value: boolean);
  72945. /**
  72946. * Gets or sets the image used to render the background
  72947. */
  72948. get backgroundImage(): Image;
  72949. set backgroundImage(value: Image);
  72950. /**
  72951. * Gets or sets the image used to render the value bar
  72952. */
  72953. get valueBarImage(): Image;
  72954. set valueBarImage(value: Image);
  72955. /**
  72956. * Gets or sets the image used to render the thumb
  72957. */
  72958. get thumbImage(): Image;
  72959. set thumbImage(value: Image);
  72960. /**
  72961. * Creates a new ImageBasedSlider
  72962. * @param name defines the control name
  72963. */
  72964. constructor(name?: string | undefined);
  72965. protected _getTypeName(): string;
  72966. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72967. }
  72968. }
  72969. declare module BABYLON.GUI {
  72970. /**
  72971. * Forcing an export so that this code will execute
  72972. * @hidden
  72973. */
  72974. const name = "Statics";
  72975. }
  72976. declare module BABYLON.GUI {
  72977. /**
  72978. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  72979. */
  72980. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  72981. /**
  72982. * Define the instrumented AdvancedDynamicTexture.
  72983. */
  72984. texture: AdvancedDynamicTexture;
  72985. private _captureRenderTime;
  72986. private _renderTime;
  72987. private _captureLayoutTime;
  72988. private _layoutTime;
  72989. private _onBeginRenderObserver;
  72990. private _onEndRenderObserver;
  72991. private _onBeginLayoutObserver;
  72992. private _onEndLayoutObserver;
  72993. /**
  72994. * Gets the perf counter used to capture render time
  72995. */
  72996. get renderTimeCounter(): BABYLON.PerfCounter;
  72997. /**
  72998. * Gets the perf counter used to capture layout time
  72999. */
  73000. get layoutTimeCounter(): BABYLON.PerfCounter;
  73001. /**
  73002. * Enable or disable the render time capture
  73003. */
  73004. get captureRenderTime(): boolean;
  73005. set captureRenderTime(value: boolean);
  73006. /**
  73007. * Enable or disable the layout time capture
  73008. */
  73009. get captureLayoutTime(): boolean;
  73010. set captureLayoutTime(value: boolean);
  73011. /**
  73012. * Instantiates a new advanced dynamic texture instrumentation.
  73013. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73014. * @param texture Defines the AdvancedDynamicTexture to instrument
  73015. */
  73016. constructor(
  73017. /**
  73018. * Define the instrumented AdvancedDynamicTexture.
  73019. */
  73020. texture: AdvancedDynamicTexture);
  73021. /**
  73022. * Dispose and release associated resources.
  73023. */
  73024. dispose(): void;
  73025. }
  73026. }
  73027. declare module BABYLON.GUI {
  73028. /**
  73029. * Class used to load GUI via XML.
  73030. */
  73031. export class XmlLoader {
  73032. private _nodes;
  73033. private _nodeTypes;
  73034. private _isLoaded;
  73035. private _objectAttributes;
  73036. private _parentClass;
  73037. /**
  73038. * Create a new xml loader
  73039. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73040. */
  73041. constructor(parentClass?: null);
  73042. private _getChainElement;
  73043. private _getClassAttribute;
  73044. private _createGuiElement;
  73045. private _parseGrid;
  73046. private _parseElement;
  73047. private _prepareSourceElement;
  73048. private _parseElementsFromSource;
  73049. private _parseXml;
  73050. /**
  73051. * Gets if the loading has finished.
  73052. * @returns whether the loading has finished or not
  73053. */
  73054. isLoaded(): boolean;
  73055. /**
  73056. * Gets a loaded node / control by id.
  73057. * @param id the Controls id set in the xml
  73058. * @returns element of type Control
  73059. */
  73060. getNodeById(id: string): any;
  73061. /**
  73062. * Gets all loaded nodes / controls
  73063. * @returns Array of controls
  73064. */
  73065. getNodes(): any;
  73066. /**
  73067. * Initiates the xml layout loading
  73068. * @param xmlFile defines the xml layout to load
  73069. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73070. * @param callback defines the callback called on layout load.
  73071. */
  73072. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73073. }
  73074. }
  73075. declare module BABYLON.GUI {
  73076. /**
  73077. * Class used to create containers for controls
  73078. */
  73079. export class Container3D extends Control3D {
  73080. private _blockLayout;
  73081. /**
  73082. * Gets the list of child controls
  73083. */
  73084. protected _children: Control3D[];
  73085. /**
  73086. * Gets the list of child controls
  73087. */
  73088. get children(): Array<Control3D>;
  73089. /**
  73090. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73091. * This is helpful to optimize layout operation when adding multiple children in a row
  73092. */
  73093. get blockLayout(): boolean;
  73094. set blockLayout(value: boolean);
  73095. /**
  73096. * Creates a new container
  73097. * @param name defines the container name
  73098. */
  73099. constructor(name?: string);
  73100. /**
  73101. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73102. * @returns the current container
  73103. */
  73104. updateLayout(): Container3D;
  73105. /**
  73106. * Gets a boolean indicating if the given control is in the children of this control
  73107. * @param control defines the control to check
  73108. * @returns true if the control is in the child list
  73109. */
  73110. containsControl(control: Control3D): boolean;
  73111. /**
  73112. * Adds a control to the children of this control
  73113. * @param control defines the control to add
  73114. * @returns the current container
  73115. */
  73116. addControl(control: Control3D): Container3D;
  73117. /**
  73118. * This function will be called everytime a new control is added
  73119. */
  73120. protected _arrangeChildren(): void;
  73121. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73122. /**
  73123. * Removes a control from the children of this control
  73124. * @param control defines the control to remove
  73125. * @returns the current container
  73126. */
  73127. removeControl(control: Control3D): Container3D;
  73128. protected _getTypeName(): string;
  73129. /**
  73130. * Releases all associated resources
  73131. */
  73132. dispose(): void;
  73133. /** Control rotation will remain unchanged */
  73134. static readonly UNSET_ORIENTATION: number;
  73135. /** Control will rotate to make it look at sphere central axis */
  73136. static readonly FACEORIGIN_ORIENTATION: number;
  73137. /** Control will rotate to make it look back at sphere central axis */
  73138. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73139. /** Control will rotate to look at z axis (0, 0, 1) */
  73140. static readonly FACEFORWARD_ORIENTATION: number;
  73141. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73142. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73143. }
  73144. }
  73145. declare module BABYLON.GUI {
  73146. /**
  73147. * Class used to manage 3D user interface
  73148. * @see http://doc.babylonjs.com/how_to/gui3d
  73149. */
  73150. export class GUI3DManager implements BABYLON.IDisposable {
  73151. private _scene;
  73152. private _sceneDisposeObserver;
  73153. private _utilityLayer;
  73154. private _rootContainer;
  73155. private _pointerObserver;
  73156. private _pointerOutObserver;
  73157. /** @hidden */
  73158. _lastPickedControl: Control3D;
  73159. /** @hidden */
  73160. _lastControlOver: {
  73161. [pointerId: number]: Control3D;
  73162. };
  73163. /** @hidden */
  73164. _lastControlDown: {
  73165. [pointerId: number]: Control3D;
  73166. };
  73167. /**
  73168. * BABYLON.Observable raised when the point picked by the pointer events changed
  73169. */
  73170. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73171. /** @hidden */
  73172. _sharedMaterials: {
  73173. [key: string]: BABYLON.Material;
  73174. };
  73175. /** Gets the hosting scene */
  73176. get scene(): BABYLON.Scene;
  73177. /** Gets associated utility layer */
  73178. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73179. /**
  73180. * Creates a new GUI3DManager
  73181. * @param scene
  73182. */
  73183. constructor(scene?: BABYLON.Scene);
  73184. private _handlePointerOut;
  73185. private _doPicking;
  73186. /**
  73187. * Gets the root container
  73188. */
  73189. get rootContainer(): Container3D;
  73190. /**
  73191. * Gets a boolean indicating if the given control is in the root child list
  73192. * @param control defines the control to check
  73193. * @returns true if the control is in the root child list
  73194. */
  73195. containsControl(control: Control3D): boolean;
  73196. /**
  73197. * Adds a control to the root child list
  73198. * @param control defines the control to add
  73199. * @returns the current manager
  73200. */
  73201. addControl(control: Control3D): GUI3DManager;
  73202. /**
  73203. * Removes a control from the root child list
  73204. * @param control defines the control to remove
  73205. * @returns the current container
  73206. */
  73207. removeControl(control: Control3D): GUI3DManager;
  73208. /**
  73209. * Releases all associated resources
  73210. */
  73211. dispose(): void;
  73212. }
  73213. }
  73214. declare module BABYLON.GUI {
  73215. /**
  73216. * Class used to transport BABYLON.Vector3 information for pointer events
  73217. */
  73218. export class Vector3WithInfo extends BABYLON.Vector3 {
  73219. /** defines the current mouse button index */
  73220. buttonIndex: number;
  73221. /**
  73222. * Creates a new Vector3WithInfo
  73223. * @param source defines the vector3 data to transport
  73224. * @param buttonIndex defines the current mouse button index
  73225. */
  73226. constructor(source: BABYLON.Vector3,
  73227. /** defines the current mouse button index */
  73228. buttonIndex?: number);
  73229. }
  73230. }
  73231. declare module BABYLON.GUI {
  73232. /**
  73233. * Class used as base class for controls
  73234. */
  73235. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73236. /** Defines the control name */
  73237. name?: string | undefined;
  73238. /** @hidden */
  73239. _host: GUI3DManager;
  73240. private _node;
  73241. private _downCount;
  73242. private _enterCount;
  73243. private _downPointerIds;
  73244. private _isVisible;
  73245. /** Gets or sets the control position in world space */
  73246. get position(): BABYLON.Vector3;
  73247. set position(value: BABYLON.Vector3);
  73248. /** Gets or sets the control scaling in world space */
  73249. get scaling(): BABYLON.Vector3;
  73250. set scaling(value: BABYLON.Vector3);
  73251. /** Callback used to start pointer enter animation */
  73252. pointerEnterAnimation: () => void;
  73253. /** Callback used to start pointer out animation */
  73254. pointerOutAnimation: () => void;
  73255. /** Callback used to start pointer down animation */
  73256. pointerDownAnimation: () => void;
  73257. /** Callback used to start pointer up animation */
  73258. pointerUpAnimation: () => void;
  73259. /**
  73260. * An event triggered when the pointer move over the control
  73261. */
  73262. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73263. /**
  73264. * An event triggered when the pointer move out of the control
  73265. */
  73266. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73267. /**
  73268. * An event triggered when the pointer taps the control
  73269. */
  73270. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73271. /**
  73272. * An event triggered when pointer is up
  73273. */
  73274. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73275. /**
  73276. * An event triggered when a control is clicked on (with a mouse)
  73277. */
  73278. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73279. /**
  73280. * An event triggered when pointer enters the control
  73281. */
  73282. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73283. /**
  73284. * Gets or sets the parent container
  73285. */
  73286. parent: BABYLON.Nullable<Container3D>;
  73287. private _behaviors;
  73288. /**
  73289. * Gets the list of attached behaviors
  73290. * @see http://doc.babylonjs.com/features/behaviour
  73291. */
  73292. get behaviors(): BABYLON.Behavior<Control3D>[];
  73293. /**
  73294. * Attach a behavior to the control
  73295. * @see http://doc.babylonjs.com/features/behaviour
  73296. * @param behavior defines the behavior to attach
  73297. * @returns the current control
  73298. */
  73299. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73300. /**
  73301. * Remove an attached behavior
  73302. * @see http://doc.babylonjs.com/features/behaviour
  73303. * @param behavior defines the behavior to attach
  73304. * @returns the current control
  73305. */
  73306. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73307. /**
  73308. * Gets an attached behavior by name
  73309. * @param name defines the name of the behavior to look for
  73310. * @see http://doc.babylonjs.com/features/behaviour
  73311. * @returns null if behavior was not found else the requested behavior
  73312. */
  73313. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73314. /** Gets or sets a boolean indicating if the control is visible */
  73315. get isVisible(): boolean;
  73316. set isVisible(value: boolean);
  73317. /**
  73318. * Creates a new control
  73319. * @param name defines the control name
  73320. */
  73321. constructor(
  73322. /** Defines the control name */
  73323. name?: string | undefined);
  73324. /**
  73325. * Gets a string representing the class name
  73326. */
  73327. get typeName(): string;
  73328. /**
  73329. * Get the current class name of the control.
  73330. * @returns current class name
  73331. */
  73332. getClassName(): string;
  73333. protected _getTypeName(): string;
  73334. /**
  73335. * Gets the transform node used by this control
  73336. */
  73337. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73338. /**
  73339. * Gets the mesh used to render this control
  73340. */
  73341. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73342. /**
  73343. * Link the control as child of the given node
  73344. * @param node defines the node to link to. Use null to unlink the control
  73345. * @returns the current control
  73346. */
  73347. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73348. /** @hidden **/
  73349. _prepareNode(scene: BABYLON.Scene): void;
  73350. /**
  73351. * Node creation.
  73352. * Can be overriden by children
  73353. * @param scene defines the scene where the node must be attached
  73354. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73355. */
  73356. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73357. /**
  73358. * Affect a material to the given mesh
  73359. * @param mesh defines the mesh which will represent the control
  73360. */
  73361. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73362. /** @hidden */
  73363. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73364. /** @hidden */
  73365. _onPointerEnter(target: Control3D): boolean;
  73366. /** @hidden */
  73367. _onPointerOut(target: Control3D): void;
  73368. /** @hidden */
  73369. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73370. /** @hidden */
  73371. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73372. /** @hidden */
  73373. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73374. /** @hidden */
  73375. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73376. /** @hidden */
  73377. _disposeNode(): void;
  73378. /**
  73379. * Releases all associated resources
  73380. */
  73381. dispose(): void;
  73382. }
  73383. }
  73384. declare module BABYLON.GUI {
  73385. /**
  73386. * Class used as a root to all buttons
  73387. */
  73388. export class AbstractButton3D extends Control3D {
  73389. /**
  73390. * Creates a new button
  73391. * @param name defines the control name
  73392. */
  73393. constructor(name?: string);
  73394. protected _getTypeName(): string;
  73395. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73396. }
  73397. }
  73398. declare module BABYLON.GUI {
  73399. /**
  73400. * Class used to create a button in 3D
  73401. */
  73402. export class Button3D extends AbstractButton3D {
  73403. /** @hidden */
  73404. protected _currentMaterial: BABYLON.Material;
  73405. private _facadeTexture;
  73406. private _content;
  73407. private _contentResolution;
  73408. private _contentScaleRatio;
  73409. /**
  73410. * Gets or sets the texture resolution used to render content (512 by default)
  73411. */
  73412. get contentResolution(): BABYLON.int;
  73413. set contentResolution(value: BABYLON.int);
  73414. /**
  73415. * Gets or sets the texture scale ratio used to render content (2 by default)
  73416. */
  73417. get contentScaleRatio(): number;
  73418. set contentScaleRatio(value: number);
  73419. protected _disposeFacadeTexture(): void;
  73420. protected _resetContent(): void;
  73421. /**
  73422. * Creates a new button
  73423. * @param name defines the control name
  73424. */
  73425. constructor(name?: string);
  73426. /**
  73427. * Gets or sets the GUI 2D content used to display the button's facade
  73428. */
  73429. get content(): Control;
  73430. set content(value: Control);
  73431. /**
  73432. * Apply the facade texture (created from the content property).
  73433. * This function can be overloaded by child classes
  73434. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73435. */
  73436. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73437. protected _getTypeName(): string;
  73438. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73439. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73440. /**
  73441. * Releases all associated resources
  73442. */
  73443. dispose(): void;
  73444. }
  73445. }
  73446. declare module BABYLON.GUI {
  73447. /**
  73448. * Abstract class used to create a container panel deployed on the surface of a volume
  73449. */
  73450. export abstract class VolumeBasedPanel extends Container3D {
  73451. private _columns;
  73452. private _rows;
  73453. private _rowThenColum;
  73454. private _orientation;
  73455. protected _cellWidth: number;
  73456. protected _cellHeight: number;
  73457. /**
  73458. * Gets or sets the distance between elements
  73459. */
  73460. margin: number;
  73461. /**
  73462. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73463. * | Value | Type | Description |
  73464. * | ----- | ----------------------------------- | ----------- |
  73465. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73466. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73467. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73468. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73469. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73470. */
  73471. get orientation(): number;
  73472. set orientation(value: number);
  73473. /**
  73474. * Gets or sets the number of columns requested (10 by default).
  73475. * The panel will automatically compute the number of rows based on number of child controls.
  73476. */
  73477. get columns(): BABYLON.int;
  73478. set columns(value: BABYLON.int);
  73479. /**
  73480. * Gets or sets a the number of rows requested.
  73481. * The panel will automatically compute the number of columns based on number of child controls.
  73482. */
  73483. get rows(): BABYLON.int;
  73484. set rows(value: BABYLON.int);
  73485. /**
  73486. * Creates new VolumeBasedPanel
  73487. */
  73488. constructor();
  73489. protected _arrangeChildren(): void;
  73490. /** Child classes must implement this function to provide correct control positioning */
  73491. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73492. /** Child classes can implement this function to provide additional processing */
  73493. protected _finalProcessing(): void;
  73494. }
  73495. }
  73496. declare module BABYLON.GUI {
  73497. /**
  73498. * Class used to create a container panel deployed on the surface of a cylinder
  73499. */
  73500. export class CylinderPanel extends VolumeBasedPanel {
  73501. private _radius;
  73502. /**
  73503. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73504. */
  73505. get radius(): BABYLON.float;
  73506. set radius(value: BABYLON.float);
  73507. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73508. private _cylindricalMapping;
  73509. }
  73510. }
  73511. declare module BABYLON.GUI {
  73512. /** @hidden */
  73513. export var fluentVertexShader: {
  73514. name: string;
  73515. shader: string;
  73516. };
  73517. }
  73518. declare module BABYLON.GUI {
  73519. /** @hidden */
  73520. export var fluentPixelShader: {
  73521. name: string;
  73522. shader: string;
  73523. };
  73524. }
  73525. declare module BABYLON.GUI {
  73526. /** @hidden */
  73527. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73528. INNERGLOW: boolean;
  73529. BORDER: boolean;
  73530. HOVERLIGHT: boolean;
  73531. TEXTURE: boolean;
  73532. constructor();
  73533. }
  73534. /**
  73535. * Class used to render controls with fluent desgin
  73536. */
  73537. export class FluentMaterial extends BABYLON.PushMaterial {
  73538. /**
  73539. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73540. */
  73541. innerGlowColorIntensity: number;
  73542. /**
  73543. * Gets or sets the inner glow color (white by default)
  73544. */
  73545. innerGlowColor: BABYLON.Color3;
  73546. /**
  73547. * Gets or sets alpha value (default is 1.0)
  73548. */
  73549. alpha: number;
  73550. /**
  73551. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73552. */
  73553. albedoColor: BABYLON.Color3;
  73554. /**
  73555. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73556. */
  73557. renderBorders: boolean;
  73558. /**
  73559. * Gets or sets border width (default is 0.5)
  73560. */
  73561. borderWidth: number;
  73562. /**
  73563. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73564. */
  73565. edgeSmoothingValue: number;
  73566. /**
  73567. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73568. */
  73569. borderMinValue: number;
  73570. /**
  73571. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73572. */
  73573. renderHoverLight: boolean;
  73574. /**
  73575. * Gets or sets the radius used to render the hover light (default is 1.0)
  73576. */
  73577. hoverRadius: number;
  73578. /**
  73579. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73580. */
  73581. hoverColor: BABYLON.Color4;
  73582. /**
  73583. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73584. */
  73585. hoverPosition: BABYLON.Vector3;
  73586. private _albedoTexture;
  73587. /** Gets or sets the texture to use for albedo color */
  73588. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73589. /**
  73590. * Creates a new Fluent material
  73591. * @param name defines the name of the material
  73592. * @param scene defines the hosting scene
  73593. */
  73594. constructor(name: string, scene: BABYLON.Scene);
  73595. needAlphaBlending(): boolean;
  73596. needAlphaTesting(): boolean;
  73597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73600. getActiveTextures(): BABYLON.BaseTexture[];
  73601. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73602. dispose(forceDisposeEffect?: boolean): void;
  73603. clone(name: string): FluentMaterial;
  73604. serialize(): any;
  73605. getClassName(): string;
  73606. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73607. }
  73608. }
  73609. declare module BABYLON.GUI {
  73610. /**
  73611. * Class used to create a holographic button in 3D
  73612. */
  73613. export class HolographicButton extends Button3D {
  73614. private _backPlate;
  73615. private _textPlate;
  73616. private _frontPlate;
  73617. private _text;
  73618. private _imageUrl;
  73619. private _shareMaterials;
  73620. private _frontMaterial;
  73621. private _backMaterial;
  73622. private _plateMaterial;
  73623. private _pickedPointObserver;
  73624. private _tooltipFade;
  73625. private _tooltipTextBlock;
  73626. private _tooltipTexture;
  73627. private _tooltipMesh;
  73628. private _tooltipHoverObserver;
  73629. private _tooltipOutObserver;
  73630. private _disposeTooltip;
  73631. /**
  73632. * Rendering ground id of all the mesh in the button
  73633. */
  73634. set renderingGroupId(id: number);
  73635. get renderingGroupId(): number;
  73636. /**
  73637. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73638. */
  73639. set tooltipText(text: BABYLON.Nullable<string>);
  73640. get tooltipText(): BABYLON.Nullable<string>;
  73641. /**
  73642. * Gets or sets text for the button
  73643. */
  73644. get text(): string;
  73645. set text(value: string);
  73646. /**
  73647. * Gets or sets the image url for the button
  73648. */
  73649. get imageUrl(): string;
  73650. set imageUrl(value: string);
  73651. /**
  73652. * Gets the back material used by this button
  73653. */
  73654. get backMaterial(): FluentMaterial;
  73655. /**
  73656. * Gets the front material used by this button
  73657. */
  73658. get frontMaterial(): FluentMaterial;
  73659. /**
  73660. * Gets the plate material used by this button
  73661. */
  73662. get plateMaterial(): BABYLON.StandardMaterial;
  73663. /**
  73664. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73665. */
  73666. get shareMaterials(): boolean;
  73667. /**
  73668. * Creates a new button
  73669. * @param name defines the control name
  73670. */
  73671. constructor(name?: string, shareMaterials?: boolean);
  73672. protected _getTypeName(): string;
  73673. private _rebuildContent;
  73674. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73675. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73676. private _createBackMaterial;
  73677. private _createFrontMaterial;
  73678. private _createPlateMaterial;
  73679. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73680. /**
  73681. * Releases all associated resources
  73682. */
  73683. dispose(): void;
  73684. }
  73685. }
  73686. declare module BABYLON.GUI {
  73687. /**
  73688. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73689. */
  73690. export class MeshButton3D extends Button3D {
  73691. /** @hidden */
  73692. protected _currentMesh: BABYLON.Mesh;
  73693. /**
  73694. * Creates a new 3D button based on a mesh
  73695. * @param mesh mesh to become a 3D button
  73696. * @param name defines the control name
  73697. */
  73698. constructor(mesh: BABYLON.Mesh, name?: string);
  73699. protected _getTypeName(): string;
  73700. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73701. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73702. }
  73703. }
  73704. declare module BABYLON.GUI {
  73705. /**
  73706. * Class used to create a container panel deployed on the surface of a plane
  73707. */
  73708. export class PlanePanel extends VolumeBasedPanel {
  73709. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73710. }
  73711. }
  73712. declare module BABYLON.GUI {
  73713. /**
  73714. * Class used to create a container panel where items get randomized planar mapping
  73715. */
  73716. export class ScatterPanel extends VolumeBasedPanel {
  73717. private _iteration;
  73718. /**
  73719. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73720. */
  73721. get iteration(): BABYLON.float;
  73722. set iteration(value: BABYLON.float);
  73723. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73724. private _scatterMapping;
  73725. protected _finalProcessing(): void;
  73726. }
  73727. }
  73728. declare module BABYLON.GUI {
  73729. /**
  73730. * Class used to create a container panel deployed on the surface of a sphere
  73731. */
  73732. export class SpherePanel extends VolumeBasedPanel {
  73733. private _radius;
  73734. /**
  73735. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73736. */
  73737. get radius(): BABYLON.float;
  73738. set radius(value: BABYLON.float);
  73739. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73740. private _sphericalMapping;
  73741. }
  73742. }
  73743. declare module BABYLON.GUI {
  73744. /**
  73745. * Class used to create a stack panel in 3D on XY plane
  73746. */
  73747. export class StackPanel3D extends Container3D {
  73748. private _isVertical;
  73749. /**
  73750. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  73751. */
  73752. get isVertical(): boolean;
  73753. set isVertical(value: boolean);
  73754. /**
  73755. * Gets or sets the distance between elements
  73756. */
  73757. margin: number;
  73758. /**
  73759. * Creates new StackPanel
  73760. * @param isVertical
  73761. */
  73762. constructor(isVertical?: boolean);
  73763. protected _arrangeChildren(): void;
  73764. }
  73765. }
  73766. declare module BABYLON {
  73767. /**
  73768. * Configuration for glTF validation
  73769. */
  73770. export interface IGLTFValidationConfiguration {
  73771. /**
  73772. * The url of the glTF validator.
  73773. */
  73774. url: string;
  73775. }
  73776. /**
  73777. * glTF validation
  73778. */
  73779. export class GLTFValidation {
  73780. /**
  73781. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  73782. */
  73783. static Configuration: IGLTFValidationConfiguration;
  73784. private static _LoadScriptPromise;
  73785. /**
  73786. * Validate a glTF asset using the glTF-Validator.
  73787. * @param data The JSON of a glTF or the array buffer of a binary glTF
  73788. * @param rootUrl The root url for the glTF
  73789. * @param fileName The file name for the glTF
  73790. * @param getExternalResource The callback to get external resources for the glTF validator
  73791. * @returns A promise that resolves with the glTF validation results once complete
  73792. */
  73793. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  73794. }
  73795. }
  73796. declare module BABYLON {
  73797. /**
  73798. * Mode that determines the coordinate system to use.
  73799. */
  73800. export enum GLTFLoaderCoordinateSystemMode {
  73801. /**
  73802. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  73803. */
  73804. AUTO = 0,
  73805. /**
  73806. * Sets the useRightHandedSystem flag on the scene.
  73807. */
  73808. FORCE_RIGHT_HANDED = 1
  73809. }
  73810. /**
  73811. * Mode that determines what animations will start.
  73812. */
  73813. export enum GLTFLoaderAnimationStartMode {
  73814. /**
  73815. * No animation will start.
  73816. */
  73817. NONE = 0,
  73818. /**
  73819. * The first animation will start.
  73820. */
  73821. FIRST = 1,
  73822. /**
  73823. * All animations will start.
  73824. */
  73825. ALL = 2
  73826. }
  73827. /**
  73828. * Interface that contains the data for the glTF asset.
  73829. */
  73830. export interface IGLTFLoaderData {
  73831. /**
  73832. * The object that represents the glTF JSON.
  73833. */
  73834. json: Object;
  73835. /**
  73836. * The BIN chunk of a binary glTF.
  73837. */
  73838. bin: Nullable<IDataBuffer>;
  73839. }
  73840. /**
  73841. * Interface for extending the loader.
  73842. */
  73843. export interface IGLTFLoaderExtension {
  73844. /**
  73845. * The name of this extension.
  73846. */
  73847. readonly name: string;
  73848. /**
  73849. * Defines whether this extension is enabled.
  73850. */
  73851. enabled: boolean;
  73852. /**
  73853. * Defines the order of this extension.
  73854. * The loader sorts the extensions using these values when loading.
  73855. */
  73856. order?: number;
  73857. }
  73858. /**
  73859. * Loader state.
  73860. */
  73861. export enum GLTFLoaderState {
  73862. /**
  73863. * The asset is loading.
  73864. */
  73865. LOADING = 0,
  73866. /**
  73867. * The asset is ready for rendering.
  73868. */
  73869. READY = 1,
  73870. /**
  73871. * The asset is completely loaded.
  73872. */
  73873. COMPLETE = 2
  73874. }
  73875. /** @hidden */
  73876. export interface IGLTFLoader extends IDisposable {
  73877. readonly state: Nullable<GLTFLoaderState>;
  73878. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  73879. meshes: AbstractMesh[];
  73880. particleSystems: IParticleSystem[];
  73881. skeletons: Skeleton[];
  73882. animationGroups: AnimationGroup[];
  73883. }>;
  73884. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  73885. }
  73886. /**
  73887. * File loader for loading glTF files into a scene.
  73888. */
  73889. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73890. /** @hidden */
  73891. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73892. /** @hidden */
  73893. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73894. /**
  73895. * Raised when the asset has been parsed
  73896. */
  73897. onParsedObservable: Observable<IGLTFLoaderData>;
  73898. private _onParsedObserver;
  73899. /**
  73900. * Raised when the asset has been parsed
  73901. */
  73902. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  73903. /**
  73904. * 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.
  73905. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  73906. * Defaults to true.
  73907. * @hidden
  73908. */
  73909. static IncrementalLoading: boolean;
  73910. /**
  73911. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  73912. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  73913. * @hidden
  73914. */
  73915. static HomogeneousCoordinates: boolean;
  73916. /**
  73917. * The coordinate system mode. Defaults to AUTO.
  73918. */
  73919. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  73920. /**
  73921. * The animation start mode. Defaults to FIRST.
  73922. */
  73923. animationStartMode: GLTFLoaderAnimationStartMode;
  73924. /**
  73925. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  73926. */
  73927. compileMaterials: boolean;
  73928. /**
  73929. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  73930. */
  73931. useClipPlane: boolean;
  73932. /**
  73933. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  73934. */
  73935. compileShadowGenerators: boolean;
  73936. /**
  73937. * Defines if the Alpha blended materials are only applied as coverage.
  73938. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  73939. * If true, no extra effects are applied to transparent pixels.
  73940. */
  73941. transparencyAsCoverage: boolean;
  73942. /**
  73943. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  73944. * Enabling will disable offline support and glTF validator.
  73945. * Defaults to false.
  73946. */
  73947. useRangeRequests: boolean;
  73948. /**
  73949. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  73950. */
  73951. createInstances: boolean;
  73952. /**
  73953. * Function called before loading a url referenced by the asset.
  73954. */
  73955. preprocessUrlAsync: (url: string) => Promise<string>;
  73956. /**
  73957. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73958. */
  73959. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  73960. private _onMeshLoadedObserver;
  73961. /**
  73962. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73963. */
  73964. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  73965. /**
  73966. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  73967. */
  73968. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  73969. private _onTextureLoadedObserver;
  73970. /**
  73971. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  73972. */
  73973. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  73974. /**
  73975. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  73976. */
  73977. readonly onMaterialLoadedObservable: Observable<Material>;
  73978. private _onMaterialLoadedObserver;
  73979. /**
  73980. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  73981. */
  73982. set onMaterialLoaded(callback: (material: Material) => void);
  73983. /**
  73984. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  73985. */
  73986. readonly onCameraLoadedObservable: Observable<Camera>;
  73987. private _onCameraLoadedObserver;
  73988. /**
  73989. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  73990. */
  73991. set onCameraLoaded(callback: (camera: Camera) => void);
  73992. /**
  73993. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  73994. * For assets with LODs, raised when all of the LODs are complete.
  73995. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73996. */
  73997. readonly onCompleteObservable: Observable<void>;
  73998. private _onCompleteObserver;
  73999. /**
  74000. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74001. * For assets with LODs, raised when all of the LODs are complete.
  74002. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74003. */
  74004. set onComplete(callback: () => void);
  74005. /**
  74006. * Observable raised when an error occurs.
  74007. */
  74008. readonly onErrorObservable: Observable<any>;
  74009. private _onErrorObserver;
  74010. /**
  74011. * Callback raised when an error occurs.
  74012. */
  74013. set onError(callback: (reason: any) => void);
  74014. /**
  74015. * Observable raised after the loader is disposed.
  74016. */
  74017. readonly onDisposeObservable: Observable<void>;
  74018. private _onDisposeObserver;
  74019. /**
  74020. * Callback raised after the loader is disposed.
  74021. */
  74022. set onDispose(callback: () => void);
  74023. /**
  74024. * Observable raised after a loader extension is created.
  74025. * Set additional options for a loader extension in this event.
  74026. */
  74027. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74028. private _onExtensionLoadedObserver;
  74029. /**
  74030. * Callback raised after a loader extension is created.
  74031. */
  74032. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74033. /**
  74034. * Defines if the loader logging is enabled.
  74035. */
  74036. get loggingEnabled(): boolean;
  74037. set loggingEnabled(value: boolean);
  74038. /**
  74039. * Defines if the loader should capture performance counters.
  74040. */
  74041. get capturePerformanceCounters(): boolean;
  74042. set capturePerformanceCounters(value: boolean);
  74043. /**
  74044. * Defines if the loader should validate the asset.
  74045. */
  74046. validate: boolean;
  74047. /**
  74048. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74049. */
  74050. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74051. private _onValidatedObserver;
  74052. /**
  74053. * Callback raised after a loader extension is created.
  74054. */
  74055. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74056. private _loader;
  74057. /**
  74058. * Name of the loader ("gltf")
  74059. */
  74060. name: string;
  74061. /** @hidden */
  74062. extensions: ISceneLoaderPluginExtensions;
  74063. /**
  74064. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74065. */
  74066. dispose(): void;
  74067. /** @hidden */
  74068. _clear(): void;
  74069. /** @hidden */
  74070. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74071. /** @hidden */
  74072. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74073. /** @hidden */
  74074. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74075. meshes: AbstractMesh[];
  74076. particleSystems: IParticleSystem[];
  74077. skeletons: Skeleton[];
  74078. animationGroups: AnimationGroup[];
  74079. }>;
  74080. /** @hidden */
  74081. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74082. /** @hidden */
  74083. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74084. /** @hidden */
  74085. canDirectLoad(data: string): boolean;
  74086. /** @hidden */
  74087. directLoad(scene: Scene, data: string): any;
  74088. /**
  74089. * The callback that allows custom handling of the root url based on the response url.
  74090. * @param rootUrl the original root url
  74091. * @param responseURL the response url if available
  74092. * @returns the new root url
  74093. */
  74094. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74095. /** @hidden */
  74096. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74097. /**
  74098. * The loader state or null if the loader is not active.
  74099. */
  74100. get loaderState(): Nullable<GLTFLoaderState>;
  74101. /**
  74102. * Returns a promise that resolves when the asset is completely loaded.
  74103. * @returns a promise that resolves when the asset is completely loaded.
  74104. */
  74105. whenCompleteAsync(): Promise<void>;
  74106. private _validate;
  74107. private _getLoader;
  74108. private _parseJson;
  74109. private _unpackBinaryAsync;
  74110. private _unpackBinaryV1Async;
  74111. private _unpackBinaryV2Async;
  74112. private static _parseVersion;
  74113. private static _compareVersion;
  74114. private static readonly _logSpaces;
  74115. private _logIndentLevel;
  74116. private _loggingEnabled;
  74117. /** @hidden */
  74118. _log: (message: string) => void;
  74119. /** @hidden */
  74120. _logOpen(message: string): void;
  74121. /** @hidden */
  74122. _logClose(): void;
  74123. private _logEnabled;
  74124. private _logDisabled;
  74125. private _capturePerformanceCounters;
  74126. /** @hidden */
  74127. _startPerformanceCounter: (counterName: string) => void;
  74128. /** @hidden */
  74129. _endPerformanceCounter: (counterName: string) => void;
  74130. private _startPerformanceCounterEnabled;
  74131. private _startPerformanceCounterDisabled;
  74132. private _endPerformanceCounterEnabled;
  74133. private _endPerformanceCounterDisabled;
  74134. }
  74135. }
  74136. declare module BABYLON.GLTF1 {
  74137. /**
  74138. * Enums
  74139. * @hidden
  74140. */
  74141. export enum EComponentType {
  74142. BYTE = 5120,
  74143. UNSIGNED_BYTE = 5121,
  74144. SHORT = 5122,
  74145. UNSIGNED_SHORT = 5123,
  74146. FLOAT = 5126
  74147. }
  74148. /** @hidden */
  74149. export enum EShaderType {
  74150. FRAGMENT = 35632,
  74151. VERTEX = 35633
  74152. }
  74153. /** @hidden */
  74154. export enum EParameterType {
  74155. BYTE = 5120,
  74156. UNSIGNED_BYTE = 5121,
  74157. SHORT = 5122,
  74158. UNSIGNED_SHORT = 5123,
  74159. INT = 5124,
  74160. UNSIGNED_INT = 5125,
  74161. FLOAT = 5126,
  74162. FLOAT_VEC2 = 35664,
  74163. FLOAT_VEC3 = 35665,
  74164. FLOAT_VEC4 = 35666,
  74165. INT_VEC2 = 35667,
  74166. INT_VEC3 = 35668,
  74167. INT_VEC4 = 35669,
  74168. BOOL = 35670,
  74169. BOOL_VEC2 = 35671,
  74170. BOOL_VEC3 = 35672,
  74171. BOOL_VEC4 = 35673,
  74172. FLOAT_MAT2 = 35674,
  74173. FLOAT_MAT3 = 35675,
  74174. FLOAT_MAT4 = 35676,
  74175. SAMPLER_2D = 35678
  74176. }
  74177. /** @hidden */
  74178. export enum ETextureWrapMode {
  74179. CLAMP_TO_EDGE = 33071,
  74180. MIRRORED_REPEAT = 33648,
  74181. REPEAT = 10497
  74182. }
  74183. /** @hidden */
  74184. export enum ETextureFilterType {
  74185. NEAREST = 9728,
  74186. LINEAR = 9728,
  74187. NEAREST_MIPMAP_NEAREST = 9984,
  74188. LINEAR_MIPMAP_NEAREST = 9985,
  74189. NEAREST_MIPMAP_LINEAR = 9986,
  74190. LINEAR_MIPMAP_LINEAR = 9987
  74191. }
  74192. /** @hidden */
  74193. export enum ETextureFormat {
  74194. ALPHA = 6406,
  74195. RGB = 6407,
  74196. RGBA = 6408,
  74197. LUMINANCE = 6409,
  74198. LUMINANCE_ALPHA = 6410
  74199. }
  74200. /** @hidden */
  74201. export enum ECullingType {
  74202. FRONT = 1028,
  74203. BACK = 1029,
  74204. FRONT_AND_BACK = 1032
  74205. }
  74206. /** @hidden */
  74207. export enum EBlendingFunction {
  74208. ZERO = 0,
  74209. ONE = 1,
  74210. SRC_COLOR = 768,
  74211. ONE_MINUS_SRC_COLOR = 769,
  74212. DST_COLOR = 774,
  74213. ONE_MINUS_DST_COLOR = 775,
  74214. SRC_ALPHA = 770,
  74215. ONE_MINUS_SRC_ALPHA = 771,
  74216. DST_ALPHA = 772,
  74217. ONE_MINUS_DST_ALPHA = 773,
  74218. CONSTANT_COLOR = 32769,
  74219. ONE_MINUS_CONSTANT_COLOR = 32770,
  74220. CONSTANT_ALPHA = 32771,
  74221. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74222. SRC_ALPHA_SATURATE = 776
  74223. }
  74224. /** @hidden */
  74225. export interface IGLTFProperty {
  74226. extensions?: {
  74227. [key: string]: any;
  74228. };
  74229. extras?: Object;
  74230. }
  74231. /** @hidden */
  74232. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74233. name?: string;
  74234. }
  74235. /** @hidden */
  74236. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74237. bufferView: string;
  74238. byteOffset: number;
  74239. byteStride: number;
  74240. count: number;
  74241. type: string;
  74242. componentType: EComponentType;
  74243. max?: number[];
  74244. min?: number[];
  74245. name?: string;
  74246. }
  74247. /** @hidden */
  74248. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74249. buffer: string;
  74250. byteOffset: number;
  74251. byteLength: number;
  74252. byteStride: number;
  74253. target?: number;
  74254. }
  74255. /** @hidden */
  74256. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74257. uri: string;
  74258. byteLength?: number;
  74259. type?: string;
  74260. }
  74261. /** @hidden */
  74262. export interface IGLTFShader extends IGLTFChildRootProperty {
  74263. uri: string;
  74264. type: EShaderType;
  74265. }
  74266. /** @hidden */
  74267. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74268. attributes: string[];
  74269. fragmentShader: string;
  74270. vertexShader: string;
  74271. }
  74272. /** @hidden */
  74273. export interface IGLTFTechniqueParameter {
  74274. type: number;
  74275. count?: number;
  74276. semantic?: string;
  74277. node?: string;
  74278. value?: number | boolean | string | Array<any>;
  74279. source?: string;
  74280. babylonValue?: any;
  74281. }
  74282. /** @hidden */
  74283. export interface IGLTFTechniqueCommonProfile {
  74284. lightingModel: string;
  74285. texcoordBindings: Object;
  74286. parameters?: Array<any>;
  74287. }
  74288. /** @hidden */
  74289. export interface IGLTFTechniqueStatesFunctions {
  74290. blendColor?: number[];
  74291. blendEquationSeparate?: number[];
  74292. blendFuncSeparate?: number[];
  74293. colorMask: boolean[];
  74294. cullFace: number[];
  74295. }
  74296. /** @hidden */
  74297. export interface IGLTFTechniqueStates {
  74298. enable: number[];
  74299. functions: IGLTFTechniqueStatesFunctions;
  74300. }
  74301. /** @hidden */
  74302. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74303. parameters: {
  74304. [key: string]: IGLTFTechniqueParameter;
  74305. };
  74306. program: string;
  74307. attributes: {
  74308. [key: string]: string;
  74309. };
  74310. uniforms: {
  74311. [key: string]: string;
  74312. };
  74313. states: IGLTFTechniqueStates;
  74314. }
  74315. /** @hidden */
  74316. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74317. technique?: string;
  74318. values: string[];
  74319. }
  74320. /** @hidden */
  74321. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74322. attributes: {
  74323. [key: string]: string;
  74324. };
  74325. indices: string;
  74326. material: string;
  74327. mode?: number;
  74328. }
  74329. /** @hidden */
  74330. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74331. primitives: IGLTFMeshPrimitive[];
  74332. }
  74333. /** @hidden */
  74334. export interface IGLTFImage extends IGLTFChildRootProperty {
  74335. uri: string;
  74336. }
  74337. /** @hidden */
  74338. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74339. magFilter?: number;
  74340. minFilter?: number;
  74341. wrapS?: number;
  74342. wrapT?: number;
  74343. }
  74344. /** @hidden */
  74345. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74346. sampler: string;
  74347. source: string;
  74348. format?: ETextureFormat;
  74349. internalFormat?: ETextureFormat;
  74350. target?: number;
  74351. type?: number;
  74352. babylonTexture?: Texture;
  74353. }
  74354. /** @hidden */
  74355. export interface IGLTFAmbienLight {
  74356. color?: number[];
  74357. }
  74358. /** @hidden */
  74359. export interface IGLTFDirectionalLight {
  74360. color?: number[];
  74361. }
  74362. /** @hidden */
  74363. export interface IGLTFPointLight {
  74364. color?: number[];
  74365. constantAttenuation?: number;
  74366. linearAttenuation?: number;
  74367. quadraticAttenuation?: number;
  74368. }
  74369. /** @hidden */
  74370. export interface IGLTFSpotLight {
  74371. color?: number[];
  74372. constantAttenuation?: number;
  74373. fallOfAngle?: number;
  74374. fallOffExponent?: number;
  74375. linearAttenuation?: number;
  74376. quadraticAttenuation?: number;
  74377. }
  74378. /** @hidden */
  74379. export interface IGLTFLight extends IGLTFChildRootProperty {
  74380. type: string;
  74381. }
  74382. /** @hidden */
  74383. export interface IGLTFCameraOrthographic {
  74384. xmag: number;
  74385. ymag: number;
  74386. zfar: number;
  74387. znear: number;
  74388. }
  74389. /** @hidden */
  74390. export interface IGLTFCameraPerspective {
  74391. aspectRatio: number;
  74392. yfov: number;
  74393. zfar: number;
  74394. znear: number;
  74395. }
  74396. /** @hidden */
  74397. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74398. type: string;
  74399. }
  74400. /** @hidden */
  74401. export interface IGLTFAnimationChannelTarget {
  74402. id: string;
  74403. path: string;
  74404. }
  74405. /** @hidden */
  74406. export interface IGLTFAnimationChannel {
  74407. sampler: string;
  74408. target: IGLTFAnimationChannelTarget;
  74409. }
  74410. /** @hidden */
  74411. export interface IGLTFAnimationSampler {
  74412. input: string;
  74413. output: string;
  74414. interpolation?: string;
  74415. }
  74416. /** @hidden */
  74417. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74418. channels?: IGLTFAnimationChannel[];
  74419. parameters?: {
  74420. [key: string]: string;
  74421. };
  74422. samplers?: {
  74423. [key: string]: IGLTFAnimationSampler;
  74424. };
  74425. }
  74426. /** @hidden */
  74427. export interface IGLTFNodeInstanceSkin {
  74428. skeletons: string[];
  74429. skin: string;
  74430. meshes: string[];
  74431. }
  74432. /** @hidden */
  74433. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74434. bindShapeMatrix: number[];
  74435. inverseBindMatrices: string;
  74436. jointNames: string[];
  74437. babylonSkeleton?: Skeleton;
  74438. }
  74439. /** @hidden */
  74440. export interface IGLTFNode extends IGLTFChildRootProperty {
  74441. camera?: string;
  74442. children: string[];
  74443. skin?: string;
  74444. jointName?: string;
  74445. light?: string;
  74446. matrix: number[];
  74447. mesh?: string;
  74448. meshes?: string[];
  74449. rotation?: number[];
  74450. scale?: number[];
  74451. translation?: number[];
  74452. babylonNode?: Node;
  74453. }
  74454. /** @hidden */
  74455. export interface IGLTFScene extends IGLTFChildRootProperty {
  74456. nodes: string[];
  74457. }
  74458. /** @hidden */
  74459. export interface IGLTFRuntime {
  74460. extensions: {
  74461. [key: string]: any;
  74462. };
  74463. accessors: {
  74464. [key: string]: IGLTFAccessor;
  74465. };
  74466. buffers: {
  74467. [key: string]: IGLTFBuffer;
  74468. };
  74469. bufferViews: {
  74470. [key: string]: IGLTFBufferView;
  74471. };
  74472. meshes: {
  74473. [key: string]: IGLTFMesh;
  74474. };
  74475. lights: {
  74476. [key: string]: IGLTFLight;
  74477. };
  74478. cameras: {
  74479. [key: string]: IGLTFCamera;
  74480. };
  74481. nodes: {
  74482. [key: string]: IGLTFNode;
  74483. };
  74484. images: {
  74485. [key: string]: IGLTFImage;
  74486. };
  74487. textures: {
  74488. [key: string]: IGLTFTexture;
  74489. };
  74490. shaders: {
  74491. [key: string]: IGLTFShader;
  74492. };
  74493. programs: {
  74494. [key: string]: IGLTFProgram;
  74495. };
  74496. samplers: {
  74497. [key: string]: IGLTFSampler;
  74498. };
  74499. techniques: {
  74500. [key: string]: IGLTFTechnique;
  74501. };
  74502. materials: {
  74503. [key: string]: IGLTFMaterial;
  74504. };
  74505. animations: {
  74506. [key: string]: IGLTFAnimation;
  74507. };
  74508. skins: {
  74509. [key: string]: IGLTFSkins;
  74510. };
  74511. currentScene?: Object;
  74512. scenes: {
  74513. [key: string]: IGLTFScene;
  74514. };
  74515. extensionsUsed: string[];
  74516. extensionsRequired?: string[];
  74517. buffersCount: number;
  74518. shaderscount: number;
  74519. scene: Scene;
  74520. rootUrl: string;
  74521. loadedBufferCount: number;
  74522. loadedBufferViews: {
  74523. [name: string]: ArrayBufferView;
  74524. };
  74525. loadedShaderCount: number;
  74526. importOnlyMeshes: boolean;
  74527. importMeshesNames?: string[];
  74528. dummyNodes: Node[];
  74529. }
  74530. /** @hidden */
  74531. export interface INodeToRoot {
  74532. bone: Bone;
  74533. node: IGLTFNode;
  74534. id: string;
  74535. }
  74536. /** @hidden */
  74537. export interface IJointNode {
  74538. node: IGLTFNode;
  74539. id: string;
  74540. }
  74541. }
  74542. declare module BABYLON.GLTF1 {
  74543. /**
  74544. * Utils functions for GLTF
  74545. * @hidden
  74546. */
  74547. export class GLTFUtils {
  74548. /**
  74549. * Sets the given "parameter" matrix
  74550. * @param scene: the Scene object
  74551. * @param source: the source node where to pick the matrix
  74552. * @param parameter: the GLTF technique parameter
  74553. * @param uniformName: the name of the shader's uniform
  74554. * @param shaderMaterial: the shader material
  74555. */
  74556. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74557. /**
  74558. * Sets the given "parameter" matrix
  74559. * @param shaderMaterial: the shader material
  74560. * @param uniform: the name of the shader's uniform
  74561. * @param value: the value of the uniform
  74562. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74563. */
  74564. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74565. /**
  74566. * Returns the wrap mode of the texture
  74567. * @param mode: the mode value
  74568. */
  74569. static GetWrapMode(mode: number): number;
  74570. /**
  74571. * Returns the byte stride giving an accessor
  74572. * @param accessor: the GLTF accessor objet
  74573. */
  74574. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74575. /**
  74576. * Returns the texture filter mode giving a mode value
  74577. * @param mode: the filter mode value
  74578. */
  74579. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74580. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74581. /**
  74582. * Returns a buffer from its accessor
  74583. * @param gltfRuntime: the GLTF runtime
  74584. * @param accessor: the GLTF accessor
  74585. */
  74586. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74587. /**
  74588. * Decodes a buffer view into a string
  74589. * @param view: the buffer view
  74590. */
  74591. static DecodeBufferToText(view: ArrayBufferView): string;
  74592. /**
  74593. * Returns the default material of gltf. Related to
  74594. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74595. * @param scene: the Babylon.js scene
  74596. */
  74597. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74598. private static _DefaultMaterial;
  74599. }
  74600. }
  74601. declare module BABYLON.GLTF1 {
  74602. /**
  74603. * Implementation of the base glTF spec
  74604. * @hidden
  74605. */
  74606. export class GLTFLoaderBase {
  74607. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74608. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74609. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74610. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74611. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74612. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74613. }
  74614. /**
  74615. * glTF V1 Loader
  74616. * @hidden
  74617. */
  74618. export class GLTFLoader implements IGLTFLoader {
  74619. static Extensions: {
  74620. [name: string]: GLTFLoaderExtension;
  74621. };
  74622. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74623. state: Nullable<GLTFLoaderState>;
  74624. dispose(): void;
  74625. private _importMeshAsync;
  74626. /**
  74627. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74628. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74629. * @param scene the scene the meshes should be added to
  74630. * @param data gltf data containing information of the meshes in a loaded file
  74631. * @param rootUrl root url to load from
  74632. * @param onProgress event that fires when loading progress has occured
  74633. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74634. */
  74635. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74636. meshes: AbstractMesh[];
  74637. particleSystems: IParticleSystem[];
  74638. skeletons: Skeleton[];
  74639. animationGroups: AnimationGroup[];
  74640. }>;
  74641. private _loadAsync;
  74642. /**
  74643. * Imports all objects from a loaded gltf file and adds them to the scene
  74644. * @param scene the scene the objects should be added to
  74645. * @param data gltf data containing information of the meshes in a loaded file
  74646. * @param rootUrl root url to load from
  74647. * @param onProgress event that fires when loading progress has occured
  74648. * @returns a promise which completes when objects have been loaded to the scene
  74649. */
  74650. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74651. private _loadShadersAsync;
  74652. private _loadBuffersAsync;
  74653. private _createNodes;
  74654. }
  74655. /** @hidden */
  74656. export abstract class GLTFLoaderExtension {
  74657. private _name;
  74658. constructor(name: string);
  74659. get name(): string;
  74660. /**
  74661. * Defines an override for loading the runtime
  74662. * Return true to stop further extensions from loading the runtime
  74663. */
  74664. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74665. /**
  74666. * Defines an onverride for creating gltf runtime
  74667. * Return true to stop further extensions from creating the runtime
  74668. */
  74669. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74670. /**
  74671. * Defines an override for loading buffers
  74672. * Return true to stop further extensions from loading this buffer
  74673. */
  74674. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74675. /**
  74676. * Defines an override for loading texture buffers
  74677. * Return true to stop further extensions from loading this texture data
  74678. */
  74679. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74680. /**
  74681. * Defines an override for creating textures
  74682. * Return true to stop further extensions from loading this texture
  74683. */
  74684. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74685. /**
  74686. * Defines an override for loading shader strings
  74687. * Return true to stop further extensions from loading this shader data
  74688. */
  74689. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74690. /**
  74691. * Defines an override for loading materials
  74692. * Return true to stop further extensions from loading this material
  74693. */
  74694. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74695. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74696. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74697. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74698. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74699. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74700. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74701. private static LoadTextureBufferAsync;
  74702. private static CreateTextureAsync;
  74703. private static ApplyExtensions;
  74704. }
  74705. }
  74706. declare module BABYLON.GLTF1 {
  74707. /** @hidden */
  74708. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74709. private _bin;
  74710. constructor();
  74711. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74712. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74713. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74714. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74715. }
  74716. }
  74717. declare module BABYLON.GLTF1 {
  74718. /** @hidden */
  74719. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74720. constructor();
  74721. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74722. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74723. private _loadTexture;
  74724. }
  74725. }
  74726. declare module BABYLON.GLTF2.Loader {
  74727. /**
  74728. * Loader interface with an index field.
  74729. */
  74730. export interface IArrayItem {
  74731. /**
  74732. * The index of this item in the array.
  74733. */
  74734. index: number;
  74735. }
  74736. /**
  74737. * Loader interface with additional members.
  74738. */
  74739. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  74740. /** @hidden */
  74741. _data?: Promise<ArrayBufferView>;
  74742. /** @hidden */
  74743. _babylonVertexBuffer?: Promise<VertexBuffer>;
  74744. }
  74745. /**
  74746. * Loader interface with additional members.
  74747. */
  74748. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  74749. }
  74750. /** @hidden */
  74751. export interface _IAnimationSamplerData {
  74752. input: Float32Array;
  74753. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  74754. output: Float32Array;
  74755. }
  74756. /**
  74757. * Loader interface with additional members.
  74758. */
  74759. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  74760. /** @hidden */
  74761. _data?: Promise<_IAnimationSamplerData>;
  74762. }
  74763. /**
  74764. * Loader interface with additional members.
  74765. */
  74766. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  74767. channels: IAnimationChannel[];
  74768. samplers: IAnimationSampler[];
  74769. /** @hidden */
  74770. _babylonAnimationGroup?: AnimationGroup;
  74771. }
  74772. /**
  74773. * Loader interface with additional members.
  74774. */
  74775. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  74776. /** @hidden */
  74777. _data?: Promise<ArrayBufferView>;
  74778. }
  74779. /**
  74780. * Loader interface with additional members.
  74781. */
  74782. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  74783. /** @hidden */
  74784. _data?: Promise<ArrayBufferView>;
  74785. /** @hidden */
  74786. _babylonBuffer?: Promise<Buffer>;
  74787. }
  74788. /**
  74789. * Loader interface with additional members.
  74790. */
  74791. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  74792. }
  74793. /**
  74794. * Loader interface with additional members.
  74795. */
  74796. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  74797. /** @hidden */
  74798. _data?: Promise<ArrayBufferView>;
  74799. }
  74800. /**
  74801. * Loader interface with additional members.
  74802. */
  74803. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  74804. }
  74805. /**
  74806. * Loader interface with additional members.
  74807. */
  74808. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  74809. }
  74810. /**
  74811. * Loader interface with additional members.
  74812. */
  74813. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  74814. baseColorTexture?: ITextureInfo;
  74815. metallicRoughnessTexture?: ITextureInfo;
  74816. }
  74817. /**
  74818. * Loader interface with additional members.
  74819. */
  74820. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  74821. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74822. normalTexture?: IMaterialNormalTextureInfo;
  74823. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74824. emissiveTexture?: ITextureInfo;
  74825. /** @hidden */
  74826. _data?: {
  74827. [babylonDrawMode: number]: {
  74828. babylonMaterial: Material;
  74829. babylonMeshes: AbstractMesh[];
  74830. promise: Promise<void>;
  74831. };
  74832. };
  74833. }
  74834. /**
  74835. * Loader interface with additional members.
  74836. */
  74837. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  74838. primitives: IMeshPrimitive[];
  74839. }
  74840. /**
  74841. * Loader interface with additional members.
  74842. */
  74843. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  74844. /** @hidden */
  74845. _instanceData?: {
  74846. babylonSourceMesh: Mesh;
  74847. promise: Promise<any>;
  74848. };
  74849. }
  74850. /**
  74851. * Loader interface with additional members.
  74852. */
  74853. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  74854. /**
  74855. * The parent glTF node.
  74856. */
  74857. parent?: INode;
  74858. /** @hidden */
  74859. _babylonTransformNode?: TransformNode;
  74860. /** @hidden */
  74861. _primitiveBabylonMeshes?: AbstractMesh[];
  74862. /** @hidden */
  74863. _babylonBones?: Bone[];
  74864. /** @hidden */
  74865. _numMorphTargets?: number;
  74866. }
  74867. /** @hidden */
  74868. export interface _ISamplerData {
  74869. noMipMaps: boolean;
  74870. samplingMode: number;
  74871. wrapU: number;
  74872. wrapV: number;
  74873. }
  74874. /**
  74875. * Loader interface with additional members.
  74876. */
  74877. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  74878. /** @hidden */
  74879. _data?: _ISamplerData;
  74880. }
  74881. /**
  74882. * Loader interface with additional members.
  74883. */
  74884. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  74885. }
  74886. /**
  74887. * Loader interface with additional members.
  74888. */
  74889. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  74890. /** @hidden */
  74891. _data?: {
  74892. babylonSkeleton: Skeleton;
  74893. promise: Promise<void>;
  74894. };
  74895. }
  74896. /**
  74897. * Loader interface with additional members.
  74898. */
  74899. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  74900. }
  74901. /**
  74902. * Loader interface with additional members.
  74903. */
  74904. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  74905. }
  74906. /**
  74907. * Loader interface with additional members.
  74908. */
  74909. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  74910. accessors?: IAccessor[];
  74911. animations?: IAnimation[];
  74912. buffers?: IBuffer[];
  74913. bufferViews?: IBufferView[];
  74914. cameras?: ICamera[];
  74915. images?: IImage[];
  74916. materials?: IMaterial[];
  74917. meshes?: IMesh[];
  74918. nodes?: INode[];
  74919. samplers?: ISampler[];
  74920. scenes?: IScene[];
  74921. skins?: ISkin[];
  74922. textures?: ITexture[];
  74923. }
  74924. }
  74925. declare module BABYLON.GLTF2 {
  74926. /**
  74927. * Interface for a glTF loader extension.
  74928. */
  74929. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  74930. /**
  74931. * Called after the loader state changes to LOADING.
  74932. */
  74933. onLoading?(): void;
  74934. /**
  74935. * Called after the loader state changes to READY.
  74936. */
  74937. onReady?(): void;
  74938. /**
  74939. * Define this method to modify the default behavior when loading scenes.
  74940. * @param context The context when loading the asset
  74941. * @param scene The glTF scene property
  74942. * @returns A promise that resolves when the load is complete or null if not handled
  74943. */
  74944. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  74945. /**
  74946. * Define this method to modify the default behavior when loading nodes.
  74947. * @param context The context when loading the asset
  74948. * @param node The glTF node property
  74949. * @param assign A function called synchronously after parsing the glTF properties
  74950. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  74951. */
  74952. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74953. /**
  74954. * Define this method to modify the default behavior when loading cameras.
  74955. * @param context The context when loading the asset
  74956. * @param camera The glTF camera property
  74957. * @param assign A function called synchronously after parsing the glTF properties
  74958. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  74959. */
  74960. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74961. /**
  74962. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  74963. * @param context The context when loading the asset
  74964. * @param primitive The glTF mesh primitive property
  74965. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  74966. */
  74967. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74968. /**
  74969. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74970. * @param context The context when loading the asset
  74971. * @param name The mesh name when loading the asset
  74972. * @param node The glTF node when loading the asset
  74973. * @param mesh The glTF mesh when loading the asset
  74974. * @param primitive The glTF mesh primitive property
  74975. * @param assign A function called synchronously after parsing the glTF properties
  74976. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74977. */
  74978. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74979. /**
  74980. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  74981. * @param context The context when loading the asset
  74982. * @param material The glTF material property
  74983. * @param assign A function called synchronously after parsing the glTF properties
  74984. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  74985. */
  74986. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74987. /**
  74988. * Define this method to modify the default behavior when creating materials.
  74989. * @param context The context when loading the asset
  74990. * @param material The glTF material property
  74991. * @param babylonDrawMode The draw mode for the Babylon material
  74992. * @returns The Babylon material or null if not handled
  74993. */
  74994. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74995. /**
  74996. * Define this method to modify the default behavior when loading material properties.
  74997. * @param context The context when loading the asset
  74998. * @param material The glTF material property
  74999. * @param babylonMaterial The Babylon material
  75000. * @returns A promise that resolves when the load is complete or null if not handled
  75001. */
  75002. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75003. /**
  75004. * Define this method to modify the default behavior when loading texture infos.
  75005. * @param context The context when loading the asset
  75006. * @param textureInfo The glTF texture info property
  75007. * @param assign A function called synchronously after parsing the glTF properties
  75008. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75009. */
  75010. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75011. /**
  75012. * Define this method to modify the default behavior when loading animations.
  75013. * @param context The context when loading the asset
  75014. * @param animation The glTF animation property
  75015. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75016. */
  75017. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75018. /**
  75019. * @hidden Define this method to modify the default behavior when loading skins.
  75020. * @param context The context when loading the asset
  75021. * @param node The glTF node property
  75022. * @param skin The glTF skin property
  75023. * @returns A promise that resolves when the load is complete or null if not handled
  75024. */
  75025. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75026. /**
  75027. * @hidden Define this method to modify the default behavior when loading uris.
  75028. * @param context The context when loading the asset
  75029. * @param property The glTF property associated with the uri
  75030. * @param uri The uri to load
  75031. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75032. */
  75033. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75034. /**
  75035. * Define this method to modify the default behavior when loading buffer views.
  75036. * @param context The context when loading the asset
  75037. * @param bufferView The glTF buffer view property
  75038. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75039. */
  75040. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75041. /**
  75042. * Define this method to modify the default behavior when loading buffers.
  75043. * @param context The context when loading the asset
  75044. * @param buffer The glTF buffer property
  75045. * @param byteOffset The byte offset to load
  75046. * @param byteLength The byte length to load
  75047. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75048. */
  75049. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75050. }
  75051. }
  75052. declare module BABYLON.GLTF2 {
  75053. /**
  75054. * Helper class for working with arrays when loading the glTF asset
  75055. */
  75056. export class ArrayItem {
  75057. /**
  75058. * Gets an item from the given array.
  75059. * @param context The context when loading the asset
  75060. * @param array The array to get the item from
  75061. * @param index The index to the array
  75062. * @returns The array item
  75063. */
  75064. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75065. /**
  75066. * Assign an `index` field to each item of the given array.
  75067. * @param array The array of items
  75068. */
  75069. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75070. }
  75071. /**
  75072. * The glTF 2.0 loader
  75073. */
  75074. export class GLTFLoader implements IGLTFLoader {
  75075. /** @hidden */
  75076. _completePromises: Promise<any>[];
  75077. private _disposed;
  75078. private _parent;
  75079. private _state;
  75080. private _extensions;
  75081. private _rootUrl;
  75082. private _fileName;
  75083. private _uniqueRootUrl;
  75084. private _gltf;
  75085. private _bin;
  75086. private _babylonScene;
  75087. private _rootBabylonMesh;
  75088. private _defaultBabylonMaterialData;
  75089. private _progressCallback?;
  75090. private _requests;
  75091. private static readonly _DefaultSampler;
  75092. private static _RegisteredExtensions;
  75093. /**
  75094. * Registers a loader extension.
  75095. * @param name The name of the loader extension.
  75096. * @param factory The factory function that creates the loader extension.
  75097. */
  75098. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75099. /**
  75100. * Unregisters a loader extension.
  75101. * @param name The name of the loader extension.
  75102. * @returns A boolean indicating whether the extension has been unregistered
  75103. */
  75104. static UnregisterExtension(name: string): boolean;
  75105. /**
  75106. * Gets the loader state.
  75107. */
  75108. get state(): Nullable<GLTFLoaderState>;
  75109. /**
  75110. * The object that represents the glTF JSON.
  75111. */
  75112. get gltf(): IGLTF;
  75113. /**
  75114. * The BIN chunk of a binary glTF.
  75115. */
  75116. get bin(): Nullable<IDataBuffer>;
  75117. /**
  75118. * The parent file loader.
  75119. */
  75120. get parent(): GLTFFileLoader;
  75121. /**
  75122. * The Babylon scene when loading the asset.
  75123. */
  75124. get babylonScene(): Scene;
  75125. /**
  75126. * The root Babylon mesh when loading the asset.
  75127. */
  75128. get rootBabylonMesh(): Mesh;
  75129. /** @hidden */
  75130. constructor(parent: GLTFFileLoader);
  75131. /** @hidden */
  75132. dispose(): void;
  75133. /** @hidden */
  75134. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75135. meshes: AbstractMesh[];
  75136. particleSystems: IParticleSystem[];
  75137. skeletons: Skeleton[];
  75138. animationGroups: AnimationGroup[];
  75139. }>;
  75140. /** @hidden */
  75141. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75142. private _loadAsync;
  75143. private _loadData;
  75144. private _setupData;
  75145. private _loadExtensions;
  75146. private _checkExtensions;
  75147. private _setState;
  75148. private _createRootNode;
  75149. /**
  75150. * Loads a glTF scene.
  75151. * @param context The context when loading the asset
  75152. * @param scene The glTF scene property
  75153. * @returns A promise that resolves when the load is complete
  75154. */
  75155. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75156. private _forEachPrimitive;
  75157. private _getMeshes;
  75158. private _getSkeletons;
  75159. private _getAnimationGroups;
  75160. private _startAnimations;
  75161. /**
  75162. * Loads a glTF node.
  75163. * @param context The context when loading the asset
  75164. * @param node The glTF node property
  75165. * @param assign A function called synchronously after parsing the glTF properties
  75166. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75167. */
  75168. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75169. private _loadMeshAsync;
  75170. /**
  75171. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75172. * @param context The context when loading the asset
  75173. * @param name The mesh name when loading the asset
  75174. * @param node The glTF node when loading the asset
  75175. * @param mesh The glTF mesh when loading the asset
  75176. * @param primitive The glTF mesh primitive property
  75177. * @param assign A function called synchronously after parsing the glTF properties
  75178. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75179. */
  75180. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75181. private _loadVertexDataAsync;
  75182. private _createMorphTargets;
  75183. private _loadMorphTargetsAsync;
  75184. private _loadMorphTargetVertexDataAsync;
  75185. private static _LoadTransform;
  75186. private _loadSkinAsync;
  75187. private _loadBones;
  75188. private _loadBone;
  75189. private _loadSkinInverseBindMatricesDataAsync;
  75190. private _updateBoneMatrices;
  75191. private _getNodeMatrix;
  75192. /**
  75193. * Loads a glTF camera.
  75194. * @param context The context when loading the asset
  75195. * @param camera The glTF camera property
  75196. * @param assign A function called synchronously after parsing the glTF properties
  75197. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75198. */
  75199. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75200. private _loadAnimationsAsync;
  75201. /**
  75202. * Loads a glTF animation.
  75203. * @param context The context when loading the asset
  75204. * @param animation The glTF animation property
  75205. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75206. */
  75207. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75208. /**
  75209. * @hidden Loads a glTF animation channel.
  75210. * @param context The context when loading the asset
  75211. * @param animationContext The context of the animation when loading the asset
  75212. * @param animation The glTF animation property
  75213. * @param channel The glTF animation channel property
  75214. * @param babylonAnimationGroup The babylon animation group property
  75215. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75216. * @returns A void promise when the channel load is complete
  75217. */
  75218. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75219. private _loadAnimationSamplerAsync;
  75220. private _loadBufferAsync;
  75221. /**
  75222. * Loads a glTF buffer view.
  75223. * @param context The context when loading the asset
  75224. * @param bufferView The glTF buffer view property
  75225. * @returns A promise that resolves with the loaded data when the load is complete
  75226. */
  75227. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75228. private _loadAccessorAsync;
  75229. private _loadFloatAccessorAsync;
  75230. private _loadIndicesAccessorAsync;
  75231. private _loadVertexBufferViewAsync;
  75232. private _loadVertexAccessorAsync;
  75233. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75234. /** @hidden */
  75235. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75236. private _createDefaultMaterial;
  75237. /**
  75238. * Creates a Babylon material from a glTF material.
  75239. * @param context The context when loading the asset
  75240. * @param material The glTF material property
  75241. * @param babylonDrawMode The draw mode for the Babylon material
  75242. * @returns The Babylon material
  75243. */
  75244. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75245. /**
  75246. * Loads properties from a glTF material into a Babylon material.
  75247. * @param context The context when loading the asset
  75248. * @param material The glTF material property
  75249. * @param babylonMaterial The Babylon material
  75250. * @returns A promise that resolves when the load is complete
  75251. */
  75252. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75253. /**
  75254. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75255. * @param context The context when loading the asset
  75256. * @param material The glTF material property
  75257. * @param babylonMaterial The Babylon material
  75258. * @returns A promise that resolves when the load is complete
  75259. */
  75260. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75261. /**
  75262. * Loads the alpha properties from a glTF material into a Babylon material.
  75263. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75264. * @param context The context when loading the asset
  75265. * @param material The glTF material property
  75266. * @param babylonMaterial The Babylon material
  75267. */
  75268. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75269. /**
  75270. * Loads a glTF texture info.
  75271. * @param context The context when loading the asset
  75272. * @param textureInfo The glTF texture info property
  75273. * @param assign A function called synchronously after parsing the glTF properties
  75274. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75275. */
  75276. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75277. private _loadTextureAsync;
  75278. private _loadSampler;
  75279. /**
  75280. * Loads a glTF image.
  75281. * @param context The context when loading the asset
  75282. * @param image The glTF image property
  75283. * @returns A promise that resolves with the loaded data when the load is complete
  75284. */
  75285. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75286. /**
  75287. * Loads a glTF uri.
  75288. * @param context The context when loading the asset
  75289. * @param property The glTF property associated with the uri
  75290. * @param uri The base64 or relative uri
  75291. * @returns A promise that resolves with the loaded data when the load is complete
  75292. */
  75293. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75294. private _onProgress;
  75295. /**
  75296. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75297. * @param babylonObject the Babylon object with metadata
  75298. * @param pointer the JSON pointer
  75299. */
  75300. static AddPointerMetadata(babylonObject: {
  75301. metadata: any;
  75302. }, pointer: string): void;
  75303. private static _GetTextureWrapMode;
  75304. private static _GetTextureSamplingMode;
  75305. private static _GetTypedArrayConstructor;
  75306. private static _GetTypedArray;
  75307. private static _GetNumComponents;
  75308. private static _ValidateUri;
  75309. private static _GetDrawMode;
  75310. private _compileMaterialsAsync;
  75311. private _compileShadowGeneratorsAsync;
  75312. private _forEachExtensions;
  75313. private _applyExtensions;
  75314. private _extensionsOnLoading;
  75315. private _extensionsOnReady;
  75316. private _extensionsLoadSceneAsync;
  75317. private _extensionsLoadNodeAsync;
  75318. private _extensionsLoadCameraAsync;
  75319. private _extensionsLoadVertexDataAsync;
  75320. private _extensionsLoadMeshPrimitiveAsync;
  75321. private _extensionsLoadMaterialAsync;
  75322. private _extensionsCreateMaterial;
  75323. private _extensionsLoadMaterialPropertiesAsync;
  75324. private _extensionsLoadTextureInfoAsync;
  75325. private _extensionsLoadAnimationAsync;
  75326. private _extensionsLoadSkinAsync;
  75327. private _extensionsLoadUriAsync;
  75328. private _extensionsLoadBufferViewAsync;
  75329. private _extensionsLoadBufferAsync;
  75330. /**
  75331. * Helper method called by a loader extension to load an glTF extension.
  75332. * @param context The context when loading the asset
  75333. * @param property The glTF property to load the extension from
  75334. * @param extensionName The name of the extension to load
  75335. * @param actionAsync The action to run
  75336. * @returns The promise returned by actionAsync or null if the extension does not exist
  75337. */
  75338. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75339. /**
  75340. * Helper method called by a loader extension to load a glTF extra.
  75341. * @param context The context when loading the asset
  75342. * @param property The glTF property to load the extra from
  75343. * @param extensionName The name of the extension to load
  75344. * @param actionAsync The action to run
  75345. * @returns The promise returned by actionAsync or null if the extra does not exist
  75346. */
  75347. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75348. /**
  75349. * Checks for presence of an extension.
  75350. * @param name The name of the extension to check
  75351. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75352. */
  75353. isExtensionUsed(name: string): boolean;
  75354. /**
  75355. * Increments the indentation level and logs a message.
  75356. * @param message The message to log
  75357. */
  75358. logOpen(message: string): void;
  75359. /**
  75360. * Decrements the indentation level.
  75361. */
  75362. logClose(): void;
  75363. /**
  75364. * Logs a message
  75365. * @param message The message to log
  75366. */
  75367. log(message: string): void;
  75368. /**
  75369. * Starts a performance counter.
  75370. * @param counterName The name of the performance counter
  75371. */
  75372. startPerformanceCounter(counterName: string): void;
  75373. /**
  75374. * Ends a performance counter.
  75375. * @param counterName The name of the performance counter
  75376. */
  75377. endPerformanceCounter(counterName: string): void;
  75378. }
  75379. }
  75380. declare module BABYLON.GLTF2.Loader.Extensions {
  75381. /**
  75382. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75383. */
  75384. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75385. /**
  75386. * The name of this extension.
  75387. */
  75388. readonly name: string;
  75389. /**
  75390. * Defines whether this extension is enabled.
  75391. */
  75392. enabled: boolean;
  75393. private _loader;
  75394. private _lights?;
  75395. /** @hidden */
  75396. constructor(loader: GLTFLoader);
  75397. /** @hidden */
  75398. dispose(): void;
  75399. /** @hidden */
  75400. onLoading(): void;
  75401. /** @hidden */
  75402. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75403. private _loadLightAsync;
  75404. }
  75405. }
  75406. declare module BABYLON.GLTF2.Loader.Extensions {
  75407. /**
  75408. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75409. */
  75410. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75411. /**
  75412. * The name of this extension.
  75413. */
  75414. readonly name: string;
  75415. /**
  75416. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75417. */
  75418. dracoCompression?: DracoCompression;
  75419. /**
  75420. * Defines whether this extension is enabled.
  75421. */
  75422. enabled: boolean;
  75423. private _loader;
  75424. /** @hidden */
  75425. constructor(loader: GLTFLoader);
  75426. /** @hidden */
  75427. dispose(): void;
  75428. /** @hidden */
  75429. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75430. }
  75431. }
  75432. declare module BABYLON.GLTF2.Loader.Extensions {
  75433. /**
  75434. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75435. */
  75436. export class KHR_lights implements IGLTFLoaderExtension {
  75437. /**
  75438. * The name of this extension.
  75439. */
  75440. readonly name: string;
  75441. /**
  75442. * Defines whether this extension is enabled.
  75443. */
  75444. enabled: boolean;
  75445. private _loader;
  75446. private _lights?;
  75447. /** @hidden */
  75448. constructor(loader: GLTFLoader);
  75449. /** @hidden */
  75450. dispose(): void;
  75451. /** @hidden */
  75452. onLoading(): void;
  75453. /** @hidden */
  75454. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75455. }
  75456. }
  75457. declare module BABYLON.GLTF2.Loader.Extensions {
  75458. /**
  75459. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75460. */
  75461. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75462. /**
  75463. * The name of this extension.
  75464. */
  75465. readonly name: string;
  75466. /**
  75467. * Defines whether this extension is enabled.
  75468. */
  75469. enabled: boolean;
  75470. /**
  75471. * Defines a number that determines the order the extensions are applied.
  75472. */
  75473. order: number;
  75474. private _loader;
  75475. /** @hidden */
  75476. constructor(loader: GLTFLoader);
  75477. /** @hidden */
  75478. dispose(): void;
  75479. /** @hidden */
  75480. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75481. private _loadSpecularGlossinessPropertiesAsync;
  75482. }
  75483. }
  75484. declare module BABYLON.GLTF2.Loader.Extensions {
  75485. /**
  75486. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75487. */
  75488. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75489. /**
  75490. * The name of this extension.
  75491. */
  75492. readonly name: string;
  75493. /**
  75494. * Defines whether this extension is enabled.
  75495. */
  75496. enabled: boolean;
  75497. /**
  75498. * Defines a number that determines the order the extensions are applied.
  75499. */
  75500. order: number;
  75501. private _loader;
  75502. /** @hidden */
  75503. constructor(loader: GLTFLoader);
  75504. /** @hidden */
  75505. dispose(): void;
  75506. /** @hidden */
  75507. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75508. private _loadUnlitPropertiesAsync;
  75509. }
  75510. }
  75511. declare module BABYLON.GLTF2.Loader.Extensions {
  75512. /**
  75513. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75514. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75515. * !!! Experimental Extension Subject to Changes !!!
  75516. */
  75517. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75518. /**
  75519. * The name of this extension.
  75520. */
  75521. readonly name: string;
  75522. /**
  75523. * Defines whether this extension is enabled.
  75524. */
  75525. enabled: boolean;
  75526. /**
  75527. * Defines a number that determines the order the extensions are applied.
  75528. */
  75529. order: number;
  75530. private _loader;
  75531. /** @hidden */
  75532. constructor(loader: GLTFLoader);
  75533. /** @hidden */
  75534. dispose(): void;
  75535. /** @hidden */
  75536. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75537. private _loadClearCoatPropertiesAsync;
  75538. }
  75539. }
  75540. declare module BABYLON.GLTF2.Loader.Extensions {
  75541. /**
  75542. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75543. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75544. * !!! Experimental Extension Subject to Changes !!!
  75545. */
  75546. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75547. /**
  75548. * The name of this extension.
  75549. */
  75550. readonly name: string;
  75551. /**
  75552. * Defines whether this extension is enabled.
  75553. */
  75554. enabled: boolean;
  75555. /**
  75556. * Defines a number that determines the order the extensions are applied.
  75557. */
  75558. order: number;
  75559. private _loader;
  75560. /** @hidden */
  75561. constructor(loader: GLTFLoader);
  75562. /** @hidden */
  75563. dispose(): void;
  75564. /** @hidden */
  75565. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75566. private _loadSheenPropertiesAsync;
  75567. }
  75568. }
  75569. declare module BABYLON.GLTF2.Loader.Extensions {
  75570. /**
  75571. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75572. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75573. * !!! Experimental Extension Subject to Changes !!!
  75574. */
  75575. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75576. /**
  75577. * The name of this extension.
  75578. */
  75579. readonly name: string;
  75580. /**
  75581. * Defines whether this extension is enabled.
  75582. */
  75583. enabled: boolean;
  75584. /**
  75585. * Defines a number that determines the order the extensions are applied.
  75586. */
  75587. order: number;
  75588. private _loader;
  75589. /** @hidden */
  75590. constructor(loader: GLTFLoader);
  75591. /** @hidden */
  75592. dispose(): void;
  75593. /** @hidden */
  75594. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75595. private _loadSpecularPropertiesAsync;
  75596. }
  75597. }
  75598. declare module BABYLON.GLTF2.Loader.Extensions {
  75599. /**
  75600. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75601. */
  75602. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75603. /**
  75604. * The name of this extension.
  75605. */
  75606. readonly name: string;
  75607. /**
  75608. * Defines whether this extension is enabled.
  75609. */
  75610. enabled: boolean;
  75611. /** @hidden */
  75612. constructor(loader: GLTFLoader);
  75613. /** @hidden */
  75614. dispose(): void;
  75615. }
  75616. }
  75617. declare module BABYLON.GLTF2.Loader.Extensions {
  75618. /**
  75619. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75620. */
  75621. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75622. /**
  75623. * The name of this extension.
  75624. */
  75625. readonly name: string;
  75626. /**
  75627. * Defines whether this extension is enabled.
  75628. */
  75629. enabled: boolean;
  75630. private _loader;
  75631. /** @hidden */
  75632. constructor(loader: GLTFLoader);
  75633. /** @hidden */
  75634. dispose(): void;
  75635. /** @hidden */
  75636. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75637. }
  75638. }
  75639. declare module BABYLON.GLTF2.Loader.Extensions {
  75640. /**
  75641. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75642. */
  75643. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75644. /**
  75645. * The name of this extension.
  75646. */
  75647. readonly name: string;
  75648. /**
  75649. * Defines whether this extension is enabled.
  75650. */
  75651. enabled: boolean;
  75652. private _loader;
  75653. private _clips;
  75654. private _emitters;
  75655. /** @hidden */
  75656. constructor(loader: GLTFLoader);
  75657. /** @hidden */
  75658. dispose(): void;
  75659. /** @hidden */
  75660. onLoading(): void;
  75661. /** @hidden */
  75662. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75663. /** @hidden */
  75664. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75665. /** @hidden */
  75666. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75667. private _loadClipAsync;
  75668. private _loadEmitterAsync;
  75669. private _getEventAction;
  75670. private _loadAnimationEventAsync;
  75671. }
  75672. }
  75673. declare module BABYLON.GLTF2.Loader.Extensions {
  75674. /**
  75675. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75676. */
  75677. export class MSFT_lod implements IGLTFLoaderExtension {
  75678. /**
  75679. * The name of this extension.
  75680. */
  75681. readonly name: string;
  75682. /**
  75683. * Defines whether this extension is enabled.
  75684. */
  75685. enabled: boolean;
  75686. /**
  75687. * Defines a number that determines the order the extensions are applied.
  75688. */
  75689. order: number;
  75690. /**
  75691. * Maximum number of LODs to load, starting from the lowest LOD.
  75692. */
  75693. maxLODsToLoad: number;
  75694. /**
  75695. * Observable raised when all node LODs of one level are loaded.
  75696. * The event data is the index of the loaded LOD starting from zero.
  75697. * Dispose the loader to cancel the loading of the next level of LODs.
  75698. */
  75699. onNodeLODsLoadedObservable: Observable<number>;
  75700. /**
  75701. * Observable raised when all material LODs of one level are loaded.
  75702. * The event data is the index of the loaded LOD starting from zero.
  75703. * Dispose the loader to cancel the loading of the next level of LODs.
  75704. */
  75705. onMaterialLODsLoadedObservable: Observable<number>;
  75706. private _loader;
  75707. private _nodeIndexLOD;
  75708. private _nodeSignalLODs;
  75709. private _nodePromiseLODs;
  75710. private _materialIndexLOD;
  75711. private _materialSignalLODs;
  75712. private _materialPromiseLODs;
  75713. private _indexLOD;
  75714. private _bufferLODs;
  75715. /** @hidden */
  75716. constructor(loader: GLTFLoader);
  75717. /** @hidden */
  75718. dispose(): void;
  75719. /** @hidden */
  75720. onReady(): void;
  75721. /** @hidden */
  75722. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75723. /** @hidden */
  75724. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75725. /** @hidden */
  75726. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75727. /** @hidden */
  75728. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75729. /** @hidden */
  75730. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75731. private _loadBufferLOD;
  75732. /**
  75733. * Gets an array of LOD properties from lowest to highest.
  75734. */
  75735. private _getLODs;
  75736. private _disposeUnusedMaterials;
  75737. }
  75738. }
  75739. declare module BABYLON.GLTF2.Loader.Extensions {
  75740. /** @hidden */
  75741. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  75742. readonly name: string;
  75743. enabled: boolean;
  75744. private _loader;
  75745. constructor(loader: GLTFLoader);
  75746. dispose(): void;
  75747. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75748. }
  75749. }
  75750. declare module BABYLON.GLTF2.Loader.Extensions {
  75751. /** @hidden */
  75752. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  75753. readonly name: string;
  75754. enabled: boolean;
  75755. private _loader;
  75756. constructor(loader: GLTFLoader);
  75757. dispose(): void;
  75758. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75759. }
  75760. }
  75761. declare module BABYLON.GLTF2.Loader.Extensions {
  75762. /**
  75763. * Store glTF extras (if present) in BJS objects' metadata
  75764. */
  75765. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  75766. /**
  75767. * The name of this extension.
  75768. */
  75769. readonly name: string;
  75770. /**
  75771. * Defines whether this extension is enabled.
  75772. */
  75773. enabled: boolean;
  75774. private _loader;
  75775. private _assignExtras;
  75776. /** @hidden */
  75777. constructor(loader: GLTFLoader);
  75778. /** @hidden */
  75779. dispose(): void;
  75780. /** @hidden */
  75781. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75782. /** @hidden */
  75783. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75784. /** @hidden */
  75785. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75786. }
  75787. }
  75788. declare module BABYLON {
  75789. /**
  75790. * Class reading and parsing the MTL file bundled with the obj file.
  75791. */
  75792. export class MTLFileLoader {
  75793. /**
  75794. * Invert Y-Axis of referenced textures on load
  75795. */
  75796. static INVERT_TEXTURE_Y: boolean;
  75797. /**
  75798. * All material loaded from the mtl will be set here
  75799. */
  75800. materials: StandardMaterial[];
  75801. /**
  75802. * This function will read the mtl file and create each material described inside
  75803. * This function could be improve by adding :
  75804. * -some component missing (Ni, Tf...)
  75805. * -including the specific options available
  75806. *
  75807. * @param scene defines the scene the material will be created in
  75808. * @param data defines the mtl data to parse
  75809. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  75810. */
  75811. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  75812. /**
  75813. * Gets the texture for the material.
  75814. *
  75815. * If the material is imported from input file,
  75816. * We sanitize the url to ensure it takes the textre from aside the material.
  75817. *
  75818. * @param rootUrl The root url to load from
  75819. * @param value The value stored in the mtl
  75820. * @return The Texture
  75821. */
  75822. private static _getTexture;
  75823. }
  75824. }
  75825. declare module BABYLON {
  75826. /**
  75827. * Options for loading OBJ/MTL files
  75828. */
  75829. type MeshLoadOptions = {
  75830. /**
  75831. * Defines if UVs are optimized by default during load.
  75832. */
  75833. OptimizeWithUV: boolean;
  75834. /**
  75835. * Defines custom scaling of UV coordinates of loaded meshes.
  75836. */
  75837. UVScaling: Vector2;
  75838. /**
  75839. * Invert model on y-axis (does a model scaling inversion)
  75840. */
  75841. InvertY: boolean;
  75842. /**
  75843. * Invert Y-Axis of referenced textures on load
  75844. */
  75845. InvertTextureY: boolean;
  75846. /**
  75847. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75848. */
  75849. ImportVertexColors: boolean;
  75850. /**
  75851. * Compute the normals for the model, even if normals are present in the file.
  75852. */
  75853. ComputeNormals: boolean;
  75854. /**
  75855. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75856. */
  75857. SkipMaterials: boolean;
  75858. /**
  75859. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75860. */
  75861. MaterialLoadingFailsSilently: boolean;
  75862. };
  75863. /**
  75864. * OBJ file type loader.
  75865. * This is a babylon scene loader plugin.
  75866. */
  75867. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75868. /**
  75869. * Defines if UVs are optimized by default during load.
  75870. */
  75871. static OPTIMIZE_WITH_UV: boolean;
  75872. /**
  75873. * Invert model on y-axis (does a model scaling inversion)
  75874. */
  75875. static INVERT_Y: boolean;
  75876. /**
  75877. * Invert Y-Axis of referenced textures on load
  75878. */
  75879. static get INVERT_TEXTURE_Y(): boolean;
  75880. static set INVERT_TEXTURE_Y(value: boolean);
  75881. /**
  75882. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75883. */
  75884. static IMPORT_VERTEX_COLORS: boolean;
  75885. /**
  75886. * Compute the normals for the model, even if normals are present in the file.
  75887. */
  75888. static COMPUTE_NORMALS: boolean;
  75889. /**
  75890. * Defines custom scaling of UV coordinates of loaded meshes.
  75891. */
  75892. static UV_SCALING: Vector2;
  75893. /**
  75894. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75895. */
  75896. static SKIP_MATERIALS: boolean;
  75897. /**
  75898. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75899. *
  75900. * Defaults to true for backwards compatibility.
  75901. */
  75902. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  75903. /**
  75904. * Defines the name of the plugin.
  75905. */
  75906. name: string;
  75907. /**
  75908. * Defines the extension the plugin is able to load.
  75909. */
  75910. extensions: string;
  75911. /** @hidden */
  75912. obj: RegExp;
  75913. /** @hidden */
  75914. group: RegExp;
  75915. /** @hidden */
  75916. mtllib: RegExp;
  75917. /** @hidden */
  75918. usemtl: RegExp;
  75919. /** @hidden */
  75920. smooth: RegExp;
  75921. /** @hidden */
  75922. vertexPattern: RegExp;
  75923. /** @hidden */
  75924. normalPattern: RegExp;
  75925. /** @hidden */
  75926. uvPattern: RegExp;
  75927. /** @hidden */
  75928. facePattern1: RegExp;
  75929. /** @hidden */
  75930. facePattern2: RegExp;
  75931. /** @hidden */
  75932. facePattern3: RegExp;
  75933. /** @hidden */
  75934. facePattern4: RegExp;
  75935. /** @hidden */
  75936. facePattern5: RegExp;
  75937. private _meshLoadOptions;
  75938. /**
  75939. * Creates loader for .OBJ files
  75940. *
  75941. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  75942. */
  75943. constructor(meshLoadOptions?: MeshLoadOptions);
  75944. private static get currentMeshLoadOptions();
  75945. /**
  75946. * Calls synchronously the MTL file attached to this obj.
  75947. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  75948. * Without this function materials are not displayed in the first frame (but displayed after).
  75949. * In consequence it is impossible to get material information in your HTML file
  75950. *
  75951. * @param url The URL of the MTL file
  75952. * @param rootUrl
  75953. * @param onSuccess Callback function to be called when the MTL file is loaded
  75954. * @private
  75955. */
  75956. private _loadMTL;
  75957. /**
  75958. * Instantiates a OBJ file loader plugin.
  75959. * @returns the created plugin
  75960. */
  75961. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  75962. /**
  75963. * If the data string can be loaded directly.
  75964. *
  75965. * @param data string containing the file data
  75966. * @returns if the data can be loaded directly
  75967. */
  75968. canDirectLoad(data: string): boolean;
  75969. /**
  75970. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  75971. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75972. * @param scene the scene the meshes should be added to
  75973. * @param data the OBJ data to load
  75974. * @param rootUrl root url to load from
  75975. * @param onProgress event that fires when loading progress has occured
  75976. * @param fileName Defines the name of the file to load
  75977. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75978. */
  75979. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75980. meshes: AbstractMesh[];
  75981. particleSystems: IParticleSystem[];
  75982. skeletons: Skeleton[];
  75983. animationGroups: AnimationGroup[];
  75984. }>;
  75985. /**
  75986. * Imports all objects from the loaded OBJ data and adds them to the scene
  75987. * @param scene the scene the objects should be added to
  75988. * @param data the OBJ data to load
  75989. * @param rootUrl root url to load from
  75990. * @param onProgress event that fires when loading progress has occured
  75991. * @param fileName Defines the name of the file to load
  75992. * @returns a promise which completes when objects have been loaded to the scene
  75993. */
  75994. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75995. /**
  75996. * Load into an asset container.
  75997. * @param scene The scene to load into
  75998. * @param data The data to import
  75999. * @param rootUrl The root url for scene and resources
  76000. * @param onProgress The callback when the load progresses
  76001. * @param fileName Defines the name of the file to load
  76002. * @returns The loaded asset container
  76003. */
  76004. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76005. /**
  76006. * Read the OBJ file and create an Array of meshes.
  76007. * Each mesh contains all information given by the OBJ and the MTL file.
  76008. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76009. *
  76010. * @param meshesNames
  76011. * @param scene Scene The scene where are displayed the data
  76012. * @param data String The content of the obj file
  76013. * @param rootUrl String The path to the folder
  76014. * @returns Array<AbstractMesh>
  76015. * @private
  76016. */
  76017. private _parseSolid;
  76018. }
  76019. }
  76020. declare module BABYLON {
  76021. /**
  76022. * STL file type loader.
  76023. * This is a babylon scene loader plugin.
  76024. */
  76025. export class STLFileLoader implements ISceneLoaderPlugin {
  76026. /** @hidden */
  76027. solidPattern: RegExp;
  76028. /** @hidden */
  76029. facetsPattern: RegExp;
  76030. /** @hidden */
  76031. normalPattern: RegExp;
  76032. /** @hidden */
  76033. vertexPattern: RegExp;
  76034. /**
  76035. * Defines the name of the plugin.
  76036. */
  76037. name: string;
  76038. /**
  76039. * Defines the extensions the stl loader is able to load.
  76040. * force data to come in as an ArrayBuffer
  76041. * we'll convert to string if it looks like it's an ASCII .stl
  76042. */
  76043. extensions: ISceneLoaderPluginExtensions;
  76044. /**
  76045. * Import meshes into a scene.
  76046. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76047. * @param scene The scene to import into
  76048. * @param data The data to import
  76049. * @param rootUrl The root url for scene and resources
  76050. * @param meshes The meshes array to import into
  76051. * @param particleSystems The particle systems array to import into
  76052. * @param skeletons The skeletons array to import into
  76053. * @param onError The callback when import fails
  76054. * @returns True if successful or false otherwise
  76055. */
  76056. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76057. /**
  76058. * Load into a scene.
  76059. * @param scene The scene to load into
  76060. * @param data The data to import
  76061. * @param rootUrl The root url for scene and resources
  76062. * @param onError The callback when import fails
  76063. * @returns true if successful or false otherwise
  76064. */
  76065. load(scene: Scene, data: any, rootUrl: string): boolean;
  76066. /**
  76067. * Load into an asset container.
  76068. * @param scene The scene to load into
  76069. * @param data The data to import
  76070. * @param rootUrl The root url for scene and resources
  76071. * @param onError The callback when import fails
  76072. * @returns The loaded asset container
  76073. */
  76074. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76075. private _isBinary;
  76076. private _parseBinary;
  76077. private _parseASCII;
  76078. }
  76079. }
  76080. declare module BABYLON {
  76081. /**
  76082. * Class for generating OBJ data from a Babylon scene.
  76083. */
  76084. export class OBJExport {
  76085. /**
  76086. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76087. * @param mesh defines the list of meshes to serialize
  76088. * @param materials defines if materials should be exported
  76089. * @param matlibname defines the name of the associated mtl file
  76090. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76091. * @returns the OBJ content
  76092. */
  76093. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76094. /**
  76095. * Exports the material(s) of a mesh in .MTL file format (text)
  76096. * @param mesh defines the mesh to extract the material from
  76097. * @returns the mtl content
  76098. */
  76099. static MTL(mesh: Mesh): string;
  76100. }
  76101. }
  76102. declare module BABYLON {
  76103. /** @hidden */
  76104. export var __IGLTFExporterExtension: number;
  76105. /**
  76106. * Interface for extending the exporter
  76107. * @hidden
  76108. */
  76109. export interface IGLTFExporterExtension {
  76110. /**
  76111. * The name of this extension
  76112. */
  76113. readonly name: string;
  76114. /**
  76115. * Defines whether this extension is enabled
  76116. */
  76117. enabled: boolean;
  76118. /**
  76119. * Defines whether this extension is required
  76120. */
  76121. required: boolean;
  76122. }
  76123. }
  76124. declare module BABYLON.GLTF2.Exporter {
  76125. /** @hidden */
  76126. export var __IGLTFExporterExtensionV2: number;
  76127. /**
  76128. * Interface for a glTF exporter extension
  76129. * @hidden
  76130. */
  76131. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76132. /**
  76133. * Define this method to modify the default behavior before exporting a texture
  76134. * @param context The context when loading the asset
  76135. * @param babylonTexture The Babylon.js texture
  76136. * @param mimeType The mime-type of the generated image
  76137. * @returns A promise that resolves with the exported texture
  76138. */
  76139. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76140. /**
  76141. * Define this method to get notified when a texture info is created
  76142. * @param context The context when loading the asset
  76143. * @param textureInfo The glTF texture info
  76144. * @param babylonTexture The Babylon.js texture
  76145. */
  76146. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76147. /**
  76148. * Define this method to modify the default behavior when exporting texture info
  76149. * @param context The context when loading the asset
  76150. * @param meshPrimitive glTF mesh primitive
  76151. * @param babylonSubMesh Babylon submesh
  76152. * @param binaryWriter glTF serializer binary writer instance
  76153. * @returns nullable IMeshPrimitive promise
  76154. */
  76155. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76156. /**
  76157. * Define this method to modify the default behavior when exporting a node
  76158. * @param context The context when exporting the node
  76159. * @param node glTF node
  76160. * @param babylonNode BabylonJS node
  76161. * @returns nullable INode promise
  76162. */
  76163. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76164. /**
  76165. * Define this method to modify the default behavior when exporting a material
  76166. * @param material glTF material
  76167. * @param babylonMaterial BabylonJS material
  76168. * @returns nullable IMaterial promise
  76169. */
  76170. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76171. /**
  76172. * Define this method to return additional textures to export from a material
  76173. * @param material glTF material
  76174. * @param babylonMaterial BabylonJS material
  76175. * @returns List of textures
  76176. */
  76177. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76178. /** Gets a boolean indicating that this extension was used */
  76179. wasUsed: boolean;
  76180. /** Gets a boolean indicating that this extension is required for the file to work */
  76181. required: boolean;
  76182. /**
  76183. * Called after the exporter state changes to EXPORTING
  76184. */
  76185. onExporting?(): void;
  76186. }
  76187. }
  76188. declare module BABYLON.GLTF2.Exporter {
  76189. /**
  76190. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76191. * @hidden
  76192. */
  76193. export class _GLTFMaterialExporter {
  76194. /**
  76195. * Represents the dielectric specular values for R, G and B
  76196. */
  76197. private static readonly _DielectricSpecular;
  76198. /**
  76199. * Allows the maximum specular power to be defined for material calculations
  76200. */
  76201. private static readonly _MaxSpecularPower;
  76202. /**
  76203. * Mapping to store textures
  76204. */
  76205. private _textureMap;
  76206. /**
  76207. * Numeric tolerance value
  76208. */
  76209. private static readonly _Epsilon;
  76210. /**
  76211. * Reference to the glTF Exporter
  76212. */
  76213. private _exporter;
  76214. constructor(exporter: _Exporter);
  76215. /**
  76216. * Specifies if two colors are approximately equal in value
  76217. * @param color1 first color to compare to
  76218. * @param color2 second color to compare to
  76219. * @param epsilon threshold value
  76220. */
  76221. private static FuzzyEquals;
  76222. /**
  76223. * Gets the materials from a Babylon scene and converts them to glTF materials
  76224. * @param scene babylonjs scene
  76225. * @param mimeType texture mime type
  76226. * @param images array of images
  76227. * @param textures array of textures
  76228. * @param materials array of materials
  76229. * @param imageData mapping of texture names to base64 textures
  76230. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76231. */
  76232. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76233. /**
  76234. * Makes a copy of the glTF material without the texture parameters
  76235. * @param originalMaterial original glTF material
  76236. * @returns glTF material without texture parameters
  76237. */
  76238. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76239. /**
  76240. * Specifies if the material has any texture parameters present
  76241. * @param material glTF Material
  76242. * @returns boolean specifying if texture parameters are present
  76243. */
  76244. _hasTexturesPresent(material: IMaterial): boolean;
  76245. /**
  76246. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76247. * @param babylonStandardMaterial
  76248. * @returns glTF Metallic Roughness Material representation
  76249. */
  76250. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76251. /**
  76252. * Computes the metallic factor
  76253. * @param diffuse diffused value
  76254. * @param specular specular value
  76255. * @param oneMinusSpecularStrength one minus the specular strength
  76256. * @returns metallic value
  76257. */
  76258. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76259. /**
  76260. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76261. * @param glTFMaterial glTF material
  76262. * @param babylonMaterial Babylon material
  76263. */
  76264. private static _SetAlphaMode;
  76265. /**
  76266. * Converts a Babylon Standard Material to a glTF Material
  76267. * @param babylonStandardMaterial BJS Standard Material
  76268. * @param mimeType mime type to use for the textures
  76269. * @param images array of glTF image interfaces
  76270. * @param textures array of glTF texture interfaces
  76271. * @param materials array of glTF material interfaces
  76272. * @param imageData map of image file name to data
  76273. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76274. */
  76275. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76276. private _finishMaterial;
  76277. /**
  76278. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76279. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76280. * @param mimeType mime type to use for the textures
  76281. * @param images array of glTF image interfaces
  76282. * @param textures array of glTF texture interfaces
  76283. * @param materials array of glTF material interfaces
  76284. * @param imageData map of image file name to data
  76285. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76286. */
  76287. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76288. /**
  76289. * Converts an image typed array buffer to a base64 image
  76290. * @param buffer typed array buffer
  76291. * @param width width of the image
  76292. * @param height height of the image
  76293. * @param mimeType mimetype of the image
  76294. * @returns base64 image string
  76295. */
  76296. private _createBase64FromCanvasAsync;
  76297. /**
  76298. * Generates a white texture based on the specified width and height
  76299. * @param width width of the texture in pixels
  76300. * @param height height of the texture in pixels
  76301. * @param scene babylonjs scene
  76302. * @returns white texture
  76303. */
  76304. private _createWhiteTexture;
  76305. /**
  76306. * 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
  76307. * @param texture1 first texture to resize
  76308. * @param texture2 second texture to resize
  76309. * @param scene babylonjs scene
  76310. * @returns resized textures or null
  76311. */
  76312. private _resizeTexturesToSameDimensions;
  76313. /**
  76314. * Converts an array of pixels to a Float32Array
  76315. * Throws an error if the pixel format is not supported
  76316. * @param pixels - array buffer containing pixel values
  76317. * @returns Float32 of pixels
  76318. */
  76319. private _convertPixelArrayToFloat32;
  76320. /**
  76321. * Convert Specular Glossiness Textures to Metallic Roughness
  76322. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76323. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76324. * @param diffuseTexture texture used to store diffuse information
  76325. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76326. * @param factors specular glossiness material factors
  76327. * @param mimeType the mime type to use for the texture
  76328. * @returns pbr metallic roughness interface or null
  76329. */
  76330. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76331. /**
  76332. * Converts specular glossiness material properties to metallic roughness
  76333. * @param specularGlossiness interface with specular glossiness material properties
  76334. * @returns interface with metallic roughness material properties
  76335. */
  76336. private _convertSpecularGlossinessToMetallicRoughness;
  76337. /**
  76338. * Calculates the surface reflectance, independent of lighting conditions
  76339. * @param color Color source to calculate brightness from
  76340. * @returns number representing the perceived brightness, or zero if color is undefined
  76341. */
  76342. private _getPerceivedBrightness;
  76343. /**
  76344. * Returns the maximum color component value
  76345. * @param color
  76346. * @returns maximum color component value, or zero if color is null or undefined
  76347. */
  76348. private _getMaxComponent;
  76349. /**
  76350. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76351. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76352. * @param mimeType mime type to use for the textures
  76353. * @param images array of glTF image interfaces
  76354. * @param textures array of glTF texture interfaces
  76355. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76356. * @param imageData map of image file name to data
  76357. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76358. * @returns glTF PBR Metallic Roughness factors
  76359. */
  76360. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76361. private _getGLTFTextureSampler;
  76362. private _getGLTFTextureWrapMode;
  76363. private _getGLTFTextureWrapModesSampler;
  76364. /**
  76365. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76366. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76367. * @param mimeType mime type to use for the textures
  76368. * @param images array of glTF image interfaces
  76369. * @param textures array of glTF texture interfaces
  76370. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76371. * @param imageData map of image file name to data
  76372. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76373. * @returns glTF PBR Metallic Roughness factors
  76374. */
  76375. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76376. /**
  76377. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76378. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76379. * @param mimeType mime type to use for the textures
  76380. * @param images array of glTF image interfaces
  76381. * @param textures array of glTF texture interfaces
  76382. * @param materials array of glTF material interfaces
  76383. * @param imageData map of image file name to data
  76384. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76385. */
  76386. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76387. private setMetallicRoughnessPbrMaterial;
  76388. private getPixelsFromTexture;
  76389. /**
  76390. * Extracts a texture from a Babylon texture into file data and glTF data
  76391. * @param babylonTexture Babylon texture to extract
  76392. * @param mimeType Mime Type of the babylonTexture
  76393. * @return glTF texture info, or null if the texture format is not supported
  76394. */
  76395. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76396. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76397. /**
  76398. * Builds a texture from base64 string
  76399. * @param base64Texture base64 texture string
  76400. * @param baseTextureName Name to use for the texture
  76401. * @param mimeType image mime type for the texture
  76402. * @param images array of images
  76403. * @param textures array of textures
  76404. * @param imageData map of image data
  76405. * @returns glTF texture info, or null if the texture format is not supported
  76406. */
  76407. private _getTextureInfoFromBase64;
  76408. }
  76409. }
  76410. declare module BABYLON {
  76411. /**
  76412. * Class for holding and downloading glTF file data
  76413. */
  76414. export class GLTFData {
  76415. /**
  76416. * Object which contains the file name as the key and its data as the value
  76417. */
  76418. glTFFiles: {
  76419. [fileName: string]: string | Blob;
  76420. };
  76421. /**
  76422. * Initializes the glTF file object
  76423. */
  76424. constructor();
  76425. /**
  76426. * Downloads the glTF data as files based on their names and data
  76427. */
  76428. downloadFiles(): void;
  76429. }
  76430. }
  76431. declare module BABYLON {
  76432. /**
  76433. * Holds a collection of exporter options and parameters
  76434. */
  76435. export interface IExportOptions {
  76436. /**
  76437. * Function which indicates whether a babylon node should be exported or not
  76438. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76439. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76440. */
  76441. shouldExportNode?(node: Node): boolean;
  76442. /**
  76443. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76444. * @param metadata source metadata to read from
  76445. * @returns the data to store to glTF node extras
  76446. */
  76447. metadataSelector?(metadata: any): any;
  76448. /**
  76449. * The sample rate to bake animation curves
  76450. */
  76451. animationSampleRate?: number;
  76452. /**
  76453. * Begin serialization without waiting for the scene to be ready
  76454. */
  76455. exportWithoutWaitingForScene?: boolean;
  76456. }
  76457. /**
  76458. * Class for generating glTF data from a Babylon scene.
  76459. */
  76460. export class GLTF2Export {
  76461. /**
  76462. * Exports the geometry of the scene to .gltf file format asynchronously
  76463. * @param scene Babylon scene with scene hierarchy information
  76464. * @param filePrefix File prefix to use when generating the glTF file
  76465. * @param options Exporter options
  76466. * @returns Returns an object with a .gltf file and associates texture names
  76467. * as keys and their data and paths as values
  76468. */
  76469. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76470. private static _PreExportAsync;
  76471. private static _PostExportAsync;
  76472. /**
  76473. * Exports the geometry of the scene to .glb file format asychronously
  76474. * @param scene Babylon scene with scene hierarchy information
  76475. * @param filePrefix File prefix to use when generating glb file
  76476. * @param options Exporter options
  76477. * @returns Returns an object with a .glb filename as key and data as value
  76478. */
  76479. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76480. }
  76481. }
  76482. declare module BABYLON.GLTF2.Exporter {
  76483. /**
  76484. * @hidden
  76485. */
  76486. export class _GLTFUtilities {
  76487. /**
  76488. * Creates a buffer view based on the supplied arguments
  76489. * @param bufferIndex index value of the specified buffer
  76490. * @param byteOffset byte offset value
  76491. * @param byteLength byte length of the bufferView
  76492. * @param byteStride byte distance between conequential elements
  76493. * @param name name of the buffer view
  76494. * @returns bufferView for glTF
  76495. */
  76496. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76497. /**
  76498. * Creates an accessor based on the supplied arguments
  76499. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76500. * @param name The name of the accessor
  76501. * @param type The type of the accessor
  76502. * @param componentType The datatype of components in the attribute
  76503. * @param count The number of attributes referenced by this accessor
  76504. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76505. * @param min Minimum value of each component in this attribute
  76506. * @param max Maximum value of each component in this attribute
  76507. * @returns accessor for glTF
  76508. */
  76509. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76510. /**
  76511. * Calculates the minimum and maximum values of an array of position floats
  76512. * @param positions Positions array of a mesh
  76513. * @param vertexStart Starting vertex offset to calculate min and max values
  76514. * @param vertexCount Number of vertices to check for min and max values
  76515. * @returns min number array and max number array
  76516. */
  76517. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76518. min: number[];
  76519. max: number[];
  76520. };
  76521. /**
  76522. * Converts a new right-handed Vector3
  76523. * @param vector vector3 array
  76524. * @returns right-handed Vector3
  76525. */
  76526. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76527. /**
  76528. * Converts a Vector3 to right-handed
  76529. * @param vector Vector3 to convert to right-handed
  76530. */
  76531. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76532. /**
  76533. * Converts a three element number array to right-handed
  76534. * @param vector number array to convert to right-handed
  76535. */
  76536. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76537. /**
  76538. * Converts a new right-handed Vector3
  76539. * @param vector vector3 array
  76540. * @returns right-handed Vector3
  76541. */
  76542. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76543. /**
  76544. * Converts a Vector3 to right-handed
  76545. * @param vector Vector3 to convert to right-handed
  76546. */
  76547. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76548. /**
  76549. * Converts a three element number array to right-handed
  76550. * @param vector number array to convert to right-handed
  76551. */
  76552. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76553. /**
  76554. * Converts a Vector4 to right-handed
  76555. * @param vector Vector4 to convert to right-handed
  76556. */
  76557. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76558. /**
  76559. * Converts a Vector4 to right-handed
  76560. * @param vector Vector4 to convert to right-handed
  76561. */
  76562. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76563. /**
  76564. * Converts a Quaternion to right-handed
  76565. * @param quaternion Source quaternion to convert to right-handed
  76566. */
  76567. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76568. /**
  76569. * Converts a Quaternion to right-handed
  76570. * @param quaternion Source quaternion to convert to right-handed
  76571. */
  76572. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76573. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76574. }
  76575. }
  76576. declare module BABYLON.GLTF2.Exporter {
  76577. /**
  76578. * Converts Babylon Scene into glTF 2.0.
  76579. * @hidden
  76580. */
  76581. export class _Exporter {
  76582. /**
  76583. * Stores the glTF to export
  76584. */
  76585. _glTF: IGLTF;
  76586. /**
  76587. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76588. */
  76589. _bufferViews: IBufferView[];
  76590. /**
  76591. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76592. */
  76593. _accessors: IAccessor[];
  76594. /**
  76595. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76596. */
  76597. private _nodes;
  76598. /**
  76599. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76600. */
  76601. private _scenes;
  76602. /**
  76603. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76604. */
  76605. private _meshes;
  76606. /**
  76607. * Stores all the generated material information, which represents the appearance of each primitive
  76608. */
  76609. _materials: IMaterial[];
  76610. _materialMap: {
  76611. [materialID: number]: number;
  76612. };
  76613. /**
  76614. * Stores all the generated texture information, which is referenced by glTF materials
  76615. */
  76616. _textures: ITexture[];
  76617. /**
  76618. * Stores all the generated image information, which is referenced by glTF textures
  76619. */
  76620. _images: IImage[];
  76621. /**
  76622. * Stores all the texture samplers
  76623. */
  76624. _samplers: ISampler[];
  76625. /**
  76626. * Stores all the generated animation samplers, which is referenced by glTF animations
  76627. */
  76628. /**
  76629. * Stores the animations for glTF models
  76630. */
  76631. private _animations;
  76632. /**
  76633. * Stores the total amount of bytes stored in the glTF buffer
  76634. */
  76635. private _totalByteLength;
  76636. /**
  76637. * Stores a reference to the Babylon scene containing the source geometry and material information
  76638. */
  76639. _babylonScene: Scene;
  76640. /**
  76641. * Stores a map of the image data, where the key is the file name and the value
  76642. * is the image data
  76643. */
  76644. _imageData: {
  76645. [fileName: string]: {
  76646. data: Uint8Array;
  76647. mimeType: ImageMimeType;
  76648. };
  76649. };
  76650. /**
  76651. * Stores a map of the unique id of a node to its index in the node array
  76652. */
  76653. private _nodeMap;
  76654. /**
  76655. * Specifies if the Babylon scene should be converted to right-handed on export
  76656. */
  76657. _convertToRightHandedSystem: boolean;
  76658. /**
  76659. * Baked animation sample rate
  76660. */
  76661. private _animationSampleRate;
  76662. private _options;
  76663. private _localEngine;
  76664. _glTFMaterialExporter: _GLTFMaterialExporter;
  76665. private _extensions;
  76666. private static _ExtensionNames;
  76667. private static _ExtensionFactories;
  76668. private _applyExtension;
  76669. private _applyExtensions;
  76670. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76671. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76672. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76673. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76674. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76675. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76676. private _forEachExtensions;
  76677. private _extensionsOnExporting;
  76678. /**
  76679. * Load glTF serializer extensions
  76680. */
  76681. private _loadExtensions;
  76682. /**
  76683. * Creates a glTF Exporter instance, which can accept optional exporter options
  76684. * @param babylonScene Babylon scene object
  76685. * @param options Options to modify the behavior of the exporter
  76686. */
  76687. constructor(babylonScene: Scene, options?: IExportOptions);
  76688. dispose(): void;
  76689. /**
  76690. * Registers a glTF exporter extension
  76691. * @param name Name of the extension to export
  76692. * @param factory The factory function that creates the exporter extension
  76693. */
  76694. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76695. /**
  76696. * Un-registers an exporter extension
  76697. * @param name The name fo the exporter extension
  76698. * @returns A boolean indicating whether the extension has been un-registered
  76699. */
  76700. static UnregisterExtension(name: string): boolean;
  76701. /**
  76702. * Lazy load a local engine
  76703. */
  76704. _getLocalEngine(): Engine;
  76705. private reorderIndicesBasedOnPrimitiveMode;
  76706. /**
  76707. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76708. * clock-wise during export to glTF
  76709. * @param submesh BabylonJS submesh
  76710. * @param primitiveMode Primitive mode of the mesh
  76711. * @param sideOrientation the winding order of the submesh
  76712. * @param vertexBufferKind The type of vertex attribute
  76713. * @param meshAttributeArray The vertex attribute data
  76714. * @param byteOffset The offset to the binary data
  76715. * @param binaryWriter The binary data for the glTF file
  76716. */
  76717. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76718. /**
  76719. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76720. * clock-wise during export to glTF
  76721. * @param submesh BabylonJS submesh
  76722. * @param primitiveMode Primitive mode of the mesh
  76723. * @param sideOrientation the winding order of the submesh
  76724. * @param vertexBufferKind The type of vertex attribute
  76725. * @param meshAttributeArray The vertex attribute data
  76726. * @param byteOffset The offset to the binary data
  76727. * @param binaryWriter The binary data for the glTF file
  76728. */
  76729. private reorderTriangleFillMode;
  76730. /**
  76731. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76732. * clock-wise during export to glTF
  76733. * @param submesh BabylonJS submesh
  76734. * @param primitiveMode Primitive mode of the mesh
  76735. * @param sideOrientation the winding order of the submesh
  76736. * @param vertexBufferKind The type of vertex attribute
  76737. * @param meshAttributeArray The vertex attribute data
  76738. * @param byteOffset The offset to the binary data
  76739. * @param binaryWriter The binary data for the glTF file
  76740. */
  76741. private reorderTriangleStripDrawMode;
  76742. /**
  76743. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  76744. * clock-wise during export to glTF
  76745. * @param submesh BabylonJS submesh
  76746. * @param primitiveMode Primitive mode of the mesh
  76747. * @param sideOrientation the winding order of the submesh
  76748. * @param vertexBufferKind The type of vertex attribute
  76749. * @param meshAttributeArray The vertex attribute data
  76750. * @param byteOffset The offset to the binary data
  76751. * @param binaryWriter The binary data for the glTF file
  76752. */
  76753. private reorderTriangleFanMode;
  76754. /**
  76755. * Writes the vertex attribute data to binary
  76756. * @param vertices The vertices to write to the binary writer
  76757. * @param byteOffset The offset into the binary writer to overwrite binary data
  76758. * @param vertexAttributeKind The vertex attribute type
  76759. * @param meshAttributeArray The vertex attribute data
  76760. * @param binaryWriter The writer containing the binary data
  76761. */
  76762. private writeVertexAttributeData;
  76763. /**
  76764. * Writes mesh attribute data to a data buffer
  76765. * Returns the bytelength of the data
  76766. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  76767. * @param meshAttributeArray Array containing the attribute data
  76768. * @param binaryWriter The buffer to write the binary data to
  76769. * @param indices Used to specify the order of the vertex data
  76770. */
  76771. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  76772. /**
  76773. * Generates glTF json data
  76774. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  76775. * @param glTFPrefix Text to use when prefixing a glTF file
  76776. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  76777. * @returns json data as string
  76778. */
  76779. private generateJSON;
  76780. /**
  76781. * Generates data for .gltf and .bin files based on the glTF prefix string
  76782. * @param glTFPrefix Text to use when prefixing a glTF file
  76783. * @param dispose Dispose the exporter
  76784. * @returns GLTFData with glTF file data
  76785. */
  76786. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76787. /**
  76788. * Creates a binary buffer for glTF
  76789. * @returns array buffer for binary data
  76790. */
  76791. private _generateBinaryAsync;
  76792. /**
  76793. * Pads the number to a multiple of 4
  76794. * @param num number to pad
  76795. * @returns padded number
  76796. */
  76797. private _getPadding;
  76798. /**
  76799. * @hidden
  76800. */
  76801. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76802. /**
  76803. * Sets the TRS for each node
  76804. * @param node glTF Node for storing the transformation data
  76805. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  76806. */
  76807. private setNodeTransformation;
  76808. private getVertexBufferFromMesh;
  76809. /**
  76810. * Creates a bufferview based on the vertices type for the Babylon mesh
  76811. * @param kind Indicates the type of vertices data
  76812. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  76813. * @param binaryWriter The buffer to write the bufferview data to
  76814. */
  76815. private createBufferViewKind;
  76816. /**
  76817. * The primitive mode of the Babylon mesh
  76818. * @param babylonMesh The BabylonJS mesh
  76819. */
  76820. private getMeshPrimitiveMode;
  76821. /**
  76822. * Sets the primitive mode of the glTF mesh primitive
  76823. * @param meshPrimitive glTF mesh primitive
  76824. * @param primitiveMode The primitive mode
  76825. */
  76826. private setPrimitiveMode;
  76827. /**
  76828. * Sets the vertex attribute accessor based of the glTF mesh primitive
  76829. * @param meshPrimitive glTF mesh primitive
  76830. * @param attributeKind vertex attribute
  76831. * @returns boolean specifying if uv coordinates are present
  76832. */
  76833. private setAttributeKind;
  76834. /**
  76835. * Sets data for the primitive attributes of each submesh
  76836. * @param mesh glTF Mesh object to store the primitive attribute information
  76837. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  76838. * @param binaryWriter Buffer to write the attribute data to
  76839. */
  76840. private setPrimitiveAttributesAsync;
  76841. /**
  76842. * Creates a glTF scene based on the array of meshes
  76843. * Returns the the total byte offset
  76844. * @param babylonScene Babylon scene to get the mesh data from
  76845. * @param binaryWriter Buffer to write binary data to
  76846. */
  76847. private createSceneAsync;
  76848. /**
  76849. * Creates a mapping of Node unique id to node index and handles animations
  76850. * @param babylonScene Babylon Scene
  76851. * @param nodes Babylon transform nodes
  76852. * @param binaryWriter Buffer to write binary data to
  76853. * @returns Node mapping of unique id to index
  76854. */
  76855. private createNodeMapAndAnimationsAsync;
  76856. /**
  76857. * Creates a glTF node from a Babylon mesh
  76858. * @param babylonMesh Source Babylon mesh
  76859. * @param binaryWriter Buffer for storing geometry data
  76860. * @returns glTF node
  76861. */
  76862. private createNodeAsync;
  76863. }
  76864. /**
  76865. * @hidden
  76866. *
  76867. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  76868. */
  76869. export class _BinaryWriter {
  76870. /**
  76871. * Array buffer which stores all binary data
  76872. */
  76873. private _arrayBuffer;
  76874. /**
  76875. * View of the array buffer
  76876. */
  76877. private _dataView;
  76878. /**
  76879. * byte offset of data in array buffer
  76880. */
  76881. private _byteOffset;
  76882. /**
  76883. * Initialize binary writer with an initial byte length
  76884. * @param byteLength Initial byte length of the array buffer
  76885. */
  76886. constructor(byteLength: number);
  76887. /**
  76888. * Resize the array buffer to the specified byte length
  76889. * @param byteLength
  76890. */
  76891. private resizeBuffer;
  76892. /**
  76893. * Get an array buffer with the length of the byte offset
  76894. * @returns ArrayBuffer resized to the byte offset
  76895. */
  76896. getArrayBuffer(): ArrayBuffer;
  76897. /**
  76898. * Get the byte offset of the array buffer
  76899. * @returns byte offset
  76900. */
  76901. getByteOffset(): number;
  76902. /**
  76903. * Stores an UInt8 in the array buffer
  76904. * @param entry
  76905. * @param byteOffset If defined, specifies where to set the value as an offset.
  76906. */
  76907. setUInt8(entry: number, byteOffset?: number): void;
  76908. /**
  76909. * Gets an UInt32 in the array buffer
  76910. * @param entry
  76911. * @param byteOffset If defined, specifies where to set the value as an offset.
  76912. */
  76913. getUInt32(byteOffset: number): number;
  76914. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76915. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76916. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76917. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76918. /**
  76919. * Stores a Float32 in the array buffer
  76920. * @param entry
  76921. */
  76922. setFloat32(entry: number, byteOffset?: number): void;
  76923. /**
  76924. * Stores an UInt32 in the array buffer
  76925. * @param entry
  76926. * @param byteOffset If defined, specifies where to set the value as an offset.
  76927. */
  76928. setUInt32(entry: number, byteOffset?: number): void;
  76929. }
  76930. }
  76931. declare module BABYLON.GLTF2.Exporter {
  76932. /**
  76933. * @hidden
  76934. * Interface to store animation data.
  76935. */
  76936. export interface _IAnimationData {
  76937. /**
  76938. * Keyframe data.
  76939. */
  76940. inputs: number[];
  76941. /**
  76942. * Value data.
  76943. */
  76944. outputs: number[][];
  76945. /**
  76946. * Animation interpolation data.
  76947. */
  76948. samplerInterpolation: AnimationSamplerInterpolation;
  76949. /**
  76950. * Minimum keyframe value.
  76951. */
  76952. inputsMin: number;
  76953. /**
  76954. * Maximum keyframe value.
  76955. */
  76956. inputsMax: number;
  76957. }
  76958. /**
  76959. * @hidden
  76960. */
  76961. export interface _IAnimationInfo {
  76962. /**
  76963. * The target channel for the animation
  76964. */
  76965. animationChannelTargetPath: AnimationChannelTargetPath;
  76966. /**
  76967. * The glTF accessor type for the data.
  76968. */
  76969. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  76970. /**
  76971. * Specifies if quaternions should be used.
  76972. */
  76973. useQuaternion: boolean;
  76974. }
  76975. /**
  76976. * @hidden
  76977. * Utility class for generating glTF animation data from BabylonJS.
  76978. */
  76979. export class _GLTFAnimation {
  76980. /**
  76981. * @ignore
  76982. *
  76983. * Creates glTF channel animation from BabylonJS animation.
  76984. * @param babylonTransformNode - BabylonJS mesh.
  76985. * @param animation - animation.
  76986. * @param animationChannelTargetPath - The target animation channel.
  76987. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  76988. * @param useQuaternion - Specifies if quaternions are used.
  76989. * @returns nullable IAnimationData
  76990. */
  76991. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  76992. private static _DeduceAnimationInfo;
  76993. /**
  76994. * @ignore
  76995. * Create node animations from the transform node animations
  76996. * @param babylonNode
  76997. * @param runtimeGLTFAnimation
  76998. * @param idleGLTFAnimations
  76999. * @param nodeMap
  77000. * @param nodes
  77001. * @param binaryWriter
  77002. * @param bufferViews
  77003. * @param accessors
  77004. * @param convertToRightHandedSystem
  77005. */
  77006. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77007. [key: number]: number;
  77008. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77009. /**
  77010. * @ignore
  77011. * Create node animations from the animation groups
  77012. * @param babylonScene
  77013. * @param glTFAnimations
  77014. * @param nodeMap
  77015. * @param nodes
  77016. * @param binaryWriter
  77017. * @param bufferViews
  77018. * @param accessors
  77019. * @param convertToRightHandedSystem
  77020. */
  77021. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77022. [key: number]: number;
  77023. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77024. private static AddAnimation;
  77025. /**
  77026. * Create a baked animation
  77027. * @param babylonTransformNode BabylonJS mesh
  77028. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77029. * @param animationChannelTargetPath animation target channel
  77030. * @param minFrame minimum animation frame
  77031. * @param maxFrame maximum animation frame
  77032. * @param fps frames per second of the animation
  77033. * @param inputs input key frames of the animation
  77034. * @param outputs output key frame data of the animation
  77035. * @param convertToRightHandedSystem converts the values to right-handed
  77036. * @param useQuaternion specifies if quaternions should be used
  77037. */
  77038. private static _CreateBakedAnimation;
  77039. private static _ConvertFactorToVector3OrQuaternion;
  77040. private static _SetInterpolatedValue;
  77041. /**
  77042. * Creates linear animation from the animation key frames
  77043. * @param babylonTransformNode BabylonJS mesh
  77044. * @param animation BabylonJS animation
  77045. * @param animationChannelTargetPath The target animation channel
  77046. * @param frameDelta The difference between the last and first frame of the animation
  77047. * @param inputs Array to store the key frame times
  77048. * @param outputs Array to store the key frame data
  77049. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77050. * @param useQuaternion Specifies if quaternions are used in the animation
  77051. */
  77052. private static _CreateLinearOrStepAnimation;
  77053. /**
  77054. * Creates cubic spline animation from the animation key frames
  77055. * @param babylonTransformNode BabylonJS mesh
  77056. * @param animation BabylonJS animation
  77057. * @param animationChannelTargetPath The target animation channel
  77058. * @param frameDelta The difference between the last and first frame of the animation
  77059. * @param inputs Array to store the key frame times
  77060. * @param outputs Array to store the key frame data
  77061. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77062. * @param useQuaternion Specifies if quaternions are used in the animation
  77063. */
  77064. private static _CreateCubicSplineAnimation;
  77065. private static _GetBasePositionRotationOrScale;
  77066. /**
  77067. * Adds a key frame value
  77068. * @param keyFrame
  77069. * @param animation
  77070. * @param outputs
  77071. * @param animationChannelTargetPath
  77072. * @param basePositionRotationOrScale
  77073. * @param convertToRightHandedSystem
  77074. * @param useQuaternion
  77075. */
  77076. private static _AddKeyframeValue;
  77077. /**
  77078. * Determine the interpolation based on the key frames
  77079. * @param keyFrames
  77080. * @param animationChannelTargetPath
  77081. * @param useQuaternion
  77082. */
  77083. private static _DeduceInterpolation;
  77084. /**
  77085. * Adds an input tangent or output tangent to the output data
  77086. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77087. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77088. * @param outputs The animation data by keyframe
  77089. * @param animationChannelTargetPath The target animation channel
  77090. * @param interpolation The interpolation type
  77091. * @param keyFrame The key frame with the animation data
  77092. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77093. * @param useQuaternion Specifies if quaternions are used
  77094. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77095. */
  77096. private static AddSplineTangent;
  77097. /**
  77098. * Get the minimum and maximum key frames' frame values
  77099. * @param keyFrames animation key frames
  77100. * @returns the minimum and maximum key frame value
  77101. */
  77102. private static calculateMinMaxKeyFrames;
  77103. }
  77104. }
  77105. declare module BABYLON.GLTF2.Exporter {
  77106. /** @hidden */
  77107. export var textureTransformPixelShader: {
  77108. name: string;
  77109. shader: string;
  77110. };
  77111. }
  77112. declare module BABYLON.GLTF2.Exporter.Extensions {
  77113. /**
  77114. * @hidden
  77115. */
  77116. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77117. private _recordedTextures;
  77118. /** Name of this extension */
  77119. readonly name: string;
  77120. /** Defines whether this extension is enabled */
  77121. enabled: boolean;
  77122. /** Defines whether this extension is required */
  77123. required: boolean;
  77124. /** Reference to the glTF exporter */
  77125. private _wasUsed;
  77126. constructor(exporter: _Exporter);
  77127. dispose(): void;
  77128. /** @hidden */
  77129. get wasUsed(): boolean;
  77130. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77131. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77132. /**
  77133. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77134. * @param babylonTexture
  77135. * @param offset
  77136. * @param rotation
  77137. * @param scale
  77138. * @param scene
  77139. */
  77140. private _textureTransformTextureAsync;
  77141. }
  77142. }
  77143. declare module BABYLON.GLTF2.Exporter.Extensions {
  77144. /**
  77145. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77146. */
  77147. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77148. /** The name of this extension. */
  77149. readonly name: string;
  77150. /** Defines whether this extension is enabled. */
  77151. enabled: boolean;
  77152. /** Defines whether this extension is required */
  77153. required: boolean;
  77154. /** Reference to the glTF exporter */
  77155. private _exporter;
  77156. private _lights;
  77157. /** @hidden */
  77158. constructor(exporter: _Exporter);
  77159. /** @hidden */
  77160. dispose(): void;
  77161. /** @hidden */
  77162. get wasUsed(): boolean;
  77163. /** @hidden */
  77164. onExporting(): void;
  77165. /**
  77166. * Define this method to modify the default behavior when exporting a node
  77167. * @param context The context when exporting the node
  77168. * @param node glTF node
  77169. * @param babylonNode BabylonJS node
  77170. * @returns nullable INode promise
  77171. */
  77172. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  77173. }
  77174. }
  77175. declare module BABYLON.GLTF2.Exporter.Extensions {
  77176. /**
  77177. * @hidden
  77178. */
  77179. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77180. /** Name of this extension */
  77181. readonly name: string;
  77182. /** Defines whether this extension is enabled */
  77183. enabled: boolean;
  77184. /** Defines whether this extension is required */
  77185. required: boolean;
  77186. /** Reference to the glTF exporter */
  77187. private _textureInfos;
  77188. private _exportedTextures;
  77189. private _wasUsed;
  77190. constructor(exporter: _Exporter);
  77191. dispose(): void;
  77192. /** @hidden */
  77193. get wasUsed(): boolean;
  77194. private _getTextureIndex;
  77195. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77196. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77197. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77198. }
  77199. }
  77200. declare module BABYLON {
  77201. /**
  77202. * Class for generating STL data from a Babylon scene.
  77203. */
  77204. export class STLExport {
  77205. /**
  77206. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77207. * @param meshes list defines the mesh to serialize
  77208. * @param download triggers the automatic download of the file.
  77209. * @param fileName changes the downloads fileName.
  77210. * @param binary changes the STL to a binary type.
  77211. * @param isLittleEndian toggle for binary type exporter.
  77212. * @returns the STL as UTF8 string
  77213. */
  77214. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77215. }
  77216. }
  77217. declare module "babylonjs-gltf2interface" {
  77218. export = BABYLON.GLTF2;
  77219. }
  77220. /**
  77221. * Module for glTF 2.0 Interface
  77222. */
  77223. declare module BABYLON.GLTF2 {
  77224. /**
  77225. * The datatype of the components in the attribute
  77226. */
  77227. const enum AccessorComponentType {
  77228. /**
  77229. * Byte
  77230. */
  77231. BYTE = 5120,
  77232. /**
  77233. * Unsigned Byte
  77234. */
  77235. UNSIGNED_BYTE = 5121,
  77236. /**
  77237. * Short
  77238. */
  77239. SHORT = 5122,
  77240. /**
  77241. * Unsigned Short
  77242. */
  77243. UNSIGNED_SHORT = 5123,
  77244. /**
  77245. * Unsigned Int
  77246. */
  77247. UNSIGNED_INT = 5125,
  77248. /**
  77249. * Float
  77250. */
  77251. FLOAT = 5126,
  77252. }
  77253. /**
  77254. * Specifies if the attirbute is a scalar, vector, or matrix
  77255. */
  77256. const enum AccessorType {
  77257. /**
  77258. * Scalar
  77259. */
  77260. SCALAR = "SCALAR",
  77261. /**
  77262. * Vector2
  77263. */
  77264. VEC2 = "VEC2",
  77265. /**
  77266. * Vector3
  77267. */
  77268. VEC3 = "VEC3",
  77269. /**
  77270. * Vector4
  77271. */
  77272. VEC4 = "VEC4",
  77273. /**
  77274. * Matrix2x2
  77275. */
  77276. MAT2 = "MAT2",
  77277. /**
  77278. * Matrix3x3
  77279. */
  77280. MAT3 = "MAT3",
  77281. /**
  77282. * Matrix4x4
  77283. */
  77284. MAT4 = "MAT4",
  77285. }
  77286. /**
  77287. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77288. */
  77289. const enum AnimationChannelTargetPath {
  77290. /**
  77291. * Translation
  77292. */
  77293. TRANSLATION = "translation",
  77294. /**
  77295. * Rotation
  77296. */
  77297. ROTATION = "rotation",
  77298. /**
  77299. * Scale
  77300. */
  77301. SCALE = "scale",
  77302. /**
  77303. * Weights
  77304. */
  77305. WEIGHTS = "weights",
  77306. }
  77307. /**
  77308. * Interpolation algorithm
  77309. */
  77310. const enum AnimationSamplerInterpolation {
  77311. /**
  77312. * The animated values are linearly interpolated between keyframes
  77313. */
  77314. LINEAR = "LINEAR",
  77315. /**
  77316. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77317. */
  77318. STEP = "STEP",
  77319. /**
  77320. * The animation's interpolation is computed using a cubic spline with specified tangents
  77321. */
  77322. CUBICSPLINE = "CUBICSPLINE",
  77323. }
  77324. /**
  77325. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77326. */
  77327. const enum CameraType {
  77328. /**
  77329. * A perspective camera containing properties to create a perspective projection matrix
  77330. */
  77331. PERSPECTIVE = "perspective",
  77332. /**
  77333. * An orthographic camera containing properties to create an orthographic projection matrix
  77334. */
  77335. ORTHOGRAPHIC = "orthographic",
  77336. }
  77337. /**
  77338. * The mime-type of the image
  77339. */
  77340. const enum ImageMimeType {
  77341. /**
  77342. * JPEG Mime-type
  77343. */
  77344. JPEG = "image/jpeg",
  77345. /**
  77346. * PNG Mime-type
  77347. */
  77348. PNG = "image/png",
  77349. }
  77350. /**
  77351. * The alpha rendering mode of the material
  77352. */
  77353. const enum MaterialAlphaMode {
  77354. /**
  77355. * The alpha value is ignored and the rendered output is fully opaque
  77356. */
  77357. OPAQUE = "OPAQUE",
  77358. /**
  77359. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77360. */
  77361. MASK = "MASK",
  77362. /**
  77363. * 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)
  77364. */
  77365. BLEND = "BLEND",
  77366. }
  77367. /**
  77368. * The type of the primitives to render
  77369. */
  77370. const enum MeshPrimitiveMode {
  77371. /**
  77372. * Points
  77373. */
  77374. POINTS = 0,
  77375. /**
  77376. * Lines
  77377. */
  77378. LINES = 1,
  77379. /**
  77380. * Line Loop
  77381. */
  77382. LINE_LOOP = 2,
  77383. /**
  77384. * Line Strip
  77385. */
  77386. LINE_STRIP = 3,
  77387. /**
  77388. * Triangles
  77389. */
  77390. TRIANGLES = 4,
  77391. /**
  77392. * Triangle Strip
  77393. */
  77394. TRIANGLE_STRIP = 5,
  77395. /**
  77396. * Triangle Fan
  77397. */
  77398. TRIANGLE_FAN = 6,
  77399. }
  77400. /**
  77401. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77402. */
  77403. const enum TextureMagFilter {
  77404. /**
  77405. * Nearest
  77406. */
  77407. NEAREST = 9728,
  77408. /**
  77409. * Linear
  77410. */
  77411. LINEAR = 9729,
  77412. }
  77413. /**
  77414. * Minification filter. All valid values correspond to WebGL enums
  77415. */
  77416. const enum TextureMinFilter {
  77417. /**
  77418. * Nearest
  77419. */
  77420. NEAREST = 9728,
  77421. /**
  77422. * Linear
  77423. */
  77424. LINEAR = 9729,
  77425. /**
  77426. * Nearest Mip-Map Nearest
  77427. */
  77428. NEAREST_MIPMAP_NEAREST = 9984,
  77429. /**
  77430. * Linear Mipmap Nearest
  77431. */
  77432. LINEAR_MIPMAP_NEAREST = 9985,
  77433. /**
  77434. * Nearest Mipmap Linear
  77435. */
  77436. NEAREST_MIPMAP_LINEAR = 9986,
  77437. /**
  77438. * Linear Mipmap Linear
  77439. */
  77440. LINEAR_MIPMAP_LINEAR = 9987,
  77441. }
  77442. /**
  77443. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77444. */
  77445. const enum TextureWrapMode {
  77446. /**
  77447. * Clamp to Edge
  77448. */
  77449. CLAMP_TO_EDGE = 33071,
  77450. /**
  77451. * Mirrored Repeat
  77452. */
  77453. MIRRORED_REPEAT = 33648,
  77454. /**
  77455. * Repeat
  77456. */
  77457. REPEAT = 10497,
  77458. }
  77459. /**
  77460. * glTF Property
  77461. */
  77462. interface IProperty {
  77463. /**
  77464. * Dictionary object with extension-specific objects
  77465. */
  77466. extensions?: {
  77467. [key: string]: any;
  77468. };
  77469. /**
  77470. * Application-Specific data
  77471. */
  77472. extras?: any;
  77473. }
  77474. /**
  77475. * glTF Child of Root Property
  77476. */
  77477. interface IChildRootProperty extends IProperty {
  77478. /**
  77479. * The user-defined name of this object
  77480. */
  77481. name?: string;
  77482. }
  77483. /**
  77484. * Indices of those attributes that deviate from their initialization value
  77485. */
  77486. interface IAccessorSparseIndices extends IProperty {
  77487. /**
  77488. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77489. */
  77490. bufferView: number;
  77491. /**
  77492. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77493. */
  77494. byteOffset?: number;
  77495. /**
  77496. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77497. */
  77498. componentType: AccessorComponentType;
  77499. }
  77500. /**
  77501. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77502. */
  77503. interface IAccessorSparseValues extends IProperty {
  77504. /**
  77505. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77506. */
  77507. bufferView: number;
  77508. /**
  77509. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77510. */
  77511. byteOffset?: number;
  77512. }
  77513. /**
  77514. * Sparse storage of attributes that deviate from their initialization value
  77515. */
  77516. interface IAccessorSparse extends IProperty {
  77517. /**
  77518. * The number of attributes encoded in this sparse accessor
  77519. */
  77520. count: number;
  77521. /**
  77522. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77523. */
  77524. indices: IAccessorSparseIndices;
  77525. /**
  77526. * 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
  77527. */
  77528. values: IAccessorSparseValues;
  77529. }
  77530. /**
  77531. * 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
  77532. */
  77533. interface IAccessor extends IChildRootProperty {
  77534. /**
  77535. * The index of the bufferview
  77536. */
  77537. bufferView?: number;
  77538. /**
  77539. * The offset relative to the start of the bufferView in bytes
  77540. */
  77541. byteOffset?: number;
  77542. /**
  77543. * The datatype of components in the attribute
  77544. */
  77545. componentType: AccessorComponentType;
  77546. /**
  77547. * Specifies whether integer data values should be normalized
  77548. */
  77549. normalized?: boolean;
  77550. /**
  77551. * The number of attributes referenced by this accessor
  77552. */
  77553. count: number;
  77554. /**
  77555. * Specifies if the attribute is a scalar, vector, or matrix
  77556. */
  77557. type: AccessorType;
  77558. /**
  77559. * Maximum value of each component in this attribute
  77560. */
  77561. max?: number[];
  77562. /**
  77563. * Minimum value of each component in this attribute
  77564. */
  77565. min?: number[];
  77566. /**
  77567. * Sparse storage of attributes that deviate from their initialization value
  77568. */
  77569. sparse?: IAccessorSparse;
  77570. }
  77571. /**
  77572. * Targets an animation's sampler at a node's property
  77573. */
  77574. interface IAnimationChannel extends IProperty {
  77575. /**
  77576. * The index of a sampler in this animation used to compute the value for the target
  77577. */
  77578. sampler: number;
  77579. /**
  77580. * The index of the node and TRS property to target
  77581. */
  77582. target: IAnimationChannelTarget;
  77583. }
  77584. /**
  77585. * The index of the node and TRS property that an animation channel targets
  77586. */
  77587. interface IAnimationChannelTarget extends IProperty {
  77588. /**
  77589. * The index of the node to target
  77590. */
  77591. node: number;
  77592. /**
  77593. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77594. */
  77595. path: AnimationChannelTargetPath;
  77596. }
  77597. /**
  77598. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77599. */
  77600. interface IAnimationSampler extends IProperty {
  77601. /**
  77602. * The index of an accessor containing keyframe input values, e.g., time
  77603. */
  77604. input: number;
  77605. /**
  77606. * Interpolation algorithm
  77607. */
  77608. interpolation?: AnimationSamplerInterpolation;
  77609. /**
  77610. * The index of an accessor, containing keyframe output values
  77611. */
  77612. output: number;
  77613. }
  77614. /**
  77615. * A keyframe animation
  77616. */
  77617. interface IAnimation extends IChildRootProperty {
  77618. /**
  77619. * An array of channels, each of which targets an animation's sampler at a node's property
  77620. */
  77621. channels: IAnimationChannel[];
  77622. /**
  77623. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77624. */
  77625. samplers: IAnimationSampler[];
  77626. }
  77627. /**
  77628. * Metadata about the glTF asset
  77629. */
  77630. interface IAsset extends IChildRootProperty {
  77631. /**
  77632. * A copyright message suitable for display to credit the content creator
  77633. */
  77634. copyright?: string;
  77635. /**
  77636. * Tool that generated this glTF model. Useful for debugging
  77637. */
  77638. generator?: string;
  77639. /**
  77640. * The glTF version that this asset targets
  77641. */
  77642. version: string;
  77643. /**
  77644. * The minimum glTF version that this asset targets
  77645. */
  77646. minVersion?: string;
  77647. }
  77648. /**
  77649. * A buffer points to binary geometry, animation, or skins
  77650. */
  77651. interface IBuffer extends IChildRootProperty {
  77652. /**
  77653. * 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
  77654. */
  77655. uri?: string;
  77656. /**
  77657. * The length of the buffer in bytes
  77658. */
  77659. byteLength: number;
  77660. }
  77661. /**
  77662. * A view into a buffer generally representing a subset of the buffer
  77663. */
  77664. interface IBufferView extends IChildRootProperty {
  77665. /**
  77666. * The index of the buffer
  77667. */
  77668. buffer: number;
  77669. /**
  77670. * The offset into the buffer in bytes
  77671. */
  77672. byteOffset?: number;
  77673. /**
  77674. * The lenth of the bufferView in bytes
  77675. */
  77676. byteLength: number;
  77677. /**
  77678. * The stride, in bytes
  77679. */
  77680. byteStride?: number;
  77681. }
  77682. /**
  77683. * An orthographic camera containing properties to create an orthographic projection matrix
  77684. */
  77685. interface ICameraOrthographic extends IProperty {
  77686. /**
  77687. * The floating-point horizontal magnification of the view. Must not be zero
  77688. */
  77689. xmag: number;
  77690. /**
  77691. * The floating-point vertical magnification of the view. Must not be zero
  77692. */
  77693. ymag: number;
  77694. /**
  77695. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77696. */
  77697. zfar: number;
  77698. /**
  77699. * The floating-point distance to the near clipping plane
  77700. */
  77701. znear: number;
  77702. }
  77703. /**
  77704. * A perspective camera containing properties to create a perspective projection matrix
  77705. */
  77706. interface ICameraPerspective extends IProperty {
  77707. /**
  77708. * The floating-point aspect ratio of the field of view
  77709. */
  77710. aspectRatio?: number;
  77711. /**
  77712. * The floating-point vertical field of view in radians
  77713. */
  77714. yfov: number;
  77715. /**
  77716. * The floating-point distance to the far clipping plane
  77717. */
  77718. zfar?: number;
  77719. /**
  77720. * The floating-point distance to the near clipping plane
  77721. */
  77722. znear: number;
  77723. }
  77724. /**
  77725. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77726. */
  77727. interface ICamera extends IChildRootProperty {
  77728. /**
  77729. * An orthographic camera containing properties to create an orthographic projection matrix
  77730. */
  77731. orthographic?: ICameraOrthographic;
  77732. /**
  77733. * A perspective camera containing properties to create a perspective projection matrix
  77734. */
  77735. perspective?: ICameraPerspective;
  77736. /**
  77737. * Specifies if the camera uses a perspective or orthographic projection
  77738. */
  77739. type: CameraType;
  77740. }
  77741. /**
  77742. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  77743. */
  77744. interface IImage extends IChildRootProperty {
  77745. /**
  77746. * 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
  77747. */
  77748. uri?: string;
  77749. /**
  77750. * The image's MIME type
  77751. */
  77752. mimeType?: ImageMimeType;
  77753. /**
  77754. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  77755. */
  77756. bufferView?: number;
  77757. }
  77758. /**
  77759. * Material Normal Texture Info
  77760. */
  77761. interface IMaterialNormalTextureInfo extends ITextureInfo {
  77762. /**
  77763. * The scalar multiplier applied to each normal vector of the normal texture
  77764. */
  77765. scale?: number;
  77766. }
  77767. /**
  77768. * Material Occlusion Texture Info
  77769. */
  77770. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  77771. /**
  77772. * A scalar multiplier controlling the amount of occlusion applied
  77773. */
  77774. strength?: number;
  77775. }
  77776. /**
  77777. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  77778. */
  77779. interface IMaterialPbrMetallicRoughness {
  77780. /**
  77781. * The material's base color factor
  77782. */
  77783. baseColorFactor?: number[];
  77784. /**
  77785. * The base color texture
  77786. */
  77787. baseColorTexture?: ITextureInfo;
  77788. /**
  77789. * The metalness of the material
  77790. */
  77791. metallicFactor?: number;
  77792. /**
  77793. * The roughness of the material
  77794. */
  77795. roughnessFactor?: number;
  77796. /**
  77797. * The metallic-roughness texture
  77798. */
  77799. metallicRoughnessTexture?: ITextureInfo;
  77800. }
  77801. /**
  77802. * The material appearance of a primitive
  77803. */
  77804. interface IMaterial extends IChildRootProperty {
  77805. /**
  77806. * 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
  77807. */
  77808. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77809. /**
  77810. * The normal map texture
  77811. */
  77812. normalTexture?: IMaterialNormalTextureInfo;
  77813. /**
  77814. * The occlusion map texture
  77815. */
  77816. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77817. /**
  77818. * The emissive map texture
  77819. */
  77820. emissiveTexture?: ITextureInfo;
  77821. /**
  77822. * 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
  77823. */
  77824. emissiveFactor?: number[];
  77825. /**
  77826. * The alpha rendering mode of the material
  77827. */
  77828. alphaMode?: MaterialAlphaMode;
  77829. /**
  77830. * The alpha cutoff value of the material
  77831. */
  77832. alphaCutoff?: number;
  77833. /**
  77834. * Specifies whether the material is double sided
  77835. */
  77836. doubleSided?: boolean;
  77837. }
  77838. /**
  77839. * Geometry to be rendered with the given material
  77840. */
  77841. interface IMeshPrimitive extends IProperty {
  77842. /**
  77843. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  77844. */
  77845. attributes: {
  77846. [name: string]: number;
  77847. };
  77848. /**
  77849. * The index of the accessor that contains the indices
  77850. */
  77851. indices?: number;
  77852. /**
  77853. * The index of the material to apply to this primitive when rendering
  77854. */
  77855. material?: number;
  77856. /**
  77857. * The type of primitives to render. All valid values correspond to WebGL enums
  77858. */
  77859. mode?: MeshPrimitiveMode;
  77860. /**
  77861. * 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
  77862. */
  77863. targets?: {
  77864. [name: string]: number;
  77865. }[];
  77866. }
  77867. /**
  77868. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  77869. */
  77870. interface IMesh extends IChildRootProperty {
  77871. /**
  77872. * An array of primitives, each defining geometry to be rendered with a material
  77873. */
  77874. primitives: IMeshPrimitive[];
  77875. /**
  77876. * Array of weights to be applied to the Morph Targets
  77877. */
  77878. weights?: number[];
  77879. }
  77880. /**
  77881. * A node in the node hierarchy
  77882. */
  77883. interface INode extends IChildRootProperty {
  77884. /**
  77885. * The index of the camera referenced by this node
  77886. */
  77887. camera?: number;
  77888. /**
  77889. * The indices of this node's children
  77890. */
  77891. children?: number[];
  77892. /**
  77893. * The index of the skin referenced by this node
  77894. */
  77895. skin?: number;
  77896. /**
  77897. * A floating-point 4x4 transformation matrix stored in column-major order
  77898. */
  77899. matrix?: number[];
  77900. /**
  77901. * The index of the mesh in this node
  77902. */
  77903. mesh?: number;
  77904. /**
  77905. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  77906. */
  77907. rotation?: number[];
  77908. /**
  77909. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  77910. */
  77911. scale?: number[];
  77912. /**
  77913. * The node's translation along the x, y, and z axes
  77914. */
  77915. translation?: number[];
  77916. /**
  77917. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  77918. */
  77919. weights?: number[];
  77920. }
  77921. /**
  77922. * Texture sampler properties for filtering and wrapping modes
  77923. */
  77924. interface ISampler extends IChildRootProperty {
  77925. /**
  77926. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77927. */
  77928. magFilter?: TextureMagFilter;
  77929. /**
  77930. * Minification filter. All valid values correspond to WebGL enums
  77931. */
  77932. minFilter?: TextureMinFilter;
  77933. /**
  77934. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77935. */
  77936. wrapS?: TextureWrapMode;
  77937. /**
  77938. * T (V) wrapping mode. All valid values correspond to WebGL enums
  77939. */
  77940. wrapT?: TextureWrapMode;
  77941. }
  77942. /**
  77943. * The root nodes of a scene
  77944. */
  77945. interface IScene extends IChildRootProperty {
  77946. /**
  77947. * The indices of each root node
  77948. */
  77949. nodes: number[];
  77950. }
  77951. /**
  77952. * Joints and matrices defining a skin
  77953. */
  77954. interface ISkin extends IChildRootProperty {
  77955. /**
  77956. * 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
  77957. */
  77958. inverseBindMatrices?: number;
  77959. /**
  77960. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  77961. */
  77962. skeleton?: number;
  77963. /**
  77964. * 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)
  77965. */
  77966. joints: number[];
  77967. }
  77968. /**
  77969. * A texture and its sampler
  77970. */
  77971. interface ITexture extends IChildRootProperty {
  77972. /**
  77973. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  77974. */
  77975. sampler?: number;
  77976. /**
  77977. * The index of the image used by this texture
  77978. */
  77979. source: number;
  77980. }
  77981. /**
  77982. * Reference to a texture
  77983. */
  77984. interface ITextureInfo extends IProperty {
  77985. /**
  77986. * The index of the texture
  77987. */
  77988. index: number;
  77989. /**
  77990. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  77991. */
  77992. texCoord?: number;
  77993. }
  77994. /**
  77995. * The root object for a glTF asset
  77996. */
  77997. interface IGLTF extends IProperty {
  77998. /**
  77999. * An array of accessors. An accessor is a typed view into a bufferView
  78000. */
  78001. accessors?: IAccessor[];
  78002. /**
  78003. * An array of keyframe animations
  78004. */
  78005. animations?: IAnimation[];
  78006. /**
  78007. * Metadata about the glTF asset
  78008. */
  78009. asset: IAsset;
  78010. /**
  78011. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78012. */
  78013. buffers?: IBuffer[];
  78014. /**
  78015. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78016. */
  78017. bufferViews?: IBufferView[];
  78018. /**
  78019. * An array of cameras
  78020. */
  78021. cameras?: ICamera[];
  78022. /**
  78023. * Names of glTF extensions used somewhere in this asset
  78024. */
  78025. extensionsUsed?: string[];
  78026. /**
  78027. * Names of glTF extensions required to properly load this asset
  78028. */
  78029. extensionsRequired?: string[];
  78030. /**
  78031. * An array of images. An image defines data used to create a texture
  78032. */
  78033. images?: IImage[];
  78034. /**
  78035. * An array of materials. A material defines the appearance of a primitive
  78036. */
  78037. materials?: IMaterial[];
  78038. /**
  78039. * An array of meshes. A mesh is a set of primitives to be rendered
  78040. */
  78041. meshes?: IMesh[];
  78042. /**
  78043. * An array of nodes
  78044. */
  78045. nodes?: INode[];
  78046. /**
  78047. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78048. */
  78049. samplers?: ISampler[];
  78050. /**
  78051. * The index of the default scene
  78052. */
  78053. scene?: number;
  78054. /**
  78055. * An array of scenes
  78056. */
  78057. scenes?: IScene[];
  78058. /**
  78059. * An array of skins. A skin is defined by joints and matrices
  78060. */
  78061. skins?: ISkin[];
  78062. /**
  78063. * An array of textures
  78064. */
  78065. textures?: ITexture[];
  78066. }
  78067. /**
  78068. * The glTF validation results
  78069. * @ignore
  78070. */
  78071. interface IGLTFValidationResults {
  78072. info: {
  78073. generator: string;
  78074. hasAnimations: boolean;
  78075. hasDefaultScene: boolean;
  78076. hasMaterials: boolean;
  78077. hasMorphTargets: boolean;
  78078. hasSkins: boolean;
  78079. hasTextures: boolean;
  78080. maxAttributesUsed: number;
  78081. primitivesCount: number
  78082. };
  78083. issues: {
  78084. messages: Array<string>;
  78085. numErrors: number;
  78086. numHints: number;
  78087. numInfos: number;
  78088. numWarnings: number;
  78089. truncated: boolean
  78090. };
  78091. mimeType: string;
  78092. uri: string;
  78093. validatedAt: string;
  78094. validatorVersion: string;
  78095. }
  78096. /**
  78097. * The glTF validation options
  78098. */
  78099. interface IGLTFValidationOptions {
  78100. /** Uri to use */
  78101. uri?: string;
  78102. /** Function used to load external resources */
  78103. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78104. /** Boolean indicating that we need to validate accessor data */
  78105. validateAccessorData?: boolean;
  78106. /** max number of issues allowed */
  78107. maxIssues?: number;
  78108. /** Ignored issues */
  78109. ignoredIssues?: Array<string>;
  78110. /** Value to override severy settings */
  78111. severityOverrides?: Object;
  78112. }
  78113. /**
  78114. * The glTF validator object
  78115. * @ignore
  78116. */
  78117. interface IGLTFValidator {
  78118. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78119. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78120. }
  78121. }
  78122. declare module BABYLON {
  78123. /** @hidden */
  78124. export var cellPixelShader: {
  78125. name: string;
  78126. shader: string;
  78127. };
  78128. }
  78129. declare module BABYLON {
  78130. /** @hidden */
  78131. export var cellVertexShader: {
  78132. name: string;
  78133. shader: string;
  78134. };
  78135. }
  78136. declare module BABYLON {
  78137. export class CellMaterial extends BABYLON.PushMaterial {
  78138. private _diffuseTexture;
  78139. diffuseTexture: BABYLON.BaseTexture;
  78140. diffuseColor: BABYLON.Color3;
  78141. _computeHighLevel: boolean;
  78142. computeHighLevel: boolean;
  78143. private _disableLighting;
  78144. disableLighting: boolean;
  78145. private _maxSimultaneousLights;
  78146. maxSimultaneousLights: number;
  78147. private _renderId;
  78148. constructor(name: string, scene: BABYLON.Scene);
  78149. needAlphaBlending(): boolean;
  78150. needAlphaTesting(): boolean;
  78151. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78152. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78153. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78154. getAnimatables(): BABYLON.IAnimatable[];
  78155. getActiveTextures(): BABYLON.BaseTexture[];
  78156. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78157. dispose(forceDisposeEffect?: boolean): void;
  78158. getClassName(): string;
  78159. clone(name: string): CellMaterial;
  78160. serialize(): any;
  78161. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78162. }
  78163. }
  78164. declare module BABYLON {
  78165. export class CustomShaderStructure {
  78166. FragmentStore: string;
  78167. VertexStore: string;
  78168. constructor();
  78169. }
  78170. export class ShaderSpecialParts {
  78171. constructor();
  78172. Fragment_Begin: string;
  78173. Fragment_Definitions: string;
  78174. Fragment_MainBegin: string;
  78175. Fragment_Custom_Diffuse: string;
  78176. Fragment_Before_Lights: string;
  78177. Fragment_Before_Fog: string;
  78178. Fragment_Custom_Alpha: string;
  78179. Fragment_Before_FragColor: string;
  78180. Vertex_Begin: string;
  78181. Vertex_Definitions: string;
  78182. Vertex_MainBegin: string;
  78183. Vertex_Before_PositionUpdated: string;
  78184. Vertex_Before_NormalUpdated: string;
  78185. Vertex_MainEnd: string;
  78186. }
  78187. export class CustomMaterial extends BABYLON.StandardMaterial {
  78188. static ShaderIndexer: number;
  78189. CustomParts: ShaderSpecialParts;
  78190. _isCreatedShader: boolean;
  78191. _createdShaderName: string;
  78192. _customUniform: string[];
  78193. _newUniforms: string[];
  78194. _newUniformInstances: any[];
  78195. _newSamplerInstances: BABYLON.Texture[];
  78196. FragmentShader: string;
  78197. VertexShader: string;
  78198. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78199. ReviewUniform(name: string, arr: string[]): string[];
  78200. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78201. constructor(name: string, scene: BABYLON.Scene);
  78202. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78203. Fragment_Begin(shaderPart: string): CustomMaterial;
  78204. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78205. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78206. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78207. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78208. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78209. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78210. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78211. Vertex_Begin(shaderPart: string): CustomMaterial;
  78212. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78213. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78214. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78215. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78216. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78217. }
  78218. }
  78219. declare module BABYLON {
  78220. export class ShaderAlebdoParts {
  78221. constructor();
  78222. Fragment_Begin: string;
  78223. Fragment_Definitions: string;
  78224. Fragment_MainBegin: string;
  78225. Fragment_Custom_Albedo: string;
  78226. Fragment_Before_Lights: string;
  78227. Fragment_Custom_MetallicRoughness: string;
  78228. Fragment_Custom_MicroSurface: string;
  78229. Fragment_Before_Fog: string;
  78230. Fragment_Custom_Alpha: string;
  78231. Fragment_Before_FragColor: string;
  78232. Vertex_Begin: string;
  78233. Vertex_Definitions: string;
  78234. Vertex_MainBegin: string;
  78235. Vertex_Before_PositionUpdated: string;
  78236. Vertex_Before_NormalUpdated: string;
  78237. Vertex_MainEnd: string;
  78238. }
  78239. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78240. static ShaderIndexer: number;
  78241. CustomParts: ShaderAlebdoParts;
  78242. _isCreatedShader: boolean;
  78243. _createdShaderName: string;
  78244. _customUniform: string[];
  78245. _newUniforms: string[];
  78246. _newUniformInstances: any[];
  78247. _newSamplerInstances: BABYLON.Texture[];
  78248. FragmentShader: string;
  78249. VertexShader: string;
  78250. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78251. ReviewUniform(name: string, arr: string[]): string[];
  78252. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78253. constructor(name: string, scene: BABYLON.Scene);
  78254. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78255. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78256. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78257. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78258. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78259. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78260. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78261. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78262. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78263. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78264. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78265. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78266. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78267. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78268. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78269. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78270. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78271. }
  78272. }
  78273. declare module BABYLON {
  78274. /** @hidden */
  78275. export var firePixelShader: {
  78276. name: string;
  78277. shader: string;
  78278. };
  78279. }
  78280. declare module BABYLON {
  78281. /** @hidden */
  78282. export var fireVertexShader: {
  78283. name: string;
  78284. shader: string;
  78285. };
  78286. }
  78287. declare module BABYLON {
  78288. export class FireMaterial extends BABYLON.PushMaterial {
  78289. private _diffuseTexture;
  78290. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78291. private _distortionTexture;
  78292. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78293. private _opacityTexture;
  78294. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78295. diffuseColor: BABYLON.Color3;
  78296. speed: number;
  78297. private _scaledDiffuse;
  78298. private _renderId;
  78299. private _lastTime;
  78300. constructor(name: string, scene: BABYLON.Scene);
  78301. needAlphaBlending(): boolean;
  78302. needAlphaTesting(): boolean;
  78303. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78304. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78305. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78306. getAnimatables(): BABYLON.IAnimatable[];
  78307. getActiveTextures(): BABYLON.BaseTexture[];
  78308. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78309. getClassName(): string;
  78310. dispose(forceDisposeEffect?: boolean): void;
  78311. clone(name: string): FireMaterial;
  78312. serialize(): any;
  78313. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78314. }
  78315. }
  78316. declare module BABYLON {
  78317. /** @hidden */
  78318. export var furPixelShader: {
  78319. name: string;
  78320. shader: string;
  78321. };
  78322. }
  78323. declare module BABYLON {
  78324. /** @hidden */
  78325. export var furVertexShader: {
  78326. name: string;
  78327. shader: string;
  78328. };
  78329. }
  78330. declare module BABYLON {
  78331. export class FurMaterial extends BABYLON.PushMaterial {
  78332. private _diffuseTexture;
  78333. diffuseTexture: BABYLON.BaseTexture;
  78334. private _heightTexture;
  78335. heightTexture: BABYLON.BaseTexture;
  78336. diffuseColor: BABYLON.Color3;
  78337. furLength: number;
  78338. furAngle: number;
  78339. furColor: BABYLON.Color3;
  78340. furOffset: number;
  78341. furSpacing: number;
  78342. furGravity: BABYLON.Vector3;
  78343. furSpeed: number;
  78344. furDensity: number;
  78345. furOcclusion: number;
  78346. furTexture: BABYLON.DynamicTexture;
  78347. private _disableLighting;
  78348. disableLighting: boolean;
  78349. private _maxSimultaneousLights;
  78350. maxSimultaneousLights: number;
  78351. highLevelFur: boolean;
  78352. _meshes: BABYLON.AbstractMesh[];
  78353. private _renderId;
  78354. private _furTime;
  78355. constructor(name: string, scene: BABYLON.Scene);
  78356. get furTime(): number;
  78357. set furTime(furTime: number);
  78358. needAlphaBlending(): boolean;
  78359. needAlphaTesting(): boolean;
  78360. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78361. updateFur(): void;
  78362. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78363. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78364. getAnimatables(): BABYLON.IAnimatable[];
  78365. getActiveTextures(): BABYLON.BaseTexture[];
  78366. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78367. dispose(forceDisposeEffect?: boolean): void;
  78368. clone(name: string): FurMaterial;
  78369. serialize(): any;
  78370. getClassName(): string;
  78371. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78372. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78373. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78374. }
  78375. }
  78376. declare module BABYLON {
  78377. /** @hidden */
  78378. export var gradientPixelShader: {
  78379. name: string;
  78380. shader: string;
  78381. };
  78382. }
  78383. declare module BABYLON {
  78384. /** @hidden */
  78385. export var gradientVertexShader: {
  78386. name: string;
  78387. shader: string;
  78388. };
  78389. }
  78390. declare module BABYLON {
  78391. export class GradientMaterial extends BABYLON.PushMaterial {
  78392. private _maxSimultaneousLights;
  78393. maxSimultaneousLights: number;
  78394. topColor: BABYLON.Color3;
  78395. topColorAlpha: number;
  78396. bottomColor: BABYLON.Color3;
  78397. bottomColorAlpha: number;
  78398. offset: number;
  78399. scale: number;
  78400. smoothness: number;
  78401. private _disableLighting;
  78402. disableLighting: boolean;
  78403. private _renderId;
  78404. constructor(name: string, scene: BABYLON.Scene);
  78405. needAlphaBlending(): boolean;
  78406. needAlphaTesting(): boolean;
  78407. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78408. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78409. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78410. getAnimatables(): BABYLON.IAnimatable[];
  78411. dispose(forceDisposeEffect?: boolean): void;
  78412. clone(name: string): GradientMaterial;
  78413. serialize(): any;
  78414. getClassName(): string;
  78415. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78416. }
  78417. }
  78418. declare module BABYLON {
  78419. /** @hidden */
  78420. export var gridPixelShader: {
  78421. name: string;
  78422. shader: string;
  78423. };
  78424. }
  78425. declare module BABYLON {
  78426. /** @hidden */
  78427. export var gridVertexShader: {
  78428. name: string;
  78429. shader: string;
  78430. };
  78431. }
  78432. declare module BABYLON {
  78433. /**
  78434. * The grid materials allows you to wrap any shape with a grid.
  78435. * Colors are customizable.
  78436. */
  78437. export class GridMaterial extends BABYLON.PushMaterial {
  78438. /**
  78439. * Main color of the grid (e.g. between lines)
  78440. */
  78441. mainColor: BABYLON.Color3;
  78442. /**
  78443. * Color of the grid lines.
  78444. */
  78445. lineColor: BABYLON.Color3;
  78446. /**
  78447. * The scale of the grid compared to unit.
  78448. */
  78449. gridRatio: number;
  78450. /**
  78451. * Allows setting an offset for the grid lines.
  78452. */
  78453. gridOffset: BABYLON.Vector3;
  78454. /**
  78455. * The frequency of thicker lines.
  78456. */
  78457. majorUnitFrequency: number;
  78458. /**
  78459. * The visibility of minor units in the grid.
  78460. */
  78461. minorUnitVisibility: number;
  78462. /**
  78463. * The grid opacity outside of the lines.
  78464. */
  78465. opacity: number;
  78466. /**
  78467. * Determine RBG output is premultiplied by alpha value.
  78468. */
  78469. preMultiplyAlpha: boolean;
  78470. private _opacityTexture;
  78471. opacityTexture: BABYLON.BaseTexture;
  78472. private _gridControl;
  78473. private _renderId;
  78474. /**
  78475. * constructor
  78476. * @param name The name given to the material in order to identify it afterwards.
  78477. * @param scene The scene the material is used in.
  78478. */
  78479. constructor(name: string, scene: BABYLON.Scene);
  78480. /**
  78481. * Returns wehter or not the grid requires alpha blending.
  78482. */
  78483. needAlphaBlending(): boolean;
  78484. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78485. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78486. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78487. /**
  78488. * Dispose the material and its associated resources.
  78489. * @param forceDisposeEffect will also dispose the used effect when true
  78490. */
  78491. dispose(forceDisposeEffect?: boolean): void;
  78492. clone(name: string): GridMaterial;
  78493. serialize(): any;
  78494. getClassName(): string;
  78495. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78496. }
  78497. }
  78498. declare module BABYLON {
  78499. /** @hidden */
  78500. export var lavaPixelShader: {
  78501. name: string;
  78502. shader: string;
  78503. };
  78504. }
  78505. declare module BABYLON {
  78506. /** @hidden */
  78507. export var lavaVertexShader: {
  78508. name: string;
  78509. shader: string;
  78510. };
  78511. }
  78512. declare module BABYLON {
  78513. export class LavaMaterial extends BABYLON.PushMaterial {
  78514. private _diffuseTexture;
  78515. diffuseTexture: BABYLON.BaseTexture;
  78516. noiseTexture: BABYLON.BaseTexture;
  78517. fogColor: BABYLON.Color3;
  78518. speed: number;
  78519. movingSpeed: number;
  78520. lowFrequencySpeed: number;
  78521. fogDensity: number;
  78522. private _lastTime;
  78523. diffuseColor: BABYLON.Color3;
  78524. private _disableLighting;
  78525. disableLighting: boolean;
  78526. private _unlit;
  78527. unlit: boolean;
  78528. private _maxSimultaneousLights;
  78529. maxSimultaneousLights: number;
  78530. private _scaledDiffuse;
  78531. private _renderId;
  78532. constructor(name: string, scene: BABYLON.Scene);
  78533. needAlphaBlending(): boolean;
  78534. needAlphaTesting(): boolean;
  78535. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78536. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78537. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78538. getAnimatables(): BABYLON.IAnimatable[];
  78539. getActiveTextures(): BABYLON.BaseTexture[];
  78540. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78541. dispose(forceDisposeEffect?: boolean): void;
  78542. clone(name: string): LavaMaterial;
  78543. serialize(): any;
  78544. getClassName(): string;
  78545. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78546. }
  78547. }
  78548. declare module BABYLON {
  78549. /** @hidden */
  78550. export var mixPixelShader: {
  78551. name: string;
  78552. shader: string;
  78553. };
  78554. }
  78555. declare module BABYLON {
  78556. /** @hidden */
  78557. export var mixVertexShader: {
  78558. name: string;
  78559. shader: string;
  78560. };
  78561. }
  78562. declare module BABYLON {
  78563. export class MixMaterial extends BABYLON.PushMaterial {
  78564. /**
  78565. * Mix textures
  78566. */
  78567. private _mixTexture1;
  78568. mixTexture1: BABYLON.BaseTexture;
  78569. private _mixTexture2;
  78570. mixTexture2: BABYLON.BaseTexture;
  78571. /**
  78572. * Diffuse textures
  78573. */
  78574. private _diffuseTexture1;
  78575. diffuseTexture1: BABYLON.Texture;
  78576. private _diffuseTexture2;
  78577. diffuseTexture2: BABYLON.Texture;
  78578. private _diffuseTexture3;
  78579. diffuseTexture3: BABYLON.Texture;
  78580. private _diffuseTexture4;
  78581. diffuseTexture4: BABYLON.Texture;
  78582. private _diffuseTexture5;
  78583. diffuseTexture5: BABYLON.Texture;
  78584. private _diffuseTexture6;
  78585. diffuseTexture6: BABYLON.Texture;
  78586. private _diffuseTexture7;
  78587. diffuseTexture7: BABYLON.Texture;
  78588. private _diffuseTexture8;
  78589. diffuseTexture8: BABYLON.Texture;
  78590. /**
  78591. * Uniforms
  78592. */
  78593. diffuseColor: BABYLON.Color3;
  78594. specularColor: BABYLON.Color3;
  78595. specularPower: number;
  78596. private _disableLighting;
  78597. disableLighting: boolean;
  78598. private _maxSimultaneousLights;
  78599. maxSimultaneousLights: number;
  78600. private _renderId;
  78601. constructor(name: string, scene: BABYLON.Scene);
  78602. needAlphaBlending(): boolean;
  78603. needAlphaTesting(): boolean;
  78604. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78605. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78606. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78607. getAnimatables(): BABYLON.IAnimatable[];
  78608. getActiveTextures(): BABYLON.BaseTexture[];
  78609. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78610. dispose(forceDisposeEffect?: boolean): void;
  78611. clone(name: string): MixMaterial;
  78612. serialize(): any;
  78613. getClassName(): string;
  78614. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78615. }
  78616. }
  78617. declare module BABYLON {
  78618. /** @hidden */
  78619. export var normalPixelShader: {
  78620. name: string;
  78621. shader: string;
  78622. };
  78623. }
  78624. declare module BABYLON {
  78625. /** @hidden */
  78626. export var normalVertexShader: {
  78627. name: string;
  78628. shader: string;
  78629. };
  78630. }
  78631. declare module BABYLON {
  78632. export class NormalMaterial extends BABYLON.PushMaterial {
  78633. private _diffuseTexture;
  78634. diffuseTexture: BABYLON.BaseTexture;
  78635. diffuseColor: BABYLON.Color3;
  78636. private _disableLighting;
  78637. disableLighting: boolean;
  78638. private _maxSimultaneousLights;
  78639. maxSimultaneousLights: number;
  78640. private _renderId;
  78641. constructor(name: string, scene: BABYLON.Scene);
  78642. needAlphaBlending(): boolean;
  78643. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78644. needAlphaTesting(): boolean;
  78645. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78646. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78647. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78648. getAnimatables(): BABYLON.IAnimatable[];
  78649. getActiveTextures(): BABYLON.BaseTexture[];
  78650. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78651. dispose(forceDisposeEffect?: boolean): void;
  78652. clone(name: string): NormalMaterial;
  78653. serialize(): any;
  78654. getClassName(): string;
  78655. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78656. }
  78657. }
  78658. declare module BABYLON {
  78659. /** @hidden */
  78660. export var shadowOnlyPixelShader: {
  78661. name: string;
  78662. shader: string;
  78663. };
  78664. }
  78665. declare module BABYLON {
  78666. /** @hidden */
  78667. export var shadowOnlyVertexShader: {
  78668. name: string;
  78669. shader: string;
  78670. };
  78671. }
  78672. declare module BABYLON {
  78673. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78674. private _renderId;
  78675. private _activeLight;
  78676. constructor(name: string, scene: BABYLON.Scene);
  78677. shadowColor: BABYLON.Color3;
  78678. needAlphaBlending(): boolean;
  78679. needAlphaTesting(): boolean;
  78680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78681. get activeLight(): BABYLON.IShadowLight;
  78682. set activeLight(light: BABYLON.IShadowLight);
  78683. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78684. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78685. clone(name: string): ShadowOnlyMaterial;
  78686. serialize(): any;
  78687. getClassName(): string;
  78688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78689. }
  78690. }
  78691. declare module BABYLON {
  78692. /** @hidden */
  78693. export var simplePixelShader: {
  78694. name: string;
  78695. shader: string;
  78696. };
  78697. }
  78698. declare module BABYLON {
  78699. /** @hidden */
  78700. export var simpleVertexShader: {
  78701. name: string;
  78702. shader: string;
  78703. };
  78704. }
  78705. declare module BABYLON {
  78706. export class SimpleMaterial extends BABYLON.PushMaterial {
  78707. private _diffuseTexture;
  78708. diffuseTexture: BABYLON.BaseTexture;
  78709. diffuseColor: BABYLON.Color3;
  78710. private _disableLighting;
  78711. disableLighting: boolean;
  78712. private _maxSimultaneousLights;
  78713. maxSimultaneousLights: number;
  78714. private _renderId;
  78715. constructor(name: string, scene: BABYLON.Scene);
  78716. needAlphaBlending(): boolean;
  78717. needAlphaTesting(): boolean;
  78718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78721. getAnimatables(): BABYLON.IAnimatable[];
  78722. getActiveTextures(): BABYLON.BaseTexture[];
  78723. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78724. dispose(forceDisposeEffect?: boolean): void;
  78725. clone(name: string): SimpleMaterial;
  78726. serialize(): any;
  78727. getClassName(): string;
  78728. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78729. }
  78730. }
  78731. declare module BABYLON {
  78732. /** @hidden */
  78733. export var skyPixelShader: {
  78734. name: string;
  78735. shader: string;
  78736. };
  78737. }
  78738. declare module BABYLON {
  78739. /** @hidden */
  78740. export var skyVertexShader: {
  78741. name: string;
  78742. shader: string;
  78743. };
  78744. }
  78745. declare module BABYLON {
  78746. /**
  78747. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  78748. * @see https://doc.babylonjs.com/extensions/sky
  78749. */
  78750. export class SkyMaterial extends BABYLON.PushMaterial {
  78751. /**
  78752. * Defines the overall luminance of sky in interval ]0, 1[.
  78753. */
  78754. luminance: number;
  78755. /**
  78756. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  78757. */
  78758. turbidity: number;
  78759. /**
  78760. * Defines the sky appearance (light intensity).
  78761. */
  78762. rayleigh: number;
  78763. /**
  78764. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  78765. */
  78766. mieCoefficient: number;
  78767. /**
  78768. * Defines the amount of haze particles following the Mie scattering theory.
  78769. */
  78770. mieDirectionalG: number;
  78771. /**
  78772. * Defines the distance of the sun according to the active scene camera.
  78773. */
  78774. distance: number;
  78775. /**
  78776. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  78777. * "inclined".
  78778. */
  78779. inclination: number;
  78780. /**
  78781. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  78782. * an object direction and a reference direction.
  78783. */
  78784. azimuth: number;
  78785. /**
  78786. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  78787. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  78788. */
  78789. sunPosition: BABYLON.Vector3;
  78790. /**
  78791. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  78792. * .sunPosition property.
  78793. */
  78794. useSunPosition: boolean;
  78795. /**
  78796. * Defines an offset vector used to get a horizon offset.
  78797. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  78798. */
  78799. cameraOffset: BABYLON.Vector3;
  78800. private _cameraPosition;
  78801. private _renderId;
  78802. /**
  78803. * Instantiates a new sky material.
  78804. * This material allows to create dynamic and texture free
  78805. * effects for skyboxes by taking care of the atmosphere state.
  78806. * @see https://doc.babylonjs.com/extensions/sky
  78807. * @param name Define the name of the material in the scene
  78808. * @param scene Define the scene the material belong to
  78809. */
  78810. constructor(name: string, scene: BABYLON.Scene);
  78811. /**
  78812. * Specifies if the material will require alpha blending
  78813. * @returns a boolean specifying if alpha blending is needed
  78814. */
  78815. needAlphaBlending(): boolean;
  78816. /**
  78817. * Specifies if this material should be rendered in alpha test mode
  78818. * @returns false as the sky material doesn't need alpha testing.
  78819. */
  78820. needAlphaTesting(): boolean;
  78821. /**
  78822. * Get the texture used for alpha test purpose.
  78823. * @returns null as the sky material has no texture.
  78824. */
  78825. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78826. /**
  78827. * Get if the submesh is ready to be used and all its information available.
  78828. * Child classes can use it to update shaders
  78829. * @param mesh defines the mesh to check
  78830. * @param subMesh defines which submesh to check
  78831. * @param useInstances specifies that instances should be used
  78832. * @returns a boolean indicating that the submesh is ready or not
  78833. */
  78834. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78835. /**
  78836. * Binds the submesh to this material by preparing the effect and shader to draw
  78837. * @param world defines the world transformation matrix
  78838. * @param mesh defines the mesh containing the submesh
  78839. * @param subMesh defines the submesh to bind the material to
  78840. */
  78841. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78842. /**
  78843. * Get the list of animatables in the material.
  78844. * @returns the list of animatables object used in the material
  78845. */
  78846. getAnimatables(): BABYLON.IAnimatable[];
  78847. /**
  78848. * Disposes the material
  78849. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78850. */
  78851. dispose(forceDisposeEffect?: boolean): void;
  78852. /**
  78853. * Makes a duplicate of the material, and gives it a new name
  78854. * @param name defines the new name for the duplicated material
  78855. * @returns the cloned material
  78856. */
  78857. clone(name: string): SkyMaterial;
  78858. /**
  78859. * Serializes this material in a JSON representation
  78860. * @returns the serialized material object
  78861. */
  78862. serialize(): any;
  78863. /**
  78864. * Gets the current class name of the material e.g. "SkyMaterial"
  78865. * Mainly use in serialization.
  78866. * @returns the class name
  78867. */
  78868. getClassName(): string;
  78869. /**
  78870. * Creates a sky material from parsed material data
  78871. * @param source defines the JSON representation of the material
  78872. * @param scene defines the hosting scene
  78873. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  78874. * @returns a new sky material
  78875. */
  78876. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  78877. }
  78878. }
  78879. declare module BABYLON {
  78880. /** @hidden */
  78881. export var terrainPixelShader: {
  78882. name: string;
  78883. shader: string;
  78884. };
  78885. }
  78886. declare module BABYLON {
  78887. /** @hidden */
  78888. export var terrainVertexShader: {
  78889. name: string;
  78890. shader: string;
  78891. };
  78892. }
  78893. declare module BABYLON {
  78894. export class TerrainMaterial extends BABYLON.PushMaterial {
  78895. private _mixTexture;
  78896. mixTexture: BABYLON.BaseTexture;
  78897. private _diffuseTexture1;
  78898. diffuseTexture1: BABYLON.Texture;
  78899. private _diffuseTexture2;
  78900. diffuseTexture2: BABYLON.Texture;
  78901. private _diffuseTexture3;
  78902. diffuseTexture3: BABYLON.Texture;
  78903. private _bumpTexture1;
  78904. bumpTexture1: BABYLON.Texture;
  78905. private _bumpTexture2;
  78906. bumpTexture2: BABYLON.Texture;
  78907. private _bumpTexture3;
  78908. bumpTexture3: BABYLON.Texture;
  78909. diffuseColor: BABYLON.Color3;
  78910. specularColor: BABYLON.Color3;
  78911. specularPower: number;
  78912. private _disableLighting;
  78913. disableLighting: boolean;
  78914. private _maxSimultaneousLights;
  78915. maxSimultaneousLights: number;
  78916. private _renderId;
  78917. constructor(name: string, scene: BABYLON.Scene);
  78918. needAlphaBlending(): boolean;
  78919. needAlphaTesting(): boolean;
  78920. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78921. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78922. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78923. getAnimatables(): BABYLON.IAnimatable[];
  78924. getActiveTextures(): BABYLON.BaseTexture[];
  78925. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78926. dispose(forceDisposeEffect?: boolean): void;
  78927. clone(name: string): TerrainMaterial;
  78928. serialize(): any;
  78929. getClassName(): string;
  78930. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  78931. }
  78932. }
  78933. declare module BABYLON {
  78934. /** @hidden */
  78935. export var triplanarPixelShader: {
  78936. name: string;
  78937. shader: string;
  78938. };
  78939. }
  78940. declare module BABYLON {
  78941. /** @hidden */
  78942. export var triplanarVertexShader: {
  78943. name: string;
  78944. shader: string;
  78945. };
  78946. }
  78947. declare module BABYLON {
  78948. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  78949. mixTexture: BABYLON.BaseTexture;
  78950. private _diffuseTextureX;
  78951. diffuseTextureX: BABYLON.BaseTexture;
  78952. private _diffuseTextureY;
  78953. diffuseTextureY: BABYLON.BaseTexture;
  78954. private _diffuseTextureZ;
  78955. diffuseTextureZ: BABYLON.BaseTexture;
  78956. private _normalTextureX;
  78957. normalTextureX: BABYLON.BaseTexture;
  78958. private _normalTextureY;
  78959. normalTextureY: BABYLON.BaseTexture;
  78960. private _normalTextureZ;
  78961. normalTextureZ: BABYLON.BaseTexture;
  78962. tileSize: number;
  78963. diffuseColor: BABYLON.Color3;
  78964. specularColor: BABYLON.Color3;
  78965. specularPower: number;
  78966. private _disableLighting;
  78967. disableLighting: boolean;
  78968. private _maxSimultaneousLights;
  78969. maxSimultaneousLights: number;
  78970. private _renderId;
  78971. constructor(name: string, scene: BABYLON.Scene);
  78972. needAlphaBlending(): boolean;
  78973. needAlphaTesting(): boolean;
  78974. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78975. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78976. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78977. getAnimatables(): BABYLON.IAnimatable[];
  78978. getActiveTextures(): BABYLON.BaseTexture[];
  78979. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78980. dispose(forceDisposeEffect?: boolean): void;
  78981. clone(name: string): TriPlanarMaterial;
  78982. serialize(): any;
  78983. getClassName(): string;
  78984. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  78985. }
  78986. }
  78987. declare module BABYLON {
  78988. /** @hidden */
  78989. export var waterPixelShader: {
  78990. name: string;
  78991. shader: string;
  78992. };
  78993. }
  78994. declare module BABYLON {
  78995. /** @hidden */
  78996. export var waterVertexShader: {
  78997. name: string;
  78998. shader: string;
  78999. };
  79000. }
  79001. declare module BABYLON {
  79002. export class WaterMaterial extends BABYLON.PushMaterial {
  79003. renderTargetSize: BABYLON.Vector2;
  79004. private _bumpTexture;
  79005. bumpTexture: BABYLON.BaseTexture;
  79006. diffuseColor: BABYLON.Color3;
  79007. specularColor: BABYLON.Color3;
  79008. specularPower: number;
  79009. private _disableLighting;
  79010. disableLighting: boolean;
  79011. private _maxSimultaneousLights;
  79012. maxSimultaneousLights: number;
  79013. /**
  79014. * @param {number}: Represents the wind force
  79015. */
  79016. windForce: number;
  79017. /**
  79018. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79019. */
  79020. windDirection: BABYLON.Vector2;
  79021. /**
  79022. * @param {number}: Wave height, represents the height of the waves
  79023. */
  79024. waveHeight: number;
  79025. /**
  79026. * @param {number}: Bump height, represents the bump height related to the bump map
  79027. */
  79028. bumpHeight: number;
  79029. /**
  79030. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79031. */
  79032. private _bumpSuperimpose;
  79033. bumpSuperimpose: boolean;
  79034. /**
  79035. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79036. */
  79037. private _fresnelSeparate;
  79038. fresnelSeparate: boolean;
  79039. /**
  79040. * @param {boolean}: bump Waves modify the reflection.
  79041. */
  79042. private _bumpAffectsReflection;
  79043. bumpAffectsReflection: boolean;
  79044. /**
  79045. * @param {number}: The water color blended with the refraction (near)
  79046. */
  79047. waterColor: BABYLON.Color3;
  79048. /**
  79049. * @param {number}: The blend factor related to the water color
  79050. */
  79051. colorBlendFactor: number;
  79052. /**
  79053. * @param {number}: The water color blended with the reflection (far)
  79054. */
  79055. waterColor2: BABYLON.Color3;
  79056. /**
  79057. * @param {number}: The blend factor related to the water color (reflection, far)
  79058. */
  79059. colorBlendFactor2: number;
  79060. /**
  79061. * @param {number}: Represents the maximum length of a wave
  79062. */
  79063. waveLength: number;
  79064. /**
  79065. * @param {number}: Defines the waves speed
  79066. */
  79067. waveSpeed: number;
  79068. /**
  79069. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79070. * will avoid calculating useless pixels in the pixel shader of the water material.
  79071. */
  79072. disableClipPlane: boolean;
  79073. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79074. private _mesh;
  79075. private _refractionRTT;
  79076. private _reflectionRTT;
  79077. private _reflectionTransform;
  79078. private _lastTime;
  79079. private _lastDeltaTime;
  79080. private _renderId;
  79081. private _useLogarithmicDepth;
  79082. private _waitingRenderList;
  79083. private _imageProcessingConfiguration;
  79084. private _imageProcessingObserver;
  79085. /**
  79086. * Gets a boolean indicating that current material needs to register RTT
  79087. */
  79088. get hasRenderTargetTextures(): boolean;
  79089. /**
  79090. * Constructor
  79091. */
  79092. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79093. get useLogarithmicDepth(): boolean;
  79094. set useLogarithmicDepth(value: boolean);
  79095. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79096. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79097. addToRenderList(node: any): void;
  79098. enableRenderTargets(enable: boolean): void;
  79099. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79100. get renderTargetsEnabled(): boolean;
  79101. needAlphaBlending(): boolean;
  79102. needAlphaTesting(): boolean;
  79103. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79104. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79106. private _createRenderTargets;
  79107. getAnimatables(): BABYLON.IAnimatable[];
  79108. getActiveTextures(): BABYLON.BaseTexture[];
  79109. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79110. dispose(forceDisposeEffect?: boolean): void;
  79111. clone(name: string): WaterMaterial;
  79112. serialize(): any;
  79113. getClassName(): string;
  79114. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79115. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79116. }
  79117. }
  79118. declare module BABYLON {
  79119. /** @hidden */
  79120. export var asciiartPixelShader: {
  79121. name: string;
  79122. shader: string;
  79123. };
  79124. }
  79125. declare module BABYLON {
  79126. /**
  79127. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79128. *
  79129. * It basically takes care rendering the font front the given font size to a texture.
  79130. * This is used later on in the postprocess.
  79131. */
  79132. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79133. private _font;
  79134. private _text;
  79135. private _charSize;
  79136. /**
  79137. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79138. */
  79139. get charSize(): number;
  79140. /**
  79141. * Create a new instance of the Ascii Art FontTexture class
  79142. * @param name the name of the texture
  79143. * @param font the font to use, use the W3C CSS notation
  79144. * @param text the caracter set to use in the rendering.
  79145. * @param scene the scene that owns the texture
  79146. */
  79147. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79148. /**
  79149. * Gets the max char width of a font.
  79150. * @param font the font to use, use the W3C CSS notation
  79151. * @return the max char width
  79152. */
  79153. private getFontWidth;
  79154. /**
  79155. * Gets the max char height of a font.
  79156. * @param font the font to use, use the W3C CSS notation
  79157. * @return the max char height
  79158. */
  79159. private getFontHeight;
  79160. /**
  79161. * Clones the current AsciiArtTexture.
  79162. * @return the clone of the texture.
  79163. */
  79164. clone(): AsciiArtFontTexture;
  79165. /**
  79166. * Parses a json object representing the texture and returns an instance of it.
  79167. * @param source the source JSON representation
  79168. * @param scene the scene to create the texture for
  79169. * @return the parsed texture
  79170. */
  79171. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79172. }
  79173. /**
  79174. * Option available in the Ascii Art Post Process.
  79175. */
  79176. export interface IAsciiArtPostProcessOptions {
  79177. /**
  79178. * The font to use following the w3c font definition.
  79179. */
  79180. font?: string;
  79181. /**
  79182. * The character set to use in the postprocess.
  79183. */
  79184. characterSet?: string;
  79185. /**
  79186. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79187. * This number is defined between 0 and 1;
  79188. */
  79189. mixToTile?: number;
  79190. /**
  79191. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79192. * This number is defined between 0 and 1;
  79193. */
  79194. mixToNormal?: number;
  79195. }
  79196. /**
  79197. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79198. *
  79199. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79200. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79201. */
  79202. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79203. /**
  79204. * The font texture used to render the char in the post process.
  79205. */
  79206. private _asciiArtFontTexture;
  79207. /**
  79208. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79209. * This number is defined between 0 and 1;
  79210. */
  79211. mixToTile: number;
  79212. /**
  79213. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79214. * This number is defined between 0 and 1;
  79215. */
  79216. mixToNormal: number;
  79217. /**
  79218. * Instantiates a new Ascii Art Post Process.
  79219. * @param name the name to give to the postprocess
  79220. * @camera the camera to apply the post process to.
  79221. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79222. */
  79223. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79224. }
  79225. }
  79226. declare module BABYLON {
  79227. /** @hidden */
  79228. export var digitalrainPixelShader: {
  79229. name: string;
  79230. shader: string;
  79231. };
  79232. }
  79233. declare module BABYLON {
  79234. /**
  79235. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79236. *
  79237. * It basically takes care rendering the font front the given font size to a texture.
  79238. * This is used later on in the postprocess.
  79239. */
  79240. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79241. private _font;
  79242. private _text;
  79243. private _charSize;
  79244. /**
  79245. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79246. */
  79247. get charSize(): number;
  79248. /**
  79249. * Create a new instance of the Digital Rain FontTexture class
  79250. * @param name the name of the texture
  79251. * @param font the font to use, use the W3C CSS notation
  79252. * @param text the caracter set to use in the rendering.
  79253. * @param scene the scene that owns the texture
  79254. */
  79255. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79256. /**
  79257. * Gets the max char width of a font.
  79258. * @param font the font to use, use the W3C CSS notation
  79259. * @return the max char width
  79260. */
  79261. private getFontWidth;
  79262. /**
  79263. * Gets the max char height of a font.
  79264. * @param font the font to use, use the W3C CSS notation
  79265. * @return the max char height
  79266. */
  79267. private getFontHeight;
  79268. /**
  79269. * Clones the current DigitalRainFontTexture.
  79270. * @return the clone of the texture.
  79271. */
  79272. clone(): DigitalRainFontTexture;
  79273. /**
  79274. * Parses a json object representing the texture and returns an instance of it.
  79275. * @param source the source JSON representation
  79276. * @param scene the scene to create the texture for
  79277. * @return the parsed texture
  79278. */
  79279. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79280. }
  79281. /**
  79282. * Option available in the Digital Rain Post Process.
  79283. */
  79284. export interface IDigitalRainPostProcessOptions {
  79285. /**
  79286. * The font to use following the w3c font definition.
  79287. */
  79288. font?: string;
  79289. /**
  79290. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79291. * This number is defined between 0 and 1;
  79292. */
  79293. mixToTile?: number;
  79294. /**
  79295. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79296. * This number is defined between 0 and 1;
  79297. */
  79298. mixToNormal?: number;
  79299. }
  79300. /**
  79301. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79302. *
  79303. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79304. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79305. */
  79306. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79307. /**
  79308. * The font texture used to render the char in the post process.
  79309. */
  79310. private _digitalRainFontTexture;
  79311. /**
  79312. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79313. * This number is defined between 0 and 1;
  79314. */
  79315. mixToTile: number;
  79316. /**
  79317. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79318. * This number is defined between 0 and 1;
  79319. */
  79320. mixToNormal: number;
  79321. /**
  79322. * Instantiates a new Digital Rain Post Process.
  79323. * @param name the name to give to the postprocess
  79324. * @camera the camera to apply the post process to.
  79325. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79326. */
  79327. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79328. }
  79329. }
  79330. declare module BABYLON {
  79331. /** @hidden */
  79332. export var brickProceduralTexturePixelShader: {
  79333. name: string;
  79334. shader: string;
  79335. };
  79336. }
  79337. declare module BABYLON {
  79338. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79339. private _numberOfBricksHeight;
  79340. private _numberOfBricksWidth;
  79341. private _jointColor;
  79342. private _brickColor;
  79343. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79344. updateShaderUniforms(): void;
  79345. get numberOfBricksHeight(): number;
  79346. set numberOfBricksHeight(value: number);
  79347. get numberOfBricksWidth(): number;
  79348. set numberOfBricksWidth(value: number);
  79349. get jointColor(): BABYLON.Color3;
  79350. set jointColor(value: BABYLON.Color3);
  79351. get brickColor(): BABYLON.Color3;
  79352. set brickColor(value: BABYLON.Color3);
  79353. /**
  79354. * Serializes this brick procedural texture
  79355. * @returns a serialized brick procedural texture object
  79356. */
  79357. serialize(): any;
  79358. /**
  79359. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79360. * @param parsedTexture defines parsed texture data
  79361. * @param scene defines the current scene
  79362. * @param rootUrl defines the root URL containing brick procedural texture information
  79363. * @returns a parsed Brick Procedural BABYLON.Texture
  79364. */
  79365. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79366. }
  79367. }
  79368. declare module BABYLON {
  79369. /** @hidden */
  79370. export var cloudProceduralTexturePixelShader: {
  79371. name: string;
  79372. shader: string;
  79373. };
  79374. }
  79375. declare module BABYLON {
  79376. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79377. private _skyColor;
  79378. private _cloudColor;
  79379. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79380. updateShaderUniforms(): void;
  79381. get skyColor(): BABYLON.Color4;
  79382. set skyColor(value: BABYLON.Color4);
  79383. get cloudColor(): BABYLON.Color4;
  79384. set cloudColor(value: BABYLON.Color4);
  79385. /**
  79386. * Serializes this cloud procedural texture
  79387. * @returns a serialized cloud procedural texture object
  79388. */
  79389. serialize(): any;
  79390. /**
  79391. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79392. * @param parsedTexture defines parsed texture data
  79393. * @param scene defines the current scene
  79394. * @param rootUrl defines the root URL containing cloud procedural texture information
  79395. * @returns a parsed Cloud Procedural BABYLON.Texture
  79396. */
  79397. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79398. }
  79399. }
  79400. declare module BABYLON {
  79401. /** @hidden */
  79402. export var fireProceduralTexturePixelShader: {
  79403. name: string;
  79404. shader: string;
  79405. };
  79406. }
  79407. declare module BABYLON {
  79408. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79409. private _time;
  79410. private _speed;
  79411. private _autoGenerateTime;
  79412. private _fireColors;
  79413. private _alphaThreshold;
  79414. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79415. updateShaderUniforms(): void;
  79416. render(useCameraPostProcess?: boolean): void;
  79417. static get PurpleFireColors(): BABYLON.Color3[];
  79418. static get GreenFireColors(): BABYLON.Color3[];
  79419. static get RedFireColors(): BABYLON.Color3[];
  79420. static get BlueFireColors(): BABYLON.Color3[];
  79421. get autoGenerateTime(): boolean;
  79422. set autoGenerateTime(value: boolean);
  79423. get fireColors(): BABYLON.Color3[];
  79424. set fireColors(value: BABYLON.Color3[]);
  79425. get time(): number;
  79426. set time(value: number);
  79427. get speed(): BABYLON.Vector2;
  79428. set speed(value: BABYLON.Vector2);
  79429. get alphaThreshold(): number;
  79430. set alphaThreshold(value: number);
  79431. /**
  79432. * Serializes this fire procedural texture
  79433. * @returns a serialized fire procedural texture object
  79434. */
  79435. serialize(): any;
  79436. /**
  79437. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79438. * @param parsedTexture defines parsed texture data
  79439. * @param scene defines the current scene
  79440. * @param rootUrl defines the root URL containing fire procedural texture information
  79441. * @returns a parsed Fire Procedural BABYLON.Texture
  79442. */
  79443. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79444. }
  79445. }
  79446. declare module BABYLON {
  79447. /** @hidden */
  79448. export var grassProceduralTexturePixelShader: {
  79449. name: string;
  79450. shader: string;
  79451. };
  79452. }
  79453. declare module BABYLON {
  79454. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79455. private _grassColors;
  79456. private _groundColor;
  79457. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79458. updateShaderUniforms(): void;
  79459. get grassColors(): BABYLON.Color3[];
  79460. set grassColors(value: BABYLON.Color3[]);
  79461. get groundColor(): BABYLON.Color3;
  79462. set groundColor(value: BABYLON.Color3);
  79463. /**
  79464. * Serializes this grass procedural texture
  79465. * @returns a serialized grass procedural texture object
  79466. */
  79467. serialize(): any;
  79468. /**
  79469. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79470. * @param parsedTexture defines parsed texture data
  79471. * @param scene defines the current scene
  79472. * @param rootUrl defines the root URL containing grass procedural texture information
  79473. * @returns a parsed Grass Procedural BABYLON.Texture
  79474. */
  79475. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79476. }
  79477. }
  79478. declare module BABYLON {
  79479. /** @hidden */
  79480. export var marbleProceduralTexturePixelShader: {
  79481. name: string;
  79482. shader: string;
  79483. };
  79484. }
  79485. declare module BABYLON {
  79486. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79487. private _numberOfTilesHeight;
  79488. private _numberOfTilesWidth;
  79489. private _amplitude;
  79490. private _jointColor;
  79491. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79492. updateShaderUniforms(): void;
  79493. get numberOfTilesHeight(): number;
  79494. set numberOfTilesHeight(value: number);
  79495. get amplitude(): number;
  79496. set amplitude(value: number);
  79497. get numberOfTilesWidth(): number;
  79498. set numberOfTilesWidth(value: number);
  79499. get jointColor(): BABYLON.Color3;
  79500. set jointColor(value: BABYLON.Color3);
  79501. /**
  79502. * Serializes this marble procedural texture
  79503. * @returns a serialized marble procedural texture object
  79504. */
  79505. serialize(): any;
  79506. /**
  79507. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79508. * @param parsedTexture defines parsed texture data
  79509. * @param scene defines the current scene
  79510. * @param rootUrl defines the root URL containing marble procedural texture information
  79511. * @returns a parsed Marble Procedural BABYLON.Texture
  79512. */
  79513. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79514. }
  79515. }
  79516. declare module BABYLON {
  79517. /** @hidden */
  79518. export var normalMapProceduralTexturePixelShader: {
  79519. name: string;
  79520. shader: string;
  79521. };
  79522. }
  79523. declare module BABYLON {
  79524. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79525. private _baseTexture;
  79526. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79527. updateShaderUniforms(): void;
  79528. render(useCameraPostProcess?: boolean): void;
  79529. resize(size: any, generateMipMaps: any): void;
  79530. get baseTexture(): BABYLON.Texture;
  79531. set baseTexture(texture: BABYLON.Texture);
  79532. /**
  79533. * Serializes this normal map procedural texture
  79534. * @returns a serialized normal map procedural texture object
  79535. */
  79536. serialize(): any;
  79537. /**
  79538. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79539. * @param parsedTexture defines parsed texture data
  79540. * @param scene defines the current scene
  79541. * @param rootUrl defines the root URL containing normal map procedural texture information
  79542. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79543. */
  79544. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79545. }
  79546. }
  79547. declare module BABYLON {
  79548. /** @hidden */
  79549. export var perlinNoiseProceduralTexturePixelShader: {
  79550. name: string;
  79551. shader: string;
  79552. };
  79553. }
  79554. declare module BABYLON {
  79555. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79556. time: number;
  79557. timeScale: number;
  79558. translationSpeed: number;
  79559. private _currentTranslation;
  79560. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79561. updateShaderUniforms(): void;
  79562. render(useCameraPostProcess?: boolean): void;
  79563. resize(size: any, generateMipMaps: any): void;
  79564. /**
  79565. * Serializes this perlin noise procedural texture
  79566. * @returns a serialized perlin noise procedural texture object
  79567. */
  79568. serialize(): any;
  79569. /**
  79570. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79571. * @param parsedTexture defines parsed texture data
  79572. * @param scene defines the current scene
  79573. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79574. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79575. */
  79576. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79577. }
  79578. }
  79579. declare module BABYLON {
  79580. /** @hidden */
  79581. export var roadProceduralTexturePixelShader: {
  79582. name: string;
  79583. shader: string;
  79584. };
  79585. }
  79586. declare module BABYLON {
  79587. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79588. private _roadColor;
  79589. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79590. updateShaderUniforms(): void;
  79591. get roadColor(): BABYLON.Color3;
  79592. set roadColor(value: BABYLON.Color3);
  79593. /**
  79594. * Serializes this road procedural texture
  79595. * @returns a serialized road procedural texture object
  79596. */
  79597. serialize(): any;
  79598. /**
  79599. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79600. * @param parsedTexture defines parsed texture data
  79601. * @param scene defines the current scene
  79602. * @param rootUrl defines the root URL containing road procedural texture information
  79603. * @returns a parsed Road Procedural BABYLON.Texture
  79604. */
  79605. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79606. }
  79607. }
  79608. declare module BABYLON {
  79609. /** @hidden */
  79610. export var starfieldProceduralTexturePixelShader: {
  79611. name: string;
  79612. shader: string;
  79613. };
  79614. }
  79615. declare module BABYLON {
  79616. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79617. private _time;
  79618. private _alpha;
  79619. private _beta;
  79620. private _zoom;
  79621. private _formuparam;
  79622. private _stepsize;
  79623. private _tile;
  79624. private _brightness;
  79625. private _darkmatter;
  79626. private _distfading;
  79627. private _saturation;
  79628. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79629. updateShaderUniforms(): void;
  79630. get time(): number;
  79631. set time(value: number);
  79632. get alpha(): number;
  79633. set alpha(value: number);
  79634. get beta(): number;
  79635. set beta(value: number);
  79636. get formuparam(): number;
  79637. set formuparam(value: number);
  79638. get stepsize(): number;
  79639. set stepsize(value: number);
  79640. get zoom(): number;
  79641. set zoom(value: number);
  79642. get tile(): number;
  79643. set tile(value: number);
  79644. get brightness(): number;
  79645. set brightness(value: number);
  79646. get darkmatter(): number;
  79647. set darkmatter(value: number);
  79648. get distfading(): number;
  79649. set distfading(value: number);
  79650. get saturation(): number;
  79651. set saturation(value: number);
  79652. /**
  79653. * Serializes this starfield procedural texture
  79654. * @returns a serialized starfield procedural texture object
  79655. */
  79656. serialize(): any;
  79657. /**
  79658. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79659. * @param parsedTexture defines parsed texture data
  79660. * @param scene defines the current scene
  79661. * @param rootUrl defines the root URL containing startfield procedural texture information
  79662. * @returns a parsed Starfield Procedural BABYLON.Texture
  79663. */
  79664. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79665. }
  79666. }
  79667. declare module BABYLON {
  79668. /** @hidden */
  79669. export var woodProceduralTexturePixelShader: {
  79670. name: string;
  79671. shader: string;
  79672. };
  79673. }
  79674. declare module BABYLON {
  79675. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79676. private _ampScale;
  79677. private _woodColor;
  79678. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79679. updateShaderUniforms(): void;
  79680. get ampScale(): number;
  79681. set ampScale(value: number);
  79682. get woodColor(): BABYLON.Color3;
  79683. set woodColor(value: BABYLON.Color3);
  79684. /**
  79685. * Serializes this wood procedural texture
  79686. * @returns a serialized wood procedural texture object
  79687. */
  79688. serialize(): any;
  79689. /**
  79690. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79691. * @param parsedTexture defines parsed texture data
  79692. * @param scene defines the current scene
  79693. * @param rootUrl defines the root URL containing wood procedural texture information
  79694. * @returns a parsed Wood Procedural BABYLON.Texture
  79695. */
  79696. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79697. }
  79698. }