documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represens a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5064. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Node | Scene) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** Id of the the submesh that was picked */
  10307. subMeshId: number;
  10308. /** If a sprite was picked, this will be the sprite the pick collided with */
  10309. pickedSprite: Nullable<Sprite>;
  10310. /**
  10311. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10312. */
  10313. originMesh: Nullable<AbstractMesh>;
  10314. /**
  10315. * The ray that was used to perform the picking.
  10316. */
  10317. ray: Nullable<Ray>;
  10318. /**
  10319. * Gets the normal correspodning to the face the pick collided with
  10320. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10321. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10322. * @returns The normal correspodning to the face the pick collided with
  10323. */
  10324. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10325. /**
  10326. * Gets the texture coordinates of where the pick occured
  10327. * @returns the vector containing the coordnates of the texture
  10328. */
  10329. getTextureCoordinates(): Nullable<Vector2>;
  10330. }
  10331. }
  10332. declare module BABYLON {
  10333. /**
  10334. * Class representing a ray with position and direction
  10335. */
  10336. export class Ray {
  10337. /** origin point */
  10338. origin: Vector3;
  10339. /** direction */
  10340. direction: Vector3;
  10341. /** length of the ray */
  10342. length: number;
  10343. private static readonly TmpVector3;
  10344. private _tmpRay;
  10345. /**
  10346. * Creates a new ray
  10347. * @param origin origin point
  10348. * @param direction direction
  10349. * @param length length of the ray
  10350. */
  10351. constructor(
  10352. /** origin point */
  10353. origin: Vector3,
  10354. /** direction */
  10355. direction: Vector3,
  10356. /** length of the ray */
  10357. length?: number);
  10358. /**
  10359. * Checks if the ray intersects a box
  10360. * This does not account for the ray lenght by design to improve perfs.
  10361. * @param minimum bound of the box
  10362. * @param maximum bound of the box
  10363. * @param intersectionTreshold extra extend to be added to the box in all direction
  10364. * @returns if the box was hit
  10365. */
  10366. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10367. /**
  10368. * Checks if the ray intersects a box
  10369. * This does not account for the ray lenght by design to improve perfs.
  10370. * @param box the bounding box to check
  10371. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10372. * @returns if the box was hit
  10373. */
  10374. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10375. /**
  10376. * If the ray hits a sphere
  10377. * @param sphere the bounding sphere to check
  10378. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10379. * @returns true if it hits the sphere
  10380. */
  10381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10382. /**
  10383. * If the ray hits a triange
  10384. * @param vertex0 triangle vertex
  10385. * @param vertex1 triangle vertex
  10386. * @param vertex2 triangle vertex
  10387. * @returns intersection information if hit
  10388. */
  10389. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10390. /**
  10391. * Checks if ray intersects a plane
  10392. * @param plane the plane to check
  10393. * @returns the distance away it was hit
  10394. */
  10395. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10396. /**
  10397. * Calculate the intercept of a ray on a given axis
  10398. * @param axis to check 'x' | 'y' | 'z'
  10399. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10400. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10401. */
  10402. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10403. /**
  10404. * Checks if ray intersects a mesh
  10405. * @param mesh the mesh to check
  10406. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10407. * @returns picking info of the intersecton
  10408. */
  10409. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10410. /**
  10411. * Checks if ray intersects a mesh
  10412. * @param meshes the meshes to check
  10413. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10414. * @param results array to store result in
  10415. * @returns Array of picking infos
  10416. */
  10417. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10418. private _comparePickingInfo;
  10419. private static smallnum;
  10420. private static rayl;
  10421. /**
  10422. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10423. * @param sega the first point of the segment to test the intersection against
  10424. * @param segb the second point of the segment to test the intersection against
  10425. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10426. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10427. */
  10428. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10429. /**
  10430. * Update the ray from viewport position
  10431. * @param x position
  10432. * @param y y position
  10433. * @param viewportWidth viewport width
  10434. * @param viewportHeight viewport height
  10435. * @param world world matrix
  10436. * @param view view matrix
  10437. * @param projection projection matrix
  10438. * @returns this ray updated
  10439. */
  10440. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10441. /**
  10442. * Creates a ray with origin and direction of 0,0,0
  10443. * @returns the new ray
  10444. */
  10445. static Zero(): Ray;
  10446. /**
  10447. * Creates a new ray from screen space and viewport
  10448. * @param x position
  10449. * @param y y position
  10450. * @param viewportWidth viewport width
  10451. * @param viewportHeight viewport height
  10452. * @param world world matrix
  10453. * @param view view matrix
  10454. * @param projection projection matrix
  10455. * @returns new ray
  10456. */
  10457. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10458. /**
  10459. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10460. * transformed to the given world matrix.
  10461. * @param origin The origin point
  10462. * @param end The end point
  10463. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10464. * @returns the new ray
  10465. */
  10466. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10467. /**
  10468. * Transforms a ray by a matrix
  10469. * @param ray ray to transform
  10470. * @param matrix matrix to apply
  10471. * @returns the resulting new ray
  10472. */
  10473. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10474. /**
  10475. * Transforms a ray by a matrix
  10476. * @param ray ray to transform
  10477. * @param matrix matrix to apply
  10478. * @param result ray to store result in
  10479. */
  10480. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10481. /**
  10482. * Unproject a ray from screen space to object space
  10483. * @param sourceX defines the screen space x coordinate to use
  10484. * @param sourceY defines the screen space y coordinate to use
  10485. * @param viewportWidth defines the current width of the viewport
  10486. * @param viewportHeight defines the current height of the viewport
  10487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10488. * @param view defines the view matrix to use
  10489. * @param projection defines the projection matrix to use
  10490. */
  10491. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10492. }
  10493. /**
  10494. * Type used to define predicate used to select faces when a mesh intersection is detected
  10495. */
  10496. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10497. interface Scene {
  10498. /** @hidden */
  10499. _tempPickingRay: Nullable<Ray>;
  10500. /** @hidden */
  10501. _cachedRayForTransform: Ray;
  10502. /** @hidden */
  10503. _pickWithRayInverseMatrix: Matrix;
  10504. /** @hidden */
  10505. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10506. /** @hidden */
  10507. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. /**
  10512. * Groups all the scene component constants in one place to ease maintenance.
  10513. * @hidden
  10514. */
  10515. export class SceneComponentConstants {
  10516. static readonly NAME_EFFECTLAYER: string;
  10517. static readonly NAME_LAYER: string;
  10518. static readonly NAME_LENSFLARESYSTEM: string;
  10519. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10520. static readonly NAME_PARTICLESYSTEM: string;
  10521. static readonly NAME_GAMEPAD: string;
  10522. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10523. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10524. static readonly NAME_DEPTHRENDERER: string;
  10525. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10526. static readonly NAME_SPRITE: string;
  10527. static readonly NAME_OUTLINERENDERER: string;
  10528. static readonly NAME_PROCEDURALTEXTURE: string;
  10529. static readonly NAME_SHADOWGENERATOR: string;
  10530. static readonly NAME_OCTREE: string;
  10531. static readonly NAME_PHYSICSENGINE: string;
  10532. static readonly NAME_AUDIO: string;
  10533. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10534. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10535. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10538. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10540. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10542. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10545. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10547. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10548. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10549. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10553. static readonly STEP_AFTERRENDER_AUDIO: number;
  10554. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10558. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10559. static readonly STEP_POINTERMOVE_SPRITE: number;
  10560. static readonly STEP_POINTERDOWN_SPRITE: number;
  10561. static readonly STEP_POINTERUP_SPRITE: number;
  10562. }
  10563. /**
  10564. * This represents a scene component.
  10565. *
  10566. * This is used to decouple the dependency the scene is having on the different workloads like
  10567. * layers, post processes...
  10568. */
  10569. export interface ISceneComponent {
  10570. /**
  10571. * The name of the component. Each component must have a unique name.
  10572. */
  10573. name: string;
  10574. /**
  10575. * The scene the component belongs to.
  10576. */
  10577. scene: Scene;
  10578. /**
  10579. * Register the component to one instance of a scene.
  10580. */
  10581. register(): void;
  10582. /**
  10583. * Rebuilds the elements related to this component in case of
  10584. * context lost for instance.
  10585. */
  10586. rebuild(): void;
  10587. /**
  10588. * Disposes the component and the associated ressources.
  10589. */
  10590. dispose(): void;
  10591. }
  10592. /**
  10593. * This represents a SERIALIZABLE scene component.
  10594. *
  10595. * This extends Scene Component to add Serialization methods on top.
  10596. */
  10597. export interface ISceneSerializableComponent extends ISceneComponent {
  10598. /**
  10599. * Adds all the elements from the container to the scene
  10600. * @param container the container holding the elements
  10601. */
  10602. addFromContainer(container: AbstractScene): void;
  10603. /**
  10604. * Removes all the elements in the container from the scene
  10605. * @param container contains the elements to remove
  10606. * @param dispose if the removed element should be disposed (default: false)
  10607. */
  10608. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10609. /**
  10610. * Serializes the component data to the specified json object
  10611. * @param serializationObject The object to serialize to
  10612. */
  10613. serialize(serializationObject: any): void;
  10614. }
  10615. /**
  10616. * Strong typing of a Mesh related stage step action
  10617. */
  10618. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10619. /**
  10620. * Strong typing of a Evaluate Sub Mesh related stage step action
  10621. */
  10622. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10623. /**
  10624. * Strong typing of a Active Mesh related stage step action
  10625. */
  10626. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10627. /**
  10628. * Strong typing of a Camera related stage step action
  10629. */
  10630. export type CameraStageAction = (camera: Camera) => void;
  10631. /**
  10632. * Strong typing of a Camera Frame buffer related stage step action
  10633. */
  10634. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10635. /**
  10636. * Strong typing of a Render Target related stage step action
  10637. */
  10638. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10639. /**
  10640. * Strong typing of a RenderingGroup related stage step action
  10641. */
  10642. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10643. /**
  10644. * Strong typing of a Mesh Render related stage step action
  10645. */
  10646. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10647. /**
  10648. * Strong typing of a simple stage step action
  10649. */
  10650. export type SimpleStageAction = () => void;
  10651. /**
  10652. * Strong typing of a render target action.
  10653. */
  10654. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10655. /**
  10656. * Strong typing of a pointer move action.
  10657. */
  10658. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10659. /**
  10660. * Strong typing of a pointer up/down action.
  10661. */
  10662. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10663. /**
  10664. * Representation of a stage in the scene (Basically a list of ordered steps)
  10665. * @hidden
  10666. */
  10667. export class Stage<T extends Function> extends Array<{
  10668. index: number;
  10669. component: ISceneComponent;
  10670. action: T;
  10671. }> {
  10672. /**
  10673. * Hide ctor from the rest of the world.
  10674. * @param items The items to add.
  10675. */
  10676. private constructor();
  10677. /**
  10678. * Creates a new Stage.
  10679. * @returns A new instance of a Stage
  10680. */
  10681. static Create<T extends Function>(): Stage<T>;
  10682. /**
  10683. * Registers a step in an ordered way in the targeted stage.
  10684. * @param index Defines the position to register the step in
  10685. * @param component Defines the component attached to the step
  10686. * @param action Defines the action to launch during the step
  10687. */
  10688. registerStep(index: number, component: ISceneComponent, action: T): void;
  10689. /**
  10690. * Clears all the steps from the stage.
  10691. */
  10692. clear(): void;
  10693. }
  10694. }
  10695. declare module BABYLON {
  10696. interface Scene {
  10697. /** @hidden */
  10698. _pointerOverSprite: Nullable<Sprite>;
  10699. /** @hidden */
  10700. _pickedDownSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _tempSpritePickingRay: Nullable<Ray>;
  10703. /**
  10704. * All of the sprite managers added to this scene
  10705. * @see http://doc.babylonjs.com/babylon101/sprites
  10706. */
  10707. spriteManagers: Array<ISpriteManager>;
  10708. /**
  10709. * An event triggered when sprites rendering is about to start
  10710. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10711. */
  10712. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10713. /**
  10714. * An event triggered when sprites rendering is done
  10715. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10716. */
  10717. onAfterSpritesRenderingObservable: Observable<Scene>;
  10718. /** @hidden */
  10719. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10720. /** Launch a ray to try to pick a sprite in the scene
  10721. * @param x position on screen
  10722. * @param y position on screen
  10723. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10724. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10725. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10726. * @returns a PickingInfo
  10727. */
  10728. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10729. /** Use the given ray to pick a sprite in the scene
  10730. * @param ray The ray (in world space) to use to pick meshes
  10731. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10733. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10734. * @returns a PickingInfo
  10735. */
  10736. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10737. /** @hidden */
  10738. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10739. /** Launch a ray to try to pick sprites in the scene
  10740. * @param x position on screen
  10741. * @param y position on screen
  10742. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10743. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10744. * @returns a PickingInfo array
  10745. */
  10746. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10747. /** Use the given ray to pick sprites in the scene
  10748. * @param ray The ray (in world space) to use to pick meshes
  10749. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10750. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10751. * @returns a PickingInfo array
  10752. */
  10753. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10754. /**
  10755. * Force the sprite under the pointer
  10756. * @param sprite defines the sprite to use
  10757. */
  10758. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10759. /**
  10760. * Gets the sprite under the pointer
  10761. * @returns a Sprite or null if no sprite is under the pointer
  10762. */
  10763. getPointerOverSprite(): Nullable<Sprite>;
  10764. }
  10765. /**
  10766. * Defines the sprite scene component responsible to manage sprites
  10767. * in a given scene.
  10768. */
  10769. export class SpriteSceneComponent implements ISceneComponent {
  10770. /**
  10771. * The component name helpfull to identify the component in the list of scene components.
  10772. */
  10773. readonly name: string;
  10774. /**
  10775. * The scene the component belongs to.
  10776. */
  10777. scene: Scene;
  10778. /** @hidden */
  10779. private _spritePredicate;
  10780. /**
  10781. * Creates a new instance of the component for the given scene
  10782. * @param scene Defines the scene to register the component in
  10783. */
  10784. constructor(scene: Scene);
  10785. /**
  10786. * Registers the component in a given scene
  10787. */
  10788. register(): void;
  10789. /**
  10790. * Rebuilds the elements related to this component in case of
  10791. * context lost for instance.
  10792. */
  10793. rebuild(): void;
  10794. /**
  10795. * Disposes the component and the associated ressources.
  10796. */
  10797. dispose(): void;
  10798. private _pickSpriteButKeepRay;
  10799. private _pointerMove;
  10800. private _pointerDown;
  10801. private _pointerUp;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var fogFragmentDeclaration: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /** @hidden */
  10813. export var fogFragment: {
  10814. name: string;
  10815. shader: string;
  10816. };
  10817. }
  10818. declare module BABYLON {
  10819. /** @hidden */
  10820. export var spritesPixelShader: {
  10821. name: string;
  10822. shader: string;
  10823. };
  10824. }
  10825. declare module BABYLON {
  10826. /** @hidden */
  10827. export var fogVertexDeclaration: {
  10828. name: string;
  10829. shader: string;
  10830. };
  10831. }
  10832. declare module BABYLON {
  10833. /** @hidden */
  10834. export var spritesVertexShader: {
  10835. name: string;
  10836. shader: string;
  10837. };
  10838. }
  10839. declare module BABYLON {
  10840. /**
  10841. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10842. */
  10843. export interface ISpriteManager extends IDisposable {
  10844. /**
  10845. * Gets manager's name
  10846. */
  10847. name: string;
  10848. /**
  10849. * Restricts the camera to viewing objects with the same layerMask.
  10850. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10851. */
  10852. layerMask: number;
  10853. /**
  10854. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10855. */
  10856. isPickable: boolean;
  10857. /**
  10858. * Gets the hosting scene
  10859. */
  10860. scene: Scene;
  10861. /**
  10862. * Specifies the rendering group id for this mesh (0 by default)
  10863. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10864. */
  10865. renderingGroupId: number;
  10866. /**
  10867. * Defines the list of sprites managed by the manager.
  10868. */
  10869. sprites: Array<Sprite>;
  10870. /**
  10871. * Gets or sets the spritesheet texture
  10872. */
  10873. texture: Texture;
  10874. /** Defines the default width of a cell in the spritesheet */
  10875. cellWidth: number;
  10876. /** Defines the default height of a cell in the spritesheet */
  10877. cellHeight: number;
  10878. /**
  10879. * Tests the intersection of a sprite with a specific ray.
  10880. * @param ray The ray we are sending to test the collision
  10881. * @param camera The camera space we are sending rays in
  10882. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10884. * @returns picking info or null.
  10885. */
  10886. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10887. /**
  10888. * Intersects the sprites with a ray
  10889. * @param ray defines the ray to intersect with
  10890. * @param camera defines the current active camera
  10891. * @param predicate defines a predicate used to select candidate sprites
  10892. * @returns null if no hit or a PickingInfo array
  10893. */
  10894. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10895. /**
  10896. * Renders the list of sprites on screen.
  10897. */
  10898. render(): void;
  10899. }
  10900. /**
  10901. * Class used to manage multiple sprites on the same spritesheet
  10902. * @see http://doc.babylonjs.com/babylon101/sprites
  10903. */
  10904. export class SpriteManager implements ISpriteManager {
  10905. /** defines the manager's name */
  10906. name: string;
  10907. /** Define the Url to load snippets */
  10908. static SnippetUrl: string;
  10909. /** Snippet ID if the manager was created from the snippet server */
  10910. snippetId: string;
  10911. /** Gets the list of sprites */
  10912. sprites: Sprite[];
  10913. /** Gets or sets the rendering group id (0 by default) */
  10914. renderingGroupId: number;
  10915. /** Gets or sets camera layer mask */
  10916. layerMask: number;
  10917. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10918. fogEnabled: boolean;
  10919. /** Gets or sets a boolean indicating if the sprites are pickable */
  10920. isPickable: boolean;
  10921. /** Defines the default width of a cell in the spritesheet */
  10922. cellWidth: number;
  10923. /** Defines the default height of a cell in the spritesheet */
  10924. cellHeight: number;
  10925. /** Associative array from JSON sprite data file */
  10926. private _cellData;
  10927. /** Array of sprite names from JSON sprite data file */
  10928. private _spriteMap;
  10929. /** True when packed cell data from JSON file is ready*/
  10930. private _packedAndReady;
  10931. private _textureContent;
  10932. /**
  10933. * An event triggered when the manager is disposed.
  10934. */
  10935. onDisposeObservable: Observable<SpriteManager>;
  10936. private _onDisposeObserver;
  10937. /**
  10938. * Callback called when the manager is disposed
  10939. */
  10940. set onDispose(callback: () => void);
  10941. private _capacity;
  10942. private _fromPacked;
  10943. private _spriteTexture;
  10944. private _epsilon;
  10945. private _scene;
  10946. private _vertexData;
  10947. private _buffer;
  10948. private _vertexBuffers;
  10949. private _indexBuffer;
  10950. private _effectBase;
  10951. private _effectFog;
  10952. /**
  10953. * Gets or sets the unique id of the sprite
  10954. */
  10955. uniqueId: number;
  10956. /**
  10957. * Gets the array of sprites
  10958. */
  10959. get children(): Sprite[];
  10960. /**
  10961. * Gets the hosting scene
  10962. */
  10963. get scene(): Scene;
  10964. /**
  10965. * Gets the capacity of the manager
  10966. */
  10967. get capacity(): number;
  10968. /**
  10969. * Gets or sets the spritesheet texture
  10970. */
  10971. get texture(): Texture;
  10972. set texture(value: Texture);
  10973. private _blendMode;
  10974. /**
  10975. * Blend mode use to render the particle, it can be any of
  10976. * the static Constants.ALPHA_x properties provided in this class.
  10977. * Default value is Constants.ALPHA_COMBINE
  10978. */
  10979. get blendMode(): number;
  10980. set blendMode(blendMode: number);
  10981. /** Disables writing to the depth buffer when rendering the sprites.
  10982. * It can be handy to disable depth writing when using textures without alpha channel
  10983. * and setting some specific blend modes.
  10984. */
  10985. disableDepthWrite: boolean;
  10986. /**
  10987. * Creates a new sprite manager
  10988. * @param name defines the manager's name
  10989. * @param imgUrl defines the sprite sheet url
  10990. * @param capacity defines the maximum allowed number of sprites
  10991. * @param cellSize defines the size of a sprite cell
  10992. * @param scene defines the hosting scene
  10993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10994. * @param samplingMode defines the smapling mode to use with spritesheet
  10995. * @param fromPacked set to false; do not alter
  10996. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10997. */
  10998. constructor(
  10999. /** defines the manager's name */
  11000. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11001. /**
  11002. * Returns the string "SpriteManager"
  11003. * @returns "SpriteManager"
  11004. */
  11005. getClassName(): string;
  11006. private _makePacked;
  11007. private _appendSpriteVertex;
  11008. private _checkTextureAlpha;
  11009. /**
  11010. * Intersects the sprites with a ray
  11011. * @param ray defines the ray to intersect with
  11012. * @param camera defines the current active camera
  11013. * @param predicate defines a predicate used to select candidate sprites
  11014. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11015. * @returns null if no hit or a PickingInfo
  11016. */
  11017. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11018. /**
  11019. * Intersects the sprites with a ray
  11020. * @param ray defines the ray to intersect with
  11021. * @param camera defines the current active camera
  11022. * @param predicate defines a predicate used to select candidate sprites
  11023. * @returns null if no hit or a PickingInfo array
  11024. */
  11025. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11026. /**
  11027. * Render all child sprites
  11028. */
  11029. render(): void;
  11030. /**
  11031. * Release associated resources
  11032. */
  11033. dispose(): void;
  11034. /**
  11035. * Serializes the sprite manager to a JSON object
  11036. * @param serializeTexture defines if the texture must be serialized as well
  11037. * @returns the JSON object
  11038. */
  11039. serialize(serializeTexture?: boolean): any;
  11040. /**
  11041. * Parses a JSON object to create a new sprite manager.
  11042. * @param parsedManager The JSON object to parse
  11043. * @param scene The scene to create the sprite managerin
  11044. * @param rootUrl The root url to use to load external dependencies like texture
  11045. * @returns the new sprite manager
  11046. */
  11047. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11048. /**
  11049. * Creates a sprite manager from a snippet saved by the sprite editor
  11050. * @param snippetId defines the snippet to load
  11051. * @param scene defines the hosting scene
  11052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11053. * @returns a promise that will resolve to the new sprite manager
  11054. */
  11055. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11056. }
  11057. }
  11058. declare module BABYLON {
  11059. /** Interface used by value gradients (color, factor, ...) */
  11060. export interface IValueGradient {
  11061. /**
  11062. * Gets or sets the gradient value (between 0 and 1)
  11063. */
  11064. gradient: number;
  11065. }
  11066. /** Class used to store color4 gradient */
  11067. export class ColorGradient implements IValueGradient {
  11068. /**
  11069. * Gets or sets the gradient value (between 0 and 1)
  11070. */
  11071. gradient: number;
  11072. /**
  11073. * Gets or sets first associated color
  11074. */
  11075. color1: Color4;
  11076. /**
  11077. * Gets or sets second associated color
  11078. */
  11079. color2?: Color4 | undefined;
  11080. /**
  11081. * Creates a new color4 gradient
  11082. * @param gradient gets or sets the gradient value (between 0 and 1)
  11083. * @param color1 gets or sets first associated color
  11084. * @param color2 gets or sets first second color
  11085. */
  11086. constructor(
  11087. /**
  11088. * Gets or sets the gradient value (between 0 and 1)
  11089. */
  11090. gradient: number,
  11091. /**
  11092. * Gets or sets first associated color
  11093. */
  11094. color1: Color4,
  11095. /**
  11096. * Gets or sets second associated color
  11097. */
  11098. color2?: Color4 | undefined);
  11099. /**
  11100. * Will get a color picked randomly between color1 and color2.
  11101. * If color2 is undefined then color1 will be used
  11102. * @param result defines the target Color4 to store the result in
  11103. */
  11104. getColorToRef(result: Color4): void;
  11105. }
  11106. /** Class used to store color 3 gradient */
  11107. export class Color3Gradient implements IValueGradient {
  11108. /**
  11109. * Gets or sets the gradient value (between 0 and 1)
  11110. */
  11111. gradient: number;
  11112. /**
  11113. * Gets or sets the associated color
  11114. */
  11115. color: Color3;
  11116. /**
  11117. * Creates a new color3 gradient
  11118. * @param gradient gets or sets the gradient value (between 0 and 1)
  11119. * @param color gets or sets associated color
  11120. */
  11121. constructor(
  11122. /**
  11123. * Gets or sets the gradient value (between 0 and 1)
  11124. */
  11125. gradient: number,
  11126. /**
  11127. * Gets or sets the associated color
  11128. */
  11129. color: Color3);
  11130. }
  11131. /** Class used to store factor gradient */
  11132. export class FactorGradient implements IValueGradient {
  11133. /**
  11134. * Gets or sets the gradient value (between 0 and 1)
  11135. */
  11136. gradient: number;
  11137. /**
  11138. * Gets or sets first associated factor
  11139. */
  11140. factor1: number;
  11141. /**
  11142. * Gets or sets second associated factor
  11143. */
  11144. factor2?: number | undefined;
  11145. /**
  11146. * Creates a new factor gradient
  11147. * @param gradient gets or sets the gradient value (between 0 and 1)
  11148. * @param factor1 gets or sets first associated factor
  11149. * @param factor2 gets or sets second associated factor
  11150. */
  11151. constructor(
  11152. /**
  11153. * Gets or sets the gradient value (between 0 and 1)
  11154. */
  11155. gradient: number,
  11156. /**
  11157. * Gets or sets first associated factor
  11158. */
  11159. factor1: number,
  11160. /**
  11161. * Gets or sets second associated factor
  11162. */
  11163. factor2?: number | undefined);
  11164. /**
  11165. * Will get a number picked randomly between factor1 and factor2.
  11166. * If factor2 is undefined then factor1 will be used
  11167. * @returns the picked number
  11168. */
  11169. getFactor(): number;
  11170. }
  11171. /**
  11172. * Helper used to simplify some generic gradient tasks
  11173. */
  11174. export class GradientHelper {
  11175. /**
  11176. * Gets the current gradient from an array of IValueGradient
  11177. * @param ratio defines the current ratio to get
  11178. * @param gradients defines the array of IValueGradient
  11179. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11180. */
  11181. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11182. }
  11183. }
  11184. declare module BABYLON {
  11185. interface ThinEngine {
  11186. /**
  11187. * Creates a dynamic texture
  11188. * @param width defines the width of the texture
  11189. * @param height defines the height of the texture
  11190. * @param generateMipMaps defines if the engine should generate the mip levels
  11191. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11192. * @returns the dynamic texture inside an InternalTexture
  11193. */
  11194. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11195. /**
  11196. * Update the content of a dynamic texture
  11197. * @param texture defines the texture to update
  11198. * @param canvas defines the canvas containing the source
  11199. * @param invertY defines if data must be stored with Y axis inverted
  11200. * @param premulAlpha defines if alpha is stored as premultiplied
  11201. * @param format defines the format of the data
  11202. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11203. */
  11204. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11205. }
  11206. }
  11207. declare module BABYLON {
  11208. /**
  11209. * Helper class used to generate a canvas to manipulate images
  11210. */
  11211. export class CanvasGenerator {
  11212. /**
  11213. * Create a new canvas (or offscreen canvas depending on the context)
  11214. * @param width defines the expected width
  11215. * @param height defines the expected height
  11216. * @return a new canvas or offscreen canvas
  11217. */
  11218. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11219. }
  11220. }
  11221. declare module BABYLON {
  11222. /**
  11223. * A class extending Texture allowing drawing on a texture
  11224. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11225. */
  11226. export class DynamicTexture extends Texture {
  11227. private _generateMipMaps;
  11228. private _canvas;
  11229. private _context;
  11230. /**
  11231. * Creates a DynamicTexture
  11232. * @param name defines the name of the texture
  11233. * @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
  11234. * @param scene defines the scene where you want the texture
  11235. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11236. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11237. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11238. */
  11239. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11240. /**
  11241. * Get the current class name of the texture useful for serialization or dynamic coding.
  11242. * @returns "DynamicTexture"
  11243. */
  11244. getClassName(): string;
  11245. /**
  11246. * Gets the current state of canRescale
  11247. */
  11248. get canRescale(): boolean;
  11249. private _recreate;
  11250. /**
  11251. * Scales the texture
  11252. * @param ratio the scale factor to apply to both width and height
  11253. */
  11254. scale(ratio: number): void;
  11255. /**
  11256. * Resizes the texture
  11257. * @param width the new width
  11258. * @param height the new height
  11259. */
  11260. scaleTo(width: number, height: number): void;
  11261. /**
  11262. * Gets the context of the canvas used by the texture
  11263. * @returns the canvas context of the dynamic texture
  11264. */
  11265. getContext(): CanvasRenderingContext2D;
  11266. /**
  11267. * Clears the texture
  11268. */
  11269. clear(): void;
  11270. /**
  11271. * Updates the texture
  11272. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11273. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11274. */
  11275. update(invertY?: boolean, premulAlpha?: boolean): void;
  11276. /**
  11277. * Draws text onto the texture
  11278. * @param text defines the text to be drawn
  11279. * @param x defines the placement of the text from the left
  11280. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11281. * @param font defines the font to be used with font-style, font-size, font-name
  11282. * @param color defines the color used for the text
  11283. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11284. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11285. * @param update defines whether texture is immediately update (default is true)
  11286. */
  11287. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11288. /**
  11289. * Clones the texture
  11290. * @returns the clone of the texture.
  11291. */
  11292. clone(): DynamicTexture;
  11293. /**
  11294. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11295. * @returns a serialized dynamic texture object
  11296. */
  11297. serialize(): any;
  11298. /** @hidden */
  11299. _rebuild(): void;
  11300. }
  11301. }
  11302. declare module BABYLON {
  11303. interface ThinEngine {
  11304. /**
  11305. * Creates a raw texture
  11306. * @param data defines the data to store in the texture
  11307. * @param width defines the width of the texture
  11308. * @param height defines the height of the texture
  11309. * @param format defines the format of the data
  11310. * @param generateMipMaps defines if the engine should generate the mip levels
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11313. * @param compression defines the compression used (null by default)
  11314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11315. * @returns the raw texture inside an InternalTexture
  11316. */
  11317. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11318. /**
  11319. * Update a raw texture
  11320. * @param texture defines the texture to update
  11321. * @param data defines the data to store in the texture
  11322. * @param format defines the format of the data
  11323. * @param invertY defines if data must be stored with Y axis inverted
  11324. */
  11325. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11326. /**
  11327. * Update a raw texture
  11328. * @param texture defines the texture to update
  11329. * @param data defines the data to store in the texture
  11330. * @param format defines the format of the data
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param compression defines the compression used (null by default)
  11333. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11334. */
  11335. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11336. /**
  11337. * Creates a new raw cube texture
  11338. * @param data defines the array of data to use to create each face
  11339. * @param size defines the size of the textures
  11340. * @param format defines the format of the data
  11341. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11342. * @param generateMipMaps defines if the engine should generate the mip levels
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11345. * @param compression defines the compression used (null by default)
  11346. * @returns the cube texture as an InternalTexture
  11347. */
  11348. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11349. /**
  11350. * Update a raw cube texture
  11351. * @param texture defines the texture to udpdate
  11352. * @param data defines the data to store
  11353. * @param format defines the data format
  11354. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11355. * @param invertY defines if data must be stored with Y axis inverted
  11356. */
  11357. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11358. /**
  11359. * Update a raw cube texture
  11360. * @param texture defines the texture to udpdate
  11361. * @param data defines the data to store
  11362. * @param format defines the data format
  11363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. * @param compression defines the compression used (null by default)
  11366. */
  11367. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11368. /**
  11369. * Update a raw cube texture
  11370. * @param texture defines the texture to udpdate
  11371. * @param data defines the data to store
  11372. * @param format defines the data format
  11373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11374. * @param invertY defines if data must be stored with Y axis inverted
  11375. * @param compression defines the compression used (null by default)
  11376. * @param level defines which level of the texture to update
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11379. /**
  11380. * Creates a new raw cube texture from a specified url
  11381. * @param url defines the url where the data is located
  11382. * @param scene defines the current scene
  11383. * @param size defines the size of the textures
  11384. * @param format defines the format of the data
  11385. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11386. * @param noMipmap defines if the engine should avoid generating the mip levels
  11387. * @param callback defines a callback used to extract texture data from loaded data
  11388. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11389. * @param onLoad defines a callback called when texture is loaded
  11390. * @param onError defines a callback called if there is an error
  11391. * @returns the cube texture as an InternalTexture
  11392. */
  11393. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11394. /**
  11395. * Creates a new raw cube texture from a specified url
  11396. * @param url defines the url where the data is located
  11397. * @param scene defines the current scene
  11398. * @param size defines the size of the textures
  11399. * @param format defines the format of the data
  11400. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11401. * @param noMipmap defines if the engine should avoid generating the mip levels
  11402. * @param callback defines a callback used to extract texture data from loaded data
  11403. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11404. * @param onLoad defines a callback called when texture is loaded
  11405. * @param onError defines a callback called if there is an error
  11406. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @returns the cube texture as an InternalTexture
  11409. */
  11410. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11411. /**
  11412. * Creates a new raw 3D texture
  11413. * @param data defines the data used to create the texture
  11414. * @param width defines the width of the texture
  11415. * @param height defines the height of the texture
  11416. * @param depth defines the depth of the texture
  11417. * @param format defines the format of the texture
  11418. * @param generateMipMaps defines if the engine must generate mip levels
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11421. * @param compression defines the compressed used (can be null)
  11422. * @param textureType defines the compressed used (can be null)
  11423. * @returns a new raw 3D texture (stored in an InternalTexture)
  11424. */
  11425. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11426. /**
  11427. * Update a raw 3D texture
  11428. * @param texture defines the texture to update
  11429. * @param data defines the data to store
  11430. * @param format defines the data format
  11431. * @param invertY defines if data must be stored with Y axis inverted
  11432. */
  11433. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11434. /**
  11435. * Update a raw 3D texture
  11436. * @param texture defines the texture to update
  11437. * @param data defines the data to store
  11438. * @param format defines the data format
  11439. * @param invertY defines if data must be stored with Y axis inverted
  11440. * @param compression defines the used compression (can be null)
  11441. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11442. */
  11443. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11444. /**
  11445. * Creates a new raw 2D array texture
  11446. * @param data defines the data used to create the texture
  11447. * @param width defines the width of the texture
  11448. * @param height defines the height of the texture
  11449. * @param depth defines the number of layers of the texture
  11450. * @param format defines the format of the texture
  11451. * @param generateMipMaps defines if the engine must generate mip levels
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11454. * @param compression defines the compressed used (can be null)
  11455. * @param textureType defines the compressed used (can be null)
  11456. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11457. */
  11458. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11459. /**
  11460. * Update a raw 2D array texture
  11461. * @param texture defines the texture to update
  11462. * @param data defines the data to store
  11463. * @param format defines the data format
  11464. * @param invertY defines if data must be stored with Y axis inverted
  11465. */
  11466. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11467. /**
  11468. * Update a raw 2D array texture
  11469. * @param texture defines the texture to update
  11470. * @param data defines the data to store
  11471. * @param format defines the data format
  11472. * @param invertY defines if data must be stored with Y axis inverted
  11473. * @param compression defines the used compression (can be null)
  11474. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11475. */
  11476. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11477. }
  11478. }
  11479. declare module BABYLON {
  11480. /**
  11481. * Raw texture can help creating a texture directly from an array of data.
  11482. * This can be super useful if you either get the data from an uncompressed source or
  11483. * if you wish to create your texture pixel by pixel.
  11484. */
  11485. export class RawTexture extends Texture {
  11486. /**
  11487. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11488. */
  11489. format: number;
  11490. /**
  11491. * Instantiates a new RawTexture.
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. * @param data define the array of data to use to create the texture
  11496. * @param width define the width of the texture
  11497. * @param height define the height of the texture
  11498. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. * @param scene define the scene the texture belongs to
  11500. * @param generateMipMaps define whether mip maps should be generated or not
  11501. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11502. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11503. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11504. */
  11505. constructor(data: ArrayBufferView, width: number, height: number,
  11506. /**
  11507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11508. */
  11509. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11510. /**
  11511. * Updates the texture underlying data.
  11512. * @param data Define the new data of the texture
  11513. */
  11514. update(data: ArrayBufferView): void;
  11515. /**
  11516. * Creates a luminance texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param scene Define the scene the texture belongs to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance texture
  11525. */
  11526. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates a luminance alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param scene Define the scene the texture belongs to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the luminance alpha texture
  11537. */
  11538. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates an alpha texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param scene Define the scene the texture belongs to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @returns the alpha texture
  11549. */
  11550. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11551. /**
  11552. * Creates a RGB texture from some data.
  11553. * @param data Define the texture data
  11554. * @param width Define the width of the texture
  11555. * @param height Define the height of the texture
  11556. * @param scene Define the scene the texture belongs to
  11557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11561. * @returns the RGB alpha texture
  11562. */
  11563. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11564. /**
  11565. * Creates a RGBA texture from some data.
  11566. * @param data Define the texture data
  11567. * @param width Define the width of the texture
  11568. * @param height Define the height of the texture
  11569. * @param scene Define the scene the texture belongs to
  11570. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11571. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11572. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11573. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11574. * @returns the RGBA texture
  11575. */
  11576. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11577. /**
  11578. * Creates a R texture from some data.
  11579. * @param data Define the texture data
  11580. * @param width Define the width of the texture
  11581. * @param height Define the height of the texture
  11582. * @param scene Define the scene the texture belongs to
  11583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11587. * @returns the R texture
  11588. */
  11589. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11590. }
  11591. }
  11592. declare module BABYLON {
  11593. interface AbstractScene {
  11594. /**
  11595. * The list of procedural textures added to the scene
  11596. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11597. */
  11598. proceduralTextures: Array<ProceduralTexture>;
  11599. }
  11600. /**
  11601. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11602. * in a given scene.
  11603. */
  11604. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11605. /**
  11606. * The component name helpfull to identify the component in the list of scene components.
  11607. */
  11608. readonly name: string;
  11609. /**
  11610. * The scene the component belongs to.
  11611. */
  11612. scene: Scene;
  11613. /**
  11614. * Creates a new instance of the component for the given scene
  11615. * @param scene Defines the scene to register the component in
  11616. */
  11617. constructor(scene: Scene);
  11618. /**
  11619. * Registers the component in a given scene
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. private _beforeClear;
  11632. }
  11633. }
  11634. declare module BABYLON {
  11635. interface ThinEngine {
  11636. /**
  11637. * Creates a new render target cube texture
  11638. * @param size defines the size of the texture
  11639. * @param options defines the options used to create the texture
  11640. * @returns a new render target cube texture stored in an InternalTexture
  11641. */
  11642. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /** @hidden */
  11647. export var proceduralVertexShader: {
  11648. name: string;
  11649. shader: string;
  11650. };
  11651. }
  11652. declare module BABYLON {
  11653. /**
  11654. * 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.
  11655. * This is the base class of any Procedural texture and contains most of the shareable code.
  11656. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11657. */
  11658. export class ProceduralTexture extends Texture {
  11659. isCube: boolean;
  11660. /**
  11661. * Define if the texture is enabled or not (disabled texture will not render)
  11662. */
  11663. isEnabled: boolean;
  11664. /**
  11665. * Define if the texture must be cleared before rendering (default is true)
  11666. */
  11667. autoClear: boolean;
  11668. /**
  11669. * Callback called when the texture is generated
  11670. */
  11671. onGenerated: () => void;
  11672. /**
  11673. * Event raised when the texture is generated
  11674. */
  11675. onGeneratedObservable: Observable<ProceduralTexture>;
  11676. /** @hidden */
  11677. _generateMipMaps: boolean;
  11678. /** @hidden **/
  11679. _effect: Effect;
  11680. /** @hidden */
  11681. _textures: {
  11682. [key: string]: Texture;
  11683. };
  11684. /** @hidden */
  11685. protected _fallbackTexture: Nullable<Texture>;
  11686. private _size;
  11687. private _currentRefreshId;
  11688. private _frameId;
  11689. private _refreshRate;
  11690. private _vertexBuffers;
  11691. private _indexBuffer;
  11692. private _uniforms;
  11693. private _samplers;
  11694. private _fragment;
  11695. private _floats;
  11696. private _ints;
  11697. private _floatsArrays;
  11698. private _colors3;
  11699. private _colors4;
  11700. private _vectors2;
  11701. private _vectors3;
  11702. private _matrices;
  11703. private _fallbackTextureUsed;
  11704. private _fullEngine;
  11705. private _cachedDefines;
  11706. private _contentUpdateId;
  11707. private _contentData;
  11708. /**
  11709. * Instantiates a new procedural texture.
  11710. * 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.
  11711. * This is the base class of any Procedural texture and contains most of the shareable code.
  11712. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11713. * @param name Define the name of the texture
  11714. * @param size Define the size of the texture to create
  11715. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11716. * @param scene Define the scene the texture belongs to
  11717. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11718. * @param generateMipMaps Define if the texture should creates mip maps or not
  11719. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11720. */
  11721. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11722. /**
  11723. * The effect that is created when initializing the post process.
  11724. * @returns The created effect corresponding the the postprocess.
  11725. */
  11726. getEffect(): Effect;
  11727. /**
  11728. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11729. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11730. */
  11731. getContent(): Nullable<ArrayBufferView>;
  11732. private _createIndexBuffer;
  11733. /** @hidden */
  11734. _rebuild(): void;
  11735. /**
  11736. * Resets the texture in order to recreate its associated resources.
  11737. * This can be called in case of context loss
  11738. */
  11739. reset(): void;
  11740. protected _getDefines(): string;
  11741. /**
  11742. * Is the texture ready to be used ? (rendered at least once)
  11743. * @returns true if ready, otherwise, false.
  11744. */
  11745. isReady(): boolean;
  11746. /**
  11747. * Resets the refresh counter of the texture and start bak from scratch.
  11748. * Could be useful to regenerate the texture if it is setup to render only once.
  11749. */
  11750. resetRefreshCounter(): void;
  11751. /**
  11752. * Set the fragment shader to use in order to render the texture.
  11753. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11754. */
  11755. setFragment(fragment: any): void;
  11756. /**
  11757. * Define the refresh rate of the texture or the rendering frequency.
  11758. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11759. */
  11760. get refreshRate(): number;
  11761. set refreshRate(value: number);
  11762. /** @hidden */
  11763. _shouldRender(): boolean;
  11764. /**
  11765. * Get the size the texture is rendering at.
  11766. * @returns the size (texture is always squared)
  11767. */
  11768. getRenderSize(): number;
  11769. /**
  11770. * Resize the texture to new value.
  11771. * @param size Define the new size the texture should have
  11772. * @param generateMipMaps Define whether the new texture should create mip maps
  11773. */
  11774. resize(size: number, generateMipMaps: boolean): void;
  11775. private _checkUniform;
  11776. /**
  11777. * Set a texture in the shader program used to render.
  11778. * @param name Define the name of the uniform samplers as defined in the shader
  11779. * @param texture Define the texture to bind to this sampler
  11780. * @return the texture itself allowing "fluent" like uniform updates
  11781. */
  11782. setTexture(name: string, texture: Texture): ProceduralTexture;
  11783. /**
  11784. * Set a float in the shader.
  11785. * @param name Define the name of the uniform as defined in the shader
  11786. * @param value Define the value to give to the uniform
  11787. * @return the texture itself allowing "fluent" like uniform updates
  11788. */
  11789. setFloat(name: string, value: number): ProceduralTexture;
  11790. /**
  11791. * Set a int in the shader.
  11792. * @param name Define the name of the uniform as defined in the shader
  11793. * @param value Define the value to give to the uniform
  11794. * @return the texture itself allowing "fluent" like uniform updates
  11795. */
  11796. setInt(name: string, value: number): ProceduralTexture;
  11797. /**
  11798. * Set an array of floats in the shader.
  11799. * @param name Define the name of the uniform as defined in the shader
  11800. * @param value Define the value to give to the uniform
  11801. * @return the texture itself allowing "fluent" like uniform updates
  11802. */
  11803. setFloats(name: string, value: number[]): ProceduralTexture;
  11804. /**
  11805. * Set a vec3 in the shader from a Color3.
  11806. * @param name Define the name of the uniform as defined in the shader
  11807. * @param value Define the value to give to the uniform
  11808. * @return the texture itself allowing "fluent" like uniform updates
  11809. */
  11810. setColor3(name: string, value: Color3): ProceduralTexture;
  11811. /**
  11812. * Set a vec4 in the shader from a Color4.
  11813. * @param name Define the name of the uniform as defined in the shader
  11814. * @param value Define the value to give to the uniform
  11815. * @return the texture itself allowing "fluent" like uniform updates
  11816. */
  11817. setColor4(name: string, value: Color4): ProceduralTexture;
  11818. /**
  11819. * Set a vec2 in the shader from a Vector2.
  11820. * @param name Define the name of the uniform as defined in the shader
  11821. * @param value Define the value to give to the uniform
  11822. * @return the texture itself allowing "fluent" like uniform updates
  11823. */
  11824. setVector2(name: string, value: Vector2): ProceduralTexture;
  11825. /**
  11826. * Set a vec3 in the shader from a Vector3.
  11827. * @param name Define the name of the uniform as defined in the shader
  11828. * @param value Define the value to give to the uniform
  11829. * @return the texture itself allowing "fluent" like uniform updates
  11830. */
  11831. setVector3(name: string, value: Vector3): ProceduralTexture;
  11832. /**
  11833. * Set a mat4 in the shader from a MAtrix.
  11834. * @param name Define the name of the uniform as defined in the shader
  11835. * @param value Define the value to give to the uniform
  11836. * @return the texture itself allowing "fluent" like uniform updates
  11837. */
  11838. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11839. /**
  11840. * Render the texture to its associated render target.
  11841. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11842. */
  11843. render(useCameraPostProcess?: boolean): void;
  11844. /**
  11845. * Clone the texture.
  11846. * @returns the cloned texture
  11847. */
  11848. clone(): ProceduralTexture;
  11849. /**
  11850. * Dispose the texture and release its asoociated resources.
  11851. */
  11852. dispose(): void;
  11853. }
  11854. }
  11855. declare module BABYLON {
  11856. /**
  11857. * This represents the base class for particle system in Babylon.
  11858. * 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.
  11859. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11860. * @example https://doc.babylonjs.com/babylon101/particles
  11861. */
  11862. export class BaseParticleSystem {
  11863. /**
  11864. * Source color is added to the destination color without alpha affecting the result
  11865. */
  11866. static BLENDMODE_ONEONE: number;
  11867. /**
  11868. * Blend current color and particle color using particle’s alpha
  11869. */
  11870. static BLENDMODE_STANDARD: number;
  11871. /**
  11872. * Add current color and particle color multiplied by particle’s alpha
  11873. */
  11874. static BLENDMODE_ADD: number;
  11875. /**
  11876. * Multiply current color with particle color
  11877. */
  11878. static BLENDMODE_MULTIPLY: number;
  11879. /**
  11880. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11881. */
  11882. static BLENDMODE_MULTIPLYADD: number;
  11883. /**
  11884. * List of animations used by the particle system.
  11885. */
  11886. animations: Animation[];
  11887. /**
  11888. * Gets or sets the unique id of the particle system
  11889. */
  11890. uniqueId: number;
  11891. /**
  11892. * The id of the Particle system.
  11893. */
  11894. id: string;
  11895. /**
  11896. * The friendly name of the Particle system.
  11897. */
  11898. name: string;
  11899. /**
  11900. * Snippet ID if the particle system was created from the snippet server
  11901. */
  11902. snippetId: string;
  11903. /**
  11904. * The rendering group used by the Particle system to chose when to render.
  11905. */
  11906. renderingGroupId: number;
  11907. /**
  11908. * The emitter represents the Mesh or position we are attaching the particle system to.
  11909. */
  11910. emitter: Nullable<AbstractMesh | Vector3>;
  11911. /**
  11912. * The maximum number of particles to emit per frame
  11913. */
  11914. emitRate: number;
  11915. /**
  11916. * If you want to launch only a few particles at once, that can be done, as well.
  11917. */
  11918. manualEmitCount: number;
  11919. /**
  11920. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11921. */
  11922. updateSpeed: number;
  11923. /**
  11924. * The amount of time the particle system is running (depends of the overall update speed).
  11925. */
  11926. targetStopDuration: number;
  11927. /**
  11928. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11929. */
  11930. disposeOnStop: boolean;
  11931. /**
  11932. * Minimum power of emitting particles.
  11933. */
  11934. minEmitPower: number;
  11935. /**
  11936. * Maximum power of emitting particles.
  11937. */
  11938. maxEmitPower: number;
  11939. /**
  11940. * Minimum life time of emitting particles.
  11941. */
  11942. minLifeTime: number;
  11943. /**
  11944. * Maximum life time of emitting particles.
  11945. */
  11946. maxLifeTime: number;
  11947. /**
  11948. * Minimum Size of emitting particles.
  11949. */
  11950. minSize: number;
  11951. /**
  11952. * Maximum Size of emitting particles.
  11953. */
  11954. maxSize: number;
  11955. /**
  11956. * Minimum scale of emitting particles on X axis.
  11957. */
  11958. minScaleX: number;
  11959. /**
  11960. * Maximum scale of emitting particles on X axis.
  11961. */
  11962. maxScaleX: number;
  11963. /**
  11964. * Minimum scale of emitting particles on Y axis.
  11965. */
  11966. minScaleY: number;
  11967. /**
  11968. * Maximum scale of emitting particles on Y axis.
  11969. */
  11970. maxScaleY: number;
  11971. /**
  11972. * Gets or sets the minimal initial rotation in radians.
  11973. */
  11974. minInitialRotation: number;
  11975. /**
  11976. * Gets or sets the maximal initial rotation in radians.
  11977. */
  11978. maxInitialRotation: number;
  11979. /**
  11980. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11981. */
  11982. minAngularSpeed: number;
  11983. /**
  11984. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11985. */
  11986. maxAngularSpeed: number;
  11987. /**
  11988. * The texture used to render each particle. (this can be a spritesheet)
  11989. */
  11990. particleTexture: Nullable<Texture>;
  11991. /**
  11992. * The layer mask we are rendering the particles through.
  11993. */
  11994. layerMask: number;
  11995. /**
  11996. * This can help using your own shader to render the particle system.
  11997. * The according effect will be created
  11998. */
  11999. customShader: any;
  12000. /**
  12001. * By default particle system starts as soon as they are created. This prevents the
  12002. * automatic start to happen and let you decide when to start emitting particles.
  12003. */
  12004. preventAutoStart: boolean;
  12005. private _noiseTexture;
  12006. /**
  12007. * Gets or sets a texture used to add random noise to particle positions
  12008. */
  12009. get noiseTexture(): Nullable<ProceduralTexture>;
  12010. set noiseTexture(value: Nullable<ProceduralTexture>);
  12011. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12012. noiseStrength: Vector3;
  12013. /**
  12014. * Callback triggered when the particle animation is ending.
  12015. */
  12016. onAnimationEnd: Nullable<() => void>;
  12017. /**
  12018. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12019. */
  12020. blendMode: number;
  12021. /**
  12022. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12023. * to override the particles.
  12024. */
  12025. forceDepthWrite: boolean;
  12026. /** 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 */
  12027. preWarmCycles: number;
  12028. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12029. preWarmStepOffset: number;
  12030. /**
  12031. * 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)
  12032. */
  12033. spriteCellChangeSpeed: number;
  12034. /**
  12035. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12036. */
  12037. startSpriteCellID: number;
  12038. /**
  12039. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12040. */
  12041. endSpriteCellID: number;
  12042. /**
  12043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12044. */
  12045. spriteCellWidth: number;
  12046. /**
  12047. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12048. */
  12049. spriteCellHeight: number;
  12050. /**
  12051. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12052. */
  12053. spriteRandomStartCell: boolean;
  12054. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12055. translationPivot: Vector2;
  12056. /** @hidden */
  12057. protected _isAnimationSheetEnabled: boolean;
  12058. /**
  12059. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12060. */
  12061. beginAnimationOnStart: boolean;
  12062. /**
  12063. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12064. */
  12065. beginAnimationFrom: number;
  12066. /**
  12067. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12068. */
  12069. beginAnimationTo: number;
  12070. /**
  12071. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12072. */
  12073. beginAnimationLoop: boolean;
  12074. /**
  12075. * Gets or sets a world offset applied to all particles
  12076. */
  12077. worldOffset: Vector3;
  12078. /**
  12079. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12080. */
  12081. get isAnimationSheetEnabled(): boolean;
  12082. set isAnimationSheetEnabled(value: boolean);
  12083. /**
  12084. * Get hosting scene
  12085. * @returns the scene
  12086. */
  12087. getScene(): Scene;
  12088. /**
  12089. * You can use gravity if you want to give an orientation to your particles.
  12090. */
  12091. gravity: Vector3;
  12092. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12093. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12094. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12095. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12096. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12097. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12098. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12099. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12100. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12102. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12103. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12104. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12105. /**
  12106. * Defines the delay in milliseconds before starting the system (0 by default)
  12107. */
  12108. startDelay: number;
  12109. /**
  12110. * Gets the current list of drag gradients.
  12111. * You must use addDragGradient and removeDragGradient to udpate this list
  12112. * @returns the list of drag gradients
  12113. */
  12114. getDragGradients(): Nullable<Array<FactorGradient>>;
  12115. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12116. limitVelocityDamping: number;
  12117. /**
  12118. * Gets the current list of limit velocity gradients.
  12119. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12120. * @returns the list of limit velocity gradients
  12121. */
  12122. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12123. /**
  12124. * Gets the current list of color gradients.
  12125. * You must use addColorGradient and removeColorGradient to udpate this list
  12126. * @returns the list of color gradients
  12127. */
  12128. getColorGradients(): Nullable<Array<ColorGradient>>;
  12129. /**
  12130. * Gets the current list of size gradients.
  12131. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12132. * @returns the list of size gradients
  12133. */
  12134. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12135. /**
  12136. * Gets the current list of color remap gradients.
  12137. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12138. * @returns the list of color remap gradients
  12139. */
  12140. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of alpha remap gradients.
  12143. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12144. * @returns the list of alpha remap gradients
  12145. */
  12146. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of life time gradients.
  12149. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12150. * @returns the list of life time gradients
  12151. */
  12152. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of angular speed gradients.
  12155. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12156. * @returns the list of angular speed gradients
  12157. */
  12158. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of velocity gradients.
  12161. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12162. * @returns the list of velocity gradients
  12163. */
  12164. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of start size gradients.
  12167. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12168. * @returns the list of start size gradients
  12169. */
  12170. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of emit rate gradients.
  12173. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12174. * @returns the list of emit rate gradients
  12175. */
  12176. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12179. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12180. */
  12181. get direction1(): Vector3;
  12182. set direction1(value: Vector3);
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction2(): Vector3;
  12188. set direction2(value: Vector3);
  12189. /**
  12190. * 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.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get minEmitBox(): Vector3;
  12194. set minEmitBox(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get maxEmitBox(): Vector3;
  12200. set maxEmitBox(value: Vector3);
  12201. /**
  12202. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12203. */
  12204. color1: Color4;
  12205. /**
  12206. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12207. */
  12208. color2: Color4;
  12209. /**
  12210. * Color the particle will have at the end of its lifetime
  12211. */
  12212. colorDead: Color4;
  12213. /**
  12214. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12215. */
  12216. textureMask: Color4;
  12217. /**
  12218. * The particle emitter type defines the emitter used by the particle system.
  12219. * It can be for example box, sphere, or cone...
  12220. */
  12221. particleEmitterType: IParticleEmitterType;
  12222. /** @hidden */
  12223. _isSubEmitter: boolean;
  12224. /**
  12225. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12226. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12227. */
  12228. billboardMode: number;
  12229. protected _isBillboardBased: boolean;
  12230. /**
  12231. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12232. */
  12233. get isBillboardBased(): boolean;
  12234. set isBillboardBased(value: boolean);
  12235. /**
  12236. * The scene the particle system belongs to.
  12237. */
  12238. protected _scene: Scene;
  12239. /**
  12240. * Local cache of defines for image processing.
  12241. */
  12242. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12243. /**
  12244. * Default configuration related to image processing available in the standard Material.
  12245. */
  12246. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12247. /**
  12248. * Gets the image processing configuration used either in this material.
  12249. */
  12250. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12251. /**
  12252. * Sets the Default image processing configuration used either in the this material.
  12253. *
  12254. * If sets to null, the scene one is in use.
  12255. */
  12256. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12257. /**
  12258. * Attaches a new image processing configuration to the Standard Material.
  12259. * @param configuration
  12260. */
  12261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12262. /** @hidden */
  12263. protected _reset(): void;
  12264. /** @hidden */
  12265. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12266. /**
  12267. * Instantiates a particle system.
  12268. * 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.
  12269. * @param name The name of the particle system
  12270. */
  12271. constructor(name: string);
  12272. /**
  12273. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12274. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12275. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12276. * @returns the emitter
  12277. */
  12278. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12279. /**
  12280. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12281. * @param radius The radius of the hemisphere to emit from
  12282. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12283. * @returns the emitter
  12284. */
  12285. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12286. /**
  12287. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12288. * @param radius The radius of the sphere to emit from
  12289. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12290. * @returns the emitter
  12291. */
  12292. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12293. /**
  12294. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12295. * @param radius The radius of the sphere to emit from
  12296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12298. * @returns the emitter
  12299. */
  12300. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12301. /**
  12302. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12303. * @param radius The radius of the emission cylinder
  12304. * @param height The height of the emission cylinder
  12305. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12306. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12307. * @returns the emitter
  12308. */
  12309. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12310. /**
  12311. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12312. * @param radius The radius of the cylinder to emit from
  12313. * @param height The height of the emission cylinder
  12314. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12317. * @returns the emitter
  12318. */
  12319. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12320. /**
  12321. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12322. * @param radius The radius of the cone to emit from
  12323. * @param angle The base angle of the cone
  12324. * @returns the emitter
  12325. */
  12326. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12327. /**
  12328. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12331. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12332. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12333. * @returns the emitter
  12334. */
  12335. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12336. }
  12337. }
  12338. declare module BABYLON {
  12339. /**
  12340. * Type of sub emitter
  12341. */
  12342. export enum SubEmitterType {
  12343. /**
  12344. * Attached to the particle over it's lifetime
  12345. */
  12346. ATTACHED = 0,
  12347. /**
  12348. * Created when the particle dies
  12349. */
  12350. END = 1
  12351. }
  12352. /**
  12353. * Sub emitter class used to emit particles from an existing particle
  12354. */
  12355. export class SubEmitter {
  12356. /**
  12357. * the particle system to be used by the sub emitter
  12358. */
  12359. particleSystem: ParticleSystem;
  12360. /**
  12361. * Type of the submitter (Default: END)
  12362. */
  12363. type: SubEmitterType;
  12364. /**
  12365. * 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)
  12366. * Note: This only is supported when using an emitter of type Mesh
  12367. */
  12368. inheritDirection: boolean;
  12369. /**
  12370. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12371. */
  12372. inheritedVelocityAmount: number;
  12373. /**
  12374. * Creates a sub emitter
  12375. * @param particleSystem the particle system to be used by the sub emitter
  12376. */
  12377. constructor(
  12378. /**
  12379. * the particle system to be used by the sub emitter
  12380. */
  12381. particleSystem: ParticleSystem);
  12382. /**
  12383. * Clones the sub emitter
  12384. * @returns the cloned sub emitter
  12385. */
  12386. clone(): SubEmitter;
  12387. /**
  12388. * Serialize current object to a JSON object
  12389. * @returns the serialized object
  12390. */
  12391. serialize(): any;
  12392. /** @hidden */
  12393. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12394. /**
  12395. * Creates a new SubEmitter from a serialized JSON version
  12396. * @param serializationObject defines the JSON object to read from
  12397. * @param scene defines the hosting scene
  12398. * @param rootUrl defines the rootUrl for data loading
  12399. * @returns a new SubEmitter
  12400. */
  12401. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12402. /** Release associated resources */
  12403. dispose(): void;
  12404. }
  12405. }
  12406. declare module BABYLON {
  12407. /** @hidden */
  12408. export var imageProcessingDeclaration: {
  12409. name: string;
  12410. shader: string;
  12411. };
  12412. }
  12413. declare module BABYLON {
  12414. /** @hidden */
  12415. export var imageProcessingFunctions: {
  12416. name: string;
  12417. shader: string;
  12418. };
  12419. }
  12420. declare module BABYLON {
  12421. /** @hidden */
  12422. export var particlesPixelShader: {
  12423. name: string;
  12424. shader: string;
  12425. };
  12426. }
  12427. declare module BABYLON {
  12428. /** @hidden */
  12429. export var particlesVertexShader: {
  12430. name: string;
  12431. shader: string;
  12432. };
  12433. }
  12434. declare module BABYLON {
  12435. /**
  12436. * This represents a particle system in Babylon.
  12437. * 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.
  12438. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12439. * @example https://doc.babylonjs.com/babylon101/particles
  12440. */
  12441. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12442. /**
  12443. * Billboard mode will only apply to Y axis
  12444. */
  12445. static readonly BILLBOARDMODE_Y: number;
  12446. /**
  12447. * Billboard mode will apply to all axes
  12448. */
  12449. static readonly BILLBOARDMODE_ALL: number;
  12450. /**
  12451. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12452. */
  12453. static readonly BILLBOARDMODE_STRETCHED: number;
  12454. /**
  12455. * This function can be defined to provide custom update for active particles.
  12456. * This function will be called instead of regular update (age, position, color, etc.).
  12457. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12458. */
  12459. updateFunction: (particles: Particle[]) => void;
  12460. private _emitterWorldMatrix;
  12461. /**
  12462. * This function can be defined to specify initial direction for every new particle.
  12463. * It by default use the emitterType defined function
  12464. */
  12465. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12466. /**
  12467. * This function can be defined to specify initial position for every new particle.
  12468. * It by default use the emitterType defined function
  12469. */
  12470. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12471. /**
  12472. * @hidden
  12473. */
  12474. _inheritedVelocityOffset: Vector3;
  12475. /**
  12476. * An event triggered when the system is disposed
  12477. */
  12478. onDisposeObservable: Observable<IParticleSystem>;
  12479. private _onDisposeObserver;
  12480. /**
  12481. * Sets a callback that will be triggered when the system is disposed
  12482. */
  12483. set onDispose(callback: () => void);
  12484. private _particles;
  12485. private _epsilon;
  12486. private _capacity;
  12487. private _stockParticles;
  12488. private _newPartsExcess;
  12489. private _vertexData;
  12490. private _vertexBuffer;
  12491. private _vertexBuffers;
  12492. private _spriteBuffer;
  12493. private _indexBuffer;
  12494. private _effect;
  12495. private _customEffect;
  12496. private _cachedDefines;
  12497. private _scaledColorStep;
  12498. private _colorDiff;
  12499. private _scaledDirection;
  12500. private _scaledGravity;
  12501. private _currentRenderId;
  12502. private _alive;
  12503. private _useInstancing;
  12504. private _started;
  12505. private _stopped;
  12506. private _actualFrame;
  12507. private _scaledUpdateSpeed;
  12508. private _vertexBufferSize;
  12509. /** @hidden */
  12510. _currentEmitRateGradient: Nullable<FactorGradient>;
  12511. /** @hidden */
  12512. _currentEmitRate1: number;
  12513. /** @hidden */
  12514. _currentEmitRate2: number;
  12515. /** @hidden */
  12516. _currentStartSizeGradient: Nullable<FactorGradient>;
  12517. /** @hidden */
  12518. _currentStartSize1: number;
  12519. /** @hidden */
  12520. _currentStartSize2: number;
  12521. private readonly _rawTextureWidth;
  12522. private _rampGradientsTexture;
  12523. private _useRampGradients;
  12524. /** Gets or sets a boolean indicating that ramp gradients must be used
  12525. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12526. */
  12527. get useRampGradients(): boolean;
  12528. set useRampGradients(value: boolean);
  12529. /**
  12530. * 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.
  12531. * 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: [])
  12532. */
  12533. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12534. private _subEmitters;
  12535. /**
  12536. * @hidden
  12537. * If the particle systems emitter should be disposed when the particle system is disposed
  12538. */
  12539. _disposeEmitterOnDispose: boolean;
  12540. /**
  12541. * The current active Sub-systems, this property is used by the root particle system only.
  12542. */
  12543. activeSubSystems: Array<ParticleSystem>;
  12544. /**
  12545. * Specifies if the particles are updated in emitter local space or world space
  12546. */
  12547. isLocal: boolean;
  12548. private _rootParticleSystem;
  12549. /**
  12550. * Gets the current list of active particles
  12551. */
  12552. get particles(): Particle[];
  12553. /**
  12554. * Gets the number of particles active at the same time.
  12555. * @returns The number of active particles.
  12556. */
  12557. getActiveCount(): number;
  12558. /**
  12559. * Returns the string "ParticleSystem"
  12560. * @returns a string containing the class name
  12561. */
  12562. getClassName(): string;
  12563. /**
  12564. * Gets a boolean indicating that the system is stopping
  12565. * @returns true if the system is currently stopping
  12566. */
  12567. isStopping(): boolean;
  12568. /**
  12569. * Gets the custom effect used to render the particles
  12570. * @param blendMode Blend mode for which the effect should be retrieved
  12571. * @returns The effect
  12572. */
  12573. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12574. /**
  12575. * Sets the custom effect used to render the particles
  12576. * @param effect The effect to set
  12577. * @param blendMode Blend mode for which the effect should be set
  12578. */
  12579. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12580. /** @hidden */
  12581. private _onBeforeDrawParticlesObservable;
  12582. /**
  12583. * Observable that will be called just before the particles are drawn
  12584. */
  12585. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12586. /**
  12587. * Gets the name of the particle vertex shader
  12588. */
  12589. get vertexShaderName(): string;
  12590. /**
  12591. * Instantiates a particle system.
  12592. * 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.
  12593. * @param name The name of the particle system
  12594. * @param capacity The max number of particles alive at the same time
  12595. * @param scene The scene the particle system belongs to
  12596. * @param customEffect a custom effect used to change the way particles are rendered by default
  12597. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12598. * @param epsilon Offset used to render the particles
  12599. */
  12600. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12601. private _addFactorGradient;
  12602. private _removeFactorGradient;
  12603. /**
  12604. * Adds a new life time gradient
  12605. * @param gradient defines the gradient to use (between 0 and 1)
  12606. * @param factor defines the life time factor to affect to the specified gradient
  12607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12608. * @returns the current particle system
  12609. */
  12610. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12611. /**
  12612. * Remove a specific life time gradient
  12613. * @param gradient defines the gradient to remove
  12614. * @returns the current particle system
  12615. */
  12616. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12617. /**
  12618. * Adds a new size gradient
  12619. * @param gradient defines the gradient to use (between 0 and 1)
  12620. * @param factor defines the size factor to affect to the specified gradient
  12621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12622. * @returns the current particle system
  12623. */
  12624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12625. /**
  12626. * Remove a specific size gradient
  12627. * @param gradient defines the gradient to remove
  12628. * @returns the current particle system
  12629. */
  12630. removeSizeGradient(gradient: number): IParticleSystem;
  12631. /**
  12632. * Adds a new color remap gradient
  12633. * @param gradient defines the gradient to use (between 0 and 1)
  12634. * @param min defines the color remap minimal range
  12635. * @param max defines the color remap maximal range
  12636. * @returns the current particle system
  12637. */
  12638. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12639. /**
  12640. * Remove a specific color remap gradient
  12641. * @param gradient defines the gradient to remove
  12642. * @returns the current particle system
  12643. */
  12644. removeColorRemapGradient(gradient: number): IParticleSystem;
  12645. /**
  12646. * Adds a new alpha remap gradient
  12647. * @param gradient defines the gradient to use (between 0 and 1)
  12648. * @param min defines the alpha remap minimal range
  12649. * @param max defines the alpha remap maximal range
  12650. * @returns the current particle system
  12651. */
  12652. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12653. /**
  12654. * Remove a specific alpha remap gradient
  12655. * @param gradient defines the gradient to remove
  12656. * @returns the current particle system
  12657. */
  12658. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12659. /**
  12660. * Adds a new angular speed gradient
  12661. * @param gradient defines the gradient to use (between 0 and 1)
  12662. * @param factor defines the angular speed to affect to the specified gradient
  12663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12664. * @returns the current particle system
  12665. */
  12666. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12667. /**
  12668. * Remove a specific angular speed gradient
  12669. * @param gradient defines the gradient to remove
  12670. * @returns the current particle system
  12671. */
  12672. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12673. /**
  12674. * Adds a new velocity gradient
  12675. * @param gradient defines the gradient to use (between 0 and 1)
  12676. * @param factor defines the velocity to affect to the specified gradient
  12677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12678. * @returns the current particle system
  12679. */
  12680. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12681. /**
  12682. * Remove a specific velocity gradient
  12683. * @param gradient defines the gradient to remove
  12684. * @returns the current particle system
  12685. */
  12686. removeVelocityGradient(gradient: number): IParticleSystem;
  12687. /**
  12688. * Adds a new limit velocity gradient
  12689. * @param gradient defines the gradient to use (between 0 and 1)
  12690. * @param factor defines the limit velocity value to affect to the specified gradient
  12691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12692. * @returns the current particle system
  12693. */
  12694. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12695. /**
  12696. * Remove a specific limit velocity gradient
  12697. * @param gradient defines the gradient to remove
  12698. * @returns the current particle system
  12699. */
  12700. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12701. /**
  12702. * Adds a new drag gradient
  12703. * @param gradient defines the gradient to use (between 0 and 1)
  12704. * @param factor defines the drag value to affect to the specified gradient
  12705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12706. * @returns the current particle system
  12707. */
  12708. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12709. /**
  12710. * Remove a specific drag gradient
  12711. * @param gradient defines the gradient to remove
  12712. * @returns the current particle system
  12713. */
  12714. removeDragGradient(gradient: number): IParticleSystem;
  12715. /**
  12716. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12717. * @param gradient defines the gradient to use (between 0 and 1)
  12718. * @param factor defines the emit rate value to affect to the specified gradient
  12719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12720. * @returns the current particle system
  12721. */
  12722. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12723. /**
  12724. * Remove a specific emit rate gradient
  12725. * @param gradient defines the gradient to remove
  12726. * @returns the current particle system
  12727. */
  12728. removeEmitRateGradient(gradient: number): IParticleSystem;
  12729. /**
  12730. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12731. * @param gradient defines the gradient to use (between 0 and 1)
  12732. * @param factor defines the start size value to affect to the specified gradient
  12733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12734. * @returns the current particle system
  12735. */
  12736. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12737. /**
  12738. * Remove a specific start size gradient
  12739. * @param gradient defines the gradient to remove
  12740. * @returns the current particle system
  12741. */
  12742. removeStartSizeGradient(gradient: number): IParticleSystem;
  12743. private _createRampGradientTexture;
  12744. /**
  12745. * Gets the current list of ramp gradients.
  12746. * You must use addRampGradient and removeRampGradient to udpate this list
  12747. * @returns the list of ramp gradients
  12748. */
  12749. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12750. /** Force the system to rebuild all gradients that need to be resync */
  12751. forceRefreshGradients(): void;
  12752. private _syncRampGradientTexture;
  12753. /**
  12754. * Adds a new ramp gradient used to remap particle colors
  12755. * @param gradient defines the gradient to use (between 0 and 1)
  12756. * @param color defines the color to affect to the specified gradient
  12757. * @returns the current particle system
  12758. */
  12759. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12760. /**
  12761. * Remove a specific ramp gradient
  12762. * @param gradient defines the gradient to remove
  12763. * @returns the current particle system
  12764. */
  12765. removeRampGradient(gradient: number): ParticleSystem;
  12766. /**
  12767. * Adds a new color gradient
  12768. * @param gradient defines the gradient to use (between 0 and 1)
  12769. * @param color1 defines the color to affect to the specified gradient
  12770. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12771. * @returns this particle system
  12772. */
  12773. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12774. /**
  12775. * Remove a specific color gradient
  12776. * @param gradient defines the gradient to remove
  12777. * @returns this particle system
  12778. */
  12779. removeColorGradient(gradient: number): IParticleSystem;
  12780. private _fetchR;
  12781. protected _reset(): void;
  12782. private _resetEffect;
  12783. private _createVertexBuffers;
  12784. private _createIndexBuffer;
  12785. /**
  12786. * Gets the maximum number of particles active at the same time.
  12787. * @returns The max number of active particles.
  12788. */
  12789. getCapacity(): number;
  12790. /**
  12791. * Gets whether there are still active particles in the system.
  12792. * @returns True if it is alive, otherwise false.
  12793. */
  12794. isAlive(): boolean;
  12795. /**
  12796. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12797. * @returns True if it has been started, otherwise false.
  12798. */
  12799. isStarted(): boolean;
  12800. private _prepareSubEmitterInternalArray;
  12801. /**
  12802. * Starts the particle system and begins to emit
  12803. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12804. */
  12805. start(delay?: number): void;
  12806. /**
  12807. * Stops the particle system.
  12808. * @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.
  12809. */
  12810. stop(stopSubEmitters?: boolean): void;
  12811. /**
  12812. * Remove all active particles
  12813. */
  12814. reset(): void;
  12815. /**
  12816. * @hidden (for internal use only)
  12817. */
  12818. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12819. /**
  12820. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12821. * Its lifetime will start back at 0.
  12822. */
  12823. recycleParticle: (particle: Particle) => void;
  12824. private _stopSubEmitters;
  12825. private _createParticle;
  12826. private _removeFromRoot;
  12827. private _emitFromParticle;
  12828. private _update;
  12829. /** @hidden */
  12830. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12831. /** @hidden */
  12832. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12833. /**
  12834. * Fill the defines array according to the current settings of the particle system
  12835. * @param defines Array to be updated
  12836. * @param blendMode blend mode to take into account when updating the array
  12837. */
  12838. fillDefines(defines: Array<string>, blendMode: number): void;
  12839. /**
  12840. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12841. * @param uniforms Uniforms array to fill
  12842. * @param attributes Attributes array to fill
  12843. * @param samplers Samplers array to fill
  12844. */
  12845. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12846. /** @hidden */
  12847. private _getEffect;
  12848. /**
  12849. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12850. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12851. */
  12852. animate(preWarmOnly?: boolean): void;
  12853. private _appendParticleVertices;
  12854. /**
  12855. * Rebuilds the particle system.
  12856. */
  12857. rebuild(): void;
  12858. /**
  12859. * Is this system ready to be used/rendered
  12860. * @return true if the system is ready
  12861. */
  12862. isReady(): boolean;
  12863. private _render;
  12864. /**
  12865. * Renders the particle system in its current state.
  12866. * @returns the current number of particles
  12867. */
  12868. render(): number;
  12869. /**
  12870. * Disposes the particle system and free the associated resources
  12871. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12872. */
  12873. dispose(disposeTexture?: boolean): void;
  12874. /**
  12875. * Clones the particle system.
  12876. * @param name The name of the cloned object
  12877. * @param newEmitter The new emitter to use
  12878. * @returns the cloned particle system
  12879. */
  12880. clone(name: string, newEmitter: any): ParticleSystem;
  12881. /**
  12882. * Serializes the particle system to a JSON object
  12883. * @param serializeTexture defines if the texture must be serialized as well
  12884. * @returns the JSON object
  12885. */
  12886. serialize(serializeTexture?: boolean): any;
  12887. /** @hidden */
  12888. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12889. /** @hidden */
  12890. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12891. /**
  12892. * Parses a JSON object to create a particle system.
  12893. * @param parsedParticleSystem The JSON object to parse
  12894. * @param scene The scene to create the particle system in
  12895. * @param rootUrl The root url to use to load external dependencies like texture
  12896. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12897. * @returns the Parsed particle system
  12898. */
  12899. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12900. }
  12901. }
  12902. declare module BABYLON {
  12903. /**
  12904. * A particle represents one of the element emitted by a particle system.
  12905. * This is mainly define by its coordinates, direction, velocity and age.
  12906. */
  12907. export class Particle {
  12908. /**
  12909. * The particle system the particle belongs to.
  12910. */
  12911. particleSystem: ParticleSystem;
  12912. private static _Count;
  12913. /**
  12914. * Unique ID of the particle
  12915. */
  12916. id: number;
  12917. /**
  12918. * The world position of the particle in the scene.
  12919. */
  12920. position: Vector3;
  12921. /**
  12922. * The world direction of the particle in the scene.
  12923. */
  12924. direction: Vector3;
  12925. /**
  12926. * The color of the particle.
  12927. */
  12928. color: Color4;
  12929. /**
  12930. * The color change of the particle per step.
  12931. */
  12932. colorStep: Color4;
  12933. /**
  12934. * Defines how long will the life of the particle be.
  12935. */
  12936. lifeTime: number;
  12937. /**
  12938. * The current age of the particle.
  12939. */
  12940. age: number;
  12941. /**
  12942. * The current size of the particle.
  12943. */
  12944. size: number;
  12945. /**
  12946. * The current scale of the particle.
  12947. */
  12948. scale: Vector2;
  12949. /**
  12950. * The current angle of the particle.
  12951. */
  12952. angle: number;
  12953. /**
  12954. * Defines how fast is the angle changing.
  12955. */
  12956. angularSpeed: number;
  12957. /**
  12958. * Defines the cell index used by the particle to be rendered from a sprite.
  12959. */
  12960. cellIndex: number;
  12961. /**
  12962. * The information required to support color remapping
  12963. */
  12964. remapData: Vector4;
  12965. /** @hidden */
  12966. _randomCellOffset?: number;
  12967. /** @hidden */
  12968. _initialDirection: Nullable<Vector3>;
  12969. /** @hidden */
  12970. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12971. /** @hidden */
  12972. _initialStartSpriteCellID: number;
  12973. /** @hidden */
  12974. _initialEndSpriteCellID: number;
  12975. /** @hidden */
  12976. _currentColorGradient: Nullable<ColorGradient>;
  12977. /** @hidden */
  12978. _currentColor1: Color4;
  12979. /** @hidden */
  12980. _currentColor2: Color4;
  12981. /** @hidden */
  12982. _currentSizeGradient: Nullable<FactorGradient>;
  12983. /** @hidden */
  12984. _currentSize1: number;
  12985. /** @hidden */
  12986. _currentSize2: number;
  12987. /** @hidden */
  12988. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12989. /** @hidden */
  12990. _currentAngularSpeed1: number;
  12991. /** @hidden */
  12992. _currentAngularSpeed2: number;
  12993. /** @hidden */
  12994. _currentVelocityGradient: Nullable<FactorGradient>;
  12995. /** @hidden */
  12996. _currentVelocity1: number;
  12997. /** @hidden */
  12998. _currentVelocity2: number;
  12999. /** @hidden */
  13000. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13001. /** @hidden */
  13002. _currentLimitVelocity1: number;
  13003. /** @hidden */
  13004. _currentLimitVelocity2: number;
  13005. /** @hidden */
  13006. _currentDragGradient: Nullable<FactorGradient>;
  13007. /** @hidden */
  13008. _currentDrag1: number;
  13009. /** @hidden */
  13010. _currentDrag2: number;
  13011. /** @hidden */
  13012. _randomNoiseCoordinates1: Vector3;
  13013. /** @hidden */
  13014. _randomNoiseCoordinates2: Vector3;
  13015. /** @hidden */
  13016. _localPosition?: Vector3;
  13017. /**
  13018. * Creates a new instance Particle
  13019. * @param particleSystem the particle system the particle belongs to
  13020. */
  13021. constructor(
  13022. /**
  13023. * The particle system the particle belongs to.
  13024. */
  13025. particleSystem: ParticleSystem);
  13026. private updateCellInfoFromSystem;
  13027. /**
  13028. * Defines how the sprite cell index is updated for the particle
  13029. */
  13030. updateCellIndex(): void;
  13031. /** @hidden */
  13032. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13033. /** @hidden */
  13034. _inheritParticleInfoToSubEmitters(): void;
  13035. /** @hidden */
  13036. _reset(): void;
  13037. /**
  13038. * Copy the properties of particle to another one.
  13039. * @param other the particle to copy the information to.
  13040. */
  13041. copyTo(other: Particle): void;
  13042. }
  13043. }
  13044. declare module BABYLON {
  13045. /**
  13046. * Particle emitter represents a volume emitting particles.
  13047. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13048. */
  13049. export interface IParticleEmitterType {
  13050. /**
  13051. * Called by the particle System when the direction is computed for the created particle.
  13052. * @param worldMatrix is the world matrix of the particle system
  13053. * @param directionToUpdate is the direction vector to update with the result
  13054. * @param particle is the particle we are computed the direction for
  13055. * @param isLocal defines if the direction should be set in local space
  13056. */
  13057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13058. /**
  13059. * Called by the particle System when the position is computed for the created particle.
  13060. * @param worldMatrix is the world matrix of the particle system
  13061. * @param positionToUpdate is the position vector to update with the result
  13062. * @param particle is the particle we are computed the position for
  13063. * @param isLocal defines if the position should be set in local space
  13064. */
  13065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13066. /**
  13067. * Clones the current emitter and returns a copy of it
  13068. * @returns the new emitter
  13069. */
  13070. clone(): IParticleEmitterType;
  13071. /**
  13072. * Called by the GPUParticleSystem to setup the update shader
  13073. * @param effect defines the update shader
  13074. */
  13075. applyToShader(effect: Effect): void;
  13076. /**
  13077. * Returns a string to use to update the GPU particles update shader
  13078. * @returns the effect defines string
  13079. */
  13080. getEffectDefines(): string;
  13081. /**
  13082. * Returns a string representing the class name
  13083. * @returns a string containing the class name
  13084. */
  13085. getClassName(): string;
  13086. /**
  13087. * Serializes the particle system to a JSON object.
  13088. * @returns the JSON object
  13089. */
  13090. serialize(): any;
  13091. /**
  13092. * Parse properties from a JSON object
  13093. * @param serializationObject defines the JSON object
  13094. * @param scene defines the hosting scene
  13095. */
  13096. parse(serializationObject: any, scene: Scene): void;
  13097. }
  13098. }
  13099. declare module BABYLON {
  13100. /**
  13101. * Particle emitter emitting particles from the inside of a box.
  13102. * It emits the particles randomly between 2 given directions.
  13103. */
  13104. export class BoxParticleEmitter implements IParticleEmitterType {
  13105. /**
  13106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13107. */
  13108. direction1: Vector3;
  13109. /**
  13110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13111. */
  13112. direction2: Vector3;
  13113. /**
  13114. * 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.
  13115. */
  13116. minEmitBox: Vector3;
  13117. /**
  13118. * 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.
  13119. */
  13120. maxEmitBox: Vector3;
  13121. /**
  13122. * Creates a new instance BoxParticleEmitter
  13123. */
  13124. constructor();
  13125. /**
  13126. * Called by the particle System when the direction is computed for the created particle.
  13127. * @param worldMatrix is the world matrix of the particle system
  13128. * @param directionToUpdate is the direction vector to update with the result
  13129. * @param particle is the particle we are computed the direction for
  13130. * @param isLocal defines if the direction should be set in local space
  13131. */
  13132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13133. /**
  13134. * Called by the particle System when the position is computed for the created particle.
  13135. * @param worldMatrix is the world matrix of the particle system
  13136. * @param positionToUpdate is the position vector to update with the result
  13137. * @param particle is the particle we are computed the position for
  13138. * @param isLocal defines if the position should be set in local space
  13139. */
  13140. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13141. /**
  13142. * Clones the current emitter and returns a copy of it
  13143. * @returns the new emitter
  13144. */
  13145. clone(): BoxParticleEmitter;
  13146. /**
  13147. * Called by the GPUParticleSystem to setup the update shader
  13148. * @param effect defines the update shader
  13149. */
  13150. applyToShader(effect: Effect): void;
  13151. /**
  13152. * Returns a string to use to update the GPU particles update shader
  13153. * @returns a string containng the defines string
  13154. */
  13155. getEffectDefines(): string;
  13156. /**
  13157. * Returns the string "BoxParticleEmitter"
  13158. * @returns a string containing the class name
  13159. */
  13160. getClassName(): string;
  13161. /**
  13162. * Serializes the particle system to a JSON object.
  13163. * @returns the JSON object
  13164. */
  13165. serialize(): any;
  13166. /**
  13167. * Parse properties from a JSON object
  13168. * @param serializationObject defines the JSON object
  13169. */
  13170. parse(serializationObject: any): void;
  13171. }
  13172. }
  13173. declare module BABYLON {
  13174. /**
  13175. * Particle emitter emitting particles from the inside of a cone.
  13176. * It emits the particles alongside the cone volume from the base to the particle.
  13177. * The emission direction might be randomized.
  13178. */
  13179. export class ConeParticleEmitter implements IParticleEmitterType {
  13180. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13181. directionRandomizer: number;
  13182. private _radius;
  13183. private _angle;
  13184. private _height;
  13185. /**
  13186. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13187. */
  13188. radiusRange: number;
  13189. /**
  13190. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13191. */
  13192. heightRange: number;
  13193. /**
  13194. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13195. */
  13196. emitFromSpawnPointOnly: boolean;
  13197. /**
  13198. * Gets or sets the radius of the emission cone
  13199. */
  13200. get radius(): number;
  13201. set radius(value: number);
  13202. /**
  13203. * Gets or sets the angle of the emission cone
  13204. */
  13205. get angle(): number;
  13206. set angle(value: number);
  13207. private _buildHeight;
  13208. /**
  13209. * Creates a new instance ConeParticleEmitter
  13210. * @param radius the radius of the emission cone (1 by default)
  13211. * @param angle the cone base angle (PI by default)
  13212. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13213. */
  13214. constructor(radius?: number, angle?: number,
  13215. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13216. directionRandomizer?: number);
  13217. /**
  13218. * Called by the particle System when the direction is computed for the created particle.
  13219. * @param worldMatrix is the world matrix of the particle system
  13220. * @param directionToUpdate is the direction vector to update with the result
  13221. * @param particle is the particle we are computed the direction for
  13222. * @param isLocal defines if the direction should be set in local space
  13223. */
  13224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13225. /**
  13226. * Called by the particle System when the position is computed for the created particle.
  13227. * @param worldMatrix is the world matrix of the particle system
  13228. * @param positionToUpdate is the position vector to update with the result
  13229. * @param particle is the particle we are computed the position for
  13230. * @param isLocal defines if the position should be set in local space
  13231. */
  13232. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13233. /**
  13234. * Clones the current emitter and returns a copy of it
  13235. * @returns the new emitter
  13236. */
  13237. clone(): ConeParticleEmitter;
  13238. /**
  13239. * Called by the GPUParticleSystem to setup the update shader
  13240. * @param effect defines the update shader
  13241. */
  13242. applyToShader(effect: Effect): void;
  13243. /**
  13244. * Returns a string to use to update the GPU particles update shader
  13245. * @returns a string containng the defines string
  13246. */
  13247. getEffectDefines(): string;
  13248. /**
  13249. * Returns the string "ConeParticleEmitter"
  13250. * @returns a string containing the class name
  13251. */
  13252. getClassName(): string;
  13253. /**
  13254. * Serializes the particle system to a JSON object.
  13255. * @returns the JSON object
  13256. */
  13257. serialize(): any;
  13258. /**
  13259. * Parse properties from a JSON object
  13260. * @param serializationObject defines the JSON object
  13261. */
  13262. parse(serializationObject: any): void;
  13263. }
  13264. }
  13265. declare module BABYLON {
  13266. /**
  13267. * Particle emitter emitting particles from the inside of a cylinder.
  13268. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13269. */
  13270. export class CylinderParticleEmitter implements IParticleEmitterType {
  13271. /**
  13272. * The radius of the emission cylinder.
  13273. */
  13274. radius: number;
  13275. /**
  13276. * The height of the emission cylinder.
  13277. */
  13278. height: number;
  13279. /**
  13280. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13281. */
  13282. radiusRange: number;
  13283. /**
  13284. * How much to randomize the particle direction [0-1].
  13285. */
  13286. directionRandomizer: number;
  13287. /**
  13288. * Creates a new instance CylinderParticleEmitter
  13289. * @param radius the radius of the emission cylinder (1 by default)
  13290. * @param height the height of the emission cylinder (1 by default)
  13291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13292. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13293. */
  13294. constructor(
  13295. /**
  13296. * The radius of the emission cylinder.
  13297. */
  13298. radius?: number,
  13299. /**
  13300. * The height of the emission cylinder.
  13301. */
  13302. height?: number,
  13303. /**
  13304. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13305. */
  13306. radiusRange?: number,
  13307. /**
  13308. * How much to randomize the particle direction [0-1].
  13309. */
  13310. directionRandomizer?: number);
  13311. /**
  13312. * Called by the particle System when the direction is computed for the created particle.
  13313. * @param worldMatrix is the world matrix of the particle system
  13314. * @param directionToUpdate is the direction vector to update with the result
  13315. * @param particle is the particle we are computed the direction for
  13316. * @param isLocal defines if the direction should be set in local space
  13317. */
  13318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13319. /**
  13320. * Called by the particle System when the position is computed for the created particle.
  13321. * @param worldMatrix is the world matrix of the particle system
  13322. * @param positionToUpdate is the position vector to update with the result
  13323. * @param particle is the particle we are computed the position for
  13324. * @param isLocal defines if the position should be set in local space
  13325. */
  13326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13327. /**
  13328. * Clones the current emitter and returns a copy of it
  13329. * @returns the new emitter
  13330. */
  13331. clone(): CylinderParticleEmitter;
  13332. /**
  13333. * Called by the GPUParticleSystem to setup the update shader
  13334. * @param effect defines the update shader
  13335. */
  13336. applyToShader(effect: Effect): void;
  13337. /**
  13338. * Returns a string to use to update the GPU particles update shader
  13339. * @returns a string containng the defines string
  13340. */
  13341. getEffectDefines(): string;
  13342. /**
  13343. * Returns the string "CylinderParticleEmitter"
  13344. * @returns a string containing the class name
  13345. */
  13346. getClassName(): string;
  13347. /**
  13348. * Serializes the particle system to a JSON object.
  13349. * @returns the JSON object
  13350. */
  13351. serialize(): any;
  13352. /**
  13353. * Parse properties from a JSON object
  13354. * @param serializationObject defines the JSON object
  13355. */
  13356. parse(serializationObject: any): void;
  13357. }
  13358. /**
  13359. * Particle emitter emitting particles from the inside of a cylinder.
  13360. * It emits the particles randomly between two vectors.
  13361. */
  13362. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13363. /**
  13364. * The min limit of the emission direction.
  13365. */
  13366. direction1: Vector3;
  13367. /**
  13368. * The max limit of the emission direction.
  13369. */
  13370. direction2: Vector3;
  13371. /**
  13372. * Creates a new instance CylinderDirectedParticleEmitter
  13373. * @param radius the radius of the emission cylinder (1 by default)
  13374. * @param height the height of the emission cylinder (1 by default)
  13375. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13376. * @param direction1 the min limit of the emission direction (up vector by default)
  13377. * @param direction2 the max limit of the emission direction (up vector by default)
  13378. */
  13379. constructor(radius?: number, height?: number, radiusRange?: number,
  13380. /**
  13381. * The min limit of the emission direction.
  13382. */
  13383. direction1?: Vector3,
  13384. /**
  13385. * The max limit of the emission direction.
  13386. */
  13387. direction2?: Vector3);
  13388. /**
  13389. * Called by the particle System when the direction is computed for the created particle.
  13390. * @param worldMatrix is the world matrix of the particle system
  13391. * @param directionToUpdate is the direction vector to update with the result
  13392. * @param particle is the particle we are computed the direction for
  13393. */
  13394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13395. /**
  13396. * Clones the current emitter and returns a copy of it
  13397. * @returns the new emitter
  13398. */
  13399. clone(): CylinderDirectedParticleEmitter;
  13400. /**
  13401. * Called by the GPUParticleSystem to setup the update shader
  13402. * @param effect defines the update shader
  13403. */
  13404. applyToShader(effect: Effect): void;
  13405. /**
  13406. * Returns a string to use to update the GPU particles update shader
  13407. * @returns a string containng the defines string
  13408. */
  13409. getEffectDefines(): string;
  13410. /**
  13411. * Returns the string "CylinderDirectedParticleEmitter"
  13412. * @returns a string containing the class name
  13413. */
  13414. getClassName(): string;
  13415. /**
  13416. * Serializes the particle system to a JSON object.
  13417. * @returns the JSON object
  13418. */
  13419. serialize(): any;
  13420. /**
  13421. * Parse properties from a JSON object
  13422. * @param serializationObject defines the JSON object
  13423. */
  13424. parse(serializationObject: any): void;
  13425. }
  13426. }
  13427. declare module BABYLON {
  13428. /**
  13429. * Particle emitter emitting particles from the inside of a hemisphere.
  13430. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13431. */
  13432. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13433. /**
  13434. * The radius of the emission hemisphere.
  13435. */
  13436. radius: number;
  13437. /**
  13438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13439. */
  13440. radiusRange: number;
  13441. /**
  13442. * How much to randomize the particle direction [0-1].
  13443. */
  13444. directionRandomizer: number;
  13445. /**
  13446. * Creates a new instance HemisphericParticleEmitter
  13447. * @param radius the radius of the emission hemisphere (1 by default)
  13448. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13449. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13450. */
  13451. constructor(
  13452. /**
  13453. * The radius of the emission hemisphere.
  13454. */
  13455. radius?: number,
  13456. /**
  13457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13458. */
  13459. radiusRange?: number,
  13460. /**
  13461. * How much to randomize the particle direction [0-1].
  13462. */
  13463. directionRandomizer?: number);
  13464. /**
  13465. * Called by the particle System when the direction is computed for the created particle.
  13466. * @param worldMatrix is the world matrix of the particle system
  13467. * @param directionToUpdate is the direction vector to update with the result
  13468. * @param particle is the particle we are computed the direction for
  13469. * @param isLocal defines if the direction should be set in local space
  13470. */
  13471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13472. /**
  13473. * Called by the particle System when the position is computed for the created particle.
  13474. * @param worldMatrix is the world matrix of the particle system
  13475. * @param positionToUpdate is the position vector to update with the result
  13476. * @param particle is the particle we are computed the position for
  13477. * @param isLocal defines if the position should be set in local space
  13478. */
  13479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13480. /**
  13481. * Clones the current emitter and returns a copy of it
  13482. * @returns the new emitter
  13483. */
  13484. clone(): HemisphericParticleEmitter;
  13485. /**
  13486. * Called by the GPUParticleSystem to setup the update shader
  13487. * @param effect defines the update shader
  13488. */
  13489. applyToShader(effect: Effect): void;
  13490. /**
  13491. * Returns a string to use to update the GPU particles update shader
  13492. * @returns a string containng the defines string
  13493. */
  13494. getEffectDefines(): string;
  13495. /**
  13496. * Returns the string "HemisphericParticleEmitter"
  13497. * @returns a string containing the class name
  13498. */
  13499. getClassName(): string;
  13500. /**
  13501. * Serializes the particle system to a JSON object.
  13502. * @returns the JSON object
  13503. */
  13504. serialize(): any;
  13505. /**
  13506. * Parse properties from a JSON object
  13507. * @param serializationObject defines the JSON object
  13508. */
  13509. parse(serializationObject: any): void;
  13510. }
  13511. }
  13512. declare module BABYLON {
  13513. /**
  13514. * Particle emitter emitting particles from a point.
  13515. * It emits the particles randomly between 2 given directions.
  13516. */
  13517. export class PointParticleEmitter implements IParticleEmitterType {
  13518. /**
  13519. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13520. */
  13521. direction1: Vector3;
  13522. /**
  13523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13524. */
  13525. direction2: Vector3;
  13526. /**
  13527. * Creates a new instance PointParticleEmitter
  13528. */
  13529. constructor();
  13530. /**
  13531. * Called by the particle System when the direction is computed for the created particle.
  13532. * @param worldMatrix is the world matrix of the particle system
  13533. * @param directionToUpdate is the direction vector to update with the result
  13534. * @param particle is the particle we are computed the direction for
  13535. * @param isLocal defines if the direction should be set in local space
  13536. */
  13537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13538. /**
  13539. * Called by the particle System when the position is computed for the created particle.
  13540. * @param worldMatrix is the world matrix of the particle system
  13541. * @param positionToUpdate is the position vector to update with the result
  13542. * @param particle is the particle we are computed the position for
  13543. * @param isLocal defines if the position should be set in local space
  13544. */
  13545. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13546. /**
  13547. * Clones the current emitter and returns a copy of it
  13548. * @returns the new emitter
  13549. */
  13550. clone(): PointParticleEmitter;
  13551. /**
  13552. * Called by the GPUParticleSystem to setup the update shader
  13553. * @param effect defines the update shader
  13554. */
  13555. applyToShader(effect: Effect): void;
  13556. /**
  13557. * Returns a string to use to update the GPU particles update shader
  13558. * @returns a string containng the defines string
  13559. */
  13560. getEffectDefines(): string;
  13561. /**
  13562. * Returns the string "PointParticleEmitter"
  13563. * @returns a string containing the class name
  13564. */
  13565. getClassName(): string;
  13566. /**
  13567. * Serializes the particle system to a JSON object.
  13568. * @returns the JSON object
  13569. */
  13570. serialize(): any;
  13571. /**
  13572. * Parse properties from a JSON object
  13573. * @param serializationObject defines the JSON object
  13574. */
  13575. parse(serializationObject: any): void;
  13576. }
  13577. }
  13578. declare module BABYLON {
  13579. /**
  13580. * Particle emitter emitting particles from the inside of a sphere.
  13581. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13582. */
  13583. export class SphereParticleEmitter implements IParticleEmitterType {
  13584. /**
  13585. * The radius of the emission sphere.
  13586. */
  13587. radius: number;
  13588. /**
  13589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13590. */
  13591. radiusRange: number;
  13592. /**
  13593. * How much to randomize the particle direction [0-1].
  13594. */
  13595. directionRandomizer: number;
  13596. /**
  13597. * Creates a new instance SphereParticleEmitter
  13598. * @param radius the radius of the emission sphere (1 by default)
  13599. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13600. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13601. */
  13602. constructor(
  13603. /**
  13604. * The radius of the emission sphere.
  13605. */
  13606. radius?: number,
  13607. /**
  13608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13609. */
  13610. radiusRange?: number,
  13611. /**
  13612. * How much to randomize the particle direction [0-1].
  13613. */
  13614. directionRandomizer?: number);
  13615. /**
  13616. * Called by the particle System when the direction is computed for the created particle.
  13617. * @param worldMatrix is the world matrix of the particle system
  13618. * @param directionToUpdate is the direction vector to update with the result
  13619. * @param particle is the particle we are computed the direction for
  13620. * @param isLocal defines if the direction should be set in local space
  13621. */
  13622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13623. /**
  13624. * Called by the particle System when the position is computed for the created particle.
  13625. * @param worldMatrix is the world matrix of the particle system
  13626. * @param positionToUpdate is the position vector to update with the result
  13627. * @param particle is the particle we are computed the position for
  13628. * @param isLocal defines if the position should be set in local space
  13629. */
  13630. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13631. /**
  13632. * Clones the current emitter and returns a copy of it
  13633. * @returns the new emitter
  13634. */
  13635. clone(): SphereParticleEmitter;
  13636. /**
  13637. * Called by the GPUParticleSystem to setup the update shader
  13638. * @param effect defines the update shader
  13639. */
  13640. applyToShader(effect: Effect): void;
  13641. /**
  13642. * Returns a string to use to update the GPU particles update shader
  13643. * @returns a string containng the defines string
  13644. */
  13645. getEffectDefines(): string;
  13646. /**
  13647. * Returns the string "SphereParticleEmitter"
  13648. * @returns a string containing the class name
  13649. */
  13650. getClassName(): string;
  13651. /**
  13652. * Serializes the particle system to a JSON object.
  13653. * @returns the JSON object
  13654. */
  13655. serialize(): any;
  13656. /**
  13657. * Parse properties from a JSON object
  13658. * @param serializationObject defines the JSON object
  13659. */
  13660. parse(serializationObject: any): void;
  13661. }
  13662. /**
  13663. * Particle emitter emitting particles from the inside of a sphere.
  13664. * It emits the particles randomly between two vectors.
  13665. */
  13666. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13667. /**
  13668. * The min limit of the emission direction.
  13669. */
  13670. direction1: Vector3;
  13671. /**
  13672. * The max limit of the emission direction.
  13673. */
  13674. direction2: Vector3;
  13675. /**
  13676. * Creates a new instance SphereDirectedParticleEmitter
  13677. * @param radius the radius of the emission sphere (1 by default)
  13678. * @param direction1 the min limit of the emission direction (up vector by default)
  13679. * @param direction2 the max limit of the emission direction (up vector by default)
  13680. */
  13681. constructor(radius?: number,
  13682. /**
  13683. * The min limit of the emission direction.
  13684. */
  13685. direction1?: Vector3,
  13686. /**
  13687. * The max limit of the emission direction.
  13688. */
  13689. direction2?: Vector3);
  13690. /**
  13691. * Called by the particle System when the direction is computed for the created particle.
  13692. * @param worldMatrix is the world matrix of the particle system
  13693. * @param directionToUpdate is the direction vector to update with the result
  13694. * @param particle is the particle we are computed the direction for
  13695. */
  13696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13697. /**
  13698. * Clones the current emitter and returns a copy of it
  13699. * @returns the new emitter
  13700. */
  13701. clone(): SphereDirectedParticleEmitter;
  13702. /**
  13703. * Called by the GPUParticleSystem to setup the update shader
  13704. * @param effect defines the update shader
  13705. */
  13706. applyToShader(effect: Effect): void;
  13707. /**
  13708. * Returns a string to use to update the GPU particles update shader
  13709. * @returns a string containng the defines string
  13710. */
  13711. getEffectDefines(): string;
  13712. /**
  13713. * Returns the string "SphereDirectedParticleEmitter"
  13714. * @returns a string containing the class name
  13715. */
  13716. getClassName(): string;
  13717. /**
  13718. * Serializes the particle system to a JSON object.
  13719. * @returns the JSON object
  13720. */
  13721. serialize(): any;
  13722. /**
  13723. * Parse properties from a JSON object
  13724. * @param serializationObject defines the JSON object
  13725. */
  13726. parse(serializationObject: any): void;
  13727. }
  13728. }
  13729. declare module BABYLON {
  13730. /**
  13731. * Particle emitter emitting particles from a custom list of positions.
  13732. */
  13733. export class CustomParticleEmitter implements IParticleEmitterType {
  13734. /**
  13735. * Gets or sets the position generator that will create the inital position of each particle.
  13736. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13737. */
  13738. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13739. /**
  13740. * Gets or sets the destination generator that will create the final destination of each particle.
  13741. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13742. */
  13743. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13744. /**
  13745. * Creates a new instance CustomParticleEmitter
  13746. */
  13747. constructor();
  13748. /**
  13749. * Called by the particle System when the direction is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param directionToUpdate is the direction vector to update with the result
  13752. * @param particle is the particle we are computed the direction for
  13753. * @param isLocal defines if the direction should be set in local space
  13754. */
  13755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Called by the particle System when the position is computed for the created particle.
  13758. * @param worldMatrix is the world matrix of the particle system
  13759. * @param positionToUpdate is the position vector to update with the result
  13760. * @param particle is the particle we are computed the position for
  13761. * @param isLocal defines if the position should be set in local space
  13762. */
  13763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13764. /**
  13765. * Clones the current emitter and returns a copy of it
  13766. * @returns the new emitter
  13767. */
  13768. clone(): CustomParticleEmitter;
  13769. /**
  13770. * Called by the GPUParticleSystem to setup the update shader
  13771. * @param effect defines the update shader
  13772. */
  13773. applyToShader(effect: Effect): void;
  13774. /**
  13775. * Returns a string to use to update the GPU particles update shader
  13776. * @returns a string containng the defines string
  13777. */
  13778. getEffectDefines(): string;
  13779. /**
  13780. * Returns the string "PointParticleEmitter"
  13781. * @returns a string containing the class name
  13782. */
  13783. getClassName(): string;
  13784. /**
  13785. * Serializes the particle system to a JSON object.
  13786. * @returns the JSON object
  13787. */
  13788. serialize(): any;
  13789. /**
  13790. * Parse properties from a JSON object
  13791. * @param serializationObject defines the JSON object
  13792. */
  13793. parse(serializationObject: any): void;
  13794. }
  13795. }
  13796. declare module BABYLON {
  13797. /**
  13798. * Particle emitter emitting particles from the inside of a box.
  13799. * It emits the particles randomly between 2 given directions.
  13800. */
  13801. export class MeshParticleEmitter implements IParticleEmitterType {
  13802. private _indices;
  13803. private _positions;
  13804. private _normals;
  13805. private _storedNormal;
  13806. private _mesh;
  13807. /**
  13808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13809. */
  13810. direction1: Vector3;
  13811. /**
  13812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13813. */
  13814. direction2: Vector3;
  13815. /**
  13816. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13817. */
  13818. useMeshNormalsForDirection: boolean;
  13819. /** Defines the mesh to use as source */
  13820. get mesh(): Nullable<AbstractMesh>;
  13821. set mesh(value: Nullable<AbstractMesh>);
  13822. /**
  13823. * Creates a new instance MeshParticleEmitter
  13824. * @param mesh defines the mesh to use as source
  13825. */
  13826. constructor(mesh?: Nullable<AbstractMesh>);
  13827. /**
  13828. * Called by the particle System when the direction is computed for the created particle.
  13829. * @param worldMatrix is the world matrix of the particle system
  13830. * @param directionToUpdate is the direction vector to update with the result
  13831. * @param particle is the particle we are computed the direction for
  13832. * @param isLocal defines if the direction should be set in local space
  13833. */
  13834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13835. /**
  13836. * Called by the particle System when the position is computed for the created particle.
  13837. * @param worldMatrix is the world matrix of the particle system
  13838. * @param positionToUpdate is the position vector to update with the result
  13839. * @param particle is the particle we are computed the position for
  13840. * @param isLocal defines if the position should be set in local space
  13841. */
  13842. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13843. /**
  13844. * Clones the current emitter and returns a copy of it
  13845. * @returns the new emitter
  13846. */
  13847. clone(): MeshParticleEmitter;
  13848. /**
  13849. * Called by the GPUParticleSystem to setup the update shader
  13850. * @param effect defines the update shader
  13851. */
  13852. applyToShader(effect: Effect): void;
  13853. /**
  13854. * Returns a string to use to update the GPU particles update shader
  13855. * @returns a string containng the defines string
  13856. */
  13857. getEffectDefines(): string;
  13858. /**
  13859. * Returns the string "BoxParticleEmitter"
  13860. * @returns a string containing the class name
  13861. */
  13862. getClassName(): string;
  13863. /**
  13864. * Serializes the particle system to a JSON object.
  13865. * @returns the JSON object
  13866. */
  13867. serialize(): any;
  13868. /**
  13869. * Parse properties from a JSON object
  13870. * @param serializationObject defines the JSON object
  13871. * @param scene defines the hosting scene
  13872. */
  13873. parse(serializationObject: any, scene: Scene): void;
  13874. }
  13875. }
  13876. declare module BABYLON {
  13877. /**
  13878. * Interface representing a particle system in Babylon.js.
  13879. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13880. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13881. */
  13882. export interface IParticleSystem {
  13883. /**
  13884. * List of animations used by the particle system.
  13885. */
  13886. animations: Animation[];
  13887. /**
  13888. * The id of the Particle system.
  13889. */
  13890. id: string;
  13891. /**
  13892. * The name of the Particle system.
  13893. */
  13894. name: string;
  13895. /**
  13896. * The emitter represents the Mesh or position we are attaching the particle system to.
  13897. */
  13898. emitter: Nullable<AbstractMesh | Vector3>;
  13899. /**
  13900. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13901. */
  13902. isBillboardBased: boolean;
  13903. /**
  13904. * The rendering group used by the Particle system to chose when to render.
  13905. */
  13906. renderingGroupId: number;
  13907. /**
  13908. * The layer mask we are rendering the particles through.
  13909. */
  13910. layerMask: number;
  13911. /**
  13912. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13913. */
  13914. updateSpeed: number;
  13915. /**
  13916. * The amount of time the particle system is running (depends of the overall update speed).
  13917. */
  13918. targetStopDuration: number;
  13919. /**
  13920. * The texture used to render each particle. (this can be a spritesheet)
  13921. */
  13922. particleTexture: Nullable<Texture>;
  13923. /**
  13924. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13925. */
  13926. blendMode: number;
  13927. /**
  13928. * Minimum life time of emitting particles.
  13929. */
  13930. minLifeTime: number;
  13931. /**
  13932. * Maximum life time of emitting particles.
  13933. */
  13934. maxLifeTime: number;
  13935. /**
  13936. * Minimum Size of emitting particles.
  13937. */
  13938. minSize: number;
  13939. /**
  13940. * Maximum Size of emitting particles.
  13941. */
  13942. maxSize: number;
  13943. /**
  13944. * Minimum scale of emitting particles on X axis.
  13945. */
  13946. minScaleX: number;
  13947. /**
  13948. * Maximum scale of emitting particles on X axis.
  13949. */
  13950. maxScaleX: number;
  13951. /**
  13952. * Minimum scale of emitting particles on Y axis.
  13953. */
  13954. minScaleY: number;
  13955. /**
  13956. * Maximum scale of emitting particles on Y axis.
  13957. */
  13958. maxScaleY: number;
  13959. /**
  13960. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13961. */
  13962. color1: Color4;
  13963. /**
  13964. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13965. */
  13966. color2: Color4;
  13967. /**
  13968. * Color the particle will have at the end of its lifetime.
  13969. */
  13970. colorDead: Color4;
  13971. /**
  13972. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13973. */
  13974. emitRate: number;
  13975. /**
  13976. * You can use gravity if you want to give an orientation to your particles.
  13977. */
  13978. gravity: Vector3;
  13979. /**
  13980. * Minimum power of emitting particles.
  13981. */
  13982. minEmitPower: number;
  13983. /**
  13984. * Maximum power of emitting particles.
  13985. */
  13986. maxEmitPower: number;
  13987. /**
  13988. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13989. */
  13990. minAngularSpeed: number;
  13991. /**
  13992. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13993. */
  13994. maxAngularSpeed: number;
  13995. /**
  13996. * Gets or sets the minimal initial rotation in radians.
  13997. */
  13998. minInitialRotation: number;
  13999. /**
  14000. * Gets or sets the maximal initial rotation in radians.
  14001. */
  14002. maxInitialRotation: number;
  14003. /**
  14004. * The particle emitter type defines the emitter used by the particle system.
  14005. * It can be for example box, sphere, or cone...
  14006. */
  14007. particleEmitterType: Nullable<IParticleEmitterType>;
  14008. /**
  14009. * Defines the delay in milliseconds before starting the system (0 by default)
  14010. */
  14011. startDelay: number;
  14012. /**
  14013. * 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
  14014. */
  14015. preWarmCycles: number;
  14016. /**
  14017. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14018. */
  14019. preWarmStepOffset: number;
  14020. /**
  14021. * 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)
  14022. */
  14023. spriteCellChangeSpeed: number;
  14024. /**
  14025. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14026. */
  14027. startSpriteCellID: number;
  14028. /**
  14029. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14030. */
  14031. endSpriteCellID: number;
  14032. /**
  14033. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14034. */
  14035. spriteCellWidth: number;
  14036. /**
  14037. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14038. */
  14039. spriteCellHeight: number;
  14040. /**
  14041. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14042. */
  14043. spriteRandomStartCell: boolean;
  14044. /**
  14045. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14046. */
  14047. isAnimationSheetEnabled: boolean;
  14048. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14049. translationPivot: Vector2;
  14050. /**
  14051. * Gets or sets a texture used to add random noise to particle positions
  14052. */
  14053. noiseTexture: Nullable<BaseTexture>;
  14054. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14055. noiseStrength: Vector3;
  14056. /**
  14057. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14058. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14059. */
  14060. billboardMode: number;
  14061. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14062. limitVelocityDamping: number;
  14063. /**
  14064. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14065. */
  14066. beginAnimationOnStart: boolean;
  14067. /**
  14068. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14069. */
  14070. beginAnimationFrom: number;
  14071. /**
  14072. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14073. */
  14074. beginAnimationTo: number;
  14075. /**
  14076. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14077. */
  14078. beginAnimationLoop: boolean;
  14079. /**
  14080. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14081. */
  14082. disposeOnStop: boolean;
  14083. /**
  14084. * Specifies if the particles are updated in emitter local space or world space
  14085. */
  14086. isLocal: boolean;
  14087. /** Snippet ID if the particle system was created from the snippet server */
  14088. snippetId: string;
  14089. /**
  14090. * Gets the maximum number of particles active at the same time.
  14091. * @returns The max number of active particles.
  14092. */
  14093. getCapacity(): number;
  14094. /**
  14095. * Gets the number of particles active at the same time.
  14096. * @returns The number of active particles.
  14097. */
  14098. getActiveCount(): number;
  14099. /**
  14100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14101. * @returns True if it has been started, otherwise false.
  14102. */
  14103. isStarted(): boolean;
  14104. /**
  14105. * Animates the particle system for this frame.
  14106. */
  14107. animate(): void;
  14108. /**
  14109. * Renders the particle system in its current state.
  14110. * @returns the current number of particles
  14111. */
  14112. render(): number;
  14113. /**
  14114. * Dispose the particle system and frees its associated resources.
  14115. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14116. */
  14117. dispose(disposeTexture?: boolean): void;
  14118. /**
  14119. * An event triggered when the system is disposed
  14120. */
  14121. onDisposeObservable: Observable<IParticleSystem>;
  14122. /**
  14123. * Clones the particle system.
  14124. * @param name The name of the cloned object
  14125. * @param newEmitter The new emitter to use
  14126. * @returns the cloned particle system
  14127. */
  14128. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14129. /**
  14130. * Serializes the particle system to a JSON object
  14131. * @param serializeTexture defines if the texture must be serialized as well
  14132. * @returns the JSON object
  14133. */
  14134. serialize(serializeTexture: boolean): any;
  14135. /**
  14136. * Rebuild the particle system
  14137. */
  14138. rebuild(): void;
  14139. /** Force the system to rebuild all gradients that need to be resync */
  14140. forceRefreshGradients(): void;
  14141. /**
  14142. * Starts the particle system and begins to emit
  14143. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14144. */
  14145. start(delay?: number): void;
  14146. /**
  14147. * Stops the particle system.
  14148. */
  14149. stop(): void;
  14150. /**
  14151. * Remove all active particles
  14152. */
  14153. reset(): void;
  14154. /**
  14155. * Gets a boolean indicating that the system is stopping
  14156. * @returns true if the system is currently stopping
  14157. */
  14158. isStopping(): boolean;
  14159. /**
  14160. * Is this system ready to be used/rendered
  14161. * @return true if the system is ready
  14162. */
  14163. isReady(): boolean;
  14164. /**
  14165. * Returns the string "ParticleSystem"
  14166. * @returns a string containing the class name
  14167. */
  14168. getClassName(): string;
  14169. /**
  14170. * Gets the custom effect used to render the particles
  14171. * @param blendMode Blend mode for which the effect should be retrieved
  14172. * @returns The effect
  14173. */
  14174. getCustomEffect(blendMode: number): Nullable<Effect>;
  14175. /**
  14176. * Sets the custom effect used to render the particles
  14177. * @param effect The effect to set
  14178. * @param blendMode Blend mode for which the effect should be set
  14179. */
  14180. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14181. /**
  14182. * Fill the defines array according to the current settings of the particle system
  14183. * @param defines Array to be updated
  14184. * @param blendMode blend mode to take into account when updating the array
  14185. */
  14186. fillDefines(defines: Array<string>, blendMode: number): void;
  14187. /**
  14188. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14189. * @param uniforms Uniforms array to fill
  14190. * @param attributes Attributes array to fill
  14191. * @param samplers Samplers array to fill
  14192. */
  14193. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14194. /**
  14195. * Observable that will be called just before the particles are drawn
  14196. */
  14197. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14198. /**
  14199. * Gets the name of the particle vertex shader
  14200. */
  14201. vertexShaderName: string;
  14202. /**
  14203. * Adds a new color gradient
  14204. * @param gradient defines the gradient to use (between 0 and 1)
  14205. * @param color1 defines the color to affect to the specified gradient
  14206. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14207. * @returns the current particle system
  14208. */
  14209. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14210. /**
  14211. * Remove a specific color gradient
  14212. * @param gradient defines the gradient to remove
  14213. * @returns the current particle system
  14214. */
  14215. removeColorGradient(gradient: number): IParticleSystem;
  14216. /**
  14217. * Adds a new size gradient
  14218. * @param gradient defines the gradient to use (between 0 and 1)
  14219. * @param factor defines the size factor to affect to the specified gradient
  14220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14221. * @returns the current particle system
  14222. */
  14223. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14224. /**
  14225. * Remove a specific size gradient
  14226. * @param gradient defines the gradient to remove
  14227. * @returns the current particle system
  14228. */
  14229. removeSizeGradient(gradient: number): IParticleSystem;
  14230. /**
  14231. * Gets the current list of color gradients.
  14232. * You must use addColorGradient and removeColorGradient to udpate this list
  14233. * @returns the list of color gradients
  14234. */
  14235. getColorGradients(): Nullable<Array<ColorGradient>>;
  14236. /**
  14237. * Gets the current list of size gradients.
  14238. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14239. * @returns the list of size gradients
  14240. */
  14241. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14242. /**
  14243. * Gets the current list of angular speed gradients.
  14244. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14245. * @returns the list of angular speed gradients
  14246. */
  14247. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14248. /**
  14249. * Adds a new angular speed gradient
  14250. * @param gradient defines the gradient to use (between 0 and 1)
  14251. * @param factor defines the angular speed to affect to the specified gradient
  14252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14253. * @returns the current particle system
  14254. */
  14255. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14256. /**
  14257. * Remove a specific angular speed gradient
  14258. * @param gradient defines the gradient to remove
  14259. * @returns the current particle system
  14260. */
  14261. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14262. /**
  14263. * Gets the current list of velocity gradients.
  14264. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14265. * @returns the list of velocity gradients
  14266. */
  14267. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14268. /**
  14269. * Adds a new velocity gradient
  14270. * @param gradient defines the gradient to use (between 0 and 1)
  14271. * @param factor defines the velocity to affect to the specified gradient
  14272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14273. * @returns the current particle system
  14274. */
  14275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14276. /**
  14277. * Remove a specific velocity gradient
  14278. * @param gradient defines the gradient to remove
  14279. * @returns the current particle system
  14280. */
  14281. removeVelocityGradient(gradient: number): IParticleSystem;
  14282. /**
  14283. * Gets the current list of limit velocity gradients.
  14284. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14285. * @returns the list of limit velocity gradients
  14286. */
  14287. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14288. /**
  14289. * Adds a new limit velocity gradient
  14290. * @param gradient defines the gradient to use (between 0 and 1)
  14291. * @param factor defines the limit velocity to affect to the specified gradient
  14292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14293. * @returns the current particle system
  14294. */
  14295. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14296. /**
  14297. * Remove a specific limit velocity gradient
  14298. * @param gradient defines the gradient to remove
  14299. * @returns the current particle system
  14300. */
  14301. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14302. /**
  14303. * Adds a new drag gradient
  14304. * @param gradient defines the gradient to use (between 0 and 1)
  14305. * @param factor defines the drag to affect to the specified gradient
  14306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14307. * @returns the current particle system
  14308. */
  14309. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14310. /**
  14311. * Remove a specific drag gradient
  14312. * @param gradient defines the gradient to remove
  14313. * @returns the current particle system
  14314. */
  14315. removeDragGradient(gradient: number): IParticleSystem;
  14316. /**
  14317. * Gets the current list of drag gradients.
  14318. * You must use addDragGradient and removeDragGradient to udpate this list
  14319. * @returns the list of drag gradients
  14320. */
  14321. getDragGradients(): Nullable<Array<FactorGradient>>;
  14322. /**
  14323. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14324. * @param gradient defines the gradient to use (between 0 and 1)
  14325. * @param factor defines the emit rate to affect to the specified gradient
  14326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14327. * @returns the current particle system
  14328. */
  14329. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14330. /**
  14331. * Remove a specific emit rate gradient
  14332. * @param gradient defines the gradient to remove
  14333. * @returns the current particle system
  14334. */
  14335. removeEmitRateGradient(gradient: number): IParticleSystem;
  14336. /**
  14337. * Gets the current list of emit rate gradients.
  14338. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14339. * @returns the list of emit rate gradients
  14340. */
  14341. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14342. /**
  14343. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14344. * @param gradient defines the gradient to use (between 0 and 1)
  14345. * @param factor defines the start size to affect to the specified gradient
  14346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14347. * @returns the current particle system
  14348. */
  14349. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14350. /**
  14351. * Remove a specific start size gradient
  14352. * @param gradient defines the gradient to remove
  14353. * @returns the current particle system
  14354. */
  14355. removeStartSizeGradient(gradient: number): IParticleSystem;
  14356. /**
  14357. * Gets the current list of start size gradients.
  14358. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14359. * @returns the list of start size gradients
  14360. */
  14361. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Adds a new life time gradient
  14364. * @param gradient defines the gradient to use (between 0 and 1)
  14365. * @param factor defines the life time factor to affect to the specified gradient
  14366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14367. * @returns the current particle system
  14368. */
  14369. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14370. /**
  14371. * Remove a specific life time gradient
  14372. * @param gradient defines the gradient to remove
  14373. * @returns the current particle system
  14374. */
  14375. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14376. /**
  14377. * Gets the current list of life time gradients.
  14378. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14379. * @returns the list of life time gradients
  14380. */
  14381. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14382. /**
  14383. * Gets the current list of color gradients.
  14384. * You must use addColorGradient and removeColorGradient to udpate this list
  14385. * @returns the list of color gradients
  14386. */
  14387. getColorGradients(): Nullable<Array<ColorGradient>>;
  14388. /**
  14389. * Adds a new ramp gradient used to remap particle colors
  14390. * @param gradient defines the gradient to use (between 0 and 1)
  14391. * @param color defines the color to affect to the specified gradient
  14392. * @returns the current particle system
  14393. */
  14394. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14395. /**
  14396. * Gets the current list of ramp gradients.
  14397. * You must use addRampGradient and removeRampGradient to udpate this list
  14398. * @returns the list of ramp gradients
  14399. */
  14400. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14401. /** Gets or sets a boolean indicating that ramp gradients must be used
  14402. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14403. */
  14404. useRampGradients: boolean;
  14405. /**
  14406. * Adds a new color remap gradient
  14407. * @param gradient defines the gradient to use (between 0 and 1)
  14408. * @param min defines the color remap minimal range
  14409. * @param max defines the color remap maximal range
  14410. * @returns the current particle system
  14411. */
  14412. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14413. /**
  14414. * Gets the current list of color remap gradients.
  14415. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14416. * @returns the list of color remap gradients
  14417. */
  14418. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14419. /**
  14420. * Adds a new alpha remap gradient
  14421. * @param gradient defines the gradient to use (between 0 and 1)
  14422. * @param min defines the alpha remap minimal range
  14423. * @param max defines the alpha remap maximal range
  14424. * @returns the current particle system
  14425. */
  14426. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14427. /**
  14428. * Gets the current list of alpha remap gradients.
  14429. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14430. * @returns the list of alpha remap gradients
  14431. */
  14432. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14433. /**
  14434. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14437. * @returns the emitter
  14438. */
  14439. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14440. /**
  14441. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14442. * @param radius The radius of the hemisphere to emit from
  14443. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14444. * @returns the emitter
  14445. */
  14446. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14447. /**
  14448. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14449. * @param radius The radius of the sphere to emit from
  14450. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14451. * @returns the emitter
  14452. */
  14453. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14454. /**
  14455. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14456. * @param radius The radius of the sphere to emit from
  14457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14459. * @returns the emitter
  14460. */
  14461. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14462. /**
  14463. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14464. * @param radius The radius of the emission cylinder
  14465. * @param height The height of the emission cylinder
  14466. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14467. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14468. * @returns the emitter
  14469. */
  14470. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14471. /**
  14472. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14473. * @param radius The radius of the cylinder to emit from
  14474. * @param height The height of the emission cylinder
  14475. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14478. * @returns the emitter
  14479. */
  14480. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14481. /**
  14482. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14483. * @param radius The radius of the cone to emit from
  14484. * @param angle The base angle of the cone
  14485. * @returns the emitter
  14486. */
  14487. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14488. /**
  14489. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14492. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14493. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14494. * @returns the emitter
  14495. */
  14496. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14497. /**
  14498. * Get hosting scene
  14499. * @returns the scene
  14500. */
  14501. getScene(): Scene;
  14502. }
  14503. }
  14504. declare module BABYLON {
  14505. /**
  14506. * 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.
  14507. * @see https://doc.babylonjs.com/how_to/transformnode
  14508. */
  14509. export class TransformNode extends Node {
  14510. /**
  14511. * Object will not rotate to face the camera
  14512. */
  14513. static BILLBOARDMODE_NONE: number;
  14514. /**
  14515. * Object will rotate to face the camera but only on the x axis
  14516. */
  14517. static BILLBOARDMODE_X: number;
  14518. /**
  14519. * Object will rotate to face the camera but only on the y axis
  14520. */
  14521. static BILLBOARDMODE_Y: number;
  14522. /**
  14523. * Object will rotate to face the camera but only on the z axis
  14524. */
  14525. static BILLBOARDMODE_Z: number;
  14526. /**
  14527. * Object will rotate to face the camera
  14528. */
  14529. static BILLBOARDMODE_ALL: number;
  14530. /**
  14531. * Object will rotate to face the camera's position instead of orientation
  14532. */
  14533. static BILLBOARDMODE_USE_POSITION: number;
  14534. private _forward;
  14535. private _forwardInverted;
  14536. private _up;
  14537. private _right;
  14538. private _rightInverted;
  14539. private _position;
  14540. private _rotation;
  14541. private _rotationQuaternion;
  14542. protected _scaling: Vector3;
  14543. protected _isDirty: boolean;
  14544. private _transformToBoneReferal;
  14545. private _isAbsoluteSynced;
  14546. private _billboardMode;
  14547. /**
  14548. * Gets or sets the billboard mode. Default is 0.
  14549. *
  14550. * | Value | Type | Description |
  14551. * | --- | --- | --- |
  14552. * | 0 | BILLBOARDMODE_NONE | |
  14553. * | 1 | BILLBOARDMODE_X | |
  14554. * | 2 | BILLBOARDMODE_Y | |
  14555. * | 4 | BILLBOARDMODE_Z | |
  14556. * | 7 | BILLBOARDMODE_ALL | |
  14557. *
  14558. */
  14559. get billboardMode(): number;
  14560. set billboardMode(value: number);
  14561. private _preserveParentRotationForBillboard;
  14562. /**
  14563. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14564. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14565. */
  14566. get preserveParentRotationForBillboard(): boolean;
  14567. set preserveParentRotationForBillboard(value: boolean);
  14568. /**
  14569. * 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
  14570. */
  14571. scalingDeterminant: number;
  14572. private _infiniteDistance;
  14573. /**
  14574. * Gets or sets the distance of the object to max, often used by skybox
  14575. */
  14576. get infiniteDistance(): boolean;
  14577. set infiniteDistance(value: boolean);
  14578. /**
  14579. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14580. * By default the system will update normals to compensate
  14581. */
  14582. ignoreNonUniformScaling: boolean;
  14583. /**
  14584. * 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
  14585. */
  14586. reIntegrateRotationIntoRotationQuaternion: boolean;
  14587. /** @hidden */
  14588. _poseMatrix: Nullable<Matrix>;
  14589. /** @hidden */
  14590. _localMatrix: Matrix;
  14591. private _usePivotMatrix;
  14592. private _absolutePosition;
  14593. private _absoluteScaling;
  14594. private _absoluteRotationQuaternion;
  14595. private _pivotMatrix;
  14596. private _pivotMatrixInverse;
  14597. protected _postMultiplyPivotMatrix: boolean;
  14598. protected _isWorldMatrixFrozen: boolean;
  14599. /** @hidden */
  14600. _indexInSceneTransformNodesArray: number;
  14601. /**
  14602. * An event triggered after the world matrix is updated
  14603. */
  14604. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14605. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14606. /**
  14607. * Gets a string identifying the name of the class
  14608. * @returns "TransformNode" string
  14609. */
  14610. getClassName(): string;
  14611. /**
  14612. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14613. */
  14614. get position(): Vector3;
  14615. set position(newPosition: Vector3);
  14616. /**
  14617. * 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)).
  14618. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14619. */
  14620. get rotation(): Vector3;
  14621. set rotation(newRotation: Vector3);
  14622. /**
  14623. * 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)).
  14624. */
  14625. get scaling(): Vector3;
  14626. set scaling(newScaling: Vector3);
  14627. /**
  14628. * 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).
  14629. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14630. */
  14631. get rotationQuaternion(): Nullable<Quaternion>;
  14632. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14633. /**
  14634. * The forward direction of that transform in world space.
  14635. */
  14636. get forward(): Vector3;
  14637. /**
  14638. * The up direction of that transform in world space.
  14639. */
  14640. get up(): Vector3;
  14641. /**
  14642. * The right direction of that transform in world space.
  14643. */
  14644. get right(): Vector3;
  14645. /**
  14646. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14647. * @param matrix the matrix to copy the pose from
  14648. * @returns this TransformNode.
  14649. */
  14650. updatePoseMatrix(matrix: Matrix): TransformNode;
  14651. /**
  14652. * Returns the mesh Pose matrix.
  14653. * @returns the pose matrix
  14654. */
  14655. getPoseMatrix(): Matrix;
  14656. /** @hidden */
  14657. _isSynchronized(): boolean;
  14658. /** @hidden */
  14659. _initCache(): void;
  14660. /**
  14661. * Flag the transform node as dirty (Forcing it to update everything)
  14662. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14663. * @returns this transform node
  14664. */
  14665. markAsDirty(property: string): TransformNode;
  14666. /**
  14667. * Returns the current mesh absolute position.
  14668. * Returns a Vector3.
  14669. */
  14670. get absolutePosition(): Vector3;
  14671. /**
  14672. * Returns the current mesh absolute scaling.
  14673. * Returns a Vector3.
  14674. */
  14675. get absoluteScaling(): Vector3;
  14676. /**
  14677. * Returns the current mesh absolute rotation.
  14678. * Returns a Quaternion.
  14679. */
  14680. get absoluteRotationQuaternion(): Quaternion;
  14681. /**
  14682. * Sets a new matrix to apply before all other transformation
  14683. * @param matrix defines the transform matrix
  14684. * @returns the current TransformNode
  14685. */
  14686. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14687. /**
  14688. * Sets a new pivot matrix to the current node
  14689. * @param matrix defines the new pivot matrix to use
  14690. * @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
  14691. * @returns the current TransformNode
  14692. */
  14693. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14694. /**
  14695. * Returns the mesh pivot matrix.
  14696. * Default : Identity.
  14697. * @returns the matrix
  14698. */
  14699. getPivotMatrix(): Matrix;
  14700. /**
  14701. * Instantiate (when possible) or clone that node with its hierarchy
  14702. * @param newParent defines the new parent to use for the instance (or clone)
  14703. * @param options defines options to configure how copy is done
  14704. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14705. * @returns an instance (or a clone) of the current node with its hiearchy
  14706. */
  14707. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14708. doNotInstantiate: boolean;
  14709. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14710. /**
  14711. * Prevents the World matrix to be computed any longer
  14712. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14713. * @returns the TransformNode.
  14714. */
  14715. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14716. /**
  14717. * Allows back the World matrix computation.
  14718. * @returns the TransformNode.
  14719. */
  14720. unfreezeWorldMatrix(): this;
  14721. /**
  14722. * True if the World matrix has been frozen.
  14723. */
  14724. get isWorldMatrixFrozen(): boolean;
  14725. /**
  14726. * Retuns the mesh absolute position in the World.
  14727. * @returns a Vector3.
  14728. */
  14729. getAbsolutePosition(): Vector3;
  14730. /**
  14731. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14732. * @param absolutePosition the absolute position to set
  14733. * @returns the TransformNode.
  14734. */
  14735. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14736. /**
  14737. * Sets the mesh position in its local space.
  14738. * @param vector3 the position to set in localspace
  14739. * @returns the TransformNode.
  14740. */
  14741. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14742. /**
  14743. * Returns the mesh position in the local space from the current World matrix values.
  14744. * @returns a new Vector3.
  14745. */
  14746. getPositionExpressedInLocalSpace(): Vector3;
  14747. /**
  14748. * Translates the mesh along the passed Vector3 in its local space.
  14749. * @param vector3 the distance to translate in localspace
  14750. * @returns the TransformNode.
  14751. */
  14752. locallyTranslate(vector3: Vector3): TransformNode;
  14753. private static _lookAtVectorCache;
  14754. /**
  14755. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14756. * @param targetPoint the position (must be in same space as current mesh) to look at
  14757. * @param yawCor optional yaw (y-axis) correction in radians
  14758. * @param pitchCor optional pitch (x-axis) correction in radians
  14759. * @param rollCor optional roll (z-axis) correction in radians
  14760. * @param space the choosen space of the target
  14761. * @returns the TransformNode.
  14762. */
  14763. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14764. /**
  14765. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14766. * This Vector3 is expressed in the World space.
  14767. * @param localAxis axis to rotate
  14768. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14769. */
  14770. getDirection(localAxis: Vector3): Vector3;
  14771. /**
  14772. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14773. * localAxis is expressed in the mesh local space.
  14774. * result is computed in the Wordl space from the mesh World matrix.
  14775. * @param localAxis axis to rotate
  14776. * @param result the resulting transformnode
  14777. * @returns this TransformNode.
  14778. */
  14779. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14780. /**
  14781. * Sets this transform node rotation to the given local axis.
  14782. * @param localAxis the axis in local space
  14783. * @param yawCor optional yaw (y-axis) correction in radians
  14784. * @param pitchCor optional pitch (x-axis) correction in radians
  14785. * @param rollCor optional roll (z-axis) correction in radians
  14786. * @returns this TransformNode
  14787. */
  14788. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14789. /**
  14790. * Sets a new pivot point to the current node
  14791. * @param point defines the new pivot point to use
  14792. * @param space defines if the point is in world or local space (local by default)
  14793. * @returns the current TransformNode
  14794. */
  14795. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14796. /**
  14797. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14798. * @returns the pivot point
  14799. */
  14800. getPivotPoint(): Vector3;
  14801. /**
  14802. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14803. * @param result the vector3 to store the result
  14804. * @returns this TransformNode.
  14805. */
  14806. getPivotPointToRef(result: Vector3): TransformNode;
  14807. /**
  14808. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14809. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14810. */
  14811. getAbsolutePivotPoint(): Vector3;
  14812. /**
  14813. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14814. * @param result vector3 to store the result
  14815. * @returns this TransformNode.
  14816. */
  14817. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14818. /**
  14819. * Defines the passed node as the parent of the current node.
  14820. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14821. * @see https://doc.babylonjs.com/how_to/parenting
  14822. * @param node the node ot set as the parent
  14823. * @returns this TransformNode.
  14824. */
  14825. setParent(node: Nullable<Node>): TransformNode;
  14826. private _nonUniformScaling;
  14827. /**
  14828. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14829. */
  14830. get nonUniformScaling(): boolean;
  14831. /** @hidden */
  14832. _updateNonUniformScalingState(value: boolean): boolean;
  14833. /**
  14834. * Attach the current TransformNode to another TransformNode associated with a bone
  14835. * @param bone Bone affecting the TransformNode
  14836. * @param affectedTransformNode TransformNode associated with the bone
  14837. * @returns this object
  14838. */
  14839. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14840. /**
  14841. * Detach the transform node if its associated with a bone
  14842. * @returns this object
  14843. */
  14844. detachFromBone(): TransformNode;
  14845. private static _rotationAxisCache;
  14846. /**
  14847. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14848. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14849. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14850. * The passed axis is also normalized.
  14851. * @param axis the axis to rotate around
  14852. * @param amount the amount to rotate in radians
  14853. * @param space Space to rotate in (Default: local)
  14854. * @returns the TransformNode.
  14855. */
  14856. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14857. /**
  14858. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14859. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14860. * The passed axis is also normalized. .
  14861. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14862. * @param point the point to rotate around
  14863. * @param axis the axis to rotate around
  14864. * @param amount the amount to rotate in radians
  14865. * @returns the TransformNode
  14866. */
  14867. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14868. /**
  14869. * Translates the mesh along the axis vector for the passed distance in the given space.
  14870. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14871. * @param axis the axis to translate in
  14872. * @param distance the distance to translate
  14873. * @param space Space to rotate in (Default: local)
  14874. * @returns the TransformNode.
  14875. */
  14876. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14877. /**
  14878. * Adds a rotation step to the mesh current rotation.
  14879. * x, y, z are Euler angles expressed in radians.
  14880. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14881. * This means this rotation is made in the mesh local space only.
  14882. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14883. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14884. * ```javascript
  14885. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14886. * ```
  14887. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14888. * 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.
  14889. * @param x Rotation to add
  14890. * @param y Rotation to add
  14891. * @param z Rotation to add
  14892. * @returns the TransformNode.
  14893. */
  14894. addRotation(x: number, y: number, z: number): TransformNode;
  14895. /**
  14896. * @hidden
  14897. */
  14898. protected _getEffectiveParent(): Nullable<Node>;
  14899. /**
  14900. * Computes the world matrix of the node
  14901. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14902. * @returns the world matrix
  14903. */
  14904. computeWorldMatrix(force?: boolean): Matrix;
  14905. /**
  14906. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14907. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14908. */
  14909. resetLocalMatrix(independentOfChildren?: boolean): void;
  14910. protected _afterComputeWorldMatrix(): void;
  14911. /**
  14912. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14913. * @param func callback function to add
  14914. *
  14915. * @returns the TransformNode.
  14916. */
  14917. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14918. /**
  14919. * Removes a registered callback function.
  14920. * @param func callback function to remove
  14921. * @returns the TransformNode.
  14922. */
  14923. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14924. /**
  14925. * Gets the position of the current mesh in camera space
  14926. * @param camera defines the camera to use
  14927. * @returns a position
  14928. */
  14929. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14930. /**
  14931. * Returns the distance from the mesh to the active camera
  14932. * @param camera defines the camera to use
  14933. * @returns the distance
  14934. */
  14935. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14936. /**
  14937. * Clone the current transform node
  14938. * @param name Name of the new clone
  14939. * @param newParent New parent for the clone
  14940. * @param doNotCloneChildren Do not clone children hierarchy
  14941. * @returns the new transform node
  14942. */
  14943. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14944. /**
  14945. * Serializes the objects information.
  14946. * @param currentSerializationObject defines the object to serialize in
  14947. * @returns the serialized object
  14948. */
  14949. serialize(currentSerializationObject?: any): any;
  14950. /**
  14951. * Returns a new TransformNode object parsed from the source provided.
  14952. * @param parsedTransformNode is the source.
  14953. * @param scene the scne the object belongs to
  14954. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14955. * @returns a new TransformNode object parsed from the source provided.
  14956. */
  14957. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14958. /**
  14959. * Get all child-transformNodes of this node
  14960. * @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
  14961. * @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
  14962. * @returns an array of TransformNode
  14963. */
  14964. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14965. /**
  14966. * Releases resources associated with this transform node.
  14967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14969. */
  14970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14971. /**
  14972. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14973. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14974. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14975. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14976. * @returns the current mesh
  14977. */
  14978. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14979. private _syncAbsoluteScalingAndRotation;
  14980. }
  14981. }
  14982. declare module BABYLON {
  14983. /**
  14984. * Class used to override all child animations of a given target
  14985. */
  14986. export class AnimationPropertiesOverride {
  14987. /**
  14988. * Gets or sets a value indicating if animation blending must be used
  14989. */
  14990. enableBlending: boolean;
  14991. /**
  14992. * Gets or sets the blending speed to use when enableBlending is true
  14993. */
  14994. blendingSpeed: number;
  14995. /**
  14996. * Gets or sets the default loop mode to use
  14997. */
  14998. loopMode: number;
  14999. }
  15000. }
  15001. declare module BABYLON {
  15002. /**
  15003. * Class used to store bone information
  15004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15005. */
  15006. export class Bone extends Node {
  15007. /**
  15008. * defines the bone name
  15009. */
  15010. name: string;
  15011. private static _tmpVecs;
  15012. private static _tmpQuat;
  15013. private static _tmpMats;
  15014. /**
  15015. * Gets the list of child bones
  15016. */
  15017. children: Bone[];
  15018. /** Gets the animations associated with this bone */
  15019. animations: Animation[];
  15020. /**
  15021. * Gets or sets bone length
  15022. */
  15023. length: number;
  15024. /**
  15025. * @hidden Internal only
  15026. * Set this value to map this bone to a different index in the transform matrices
  15027. * Set this value to -1 to exclude the bone from the transform matrices
  15028. */
  15029. _index: Nullable<number>;
  15030. private _skeleton;
  15031. private _localMatrix;
  15032. private _restPose;
  15033. private _baseMatrix;
  15034. private _absoluteTransform;
  15035. private _invertedAbsoluteTransform;
  15036. private _parent;
  15037. private _scalingDeterminant;
  15038. private _worldTransform;
  15039. private _localScaling;
  15040. private _localRotation;
  15041. private _localPosition;
  15042. private _needToDecompose;
  15043. private _needToCompose;
  15044. /** @hidden */
  15045. _linkedTransformNode: Nullable<TransformNode>;
  15046. /** @hidden */
  15047. _waitingTransformNodeId: Nullable<string>;
  15048. /** @hidden */
  15049. get _matrix(): Matrix;
  15050. /** @hidden */
  15051. set _matrix(value: Matrix);
  15052. /**
  15053. * Create a new bone
  15054. * @param name defines the bone name
  15055. * @param skeleton defines the parent skeleton
  15056. * @param parentBone defines the parent (can be null if the bone is the root)
  15057. * @param localMatrix defines the local matrix
  15058. * @param restPose defines the rest pose matrix
  15059. * @param baseMatrix defines the base matrix
  15060. * @param index defines index of the bone in the hiearchy
  15061. */
  15062. constructor(
  15063. /**
  15064. * defines the bone name
  15065. */
  15066. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15067. /**
  15068. * Gets the current object class name.
  15069. * @return the class name
  15070. */
  15071. getClassName(): string;
  15072. /**
  15073. * Gets the parent skeleton
  15074. * @returns a skeleton
  15075. */
  15076. getSkeleton(): Skeleton;
  15077. /**
  15078. * Gets parent bone
  15079. * @returns a bone or null if the bone is the root of the bone hierarchy
  15080. */
  15081. getParent(): Nullable<Bone>;
  15082. /**
  15083. * Returns an array containing the root bones
  15084. * @returns an array containing the root bones
  15085. */
  15086. getChildren(): Array<Bone>;
  15087. /**
  15088. * Gets the node index in matrix array generated for rendering
  15089. * @returns the node index
  15090. */
  15091. getIndex(): number;
  15092. /**
  15093. * Sets the parent bone
  15094. * @param parent defines the parent (can be null if the bone is the root)
  15095. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15096. */
  15097. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15098. /**
  15099. * Gets the local matrix
  15100. * @returns a matrix
  15101. */
  15102. getLocalMatrix(): Matrix;
  15103. /**
  15104. * Gets the base matrix (initial matrix which remains unchanged)
  15105. * @returns a matrix
  15106. */
  15107. getBaseMatrix(): Matrix;
  15108. /**
  15109. * Gets the rest pose matrix
  15110. * @returns a matrix
  15111. */
  15112. getRestPose(): Matrix;
  15113. /**
  15114. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15115. */
  15116. getWorldMatrix(): Matrix;
  15117. /**
  15118. * Sets the local matrix to rest pose matrix
  15119. */
  15120. returnToRest(): void;
  15121. /**
  15122. * Gets the inverse of the absolute transform matrix.
  15123. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15124. * @returns a matrix
  15125. */
  15126. getInvertedAbsoluteTransform(): Matrix;
  15127. /**
  15128. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15129. * @returns a matrix
  15130. */
  15131. getAbsoluteTransform(): Matrix;
  15132. /**
  15133. * Links with the given transform node.
  15134. * The local matrix of this bone is copied from the transform node every frame.
  15135. * @param transformNode defines the transform node to link to
  15136. */
  15137. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15138. /**
  15139. * Gets the node used to drive the bone's transformation
  15140. * @returns a transform node or null
  15141. */
  15142. getTransformNode(): Nullable<TransformNode>;
  15143. /** Gets or sets current position (in local space) */
  15144. get position(): Vector3;
  15145. set position(newPosition: Vector3);
  15146. /** Gets or sets current rotation (in local space) */
  15147. get rotation(): Vector3;
  15148. set rotation(newRotation: Vector3);
  15149. /** Gets or sets current rotation quaternion (in local space) */
  15150. get rotationQuaternion(): Quaternion;
  15151. set rotationQuaternion(newRotation: Quaternion);
  15152. /** Gets or sets current scaling (in local space) */
  15153. get scaling(): Vector3;
  15154. set scaling(newScaling: Vector3);
  15155. /**
  15156. * Gets the animation properties override
  15157. */
  15158. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15159. private _decompose;
  15160. private _compose;
  15161. /**
  15162. * Update the base and local matrices
  15163. * @param matrix defines the new base or local matrix
  15164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15165. * @param updateLocalMatrix defines if the local matrix should be updated
  15166. */
  15167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15168. /** @hidden */
  15169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15170. /**
  15171. * Flag the bone as dirty (Forcing it to update everything)
  15172. */
  15173. markAsDirty(): void;
  15174. /** @hidden */
  15175. _markAsDirtyAndCompose(): void;
  15176. private _markAsDirtyAndDecompose;
  15177. /**
  15178. * Translate the bone in local or world space
  15179. * @param vec The amount to translate the bone
  15180. * @param space The space that the translation is in
  15181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15182. */
  15183. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15184. /**
  15185. * Set the postion of the bone in local or world space
  15186. * @param position The position to set the bone
  15187. * @param space The space that the position is in
  15188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15189. */
  15190. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15191. /**
  15192. * Set the absolute position of the bone (world space)
  15193. * @param position The position to set the bone
  15194. * @param mesh The mesh that this bone is attached to
  15195. */
  15196. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15197. /**
  15198. * Scale the bone on the x, y and z axes (in local space)
  15199. * @param x The amount to scale the bone on the x axis
  15200. * @param y The amount to scale the bone on the y axis
  15201. * @param z The amount to scale the bone on the z axis
  15202. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15203. */
  15204. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15205. /**
  15206. * Set the bone scaling in local space
  15207. * @param scale defines the scaling vector
  15208. */
  15209. setScale(scale: Vector3): void;
  15210. /**
  15211. * Gets the current scaling in local space
  15212. * @returns the current scaling vector
  15213. */
  15214. getScale(): Vector3;
  15215. /**
  15216. * Gets the current scaling in local space and stores it in a target vector
  15217. * @param result defines the target vector
  15218. */
  15219. getScaleToRef(result: Vector3): void;
  15220. /**
  15221. * Set the yaw, pitch, and roll of the bone in local or world space
  15222. * @param yaw The rotation of the bone on the y axis
  15223. * @param pitch The rotation of the bone on the x axis
  15224. * @param roll The rotation of the bone on the z axis
  15225. * @param space The space that the axes of rotation are in
  15226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15227. */
  15228. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15229. /**
  15230. * Add a rotation to the bone on an axis in local or world space
  15231. * @param axis The axis to rotate the bone on
  15232. * @param amount The amount to rotate the bone
  15233. * @param space The space that the axis is in
  15234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15235. */
  15236. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15237. /**
  15238. * Set the rotation of the bone to a particular axis angle in local or world space
  15239. * @param axis The axis to rotate the bone on
  15240. * @param angle The angle that the bone should be rotated to
  15241. * @param space The space that the axis is in
  15242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15243. */
  15244. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15245. /**
  15246. * Set the euler rotation of the bone in local of world space
  15247. * @param rotation The euler rotation that the bone should be set to
  15248. * @param space The space that the rotation is in
  15249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15250. */
  15251. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15252. /**
  15253. * Set the quaternion rotation of the bone in local of world space
  15254. * @param quat The quaternion rotation that the bone should be set to
  15255. * @param space The space that the rotation is in
  15256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15257. */
  15258. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15259. /**
  15260. * Set the rotation matrix of the bone in local of world space
  15261. * @param rotMat The rotation matrix that the bone should be set to
  15262. * @param space The space that the rotation is in
  15263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15264. */
  15265. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15266. private _rotateWithMatrix;
  15267. private _getNegativeRotationToRef;
  15268. /**
  15269. * Get the position of the bone in local or world space
  15270. * @param space The space that the returned position is in
  15271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15272. * @returns The position of the bone
  15273. */
  15274. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15275. /**
  15276. * Copy the position of the bone to a vector3 in local or world space
  15277. * @param space The space that the returned position is in
  15278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15279. * @param result The vector3 to copy the position to
  15280. */
  15281. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15282. /**
  15283. * Get the absolute position of the bone (world space)
  15284. * @param mesh The mesh that this bone is attached to
  15285. * @returns The absolute position of the bone
  15286. */
  15287. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15288. /**
  15289. * Copy the absolute position of the bone (world space) to the result param
  15290. * @param mesh The mesh that this bone is attached to
  15291. * @param result The vector3 to copy the absolute position to
  15292. */
  15293. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15294. /**
  15295. * Compute the absolute transforms of this bone and its children
  15296. */
  15297. computeAbsoluteTransforms(): void;
  15298. /**
  15299. * Get the world direction from an axis that is in the local space of the bone
  15300. * @param localAxis The local direction that is used to compute the world direction
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @returns The world direction
  15303. */
  15304. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15305. /**
  15306. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15307. * @param localAxis The local direction that is used to compute the world direction
  15308. * @param mesh The mesh that this bone is attached to
  15309. * @param result The vector3 that the world direction will be copied to
  15310. */
  15311. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15312. /**
  15313. * Get the euler rotation of the bone in local or world space
  15314. * @param space The space that the rotation should be in
  15315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15316. * @returns The euler rotation
  15317. */
  15318. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15319. /**
  15320. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15321. * @param space The space that the rotation should be in
  15322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15323. * @param result The vector3 that the rotation should be copied to
  15324. */
  15325. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15326. /**
  15327. * Get the quaternion rotation of the bone in either local or world space
  15328. * @param space The space that the rotation should be in
  15329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15330. * @returns The quaternion rotation
  15331. */
  15332. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15333. /**
  15334. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15335. * @param space The space that the rotation should be in
  15336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15337. * @param result The quaternion that the rotation should be copied to
  15338. */
  15339. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15340. /**
  15341. * Get the rotation matrix of the bone in local or world space
  15342. * @param space The space that the rotation should be in
  15343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15344. * @returns The rotation matrix
  15345. */
  15346. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15347. /**
  15348. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15349. * @param space The space that the rotation should be in
  15350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15351. * @param result The quaternion that the rotation should be copied to
  15352. */
  15353. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15354. /**
  15355. * Get the world position of a point that is in the local space of the bone
  15356. * @param position The local position
  15357. * @param mesh The mesh that this bone is attached to
  15358. * @returns The world position
  15359. */
  15360. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15361. /**
  15362. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15363. * @param position The local position
  15364. * @param mesh The mesh that this bone is attached to
  15365. * @param result The vector3 that the world position should be copied to
  15366. */
  15367. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15368. /**
  15369. * Get the local position of a point that is in world space
  15370. * @param position The world position
  15371. * @param mesh The mesh that this bone is attached to
  15372. * @returns The local position
  15373. */
  15374. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15375. /**
  15376. * Get the local position of a point that is in world space and copy it to the result param
  15377. * @param position The world position
  15378. * @param mesh The mesh that this bone is attached to
  15379. * @param result The vector3 that the local position should be copied to
  15380. */
  15381. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15382. }
  15383. }
  15384. declare module BABYLON {
  15385. /**
  15386. * Defines a runtime animation
  15387. */
  15388. export class RuntimeAnimation {
  15389. private _events;
  15390. /**
  15391. * The current frame of the runtime animation
  15392. */
  15393. private _currentFrame;
  15394. /**
  15395. * The animation used by the runtime animation
  15396. */
  15397. private _animation;
  15398. /**
  15399. * The target of the runtime animation
  15400. */
  15401. private _target;
  15402. /**
  15403. * The initiating animatable
  15404. */
  15405. private _host;
  15406. /**
  15407. * The original value of the runtime animation
  15408. */
  15409. private _originalValue;
  15410. /**
  15411. * The original blend value of the runtime animation
  15412. */
  15413. private _originalBlendValue;
  15414. /**
  15415. * The offsets cache of the runtime animation
  15416. */
  15417. private _offsetsCache;
  15418. /**
  15419. * The high limits cache of the runtime animation
  15420. */
  15421. private _highLimitsCache;
  15422. /**
  15423. * Specifies if the runtime animation has been stopped
  15424. */
  15425. private _stopped;
  15426. /**
  15427. * The blending factor of the runtime animation
  15428. */
  15429. private _blendingFactor;
  15430. /**
  15431. * The BabylonJS scene
  15432. */
  15433. private _scene;
  15434. /**
  15435. * The current value of the runtime animation
  15436. */
  15437. private _currentValue;
  15438. /** @hidden */
  15439. _animationState: _IAnimationState;
  15440. /**
  15441. * The active target of the runtime animation
  15442. */
  15443. private _activeTargets;
  15444. private _currentActiveTarget;
  15445. private _directTarget;
  15446. /**
  15447. * The target path of the runtime animation
  15448. */
  15449. private _targetPath;
  15450. /**
  15451. * The weight of the runtime animation
  15452. */
  15453. private _weight;
  15454. /**
  15455. * The ratio offset of the runtime animation
  15456. */
  15457. private _ratioOffset;
  15458. /**
  15459. * The previous delay of the runtime animation
  15460. */
  15461. private _previousDelay;
  15462. /**
  15463. * The previous ratio of the runtime animation
  15464. */
  15465. private _previousRatio;
  15466. private _enableBlending;
  15467. private _keys;
  15468. private _minFrame;
  15469. private _maxFrame;
  15470. private _minValue;
  15471. private _maxValue;
  15472. private _targetIsArray;
  15473. /**
  15474. * Gets the current frame of the runtime animation
  15475. */
  15476. get currentFrame(): number;
  15477. /**
  15478. * Gets the weight of the runtime animation
  15479. */
  15480. get weight(): number;
  15481. /**
  15482. * Gets the current value of the runtime animation
  15483. */
  15484. get currentValue(): any;
  15485. /**
  15486. * Gets the target path of the runtime animation
  15487. */
  15488. get targetPath(): string;
  15489. /**
  15490. * Gets the actual target of the runtime animation
  15491. */
  15492. get target(): any;
  15493. /**
  15494. * Gets the additive state of the runtime animation
  15495. */
  15496. get isAdditive(): boolean;
  15497. /** @hidden */
  15498. _onLoop: () => void;
  15499. /**
  15500. * Create a new RuntimeAnimation object
  15501. * @param target defines the target of the animation
  15502. * @param animation defines the source animation object
  15503. * @param scene defines the hosting scene
  15504. * @param host defines the initiating Animatable
  15505. */
  15506. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15507. private _preparePath;
  15508. /**
  15509. * Gets the animation from the runtime animation
  15510. */
  15511. get animation(): Animation;
  15512. /**
  15513. * Resets the runtime animation to the beginning
  15514. * @param restoreOriginal defines whether to restore the target property to the original value
  15515. */
  15516. reset(restoreOriginal?: boolean): void;
  15517. /**
  15518. * Specifies if the runtime animation is stopped
  15519. * @returns Boolean specifying if the runtime animation is stopped
  15520. */
  15521. isStopped(): boolean;
  15522. /**
  15523. * Disposes of the runtime animation
  15524. */
  15525. dispose(): void;
  15526. /**
  15527. * Apply the interpolated value to the target
  15528. * @param currentValue defines the value computed by the animation
  15529. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15530. */
  15531. setValue(currentValue: any, weight: number): void;
  15532. private _getOriginalValues;
  15533. private _setValue;
  15534. /**
  15535. * Gets the loop pmode of the runtime animation
  15536. * @returns Loop Mode
  15537. */
  15538. private _getCorrectLoopMode;
  15539. /**
  15540. * Move the current animation to a given frame
  15541. * @param frame defines the frame to move to
  15542. */
  15543. goToFrame(frame: number): void;
  15544. /**
  15545. * @hidden Internal use only
  15546. */
  15547. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15548. /**
  15549. * Execute the current animation
  15550. * @param delay defines the delay to add to the current frame
  15551. * @param from defines the lower bound of the animation range
  15552. * @param to defines the upper bound of the animation range
  15553. * @param loop defines if the current animation must loop
  15554. * @param speedRatio defines the current speed ratio
  15555. * @param weight defines the weight of the animation (default is -1 so no weight)
  15556. * @param onLoop optional callback called when animation loops
  15557. * @returns a boolean indicating if the animation is running
  15558. */
  15559. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15560. }
  15561. }
  15562. declare module BABYLON {
  15563. /**
  15564. * Class used to store an actual running animation
  15565. */
  15566. export class Animatable {
  15567. /** defines the target object */
  15568. target: any;
  15569. /** defines the starting frame number (default is 0) */
  15570. fromFrame: number;
  15571. /** defines the ending frame number (default is 100) */
  15572. toFrame: number;
  15573. /** defines if the animation must loop (default is false) */
  15574. loopAnimation: boolean;
  15575. /** defines a callback to call when animation ends if it is not looping */
  15576. onAnimationEnd?: (() => void) | null | undefined;
  15577. /** defines a callback to call when animation loops */
  15578. onAnimationLoop?: (() => void) | null | undefined;
  15579. /** defines whether the animation should be evaluated additively */
  15580. isAdditive: boolean;
  15581. private _localDelayOffset;
  15582. private _pausedDelay;
  15583. private _runtimeAnimations;
  15584. private _paused;
  15585. private _scene;
  15586. private _speedRatio;
  15587. private _weight;
  15588. private _syncRoot;
  15589. /**
  15590. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15591. * This will only apply for non looping animation (default is true)
  15592. */
  15593. disposeOnEnd: boolean;
  15594. /**
  15595. * Gets a boolean indicating if the animation has started
  15596. */
  15597. animationStarted: boolean;
  15598. /**
  15599. * Observer raised when the animation ends
  15600. */
  15601. onAnimationEndObservable: Observable<Animatable>;
  15602. /**
  15603. * Observer raised when the animation loops
  15604. */
  15605. onAnimationLoopObservable: Observable<Animatable>;
  15606. /**
  15607. * Gets the root Animatable used to synchronize and normalize animations
  15608. */
  15609. get syncRoot(): Nullable<Animatable>;
  15610. /**
  15611. * Gets the current frame of the first RuntimeAnimation
  15612. * Used to synchronize Animatables
  15613. */
  15614. get masterFrame(): number;
  15615. /**
  15616. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15617. */
  15618. get weight(): number;
  15619. set weight(value: number);
  15620. /**
  15621. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15622. */
  15623. get speedRatio(): number;
  15624. set speedRatio(value: number);
  15625. /**
  15626. * Creates a new Animatable
  15627. * @param scene defines the hosting scene
  15628. * @param target defines the target object
  15629. * @param fromFrame defines the starting frame number (default is 0)
  15630. * @param toFrame defines the ending frame number (default is 100)
  15631. * @param loopAnimation defines if the animation must loop (default is false)
  15632. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15633. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15634. * @param animations defines a group of animation to add to the new Animatable
  15635. * @param onAnimationLoop defines a callback to call when animation loops
  15636. * @param isAdditive defines whether the animation should be evaluated additively
  15637. */
  15638. constructor(scene: Scene,
  15639. /** defines the target object */
  15640. target: any,
  15641. /** defines the starting frame number (default is 0) */
  15642. fromFrame?: number,
  15643. /** defines the ending frame number (default is 100) */
  15644. toFrame?: number,
  15645. /** defines if the animation must loop (default is false) */
  15646. loopAnimation?: boolean, speedRatio?: number,
  15647. /** defines a callback to call when animation ends if it is not looping */
  15648. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15649. /** defines a callback to call when animation loops */
  15650. onAnimationLoop?: (() => void) | null | undefined,
  15651. /** defines whether the animation should be evaluated additively */
  15652. isAdditive?: boolean);
  15653. /**
  15654. * Synchronize and normalize current Animatable with a source Animatable
  15655. * This is useful when using animation weights and when animations are not of the same length
  15656. * @param root defines the root Animatable to synchronize with
  15657. * @returns the current Animatable
  15658. */
  15659. syncWith(root: Animatable): Animatable;
  15660. /**
  15661. * Gets the list of runtime animations
  15662. * @returns an array of RuntimeAnimation
  15663. */
  15664. getAnimations(): RuntimeAnimation[];
  15665. /**
  15666. * Adds more animations to the current animatable
  15667. * @param target defines the target of the animations
  15668. * @param animations defines the new animations to add
  15669. */
  15670. appendAnimations(target: any, animations: Animation[]): void;
  15671. /**
  15672. * Gets the source animation for a specific property
  15673. * @param property defines the propertyu to look for
  15674. * @returns null or the source animation for the given property
  15675. */
  15676. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15677. /**
  15678. * Gets the runtime animation for a specific property
  15679. * @param property defines the propertyu to look for
  15680. * @returns null or the runtime animation for the given property
  15681. */
  15682. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15683. /**
  15684. * Resets the animatable to its original state
  15685. */
  15686. reset(): void;
  15687. /**
  15688. * Allows the animatable to blend with current running animations
  15689. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15690. * @param blendingSpeed defines the blending speed to use
  15691. */
  15692. enableBlending(blendingSpeed: number): void;
  15693. /**
  15694. * Disable animation blending
  15695. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15696. */
  15697. disableBlending(): void;
  15698. /**
  15699. * Jump directly to a given frame
  15700. * @param frame defines the frame to jump to
  15701. */
  15702. goToFrame(frame: number): void;
  15703. /**
  15704. * Pause the animation
  15705. */
  15706. pause(): void;
  15707. /**
  15708. * Restart the animation
  15709. */
  15710. restart(): void;
  15711. private _raiseOnAnimationEnd;
  15712. /**
  15713. * Stop and delete the current animation
  15714. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15715. * @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)
  15716. */
  15717. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15718. /**
  15719. * Wait asynchronously for the animation to end
  15720. * @returns a promise which will be fullfilled when the animation ends
  15721. */
  15722. waitAsync(): Promise<Animatable>;
  15723. /** @hidden */
  15724. _animate(delay: number): boolean;
  15725. }
  15726. interface Scene {
  15727. /** @hidden */
  15728. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15729. /** @hidden */
  15730. _processLateAnimationBindingsForMatrices(holder: {
  15731. totalWeight: number;
  15732. totalAdditiveWeight: number;
  15733. animations: RuntimeAnimation[];
  15734. additiveAnimations: RuntimeAnimation[];
  15735. originalValue: Matrix;
  15736. }): any;
  15737. /** @hidden */
  15738. _processLateAnimationBindingsForQuaternions(holder: {
  15739. totalWeight: number;
  15740. totalAdditiveWeight: number;
  15741. animations: RuntimeAnimation[];
  15742. additiveAnimations: RuntimeAnimation[];
  15743. originalValue: Quaternion;
  15744. }, refQuaternion: Quaternion): Quaternion;
  15745. /** @hidden */
  15746. _processLateAnimationBindings(): void;
  15747. /**
  15748. * Will start the animation sequence of a given target
  15749. * @param target defines the target
  15750. * @param from defines from which frame should animation start
  15751. * @param to defines until which frame should animation run.
  15752. * @param weight defines the weight to apply to the animation (1.0 by default)
  15753. * @param loop defines if the animation loops
  15754. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15755. * @param onAnimationEnd defines the function to be executed when the animation ends
  15756. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15757. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15758. * @param onAnimationLoop defines the callback to call when an animation loops
  15759. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15760. * @returns the animatable object created for this animation
  15761. */
  15762. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15763. /**
  15764. * Will start the animation sequence of a given target
  15765. * @param target defines the target
  15766. * @param from defines from which frame should animation start
  15767. * @param to defines until which frame should animation run.
  15768. * @param loop defines if the animation loops
  15769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15770. * @param onAnimationEnd defines the function to be executed when the animation ends
  15771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15772. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15773. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15774. * @param onAnimationLoop defines the callback to call when an animation loops
  15775. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15776. * @returns the animatable object created for this animation
  15777. */
  15778. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15779. /**
  15780. * Will start the animation sequence of a given target and its hierarchy
  15781. * @param target defines the target
  15782. * @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.
  15783. * @param from defines from which frame should animation start
  15784. * @param to defines until which frame should animation run.
  15785. * @param loop defines if the animation loops
  15786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15787. * @param onAnimationEnd defines the function to be executed when the animation ends
  15788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15791. * @param onAnimationLoop defines the callback to call when an animation loops
  15792. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15793. * @returns the list of created animatables
  15794. */
  15795. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15796. /**
  15797. * Begin a new animation on a given node
  15798. * @param target defines the target where the animation will take place
  15799. * @param animations defines the list of animations to start
  15800. * @param from defines the initial value
  15801. * @param to defines the final value
  15802. * @param loop defines if you want animation to loop (off by default)
  15803. * @param speedRatio defines the speed ratio to apply to all animations
  15804. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15805. * @param onAnimationLoop defines the callback to call when an animation loops
  15806. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15807. * @returns the list of created animatables
  15808. */
  15809. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15810. /**
  15811. * Begin a new animation on a given node and its hierarchy
  15812. * @param target defines the root node where the animation will take place
  15813. * @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.
  15814. * @param animations defines the list of animations to start
  15815. * @param from defines the initial value
  15816. * @param to defines the final value
  15817. * @param loop defines if you want animation to loop (off by default)
  15818. * @param speedRatio defines the speed ratio to apply to all animations
  15819. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15820. * @param onAnimationLoop defines the callback to call when an animation loops
  15821. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15822. * @returns the list of animatables created for all nodes
  15823. */
  15824. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15825. /**
  15826. * Gets the animatable associated with a specific target
  15827. * @param target defines the target of the animatable
  15828. * @returns the required animatable if found
  15829. */
  15830. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15831. /**
  15832. * Gets all animatables associated with a given target
  15833. * @param target defines the target to look animatables for
  15834. * @returns an array of Animatables
  15835. */
  15836. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15837. /**
  15838. * Stops and removes all animations that have been applied to the scene
  15839. */
  15840. stopAllAnimations(): void;
  15841. /**
  15842. * Gets the current delta time used by animation engine
  15843. */
  15844. deltaTime: number;
  15845. }
  15846. interface Bone {
  15847. /**
  15848. * Copy an animation range from another bone
  15849. * @param source defines the source bone
  15850. * @param rangeName defines the range name to copy
  15851. * @param frameOffset defines the frame offset
  15852. * @param rescaleAsRequired defines if rescaling must be applied if required
  15853. * @param skelDimensionsRatio defines the scaling ratio
  15854. * @returns true if operation was successful
  15855. */
  15856. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15857. }
  15858. }
  15859. declare module BABYLON {
  15860. /**
  15861. * Class used to handle skinning animations
  15862. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15863. */
  15864. export class Skeleton implements IAnimatable {
  15865. /** defines the skeleton name */
  15866. name: string;
  15867. /** defines the skeleton Id */
  15868. id: string;
  15869. /**
  15870. * Defines the list of child bones
  15871. */
  15872. bones: Bone[];
  15873. /**
  15874. * Defines an estimate of the dimension of the skeleton at rest
  15875. */
  15876. dimensionsAtRest: Vector3;
  15877. /**
  15878. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15879. */
  15880. needInitialSkinMatrix: boolean;
  15881. /**
  15882. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15883. */
  15884. overrideMesh: Nullable<AbstractMesh>;
  15885. /**
  15886. * Gets the list of animations attached to this skeleton
  15887. */
  15888. animations: Array<Animation>;
  15889. private _scene;
  15890. private _isDirty;
  15891. private _transformMatrices;
  15892. private _transformMatrixTexture;
  15893. private _meshesWithPoseMatrix;
  15894. private _animatables;
  15895. private _identity;
  15896. private _synchronizedWithMesh;
  15897. private _ranges;
  15898. private _lastAbsoluteTransformsUpdateId;
  15899. private _canUseTextureForBones;
  15900. private _uniqueId;
  15901. /** @hidden */
  15902. _numBonesWithLinkedTransformNode: number;
  15903. /** @hidden */
  15904. _hasWaitingData: Nullable<boolean>;
  15905. /**
  15906. * Specifies if the skeleton should be serialized
  15907. */
  15908. doNotSerialize: boolean;
  15909. private _useTextureToStoreBoneMatrices;
  15910. /**
  15911. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15912. * Please note that this option is not available if the hardware does not support it
  15913. */
  15914. get useTextureToStoreBoneMatrices(): boolean;
  15915. set useTextureToStoreBoneMatrices(value: boolean);
  15916. private _animationPropertiesOverride;
  15917. /**
  15918. * Gets or sets the animation properties override
  15919. */
  15920. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15921. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15922. /**
  15923. * List of inspectable custom properties (used by the Inspector)
  15924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15925. */
  15926. inspectableCustomProperties: IInspectable[];
  15927. /**
  15928. * An observable triggered before computing the skeleton's matrices
  15929. */
  15930. onBeforeComputeObservable: Observable<Skeleton>;
  15931. /**
  15932. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15933. */
  15934. get isUsingTextureForMatrices(): boolean;
  15935. /**
  15936. * Gets the unique ID of this skeleton
  15937. */
  15938. get uniqueId(): number;
  15939. /**
  15940. * Creates a new skeleton
  15941. * @param name defines the skeleton name
  15942. * @param id defines the skeleton Id
  15943. * @param scene defines the hosting scene
  15944. */
  15945. constructor(
  15946. /** defines the skeleton name */
  15947. name: string,
  15948. /** defines the skeleton Id */
  15949. id: string, scene: Scene);
  15950. /**
  15951. * Gets the current object class name.
  15952. * @return the class name
  15953. */
  15954. getClassName(): string;
  15955. /**
  15956. * Returns an array containing the root bones
  15957. * @returns an array containing the root bones
  15958. */
  15959. getChildren(): Array<Bone>;
  15960. /**
  15961. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15962. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15963. * @returns a Float32Array containing matrices data
  15964. */
  15965. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15966. /**
  15967. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15968. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15969. * @returns a raw texture containing the data
  15970. */
  15971. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15972. /**
  15973. * Gets the current hosting scene
  15974. * @returns a scene object
  15975. */
  15976. getScene(): Scene;
  15977. /**
  15978. * Gets a string representing the current skeleton data
  15979. * @param fullDetails defines a boolean indicating if we want a verbose version
  15980. * @returns a string representing the current skeleton data
  15981. */
  15982. toString(fullDetails?: boolean): string;
  15983. /**
  15984. * Get bone's index searching by name
  15985. * @param name defines bone's name to search for
  15986. * @return the indice of the bone. Returns -1 if not found
  15987. */
  15988. getBoneIndexByName(name: string): number;
  15989. /**
  15990. * Creater a new animation range
  15991. * @param name defines the name of the range
  15992. * @param from defines the start key
  15993. * @param to defines the end key
  15994. */
  15995. createAnimationRange(name: string, from: number, to: number): void;
  15996. /**
  15997. * Delete a specific animation range
  15998. * @param name defines the name of the range
  15999. * @param deleteFrames defines if frames must be removed as well
  16000. */
  16001. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16002. /**
  16003. * Gets a specific animation range
  16004. * @param name defines the name of the range to look for
  16005. * @returns the requested animation range or null if not found
  16006. */
  16007. getAnimationRange(name: string): Nullable<AnimationRange>;
  16008. /**
  16009. * Gets the list of all animation ranges defined on this skeleton
  16010. * @returns an array
  16011. */
  16012. getAnimationRanges(): Nullable<AnimationRange>[];
  16013. /**
  16014. * Copy animation range from a source skeleton.
  16015. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16016. * @param source defines the source skeleton
  16017. * @param name defines the name of the range to copy
  16018. * @param rescaleAsRequired defines if rescaling must be applied if required
  16019. * @returns true if operation was successful
  16020. */
  16021. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16022. /**
  16023. * Forces the skeleton to go to rest pose
  16024. */
  16025. returnToRest(): void;
  16026. private _getHighestAnimationFrame;
  16027. /**
  16028. * Begin a specific animation range
  16029. * @param name defines the name of the range to start
  16030. * @param loop defines if looping must be turned on (false by default)
  16031. * @param speedRatio defines the speed ratio to apply (1 by default)
  16032. * @param onAnimationEnd defines a callback which will be called when animation will end
  16033. * @returns a new animatable
  16034. */
  16035. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16036. /**
  16037. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16038. * @param skeleton defines the Skeleton containing the animation range to convert
  16039. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16040. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16041. * @returns the original skeleton
  16042. */
  16043. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16044. /** @hidden */
  16045. _markAsDirty(): void;
  16046. /** @hidden */
  16047. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16048. /** @hidden */
  16049. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16050. private _computeTransformMatrices;
  16051. /**
  16052. * Build all resources required to render a skeleton
  16053. */
  16054. prepare(): void;
  16055. /**
  16056. * Gets the list of animatables currently running for this skeleton
  16057. * @returns an array of animatables
  16058. */
  16059. getAnimatables(): IAnimatable[];
  16060. /**
  16061. * Clone the current skeleton
  16062. * @param name defines the name of the new skeleton
  16063. * @param id defines the id of the new skeleton
  16064. * @returns the new skeleton
  16065. */
  16066. clone(name: string, id?: string): Skeleton;
  16067. /**
  16068. * Enable animation blending for this skeleton
  16069. * @param blendingSpeed defines the blending speed to apply
  16070. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16071. */
  16072. enableBlending(blendingSpeed?: number): void;
  16073. /**
  16074. * Releases all resources associated with the current skeleton
  16075. */
  16076. dispose(): void;
  16077. /**
  16078. * Serialize the skeleton in a JSON object
  16079. * @returns a JSON object
  16080. */
  16081. serialize(): any;
  16082. /**
  16083. * Creates a new skeleton from serialized data
  16084. * @param parsedSkeleton defines the serialized data
  16085. * @param scene defines the hosting scene
  16086. * @returns a new skeleton
  16087. */
  16088. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16089. /**
  16090. * Compute all node absolute transforms
  16091. * @param forceUpdate defines if computation must be done even if cache is up to date
  16092. */
  16093. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16094. /**
  16095. * Gets the root pose matrix
  16096. * @returns a matrix
  16097. */
  16098. getPoseMatrix(): Nullable<Matrix>;
  16099. /**
  16100. * Sorts bones per internal index
  16101. */
  16102. sortBones(): void;
  16103. private _sortBones;
  16104. }
  16105. }
  16106. declare module BABYLON {
  16107. /**
  16108. * Creates an instance based on a source mesh.
  16109. */
  16110. export class InstancedMesh extends AbstractMesh {
  16111. private _sourceMesh;
  16112. private _currentLOD;
  16113. /** @hidden */
  16114. _indexInSourceMeshInstanceArray: number;
  16115. constructor(name: string, source: Mesh);
  16116. /**
  16117. * Returns the string "InstancedMesh".
  16118. */
  16119. getClassName(): string;
  16120. /** Gets the list of lights affecting that mesh */
  16121. get lightSources(): Light[];
  16122. _resyncLightSources(): void;
  16123. _resyncLightSource(light: Light): void;
  16124. _removeLightSource(light: Light, dispose: boolean): void;
  16125. /**
  16126. * If the source mesh receives shadows
  16127. */
  16128. get receiveShadows(): boolean;
  16129. /**
  16130. * The material of the source mesh
  16131. */
  16132. get material(): Nullable<Material>;
  16133. /**
  16134. * Visibility of the source mesh
  16135. */
  16136. get visibility(): number;
  16137. /**
  16138. * Skeleton of the source mesh
  16139. */
  16140. get skeleton(): Nullable<Skeleton>;
  16141. /**
  16142. * Rendering ground id of the source mesh
  16143. */
  16144. get renderingGroupId(): number;
  16145. set renderingGroupId(value: number);
  16146. /**
  16147. * Returns the total number of vertices (integer).
  16148. */
  16149. getTotalVertices(): number;
  16150. /**
  16151. * Returns a positive integer : the total number of indices in this mesh geometry.
  16152. * @returns the numner of indices or zero if the mesh has no geometry.
  16153. */
  16154. getTotalIndices(): number;
  16155. /**
  16156. * The source mesh of the instance
  16157. */
  16158. get sourceMesh(): Mesh;
  16159. /**
  16160. * Creates a new InstancedMesh object from the mesh model.
  16161. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16162. * @param name defines the name of the new instance
  16163. * @returns a new InstancedMesh
  16164. */
  16165. createInstance(name: string): InstancedMesh;
  16166. /**
  16167. * Is this node ready to be used/rendered
  16168. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16169. * @return {boolean} is it ready
  16170. */
  16171. isReady(completeCheck?: boolean): boolean;
  16172. /**
  16173. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16174. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16175. * @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.
  16176. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16177. */
  16178. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16179. /**
  16180. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16181. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16182. * The `data` are either a numeric array either a Float32Array.
  16183. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16184. * 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).
  16185. * Note that a new underlying VertexBuffer object is created each call.
  16186. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16187. *
  16188. * Possible `kind` values :
  16189. * - VertexBuffer.PositionKind
  16190. * - VertexBuffer.UVKind
  16191. * - VertexBuffer.UV2Kind
  16192. * - VertexBuffer.UV3Kind
  16193. * - VertexBuffer.UV4Kind
  16194. * - VertexBuffer.UV5Kind
  16195. * - VertexBuffer.UV6Kind
  16196. * - VertexBuffer.ColorKind
  16197. * - VertexBuffer.MatricesIndicesKind
  16198. * - VertexBuffer.MatricesIndicesExtraKind
  16199. * - VertexBuffer.MatricesWeightsKind
  16200. * - VertexBuffer.MatricesWeightsExtraKind
  16201. *
  16202. * Returns the Mesh.
  16203. */
  16204. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16205. /**
  16206. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16207. * If the mesh has no geometry, it is simply returned as it is.
  16208. * The `data` are either a numeric array either a Float32Array.
  16209. * No new underlying VertexBuffer object is created.
  16210. * 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.
  16211. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16212. *
  16213. * Possible `kind` values :
  16214. * - VertexBuffer.PositionKind
  16215. * - VertexBuffer.UVKind
  16216. * - VertexBuffer.UV2Kind
  16217. * - VertexBuffer.UV3Kind
  16218. * - VertexBuffer.UV4Kind
  16219. * - VertexBuffer.UV5Kind
  16220. * - VertexBuffer.UV6Kind
  16221. * - VertexBuffer.ColorKind
  16222. * - VertexBuffer.MatricesIndicesKind
  16223. * - VertexBuffer.MatricesIndicesExtraKind
  16224. * - VertexBuffer.MatricesWeightsKind
  16225. * - VertexBuffer.MatricesWeightsExtraKind
  16226. *
  16227. * Returns the Mesh.
  16228. */
  16229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16230. /**
  16231. * Sets the mesh indices.
  16232. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16233. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16234. * This method creates a new index buffer each call.
  16235. * Returns the Mesh.
  16236. */
  16237. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16238. /**
  16239. * Boolean : True if the mesh owns the requested kind of data.
  16240. */
  16241. isVerticesDataPresent(kind: string): boolean;
  16242. /**
  16243. * Returns an array of indices (IndicesArray).
  16244. */
  16245. getIndices(): Nullable<IndicesArray>;
  16246. get _positions(): Nullable<Vector3[]>;
  16247. /**
  16248. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16249. * This means the mesh underlying bounding box and sphere are recomputed.
  16250. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16251. * @returns the current mesh
  16252. */
  16253. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16254. /** @hidden */
  16255. _preActivate(): InstancedMesh;
  16256. /** @hidden */
  16257. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16258. /** @hidden */
  16259. _postActivate(): void;
  16260. getWorldMatrix(): Matrix;
  16261. get isAnInstance(): boolean;
  16262. /**
  16263. * Returns the current associated LOD AbstractMesh.
  16264. */
  16265. getLOD(camera: Camera): AbstractMesh;
  16266. /** @hidden */
  16267. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16268. /** @hidden */
  16269. _syncSubMeshes(): InstancedMesh;
  16270. /** @hidden */
  16271. _generatePointsArray(): boolean;
  16272. /**
  16273. * Creates a new InstancedMesh from the current mesh.
  16274. * - name (string) : the cloned mesh name
  16275. * - newParent (optional Node) : the optional Node to parent the clone to.
  16276. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16277. *
  16278. * Returns the clone.
  16279. */
  16280. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16281. /**
  16282. * Disposes the InstancedMesh.
  16283. * Returns nothing.
  16284. */
  16285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16286. }
  16287. interface Mesh {
  16288. /**
  16289. * Register a custom buffer that will be instanced
  16290. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16291. * @param kind defines the buffer kind
  16292. * @param stride defines the stride in floats
  16293. */
  16294. registerInstancedBuffer(kind: string, stride: number): void;
  16295. /** @hidden */
  16296. _userInstancedBuffersStorage: {
  16297. data: {
  16298. [key: string]: Float32Array;
  16299. };
  16300. sizes: {
  16301. [key: string]: number;
  16302. };
  16303. vertexBuffers: {
  16304. [key: string]: Nullable<VertexBuffer>;
  16305. };
  16306. strides: {
  16307. [key: string]: number;
  16308. };
  16309. };
  16310. }
  16311. interface AbstractMesh {
  16312. /**
  16313. * Object used to store instanced buffers defined by user
  16314. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16315. */
  16316. instancedBuffers: {
  16317. [key: string]: any;
  16318. };
  16319. }
  16320. }
  16321. declare module BABYLON {
  16322. /**
  16323. * Defines the options associated with the creation of a shader material.
  16324. */
  16325. export interface IShaderMaterialOptions {
  16326. /**
  16327. * Does the material work in alpha blend mode
  16328. */
  16329. needAlphaBlending: boolean;
  16330. /**
  16331. * Does the material work in alpha test mode
  16332. */
  16333. needAlphaTesting: boolean;
  16334. /**
  16335. * The list of attribute names used in the shader
  16336. */
  16337. attributes: string[];
  16338. /**
  16339. * The list of unifrom names used in the shader
  16340. */
  16341. uniforms: string[];
  16342. /**
  16343. * The list of UBO names used in the shader
  16344. */
  16345. uniformBuffers: string[];
  16346. /**
  16347. * The list of sampler names used in the shader
  16348. */
  16349. samplers: string[];
  16350. /**
  16351. * The list of defines used in the shader
  16352. */
  16353. defines: string[];
  16354. }
  16355. /**
  16356. * 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.
  16357. *
  16358. * This returned material effects how the mesh will look based on the code in the shaders.
  16359. *
  16360. * @see http://doc.babylonjs.com/how_to/shader_material
  16361. */
  16362. export class ShaderMaterial extends Material {
  16363. private _shaderPath;
  16364. private _options;
  16365. private _textures;
  16366. private _textureArrays;
  16367. private _floats;
  16368. private _ints;
  16369. private _floatsArrays;
  16370. private _colors3;
  16371. private _colors3Arrays;
  16372. private _colors4;
  16373. private _colors4Arrays;
  16374. private _vectors2;
  16375. private _vectors3;
  16376. private _vectors4;
  16377. private _matrices;
  16378. private _matrixArrays;
  16379. private _matrices3x3;
  16380. private _matrices2x2;
  16381. private _vectors2Arrays;
  16382. private _vectors3Arrays;
  16383. private _vectors4Arrays;
  16384. private _cachedWorldViewMatrix;
  16385. private _cachedWorldViewProjectionMatrix;
  16386. private _renderId;
  16387. private _multiview;
  16388. private _cachedDefines;
  16389. /**
  16390. * Instantiate a new shader material.
  16391. * 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.
  16392. * This returned material effects how the mesh will look based on the code in the shaders.
  16393. * @see http://doc.babylonjs.com/how_to/shader_material
  16394. * @param name Define the name of the material in the scene
  16395. * @param scene Define the scene the material belongs to
  16396. * @param shaderPath Defines the route to the shader code in one of three ways:
  16397. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16398. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16399. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16400. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16401. * @param options Define the options used to create the shader
  16402. */
  16403. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16404. /**
  16405. * Gets the shader path used to define the shader code
  16406. * It can be modified to trigger a new compilation
  16407. */
  16408. get shaderPath(): any;
  16409. /**
  16410. * Sets the shader path used to define the shader code
  16411. * It can be modified to trigger a new compilation
  16412. */
  16413. set shaderPath(shaderPath: any);
  16414. /**
  16415. * Gets the options used to compile the shader.
  16416. * They can be modified to trigger a new compilation
  16417. */
  16418. get options(): IShaderMaterialOptions;
  16419. /**
  16420. * Gets the current class name of the material e.g. "ShaderMaterial"
  16421. * Mainly use in serialization.
  16422. * @returns the class name
  16423. */
  16424. getClassName(): string;
  16425. /**
  16426. * Specifies if the material will require alpha blending
  16427. * @returns a boolean specifying if alpha blending is needed
  16428. */
  16429. needAlphaBlending(): boolean;
  16430. /**
  16431. * Specifies if this material should be rendered in alpha test mode
  16432. * @returns a boolean specifying if an alpha test is needed.
  16433. */
  16434. needAlphaTesting(): boolean;
  16435. private _checkUniform;
  16436. /**
  16437. * Set a texture in the shader.
  16438. * @param name Define the name of the uniform samplers as defined in the shader
  16439. * @param texture Define the texture to bind to this sampler
  16440. * @return the material itself allowing "fluent" like uniform updates
  16441. */
  16442. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16443. /**
  16444. * Set a texture array in the shader.
  16445. * @param name Define the name of the uniform sampler array as defined in the shader
  16446. * @param textures Define the list of textures to bind to this sampler
  16447. * @return the material itself allowing "fluent" like uniform updates
  16448. */
  16449. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16450. /**
  16451. * Set a float in the shader.
  16452. * @param name Define the name of the uniform as defined in the shader
  16453. * @param value Define the value to give to the uniform
  16454. * @return the material itself allowing "fluent" like uniform updates
  16455. */
  16456. setFloat(name: string, value: number): ShaderMaterial;
  16457. /**
  16458. * Set a int in the shader.
  16459. * @param name Define the name of the uniform as defined in the shader
  16460. * @param value Define the value to give to the uniform
  16461. * @return the material itself allowing "fluent" like uniform updates
  16462. */
  16463. setInt(name: string, value: number): ShaderMaterial;
  16464. /**
  16465. * Set an array of floats in the shader.
  16466. * @param name Define the name of the uniform as defined in the shader
  16467. * @param value Define the value to give to the uniform
  16468. * @return the material itself allowing "fluent" like uniform updates
  16469. */
  16470. setFloats(name: string, value: number[]): ShaderMaterial;
  16471. /**
  16472. * Set a vec3 in the shader from a Color3.
  16473. * @param name Define the name of the uniform as defined in the shader
  16474. * @param value Define the value to give to the uniform
  16475. * @return the material itself allowing "fluent" like uniform updates
  16476. */
  16477. setColor3(name: string, value: Color3): ShaderMaterial;
  16478. /**
  16479. * Set a vec3 array in the shader from a Color3 array.
  16480. * @param name Define the name of the uniform as defined in the shader
  16481. * @param value Define the value to give to the uniform
  16482. * @return the material itself allowing "fluent" like uniform updates
  16483. */
  16484. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16485. /**
  16486. * Set a vec4 in the shader from a Color4.
  16487. * @param name Define the name of the uniform as defined in the shader
  16488. * @param value Define the value to give to the uniform
  16489. * @return the material itself allowing "fluent" like uniform updates
  16490. */
  16491. setColor4(name: string, value: Color4): ShaderMaterial;
  16492. /**
  16493. * Set a vec4 array in the shader from a Color4 array.
  16494. * @param name Define the name of the uniform as defined in the shader
  16495. * @param value Define the value to give to the uniform
  16496. * @return the material itself allowing "fluent" like uniform updates
  16497. */
  16498. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16499. /**
  16500. * Set a vec2 in the shader from a Vector2.
  16501. * @param name Define the name of the uniform as defined in the shader
  16502. * @param value Define the value to give to the uniform
  16503. * @return the material itself allowing "fluent" like uniform updates
  16504. */
  16505. setVector2(name: string, value: Vector2): ShaderMaterial;
  16506. /**
  16507. * Set a vec3 in the shader from a Vector3.
  16508. * @param name Define the name of the uniform as defined in the shader
  16509. * @param value Define the value to give to the uniform
  16510. * @return the material itself allowing "fluent" like uniform updates
  16511. */
  16512. setVector3(name: string, value: Vector3): ShaderMaterial;
  16513. /**
  16514. * Set a vec4 in the shader from a Vector4.
  16515. * @param name Define the name of the uniform as defined in the shader
  16516. * @param value Define the value to give to the uniform
  16517. * @return the material itself allowing "fluent" like uniform updates
  16518. */
  16519. setVector4(name: string, value: Vector4): ShaderMaterial;
  16520. /**
  16521. * Set a mat4 in the shader from a Matrix.
  16522. * @param name Define the name of the uniform as defined in the shader
  16523. * @param value Define the value to give to the uniform
  16524. * @return the material itself allowing "fluent" like uniform updates
  16525. */
  16526. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16527. /**
  16528. * Set a float32Array in the shader from a matrix array.
  16529. * @param name Define the name of the uniform as defined in the shader
  16530. * @param value Define the value to give to the uniform
  16531. * @return the material itself allowing "fluent" like uniform updates
  16532. */
  16533. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16534. /**
  16535. * Set a mat3 in the shader from a Float32Array.
  16536. * @param name Define the name of the uniform as defined in the shader
  16537. * @param value Define the value to give to the uniform
  16538. * @return the material itself allowing "fluent" like uniform updates
  16539. */
  16540. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16541. /**
  16542. * Set a mat2 in the shader from a Float32Array.
  16543. * @param name Define the name of the uniform as defined in the shader
  16544. * @param value Define the value to give to the uniform
  16545. * @return the material itself allowing "fluent" like uniform updates
  16546. */
  16547. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16548. /**
  16549. * Set a vec2 array in the shader from a number array.
  16550. * @param name Define the name of the uniform as defined in the shader
  16551. * @param value Define the value to give to the uniform
  16552. * @return the material itself allowing "fluent" like uniform updates
  16553. */
  16554. setArray2(name: string, value: number[]): ShaderMaterial;
  16555. /**
  16556. * Set a vec3 array in the shader from a number array.
  16557. * @param name Define the name of the uniform as defined in the shader
  16558. * @param value Define the value to give to the uniform
  16559. * @return the material itself allowing "fluent" like uniform updates
  16560. */
  16561. setArray3(name: string, value: number[]): ShaderMaterial;
  16562. /**
  16563. * Set a vec4 array in the shader from a number array.
  16564. * @param name Define the name of the uniform as defined in the shader
  16565. * @param value Define the value to give to the uniform
  16566. * @return the material itself allowing "fluent" like uniform updates
  16567. */
  16568. setArray4(name: string, value: number[]): ShaderMaterial;
  16569. private _checkCache;
  16570. /**
  16571. * Specifies that the submesh is ready to be used
  16572. * @param mesh defines the mesh to check
  16573. * @param subMesh defines which submesh to check
  16574. * @param useInstances specifies that instances should be used
  16575. * @returns a boolean indicating that the submesh is ready or not
  16576. */
  16577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16578. /**
  16579. * Checks if the material is ready to render the requested mesh
  16580. * @param mesh Define the mesh to render
  16581. * @param useInstances Define whether or not the material is used with instances
  16582. * @returns true if ready, otherwise false
  16583. */
  16584. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16585. /**
  16586. * Binds the world matrix to the material
  16587. * @param world defines the world transformation matrix
  16588. * @param effectOverride - If provided, use this effect instead of internal effect
  16589. */
  16590. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16591. /**
  16592. * Binds the submesh to this material by preparing the effect and shader to draw
  16593. * @param world defines the world transformation matrix
  16594. * @param mesh defines the mesh containing the submesh
  16595. * @param subMesh defines the submesh to bind the material to
  16596. */
  16597. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16598. /**
  16599. * Binds the material to the mesh
  16600. * @param world defines the world transformation matrix
  16601. * @param mesh defines the mesh to bind the material to
  16602. * @param effectOverride - If provided, use this effect instead of internal effect
  16603. */
  16604. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16605. protected _afterBind(mesh?: Mesh): void;
  16606. /**
  16607. * Gets the active textures from the material
  16608. * @returns an array of textures
  16609. */
  16610. getActiveTextures(): BaseTexture[];
  16611. /**
  16612. * Specifies if the material uses a texture
  16613. * @param texture defines the texture to check against the material
  16614. * @returns a boolean specifying if the material uses the texture
  16615. */
  16616. hasTexture(texture: BaseTexture): boolean;
  16617. /**
  16618. * Makes a duplicate of the material, and gives it a new name
  16619. * @param name defines the new name for the duplicated material
  16620. * @returns the cloned material
  16621. */
  16622. clone(name: string): ShaderMaterial;
  16623. /**
  16624. * Disposes the material
  16625. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16626. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16627. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16628. */
  16629. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16630. /**
  16631. * Serializes this material in a JSON representation
  16632. * @returns the serialized material object
  16633. */
  16634. serialize(): any;
  16635. /**
  16636. * Creates a shader material from parsed shader material data
  16637. * @param source defines the JSON represnetation of the material
  16638. * @param scene defines the hosting scene
  16639. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16640. * @returns a new material
  16641. */
  16642. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16643. }
  16644. }
  16645. declare module BABYLON {
  16646. /** @hidden */
  16647. export var colorPixelShader: {
  16648. name: string;
  16649. shader: string;
  16650. };
  16651. }
  16652. declare module BABYLON {
  16653. /** @hidden */
  16654. export var colorVertexShader: {
  16655. name: string;
  16656. shader: string;
  16657. };
  16658. }
  16659. declare module BABYLON {
  16660. /**
  16661. * Line mesh
  16662. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16663. */
  16664. export class LinesMesh extends Mesh {
  16665. /**
  16666. * If vertex color should be applied to the mesh
  16667. */
  16668. readonly useVertexColor?: boolean | undefined;
  16669. /**
  16670. * If vertex alpha should be applied to the mesh
  16671. */
  16672. readonly useVertexAlpha?: boolean | undefined;
  16673. /**
  16674. * Color of the line (Default: White)
  16675. */
  16676. color: Color3;
  16677. /**
  16678. * Alpha of the line (Default: 1)
  16679. */
  16680. alpha: number;
  16681. /**
  16682. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16683. * This margin is expressed in world space coordinates, so its value may vary.
  16684. * Default value is 0.1
  16685. */
  16686. intersectionThreshold: number;
  16687. private _colorShader;
  16688. private color4;
  16689. /**
  16690. * Creates a new LinesMesh
  16691. * @param name defines the name
  16692. * @param scene defines the hosting scene
  16693. * @param parent defines the parent mesh if any
  16694. * @param source defines the optional source LinesMesh used to clone data from
  16695. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16696. * When false, achieved by calling a clone(), also passing False.
  16697. * This will make creation of children, recursive.
  16698. * @param useVertexColor defines if this LinesMesh supports vertex color
  16699. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16700. */
  16701. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16702. /**
  16703. * If vertex color should be applied to the mesh
  16704. */
  16705. useVertexColor?: boolean | undefined,
  16706. /**
  16707. * If vertex alpha should be applied to the mesh
  16708. */
  16709. useVertexAlpha?: boolean | undefined);
  16710. private _addClipPlaneDefine;
  16711. private _removeClipPlaneDefine;
  16712. isReady(): boolean;
  16713. /**
  16714. * Returns the string "LineMesh"
  16715. */
  16716. getClassName(): string;
  16717. /**
  16718. * @hidden
  16719. */
  16720. get material(): Material;
  16721. /**
  16722. * @hidden
  16723. */
  16724. set material(value: Material);
  16725. /**
  16726. * @hidden
  16727. */
  16728. get checkCollisions(): boolean;
  16729. /** @hidden */
  16730. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16731. /** @hidden */
  16732. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16733. /**
  16734. * Disposes of the line mesh
  16735. * @param doNotRecurse If children should be disposed
  16736. */
  16737. dispose(doNotRecurse?: boolean): void;
  16738. /**
  16739. * Returns a new LineMesh object cloned from the current one.
  16740. */
  16741. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16742. /**
  16743. * Creates a new InstancedLinesMesh object from the mesh model.
  16744. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16745. * @param name defines the name of the new instance
  16746. * @returns a new InstancedLinesMesh
  16747. */
  16748. createInstance(name: string): InstancedLinesMesh;
  16749. }
  16750. /**
  16751. * Creates an instance based on a source LinesMesh
  16752. */
  16753. export class InstancedLinesMesh extends InstancedMesh {
  16754. /**
  16755. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16756. * This margin is expressed in world space coordinates, so its value may vary.
  16757. * Initilized with the intersectionThreshold value of the source LinesMesh
  16758. */
  16759. intersectionThreshold: number;
  16760. constructor(name: string, source: LinesMesh);
  16761. /**
  16762. * Returns the string "InstancedLinesMesh".
  16763. */
  16764. getClassName(): string;
  16765. }
  16766. }
  16767. declare module BABYLON {
  16768. /** @hidden */
  16769. export var linePixelShader: {
  16770. name: string;
  16771. shader: string;
  16772. };
  16773. }
  16774. declare module BABYLON {
  16775. /** @hidden */
  16776. export var lineVertexShader: {
  16777. name: string;
  16778. shader: string;
  16779. };
  16780. }
  16781. declare module BABYLON {
  16782. interface AbstractMesh {
  16783. /**
  16784. * Gets the edgesRenderer associated with the mesh
  16785. */
  16786. edgesRenderer: Nullable<EdgesRenderer>;
  16787. }
  16788. interface LinesMesh {
  16789. /**
  16790. * Enables the edge rendering mode on the mesh.
  16791. * This mode makes the mesh edges visible
  16792. * @param epsilon defines the maximal distance between two angles to detect a face
  16793. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16794. * @returns the currentAbstractMesh
  16795. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16796. */
  16797. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16798. }
  16799. interface InstancedLinesMesh {
  16800. /**
  16801. * Enables the edge rendering mode on the mesh.
  16802. * This mode makes the mesh edges visible
  16803. * @param epsilon defines the maximal distance between two angles to detect a face
  16804. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16805. * @returns the current InstancedLinesMesh
  16806. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16807. */
  16808. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16809. }
  16810. /**
  16811. * Defines the minimum contract an Edges renderer should follow.
  16812. */
  16813. export interface IEdgesRenderer extends IDisposable {
  16814. /**
  16815. * Gets or sets a boolean indicating if the edgesRenderer is active
  16816. */
  16817. isEnabled: boolean;
  16818. /**
  16819. * Renders the edges of the attached mesh,
  16820. */
  16821. render(): void;
  16822. /**
  16823. * Checks wether or not the edges renderer is ready to render.
  16824. * @return true if ready, otherwise false.
  16825. */
  16826. isReady(): boolean;
  16827. }
  16828. /**
  16829. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16830. */
  16831. export class EdgesRenderer implements IEdgesRenderer {
  16832. /**
  16833. * Define the size of the edges with an orthographic camera
  16834. */
  16835. edgesWidthScalerForOrthographic: number;
  16836. /**
  16837. * Define the size of the edges with a perspective camera
  16838. */
  16839. edgesWidthScalerForPerspective: number;
  16840. protected _source: AbstractMesh;
  16841. protected _linesPositions: number[];
  16842. protected _linesNormals: number[];
  16843. protected _linesIndices: number[];
  16844. protected _epsilon: number;
  16845. protected _indicesCount: number;
  16846. protected _lineShader: ShaderMaterial;
  16847. protected _ib: DataBuffer;
  16848. protected _buffers: {
  16849. [key: string]: Nullable<VertexBuffer>;
  16850. };
  16851. protected _checkVerticesInsteadOfIndices: boolean;
  16852. private _meshRebuildObserver;
  16853. private _meshDisposeObserver;
  16854. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16855. isEnabled: boolean;
  16856. /**
  16857. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16858. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16859. * @param source Mesh used to create edges
  16860. * @param epsilon sum of angles in adjacency to check for edge
  16861. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16862. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16863. */
  16864. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16865. protected _prepareRessources(): void;
  16866. /** @hidden */
  16867. _rebuild(): void;
  16868. /**
  16869. * Releases the required resources for the edges renderer
  16870. */
  16871. dispose(): void;
  16872. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16873. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16874. /**
  16875. * Checks if the pair of p0 and p1 is en edge
  16876. * @param faceIndex
  16877. * @param edge
  16878. * @param faceNormals
  16879. * @param p0
  16880. * @param p1
  16881. * @private
  16882. */
  16883. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16884. /**
  16885. * push line into the position, normal and index buffer
  16886. * @protected
  16887. */
  16888. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16889. /**
  16890. * Generates lines edges from adjacencjes
  16891. * @private
  16892. */
  16893. _generateEdgesLines(): void;
  16894. /**
  16895. * Checks wether or not the edges renderer is ready to render.
  16896. * @return true if ready, otherwise false.
  16897. */
  16898. isReady(): boolean;
  16899. /**
  16900. * Renders the edges of the attached mesh,
  16901. */
  16902. render(): void;
  16903. }
  16904. /**
  16905. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16906. */
  16907. export class LineEdgesRenderer extends EdgesRenderer {
  16908. /**
  16909. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16910. * @param source LineMesh used to generate edges
  16911. * @param epsilon not important (specified angle for edge detection)
  16912. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16913. */
  16914. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16915. /**
  16916. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16917. */
  16918. _generateEdgesLines(): void;
  16919. }
  16920. }
  16921. declare module BABYLON {
  16922. /**
  16923. * This represents the object necessary to create a rendering group.
  16924. * This is exclusively used and created by the rendering manager.
  16925. * To modify the behavior, you use the available helpers in your scene or meshes.
  16926. * @hidden
  16927. */
  16928. export class RenderingGroup {
  16929. index: number;
  16930. private static _zeroVector;
  16931. private _scene;
  16932. private _opaqueSubMeshes;
  16933. private _transparentSubMeshes;
  16934. private _alphaTestSubMeshes;
  16935. private _depthOnlySubMeshes;
  16936. private _particleSystems;
  16937. private _spriteManagers;
  16938. private _opaqueSortCompareFn;
  16939. private _alphaTestSortCompareFn;
  16940. private _transparentSortCompareFn;
  16941. private _renderOpaque;
  16942. private _renderAlphaTest;
  16943. private _renderTransparent;
  16944. /** @hidden */
  16945. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16946. onBeforeTransparentRendering: () => void;
  16947. /**
  16948. * Set the opaque sort comparison function.
  16949. * If null the sub meshes will be render in the order they were created
  16950. */
  16951. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16952. /**
  16953. * Set the alpha test sort comparison function.
  16954. * If null the sub meshes will be render in the order they were created
  16955. */
  16956. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16957. /**
  16958. * Set the transparent sort comparison function.
  16959. * If null the sub meshes will be render in the order they were created
  16960. */
  16961. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16962. /**
  16963. * Creates a new rendering group.
  16964. * @param index The rendering group index
  16965. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16966. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16967. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16968. */
  16969. 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>);
  16970. /**
  16971. * Render all the sub meshes contained in the group.
  16972. * @param customRenderFunction Used to override the default render behaviour of the group.
  16973. * @returns true if rendered some submeshes.
  16974. */
  16975. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16976. /**
  16977. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16978. * @param subMeshes The submeshes to render
  16979. */
  16980. private renderOpaqueSorted;
  16981. /**
  16982. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16983. * @param subMeshes The submeshes to render
  16984. */
  16985. private renderAlphaTestSorted;
  16986. /**
  16987. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16988. * @param subMeshes The submeshes to render
  16989. */
  16990. private renderTransparentSorted;
  16991. /**
  16992. * Renders the submeshes in a specified order.
  16993. * @param subMeshes The submeshes to sort before render
  16994. * @param sortCompareFn The comparison function use to sort
  16995. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16996. * @param transparent Specifies to activate blending if true
  16997. */
  16998. private static renderSorted;
  16999. /**
  17000. * Renders the submeshes in the order they were dispatched (no sort applied).
  17001. * @param subMeshes The submeshes to render
  17002. */
  17003. private static renderUnsorted;
  17004. /**
  17005. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17006. * are rendered back to front if in the same alpha index.
  17007. *
  17008. * @param a The first submesh
  17009. * @param b The second submesh
  17010. * @returns The result of the comparison
  17011. */
  17012. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17013. /**
  17014. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17015. * are rendered back to front.
  17016. *
  17017. * @param a The first submesh
  17018. * @param b The second submesh
  17019. * @returns The result of the comparison
  17020. */
  17021. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17022. /**
  17023. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17024. * are rendered front to back (prevent overdraw).
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Resets the different lists of submeshes to prepare a new frame.
  17033. */
  17034. prepare(): void;
  17035. dispose(): void;
  17036. /**
  17037. * Inserts the submesh in its correct queue depending on its material.
  17038. * @param subMesh The submesh to dispatch
  17039. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17040. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17041. */
  17042. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17043. dispatchSprites(spriteManager: ISpriteManager): void;
  17044. dispatchParticles(particleSystem: IParticleSystem): void;
  17045. private _renderParticles;
  17046. private _renderSprites;
  17047. }
  17048. }
  17049. declare module BABYLON {
  17050. /**
  17051. * Interface describing the different options available in the rendering manager
  17052. * regarding Auto Clear between groups.
  17053. */
  17054. export interface IRenderingManagerAutoClearSetup {
  17055. /**
  17056. * Defines whether or not autoclear is enable.
  17057. */
  17058. autoClear: boolean;
  17059. /**
  17060. * Defines whether or not to autoclear the depth buffer.
  17061. */
  17062. depth: boolean;
  17063. /**
  17064. * Defines whether or not to autoclear the stencil buffer.
  17065. */
  17066. stencil: boolean;
  17067. }
  17068. /**
  17069. * This class is used by the onRenderingGroupObservable
  17070. */
  17071. export class RenderingGroupInfo {
  17072. /**
  17073. * The Scene that being rendered
  17074. */
  17075. scene: Scene;
  17076. /**
  17077. * The camera currently used for the rendering pass
  17078. */
  17079. camera: Nullable<Camera>;
  17080. /**
  17081. * The ID of the renderingGroup being processed
  17082. */
  17083. renderingGroupId: number;
  17084. }
  17085. /**
  17086. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17087. * It is enable to manage the different groups as well as the different necessary sort functions.
  17088. * This should not be used directly aside of the few static configurations
  17089. */
  17090. export class RenderingManager {
  17091. /**
  17092. * The max id used for rendering groups (not included)
  17093. */
  17094. static MAX_RENDERINGGROUPS: number;
  17095. /**
  17096. * The min id used for rendering groups (included)
  17097. */
  17098. static MIN_RENDERINGGROUPS: number;
  17099. /**
  17100. * Used to globally prevent autoclearing scenes.
  17101. */
  17102. static AUTOCLEAR: boolean;
  17103. /**
  17104. * @hidden
  17105. */
  17106. _useSceneAutoClearSetup: boolean;
  17107. private _scene;
  17108. private _renderingGroups;
  17109. private _depthStencilBufferAlreadyCleaned;
  17110. private _autoClearDepthStencil;
  17111. private _customOpaqueSortCompareFn;
  17112. private _customAlphaTestSortCompareFn;
  17113. private _customTransparentSortCompareFn;
  17114. private _renderingGroupInfo;
  17115. /**
  17116. * Instantiates a new rendering group for a particular scene
  17117. * @param scene Defines the scene the groups belongs to
  17118. */
  17119. constructor(scene: Scene);
  17120. private _clearDepthStencilBuffer;
  17121. /**
  17122. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17123. * @hidden
  17124. */
  17125. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17126. /**
  17127. * Resets the different information of the group to prepare a new frame
  17128. * @hidden
  17129. */
  17130. reset(): void;
  17131. /**
  17132. * Dispose and release the group and its associated resources.
  17133. * @hidden
  17134. */
  17135. dispose(): void;
  17136. /**
  17137. * Clear the info related to rendering groups preventing retention points during dispose.
  17138. */
  17139. freeRenderingGroups(): void;
  17140. private _prepareRenderingGroup;
  17141. /**
  17142. * Add a sprite manager to the rendering manager in order to render it this frame.
  17143. * @param spriteManager Define the sprite manager to render
  17144. */
  17145. dispatchSprites(spriteManager: ISpriteManager): void;
  17146. /**
  17147. * Add a particle system to the rendering manager in order to render it this frame.
  17148. * @param particleSystem Define the particle system to render
  17149. */
  17150. dispatchParticles(particleSystem: IParticleSystem): void;
  17151. /**
  17152. * Add a submesh to the manager in order to render it this frame
  17153. * @param subMesh The submesh to dispatch
  17154. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17155. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17156. */
  17157. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17158. /**
  17159. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17160. * This allowed control for front to back rendering or reversly depending of the special needs.
  17161. *
  17162. * @param renderingGroupId The rendering group id corresponding to its index
  17163. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17164. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17165. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17166. */
  17167. 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;
  17168. /**
  17169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17170. *
  17171. * @param renderingGroupId The rendering group id corresponding to its index
  17172. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17173. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17174. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17175. */
  17176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17177. /**
  17178. * Gets the current auto clear configuration for one rendering group of the rendering
  17179. * manager.
  17180. * @param index the rendering group index to get the information for
  17181. * @returns The auto clear setup for the requested rendering group
  17182. */
  17183. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17184. }
  17185. }
  17186. declare module BABYLON {
  17187. /**
  17188. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17189. */
  17190. export interface ICustomShaderOptions {
  17191. /**
  17192. * Gets or sets the custom shader name to use
  17193. */
  17194. shaderName: string;
  17195. /**
  17196. * The list of attribute names used in the shader
  17197. */
  17198. attributes?: string[];
  17199. /**
  17200. * The list of unifrom names used in the shader
  17201. */
  17202. uniforms?: string[];
  17203. /**
  17204. * The list of sampler names used in the shader
  17205. */
  17206. samplers?: string[];
  17207. /**
  17208. * The list of defines used in the shader
  17209. */
  17210. defines?: string[];
  17211. }
  17212. /**
  17213. * Interface to implement to create a shadow generator compatible with BJS.
  17214. */
  17215. export interface IShadowGenerator {
  17216. /**
  17217. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17218. * @returns The render target texture if present otherwise, null
  17219. */
  17220. getShadowMap(): Nullable<RenderTargetTexture>;
  17221. /**
  17222. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17223. * @param subMesh The submesh we want to render in the shadow map
  17224. * @param useInstances Defines wether will draw in the map using instances
  17225. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17226. * @returns true if ready otherwise, false
  17227. */
  17228. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17229. /**
  17230. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17231. * @param defines Defines of the material we want to update
  17232. * @param lightIndex Index of the light in the enabled light list of the material
  17233. */
  17234. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17235. /**
  17236. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17237. * defined in the generator but impacting the effect).
  17238. * It implies the unifroms available on the materials are the standard BJS ones.
  17239. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17240. * @param effect The effect we are binfing the information for
  17241. */
  17242. bindShadowLight(lightIndex: string, effect: Effect): void;
  17243. /**
  17244. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17245. * (eq to shadow prjection matrix * light transform matrix)
  17246. * @returns The transform matrix used to create the shadow map
  17247. */
  17248. getTransformMatrix(): Matrix;
  17249. /**
  17250. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17251. * Cube and 2D textures for instance.
  17252. */
  17253. recreateShadowMap(): void;
  17254. /**
  17255. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17256. * @param onCompiled Callback triggered at the and of the effects compilation
  17257. * @param options Sets of optional options forcing the compilation with different modes
  17258. */
  17259. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17260. useInstances: boolean;
  17261. }>): void;
  17262. /**
  17263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17264. * @param options Sets of optional options forcing the compilation with different modes
  17265. * @returns A promise that resolves when the compilation completes
  17266. */
  17267. forceCompilationAsync(options?: Partial<{
  17268. useInstances: boolean;
  17269. }>): Promise<void>;
  17270. /**
  17271. * Serializes the shadow generator setup to a json object.
  17272. * @returns The serialized JSON object
  17273. */
  17274. serialize(): any;
  17275. /**
  17276. * Disposes the Shadow map and related Textures and effects.
  17277. */
  17278. dispose(): void;
  17279. }
  17280. /**
  17281. * Default implementation IShadowGenerator.
  17282. * This is the main object responsible of generating shadows in the framework.
  17283. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17284. */
  17285. export class ShadowGenerator implements IShadowGenerator {
  17286. /**
  17287. * Name of the shadow generator class
  17288. */
  17289. static CLASSNAME: string;
  17290. /**
  17291. * Shadow generator mode None: no filtering applied.
  17292. */
  17293. static readonly FILTER_NONE: number;
  17294. /**
  17295. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17296. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17297. */
  17298. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17299. /**
  17300. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17301. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17302. */
  17303. static readonly FILTER_POISSONSAMPLING: number;
  17304. /**
  17305. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17306. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17307. */
  17308. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17309. /**
  17310. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17311. * edge artifacts on steep falloff.
  17312. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17313. */
  17314. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17315. /**
  17316. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17317. * edge artifacts on steep falloff.
  17318. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17319. */
  17320. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17321. /**
  17322. * Shadow generator mode PCF: Percentage Closer Filtering
  17323. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17324. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17325. */
  17326. static readonly FILTER_PCF: number;
  17327. /**
  17328. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17329. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17330. * Contact Hardening
  17331. */
  17332. static readonly FILTER_PCSS: number;
  17333. /**
  17334. * Reserved for PCF and PCSS
  17335. * Highest Quality.
  17336. *
  17337. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17338. *
  17339. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17340. */
  17341. static readonly QUALITY_HIGH: number;
  17342. /**
  17343. * Reserved for PCF and PCSS
  17344. * Good tradeoff for quality/perf cross devices
  17345. *
  17346. * Execute PCF on a 3*3 kernel.
  17347. *
  17348. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17349. */
  17350. static readonly QUALITY_MEDIUM: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * The lowest quality but the fastest.
  17354. *
  17355. * Execute PCF on a 1*1 kernel.
  17356. *
  17357. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17358. */
  17359. static readonly QUALITY_LOW: number;
  17360. /** Gets or sets the custom shader name to use */
  17361. customShaderOptions: ICustomShaderOptions;
  17362. /**
  17363. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17364. */
  17365. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17366. /**
  17367. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17368. */
  17369. onAfterShadowMapRenderObservable: Observable<Effect>;
  17370. /**
  17371. * Observable triggered before a mesh is rendered in the shadow map.
  17372. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17373. */
  17374. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17375. /**
  17376. * Observable triggered after a mesh is rendered in the shadow map.
  17377. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17378. */
  17379. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17380. protected _bias: number;
  17381. /**
  17382. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17383. */
  17384. get bias(): number;
  17385. /**
  17386. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17387. */
  17388. set bias(bias: number);
  17389. protected _normalBias: number;
  17390. /**
  17391. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17392. */
  17393. get normalBias(): number;
  17394. /**
  17395. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17396. */
  17397. set normalBias(normalBias: number);
  17398. protected _blurBoxOffset: number;
  17399. /**
  17400. * Gets the blur box offset: offset applied during the blur pass.
  17401. * Only useful if useKernelBlur = false
  17402. */
  17403. get blurBoxOffset(): number;
  17404. /**
  17405. * Sets the blur box offset: offset applied during the blur pass.
  17406. * Only useful if useKernelBlur = false
  17407. */
  17408. set blurBoxOffset(value: number);
  17409. protected _blurScale: number;
  17410. /**
  17411. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17412. * 2 means half of the size.
  17413. */
  17414. get blurScale(): number;
  17415. /**
  17416. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17417. * 2 means half of the size.
  17418. */
  17419. set blurScale(value: number);
  17420. protected _blurKernel: number;
  17421. /**
  17422. * Gets the blur kernel: kernel size of the blur pass.
  17423. * Only useful if useKernelBlur = true
  17424. */
  17425. get blurKernel(): number;
  17426. /**
  17427. * Sets the blur kernel: kernel size of the blur pass.
  17428. * Only useful if useKernelBlur = true
  17429. */
  17430. set blurKernel(value: number);
  17431. protected _useKernelBlur: boolean;
  17432. /**
  17433. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17434. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17435. */
  17436. get useKernelBlur(): boolean;
  17437. /**
  17438. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17439. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17440. */
  17441. set useKernelBlur(value: boolean);
  17442. protected _depthScale: number;
  17443. /**
  17444. * Gets the depth scale used in ESM mode.
  17445. */
  17446. get depthScale(): number;
  17447. /**
  17448. * Sets the depth scale used in ESM mode.
  17449. * This can override the scale stored on the light.
  17450. */
  17451. set depthScale(value: number);
  17452. protected _validateFilter(filter: number): number;
  17453. protected _filter: number;
  17454. /**
  17455. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17456. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17457. */
  17458. get filter(): number;
  17459. /**
  17460. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17461. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17462. */
  17463. set filter(value: number);
  17464. /**
  17465. * Gets if the current filter is set to Poisson Sampling.
  17466. */
  17467. get usePoissonSampling(): boolean;
  17468. /**
  17469. * Sets the current filter to Poisson Sampling.
  17470. */
  17471. set usePoissonSampling(value: boolean);
  17472. /**
  17473. * Gets if the current filter is set to ESM.
  17474. */
  17475. get useExponentialShadowMap(): boolean;
  17476. /**
  17477. * Sets the current filter is to ESM.
  17478. */
  17479. set useExponentialShadowMap(value: boolean);
  17480. /**
  17481. * Gets if the current filter is set to filtered ESM.
  17482. */
  17483. get useBlurExponentialShadowMap(): boolean;
  17484. /**
  17485. * Gets if the current filter is set to filtered ESM.
  17486. */
  17487. set useBlurExponentialShadowMap(value: boolean);
  17488. /**
  17489. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17490. * exponential to prevent steep falloff artifacts).
  17491. */
  17492. get useCloseExponentialShadowMap(): boolean;
  17493. /**
  17494. * Sets the current filter to "close ESM" (using the inverse of the
  17495. * exponential to prevent steep falloff artifacts).
  17496. */
  17497. set useCloseExponentialShadowMap(value: boolean);
  17498. /**
  17499. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17500. * exponential to prevent steep falloff artifacts).
  17501. */
  17502. get useBlurCloseExponentialShadowMap(): boolean;
  17503. /**
  17504. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17505. * exponential to prevent steep falloff artifacts).
  17506. */
  17507. set useBlurCloseExponentialShadowMap(value: boolean);
  17508. /**
  17509. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17510. */
  17511. get usePercentageCloserFiltering(): boolean;
  17512. /**
  17513. * Sets the current filter to "PCF" (percentage closer filtering).
  17514. */
  17515. set usePercentageCloserFiltering(value: boolean);
  17516. protected _filteringQuality: number;
  17517. /**
  17518. * Gets the PCF or PCSS Quality.
  17519. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17520. */
  17521. get filteringQuality(): number;
  17522. /**
  17523. * Sets the PCF or PCSS Quality.
  17524. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17525. */
  17526. set filteringQuality(filteringQuality: number);
  17527. /**
  17528. * Gets if the current filter is set to "PCSS" (contact hardening).
  17529. */
  17530. get useContactHardeningShadow(): boolean;
  17531. /**
  17532. * Sets the current filter to "PCSS" (contact hardening).
  17533. */
  17534. set useContactHardeningShadow(value: boolean);
  17535. protected _contactHardeningLightSizeUVRatio: number;
  17536. /**
  17537. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17538. * Using a ratio helps keeping shape stability independently of the map size.
  17539. *
  17540. * It does not account for the light projection as it was having too much
  17541. * instability during the light setup or during light position changes.
  17542. *
  17543. * Only valid if useContactHardeningShadow is true.
  17544. */
  17545. get contactHardeningLightSizeUVRatio(): number;
  17546. /**
  17547. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17548. * Using a ratio helps keeping shape stability independently of the map size.
  17549. *
  17550. * It does not account for the light projection as it was having too much
  17551. * instability during the light setup or during light position changes.
  17552. *
  17553. * Only valid if useContactHardeningShadow is true.
  17554. */
  17555. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17556. protected _darkness: number;
  17557. /** Gets or sets the actual darkness of a shadow */
  17558. get darkness(): number;
  17559. set darkness(value: number);
  17560. /**
  17561. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17562. * 0 means strongest and 1 would means no shadow.
  17563. * @returns the darkness.
  17564. */
  17565. getDarkness(): number;
  17566. /**
  17567. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17568. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17569. * @returns the shadow generator allowing fluent coding.
  17570. */
  17571. setDarkness(darkness: number): ShadowGenerator;
  17572. protected _transparencyShadow: boolean;
  17573. /** Gets or sets the ability to have transparent shadow */
  17574. get transparencyShadow(): boolean;
  17575. set transparencyShadow(value: boolean);
  17576. /**
  17577. * Sets the ability to have transparent shadow (boolean).
  17578. * @param transparent True if transparent else False
  17579. * @returns the shadow generator allowing fluent coding
  17580. */
  17581. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17582. /**
  17583. * Enables or disables shadows with varying strength based on the transparency
  17584. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17585. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17586. * mesh.visibility * alphaTexture.a
  17587. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17588. */
  17589. enableSoftTransparentShadow: boolean;
  17590. protected _shadowMap: Nullable<RenderTargetTexture>;
  17591. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17592. /**
  17593. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17594. * @returns The render target texture if present otherwise, null
  17595. */
  17596. getShadowMap(): Nullable<RenderTargetTexture>;
  17597. /**
  17598. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17599. * @returns The render target texture if the shadow map is present otherwise, null
  17600. */
  17601. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17602. /**
  17603. * Gets the class name of that object
  17604. * @returns "ShadowGenerator"
  17605. */
  17606. getClassName(): string;
  17607. /**
  17608. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17609. * @param mesh Mesh to add
  17610. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17611. * @returns the Shadow Generator itself
  17612. */
  17613. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17614. /**
  17615. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17616. * @param mesh Mesh to remove
  17617. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17618. * @returns the Shadow Generator itself
  17619. */
  17620. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17621. /**
  17622. * Controls the extent to which the shadows fade out at the edge of the frustum
  17623. */
  17624. frustumEdgeFalloff: number;
  17625. protected _light: IShadowLight;
  17626. /**
  17627. * Returns the associated light object.
  17628. * @returns the light generating the shadow
  17629. */
  17630. getLight(): IShadowLight;
  17631. /**
  17632. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17633. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17634. * It might on the other hand introduce peter panning.
  17635. */
  17636. forceBackFacesOnly: boolean;
  17637. protected _scene: Scene;
  17638. protected _lightDirection: Vector3;
  17639. protected _effect: Effect;
  17640. protected _viewMatrix: Matrix;
  17641. protected _projectionMatrix: Matrix;
  17642. protected _transformMatrix: Matrix;
  17643. protected _cachedPosition: Vector3;
  17644. protected _cachedDirection: Vector3;
  17645. protected _cachedDefines: string;
  17646. protected _currentRenderID: number;
  17647. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17648. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17649. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17650. protected _blurPostProcesses: PostProcess[];
  17651. protected _mapSize: number;
  17652. protected _currentFaceIndex: number;
  17653. protected _currentFaceIndexCache: number;
  17654. protected _textureType: number;
  17655. protected _defaultTextureMatrix: Matrix;
  17656. protected _storedUniqueId: Nullable<number>;
  17657. /** @hidden */
  17658. static _SceneComponentInitialization: (scene: Scene) => void;
  17659. /**
  17660. * Creates a ShadowGenerator object.
  17661. * A ShadowGenerator is the required tool to use the shadows.
  17662. * Each light casting shadows needs to use its own ShadowGenerator.
  17663. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17664. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17665. * @param light The light object generating the shadows.
  17666. * @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.
  17667. */
  17668. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17669. protected _initializeGenerator(): void;
  17670. protected _createTargetRenderTexture(): void;
  17671. protected _initializeShadowMap(): void;
  17672. protected _initializeBlurRTTAndPostProcesses(): void;
  17673. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17674. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17675. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17676. protected _applyFilterValues(): void;
  17677. /**
  17678. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17679. * @param onCompiled Callback triggered at the and of the effects compilation
  17680. * @param options Sets of optional options forcing the compilation with different modes
  17681. */
  17682. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17683. useInstances: boolean;
  17684. }>): void;
  17685. /**
  17686. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17687. * @param options Sets of optional options forcing the compilation with different modes
  17688. * @returns A promise that resolves when the compilation completes
  17689. */
  17690. forceCompilationAsync(options?: Partial<{
  17691. useInstances: boolean;
  17692. }>): Promise<void>;
  17693. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17694. private _prepareShadowDefines;
  17695. /**
  17696. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17697. * @param subMesh The submesh we want to render in the shadow map
  17698. * @param useInstances Defines wether will draw in the map using instances
  17699. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17700. * @returns true if ready otherwise, false
  17701. */
  17702. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17703. /**
  17704. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17705. * @param defines Defines of the material we want to update
  17706. * @param lightIndex Index of the light in the enabled light list of the material
  17707. */
  17708. prepareDefines(defines: any, lightIndex: number): void;
  17709. /**
  17710. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17711. * defined in the generator but impacting the effect).
  17712. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17713. * @param effect The effect we are binfing the information for
  17714. */
  17715. bindShadowLight(lightIndex: string, effect: Effect): void;
  17716. /**
  17717. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17718. * (eq to shadow prjection matrix * light transform matrix)
  17719. * @returns The transform matrix used to create the shadow map
  17720. */
  17721. getTransformMatrix(): Matrix;
  17722. /**
  17723. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17724. * Cube and 2D textures for instance.
  17725. */
  17726. recreateShadowMap(): void;
  17727. protected _disposeBlurPostProcesses(): void;
  17728. protected _disposeRTTandPostProcesses(): void;
  17729. /**
  17730. * Disposes the ShadowGenerator.
  17731. * Returns nothing.
  17732. */
  17733. dispose(): void;
  17734. /**
  17735. * Serializes the shadow generator setup to a json object.
  17736. * @returns The serialized JSON object
  17737. */
  17738. serialize(): any;
  17739. /**
  17740. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17741. * @param parsedShadowGenerator The JSON object to parse
  17742. * @param scene The scene to create the shadow map for
  17743. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17744. * @returns The parsed shadow generator
  17745. */
  17746. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17747. }
  17748. }
  17749. declare module BABYLON {
  17750. /**
  17751. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17752. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17753. * 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.
  17754. */
  17755. export abstract class Light extends Node {
  17756. /**
  17757. * Falloff Default: light is falling off following the material specification:
  17758. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17759. */
  17760. static readonly FALLOFF_DEFAULT: number;
  17761. /**
  17762. * Falloff Physical: light is falling off following the inverse squared distance law.
  17763. */
  17764. static readonly FALLOFF_PHYSICAL: number;
  17765. /**
  17766. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17767. * to enhance interoperability with other engines.
  17768. */
  17769. static readonly FALLOFF_GLTF: number;
  17770. /**
  17771. * Falloff Standard: light is falling off like in the standard material
  17772. * to enhance interoperability with other materials.
  17773. */
  17774. static readonly FALLOFF_STANDARD: number;
  17775. /**
  17776. * If every light affecting the material is in this lightmapMode,
  17777. * material.lightmapTexture adds or multiplies
  17778. * (depends on material.useLightmapAsShadowmap)
  17779. * after every other light calculations.
  17780. */
  17781. static readonly LIGHTMAP_DEFAULT: number;
  17782. /**
  17783. * material.lightmapTexture as only diffuse lighting from this light
  17784. * adds only specular lighting from this light
  17785. * adds dynamic shadows
  17786. */
  17787. static readonly LIGHTMAP_SPECULAR: number;
  17788. /**
  17789. * material.lightmapTexture as only lighting
  17790. * no light calculation from this light
  17791. * only adds dynamic shadows from this light
  17792. */
  17793. static readonly LIGHTMAP_SHADOWSONLY: number;
  17794. /**
  17795. * Each light type uses the default quantity according to its type:
  17796. * point/spot lights use luminous intensity
  17797. * directional lights use illuminance
  17798. */
  17799. static readonly INTENSITYMODE_AUTOMATIC: number;
  17800. /**
  17801. * lumen (lm)
  17802. */
  17803. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17804. /**
  17805. * candela (lm/sr)
  17806. */
  17807. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17808. /**
  17809. * lux (lm/m^2)
  17810. */
  17811. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17812. /**
  17813. * nit (cd/m^2)
  17814. */
  17815. static readonly INTENSITYMODE_LUMINANCE: number;
  17816. /**
  17817. * Light type const id of the point light.
  17818. */
  17819. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17820. /**
  17821. * Light type const id of the directional light.
  17822. */
  17823. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17824. /**
  17825. * Light type const id of the spot light.
  17826. */
  17827. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17828. /**
  17829. * Light type const id of the hemispheric light.
  17830. */
  17831. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17832. /**
  17833. * Diffuse gives the basic color to an object.
  17834. */
  17835. diffuse: Color3;
  17836. /**
  17837. * Specular produces a highlight color on an object.
  17838. * Note: This is note affecting PBR materials.
  17839. */
  17840. specular: Color3;
  17841. /**
  17842. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17843. * falling off base on range or angle.
  17844. * This can be set to any values in Light.FALLOFF_x.
  17845. *
  17846. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17847. * other types of materials.
  17848. */
  17849. falloffType: number;
  17850. /**
  17851. * Strength of the light.
  17852. * Note: By default it is define in the framework own unit.
  17853. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17854. */
  17855. intensity: number;
  17856. private _range;
  17857. protected _inverseSquaredRange: number;
  17858. /**
  17859. * Defines how far from the source the light is impacting in scene units.
  17860. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17861. */
  17862. get range(): number;
  17863. /**
  17864. * Defines how far from the source the light is impacting in scene units.
  17865. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17866. */
  17867. set range(value: number);
  17868. /**
  17869. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17870. * of light.
  17871. */
  17872. private _photometricScale;
  17873. private _intensityMode;
  17874. /**
  17875. * Gets the photometric scale used to interpret the intensity.
  17876. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17877. */
  17878. get intensityMode(): number;
  17879. /**
  17880. * Sets the photometric scale used to interpret the intensity.
  17881. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17882. */
  17883. set intensityMode(value: number);
  17884. private _radius;
  17885. /**
  17886. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17887. */
  17888. get radius(): number;
  17889. /**
  17890. * sets the light radius used by PBR Materials to simulate soft area lights.
  17891. */
  17892. set radius(value: number);
  17893. private _renderPriority;
  17894. /**
  17895. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17896. * exceeding the number allowed of the materials.
  17897. */
  17898. renderPriority: number;
  17899. private _shadowEnabled;
  17900. /**
  17901. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17902. * the current shadow generator.
  17903. */
  17904. get shadowEnabled(): boolean;
  17905. /**
  17906. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17907. * the current shadow generator.
  17908. */
  17909. set shadowEnabled(value: boolean);
  17910. private _includedOnlyMeshes;
  17911. /**
  17912. * Gets the only meshes impacted by this light.
  17913. */
  17914. get includedOnlyMeshes(): AbstractMesh[];
  17915. /**
  17916. * Sets the only meshes impacted by this light.
  17917. */
  17918. set includedOnlyMeshes(value: AbstractMesh[]);
  17919. private _excludedMeshes;
  17920. /**
  17921. * Gets the meshes not impacted by this light.
  17922. */
  17923. get excludedMeshes(): AbstractMesh[];
  17924. /**
  17925. * Sets the meshes not impacted by this light.
  17926. */
  17927. set excludedMeshes(value: AbstractMesh[]);
  17928. private _excludeWithLayerMask;
  17929. /**
  17930. * Gets the layer id use to find what meshes are not impacted by the light.
  17931. * Inactive if 0
  17932. */
  17933. get excludeWithLayerMask(): number;
  17934. /**
  17935. * Sets the layer id use to find what meshes are not impacted by the light.
  17936. * Inactive if 0
  17937. */
  17938. set excludeWithLayerMask(value: number);
  17939. private _includeOnlyWithLayerMask;
  17940. /**
  17941. * Gets the layer id use to find what meshes are impacted by the light.
  17942. * Inactive if 0
  17943. */
  17944. get includeOnlyWithLayerMask(): number;
  17945. /**
  17946. * Sets the layer id use to find what meshes are impacted by the light.
  17947. * Inactive if 0
  17948. */
  17949. set includeOnlyWithLayerMask(value: number);
  17950. private _lightmapMode;
  17951. /**
  17952. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17953. */
  17954. get lightmapMode(): number;
  17955. /**
  17956. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17957. */
  17958. set lightmapMode(value: number);
  17959. /**
  17960. * Shadow generator associted to the light.
  17961. * @hidden Internal use only.
  17962. */
  17963. _shadowGenerator: Nullable<IShadowGenerator>;
  17964. /**
  17965. * @hidden Internal use only.
  17966. */
  17967. _excludedMeshesIds: string[];
  17968. /**
  17969. * @hidden Internal use only.
  17970. */
  17971. _includedOnlyMeshesIds: string[];
  17972. /**
  17973. * The current light unifom buffer.
  17974. * @hidden Internal use only.
  17975. */
  17976. _uniformBuffer: UniformBuffer;
  17977. /** @hidden */
  17978. _renderId: number;
  17979. /**
  17980. * Creates a Light object in the scene.
  17981. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17982. * @param name The firendly name of the light
  17983. * @param scene The scene the light belongs too
  17984. */
  17985. constructor(name: string, scene: Scene);
  17986. protected abstract _buildUniformLayout(): void;
  17987. /**
  17988. * Sets the passed Effect "effect" with the Light information.
  17989. * @param effect The effect to update
  17990. * @param lightIndex The index of the light in the effect to update
  17991. * @returns The light
  17992. */
  17993. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17994. /**
  17995. * Sets the passed Effect "effect" with the Light textures.
  17996. * @param effect The effect to update
  17997. * @param lightIndex The index of the light in the effect to update
  17998. * @returns The light
  17999. */
  18000. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18001. /**
  18002. * Binds the lights information from the scene to the effect for the given mesh.
  18003. * @param lightIndex Light index
  18004. * @param scene The scene where the light belongs to
  18005. * @param effect The effect we are binding the data to
  18006. * @param useSpecular Defines if specular is supported
  18007. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18008. */
  18009. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18010. /**
  18011. * Sets the passed Effect "effect" with the Light information.
  18012. * @param effect The effect to update
  18013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18014. * @returns The light
  18015. */
  18016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18017. /**
  18018. * Returns the string "Light".
  18019. * @returns the class name
  18020. */
  18021. getClassName(): string;
  18022. /** @hidden */
  18023. readonly _isLight: boolean;
  18024. /**
  18025. * Converts the light information to a readable string for debug purpose.
  18026. * @param fullDetails Supports for multiple levels of logging within scene loading
  18027. * @returns the human readable light info
  18028. */
  18029. toString(fullDetails?: boolean): string;
  18030. /** @hidden */
  18031. protected _syncParentEnabledState(): void;
  18032. /**
  18033. * Set the enabled state of this node.
  18034. * @param value - the new enabled state
  18035. */
  18036. setEnabled(value: boolean): void;
  18037. /**
  18038. * Returns the Light associated shadow generator if any.
  18039. * @return the associated shadow generator.
  18040. */
  18041. getShadowGenerator(): Nullable<IShadowGenerator>;
  18042. /**
  18043. * Returns a Vector3, the absolute light position in the World.
  18044. * @returns the world space position of the light
  18045. */
  18046. getAbsolutePosition(): Vector3;
  18047. /**
  18048. * Specifies if the light will affect the passed mesh.
  18049. * @param mesh The mesh to test against the light
  18050. * @return true the mesh is affected otherwise, false.
  18051. */
  18052. canAffectMesh(mesh: AbstractMesh): boolean;
  18053. /**
  18054. * Sort function to order lights for rendering.
  18055. * @param a First Light object to compare to second.
  18056. * @param b Second Light object to compare first.
  18057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18058. */
  18059. static CompareLightsPriority(a: Light, b: Light): number;
  18060. /**
  18061. * Releases resources associated with this node.
  18062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18064. */
  18065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18066. /**
  18067. * Returns the light type ID (integer).
  18068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18069. */
  18070. getTypeID(): number;
  18071. /**
  18072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18073. * @returns the scaled intensity in intensity mode unit
  18074. */
  18075. getScaledIntensity(): number;
  18076. /**
  18077. * Returns a new Light object, named "name", from the current one.
  18078. * @param name The name of the cloned light
  18079. * @param newParent The parent of this light, if it has one
  18080. * @returns the new created light
  18081. */
  18082. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18083. /**
  18084. * Serializes the current light into a Serialization object.
  18085. * @returns the serialized object.
  18086. */
  18087. serialize(): any;
  18088. /**
  18089. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18090. * This new light is named "name" and added to the passed scene.
  18091. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18092. * @param name The friendly name of the light
  18093. * @param scene The scene the new light will belong to
  18094. * @returns the constructor function
  18095. */
  18096. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18097. /**
  18098. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18099. * @param parsedLight The JSON representation of the light
  18100. * @param scene The scene to create the parsed light in
  18101. * @returns the created light after parsing
  18102. */
  18103. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18104. private _hookArrayForExcluded;
  18105. private _hookArrayForIncludedOnly;
  18106. private _resyncMeshes;
  18107. /**
  18108. * Forces the meshes to update their light related information in their rendering used effects
  18109. * @hidden Internal Use Only
  18110. */
  18111. _markMeshesAsLightDirty(): void;
  18112. /**
  18113. * Recomputes the cached photometric scale if needed.
  18114. */
  18115. private _computePhotometricScale;
  18116. /**
  18117. * Returns the Photometric Scale according to the light type and intensity mode.
  18118. */
  18119. private _getPhotometricScale;
  18120. /**
  18121. * Reorder the light in the scene according to their defined priority.
  18122. * @hidden Internal Use Only
  18123. */
  18124. _reorderLightsInScene(): void;
  18125. /**
  18126. * Prepares the list of defines specific to the light type.
  18127. * @param defines the list of defines
  18128. * @param lightIndex defines the index of the light for the effect
  18129. */
  18130. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18131. }
  18132. }
  18133. declare module BABYLON {
  18134. /**
  18135. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18136. * This is the base of the follow, arc rotate cameras and Free camera
  18137. * @see http://doc.babylonjs.com/features/cameras
  18138. */
  18139. export class TargetCamera extends Camera {
  18140. private static _RigCamTransformMatrix;
  18141. private static _TargetTransformMatrix;
  18142. private static _TargetFocalPoint;
  18143. /**
  18144. * Define the current direction the camera is moving to
  18145. */
  18146. cameraDirection: Vector3;
  18147. /**
  18148. * Define the current rotation the camera is rotating to
  18149. */
  18150. cameraRotation: Vector2;
  18151. /**
  18152. * When set, the up vector of the camera will be updated by the rotation of the camera
  18153. */
  18154. updateUpVectorFromRotation: boolean;
  18155. private _tmpQuaternion;
  18156. /**
  18157. * Define the current rotation of the camera
  18158. */
  18159. rotation: Vector3;
  18160. /**
  18161. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18162. */
  18163. rotationQuaternion: Quaternion;
  18164. /**
  18165. * Define the current speed of the camera
  18166. */
  18167. speed: number;
  18168. /**
  18169. * Add constraint to the camera to prevent it to move freely in all directions and
  18170. * around all axis.
  18171. */
  18172. noRotationConstraint: boolean;
  18173. /**
  18174. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18175. * panning
  18176. */
  18177. invertRotation: boolean;
  18178. /**
  18179. * Speed multiplier for inverse camera panning
  18180. */
  18181. inverseRotationSpeed: number;
  18182. /**
  18183. * Define the current target of the camera as an object or a position.
  18184. */
  18185. lockedTarget: any;
  18186. /** @hidden */
  18187. _currentTarget: Vector3;
  18188. /** @hidden */
  18189. _initialFocalDistance: number;
  18190. /** @hidden */
  18191. _viewMatrix: Matrix;
  18192. /** @hidden */
  18193. _camMatrix: Matrix;
  18194. /** @hidden */
  18195. _cameraTransformMatrix: Matrix;
  18196. /** @hidden */
  18197. _cameraRotationMatrix: Matrix;
  18198. /** @hidden */
  18199. _referencePoint: Vector3;
  18200. /** @hidden */
  18201. _transformedReferencePoint: Vector3;
  18202. protected _globalCurrentTarget: Vector3;
  18203. protected _globalCurrentUpVector: Vector3;
  18204. /** @hidden */
  18205. _reset: () => void;
  18206. private _defaultUp;
  18207. /**
  18208. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18209. * This is the base of the follow, arc rotate cameras and Free camera
  18210. * @see http://doc.babylonjs.com/features/cameras
  18211. * @param name Defines the name of the camera in the scene
  18212. * @param position Defines the start position of the camera in the scene
  18213. * @param scene Defines the scene the camera belongs to
  18214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18215. */
  18216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18217. /**
  18218. * Gets the position in front of the camera at a given distance.
  18219. * @param distance The distance from the camera we want the position to be
  18220. * @returns the position
  18221. */
  18222. getFrontPosition(distance: number): Vector3;
  18223. /** @hidden */
  18224. _getLockedTargetPosition(): Nullable<Vector3>;
  18225. private _storedPosition;
  18226. private _storedRotation;
  18227. private _storedRotationQuaternion;
  18228. /**
  18229. * Store current camera state of the camera (fov, position, rotation, etc..)
  18230. * @returns the camera
  18231. */
  18232. storeState(): Camera;
  18233. /**
  18234. * Restored camera state. You must call storeState() first
  18235. * @returns whether it was successful or not
  18236. * @hidden
  18237. */
  18238. _restoreStateValues(): boolean;
  18239. /** @hidden */
  18240. _initCache(): void;
  18241. /** @hidden */
  18242. _updateCache(ignoreParentClass?: boolean): void;
  18243. /** @hidden */
  18244. _isSynchronizedViewMatrix(): boolean;
  18245. /** @hidden */
  18246. _computeLocalCameraSpeed(): number;
  18247. /**
  18248. * Defines the target the camera should look at.
  18249. * @param target Defines the new target as a Vector or a mesh
  18250. */
  18251. setTarget(target: Vector3): void;
  18252. /**
  18253. * Return the current target position of the camera. This value is expressed in local space.
  18254. * @returns the target position
  18255. */
  18256. getTarget(): Vector3;
  18257. /** @hidden */
  18258. _decideIfNeedsToMove(): boolean;
  18259. /** @hidden */
  18260. _updatePosition(): void;
  18261. /** @hidden */
  18262. _checkInputs(): void;
  18263. protected _updateCameraRotationMatrix(): void;
  18264. /**
  18265. * 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)
  18266. * @returns the current camera
  18267. */
  18268. private _rotateUpVectorWithCameraRotationMatrix;
  18269. private _cachedRotationZ;
  18270. private _cachedQuaternionRotationZ;
  18271. /** @hidden */
  18272. _getViewMatrix(): Matrix;
  18273. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18274. /**
  18275. * @hidden
  18276. */
  18277. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18278. /**
  18279. * @hidden
  18280. */
  18281. _updateRigCameras(): void;
  18282. private _getRigCamPositionAndTarget;
  18283. /**
  18284. * Gets the current object class name.
  18285. * @return the class name
  18286. */
  18287. getClassName(): string;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * Gather the list of keyboard event types as constants.
  18293. */
  18294. export class KeyboardEventTypes {
  18295. /**
  18296. * The keydown event is fired when a key becomes active (pressed).
  18297. */
  18298. static readonly KEYDOWN: number;
  18299. /**
  18300. * The keyup event is fired when a key has been released.
  18301. */
  18302. static readonly KEYUP: number;
  18303. }
  18304. /**
  18305. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18306. */
  18307. export class KeyboardInfo {
  18308. /**
  18309. * Defines the type of event (KeyboardEventTypes)
  18310. */
  18311. type: number;
  18312. /**
  18313. * Defines the related dom event
  18314. */
  18315. event: KeyboardEvent;
  18316. /**
  18317. * Instantiates a new keyboard info.
  18318. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18319. * @param type Defines the type of event (KeyboardEventTypes)
  18320. * @param event Defines the related dom event
  18321. */
  18322. constructor(
  18323. /**
  18324. * Defines the type of event (KeyboardEventTypes)
  18325. */
  18326. type: number,
  18327. /**
  18328. * Defines the related dom event
  18329. */
  18330. event: KeyboardEvent);
  18331. }
  18332. /**
  18333. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18334. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18335. */
  18336. export class KeyboardInfoPre extends KeyboardInfo {
  18337. /**
  18338. * Defines the type of event (KeyboardEventTypes)
  18339. */
  18340. type: number;
  18341. /**
  18342. * Defines the related dom event
  18343. */
  18344. event: KeyboardEvent;
  18345. /**
  18346. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18347. */
  18348. skipOnPointerObservable: boolean;
  18349. /**
  18350. * Instantiates a new keyboard pre info.
  18351. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18352. * @param type Defines the type of event (KeyboardEventTypes)
  18353. * @param event Defines the related dom event
  18354. */
  18355. constructor(
  18356. /**
  18357. * Defines the type of event (KeyboardEventTypes)
  18358. */
  18359. type: number,
  18360. /**
  18361. * Defines the related dom event
  18362. */
  18363. event: KeyboardEvent);
  18364. }
  18365. }
  18366. declare module BABYLON {
  18367. /**
  18368. * Manage the keyboard inputs to control the movement of a free camera.
  18369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18370. */
  18371. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18372. /**
  18373. * Defines the camera the input is attached to.
  18374. */
  18375. camera: FreeCamera;
  18376. /**
  18377. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18378. */
  18379. keysUp: number[];
  18380. /**
  18381. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18382. */
  18383. keysUpward: number[];
  18384. /**
  18385. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18386. */
  18387. keysDown: number[];
  18388. /**
  18389. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18390. */
  18391. keysDownward: number[];
  18392. /**
  18393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18394. */
  18395. keysLeft: number[];
  18396. /**
  18397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18398. */
  18399. keysRight: number[];
  18400. private _keys;
  18401. private _onCanvasBlurObserver;
  18402. private _onKeyboardObserver;
  18403. private _engine;
  18404. private _scene;
  18405. /**
  18406. * Attach the input controls to a specific dom element to get the input from.
  18407. * @param element Defines the element the controls should be listened from
  18408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18409. */
  18410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18411. /**
  18412. * Detach the current controls from the specified dom element.
  18413. * @param element Defines the element to stop listening the inputs from
  18414. */
  18415. detachControl(element: Nullable<HTMLElement>): void;
  18416. /**
  18417. * Update the current camera state depending on the inputs that have been used this frame.
  18418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18419. */
  18420. checkInputs(): void;
  18421. /**
  18422. * Gets the class name of the current intput.
  18423. * @returns the class name
  18424. */
  18425. getClassName(): string;
  18426. /** @hidden */
  18427. _onLostFocus(): void;
  18428. /**
  18429. * Get the friendly name associated with the input class.
  18430. * @returns the input friendly name
  18431. */
  18432. getSimpleName(): string;
  18433. }
  18434. }
  18435. declare module BABYLON {
  18436. /**
  18437. * Gather the list of pointer event types as constants.
  18438. */
  18439. export class PointerEventTypes {
  18440. /**
  18441. * 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.
  18442. */
  18443. static readonly POINTERDOWN: number;
  18444. /**
  18445. * The pointerup event is fired when a pointer is no longer active.
  18446. */
  18447. static readonly POINTERUP: number;
  18448. /**
  18449. * The pointermove event is fired when a pointer changes coordinates.
  18450. */
  18451. static readonly POINTERMOVE: number;
  18452. /**
  18453. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18454. */
  18455. static readonly POINTERWHEEL: number;
  18456. /**
  18457. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18458. */
  18459. static readonly POINTERPICK: number;
  18460. /**
  18461. * The pointertap event is fired when a the object has been touched and released without drag.
  18462. */
  18463. static readonly POINTERTAP: number;
  18464. /**
  18465. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18466. */
  18467. static readonly POINTERDOUBLETAP: number;
  18468. }
  18469. /**
  18470. * Base class of pointer info types.
  18471. */
  18472. export class PointerInfoBase {
  18473. /**
  18474. * Defines the type of event (PointerEventTypes)
  18475. */
  18476. type: number;
  18477. /**
  18478. * Defines the related dom event
  18479. */
  18480. event: PointerEvent | MouseWheelEvent;
  18481. /**
  18482. * Instantiates the base class of pointers info.
  18483. * @param type Defines the type of event (PointerEventTypes)
  18484. * @param event Defines the related dom event
  18485. */
  18486. constructor(
  18487. /**
  18488. * Defines the type of event (PointerEventTypes)
  18489. */
  18490. type: number,
  18491. /**
  18492. * Defines the related dom event
  18493. */
  18494. event: PointerEvent | MouseWheelEvent);
  18495. }
  18496. /**
  18497. * This class is used to store pointer related info for the onPrePointerObservable event.
  18498. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18499. */
  18500. export class PointerInfoPre extends PointerInfoBase {
  18501. /**
  18502. * Ray from a pointer if availible (eg. 6dof controller)
  18503. */
  18504. ray: Nullable<Ray>;
  18505. /**
  18506. * Defines the local position of the pointer on the canvas.
  18507. */
  18508. localPosition: Vector2;
  18509. /**
  18510. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18511. */
  18512. skipOnPointerObservable: boolean;
  18513. /**
  18514. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18515. * @param type Defines the type of event (PointerEventTypes)
  18516. * @param event Defines the related dom event
  18517. * @param localX Defines the local x coordinates of the pointer when the event occured
  18518. * @param localY Defines the local y coordinates of the pointer when the event occured
  18519. */
  18520. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18521. }
  18522. /**
  18523. * This type contains all the data related to a pointer event in Babylon.js.
  18524. * 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.
  18525. */
  18526. export class PointerInfo extends PointerInfoBase {
  18527. /**
  18528. * Defines the picking info associated to the info (if any)\
  18529. */
  18530. pickInfo: Nullable<PickingInfo>;
  18531. /**
  18532. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18533. * @param type Defines the type of event (PointerEventTypes)
  18534. * @param event Defines the related dom event
  18535. * @param pickInfo Defines the picking info associated to the info (if any)\
  18536. */
  18537. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18538. /**
  18539. * Defines the picking info associated to the info (if any)\
  18540. */
  18541. pickInfo: Nullable<PickingInfo>);
  18542. }
  18543. /**
  18544. * Data relating to a touch event on the screen.
  18545. */
  18546. export interface PointerTouch {
  18547. /**
  18548. * X coordinate of touch.
  18549. */
  18550. x: number;
  18551. /**
  18552. * Y coordinate of touch.
  18553. */
  18554. y: number;
  18555. /**
  18556. * Id of touch. Unique for each finger.
  18557. */
  18558. pointerId: number;
  18559. /**
  18560. * Event type passed from DOM.
  18561. */
  18562. type: any;
  18563. }
  18564. }
  18565. declare module BABYLON {
  18566. /**
  18567. * Manage the mouse inputs to control the movement of a free camera.
  18568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18569. */
  18570. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18571. /**
  18572. * Define if touch is enabled in the mouse input
  18573. */
  18574. touchEnabled: boolean;
  18575. /**
  18576. * Defines the camera the input is attached to.
  18577. */
  18578. camera: FreeCamera;
  18579. /**
  18580. * Defines the buttons associated with the input to handle camera move.
  18581. */
  18582. buttons: number[];
  18583. /**
  18584. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18585. */
  18586. angularSensibility: number;
  18587. private _pointerInput;
  18588. private _onMouseMove;
  18589. private _observer;
  18590. private previousPosition;
  18591. /**
  18592. * Observable for when a pointer move event occurs containing the move offset
  18593. */
  18594. onPointerMovedObservable: Observable<{
  18595. offsetX: number;
  18596. offsetY: number;
  18597. }>;
  18598. /**
  18599. * @hidden
  18600. * If the camera should be rotated automatically based on pointer movement
  18601. */
  18602. _allowCameraRotation: boolean;
  18603. /**
  18604. * Manage the mouse inputs to control the movement of a free camera.
  18605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18606. * @param touchEnabled Defines if touch is enabled or not
  18607. */
  18608. constructor(
  18609. /**
  18610. * Define if touch is enabled in the mouse input
  18611. */
  18612. touchEnabled?: boolean);
  18613. /**
  18614. * Attach the input controls to a specific dom element to get the input from.
  18615. * @param element Defines the element the controls should be listened from
  18616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18617. */
  18618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18619. /**
  18620. * Called on JS contextmenu event.
  18621. * Override this method to provide functionality.
  18622. */
  18623. protected onContextMenu(evt: PointerEvent): void;
  18624. /**
  18625. * Detach the current controls from the specified dom element.
  18626. * @param element Defines the element to stop listening the inputs from
  18627. */
  18628. detachControl(element: Nullable<HTMLElement>): void;
  18629. /**
  18630. * Gets the class name of the current intput.
  18631. * @returns the class name
  18632. */
  18633. getClassName(): string;
  18634. /**
  18635. * Get the friendly name associated with the input class.
  18636. * @returns the input friendly name
  18637. */
  18638. getSimpleName(): string;
  18639. }
  18640. }
  18641. declare module BABYLON {
  18642. /**
  18643. * Manage the touch inputs to control the movement of a free camera.
  18644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18645. */
  18646. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18647. /**
  18648. * Defines the camera the input is attached to.
  18649. */
  18650. camera: FreeCamera;
  18651. /**
  18652. * Defines the touch sensibility for rotation.
  18653. * The higher the faster.
  18654. */
  18655. touchAngularSensibility: number;
  18656. /**
  18657. * Defines the touch sensibility for move.
  18658. * The higher the faster.
  18659. */
  18660. touchMoveSensibility: number;
  18661. private _offsetX;
  18662. private _offsetY;
  18663. private _pointerPressed;
  18664. private _pointerInput;
  18665. private _observer;
  18666. private _onLostFocus;
  18667. /**
  18668. * Attach the input controls to a specific dom element to get the input from.
  18669. * @param element Defines the element the controls should be listened from
  18670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18671. */
  18672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18673. /**
  18674. * Detach the current controls from the specified dom element.
  18675. * @param element Defines the element to stop listening the inputs from
  18676. */
  18677. detachControl(element: Nullable<HTMLElement>): void;
  18678. /**
  18679. * Update the current camera state depending on the inputs that have been used this frame.
  18680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18681. */
  18682. checkInputs(): void;
  18683. /**
  18684. * Gets the class name of the current intput.
  18685. * @returns the class name
  18686. */
  18687. getClassName(): string;
  18688. /**
  18689. * Get the friendly name associated with the input class.
  18690. * @returns the input friendly name
  18691. */
  18692. getSimpleName(): string;
  18693. }
  18694. }
  18695. declare module BABYLON {
  18696. /**
  18697. * Default Inputs manager for the FreeCamera.
  18698. * It groups all the default supported inputs for ease of use.
  18699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18700. */
  18701. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18702. /**
  18703. * @hidden
  18704. */
  18705. _mouseInput: Nullable<FreeCameraMouseInput>;
  18706. /**
  18707. * Instantiates a new FreeCameraInputsManager.
  18708. * @param camera Defines the camera the inputs belong to
  18709. */
  18710. constructor(camera: FreeCamera);
  18711. /**
  18712. * Add keyboard input support to the input manager.
  18713. * @returns the current input manager
  18714. */
  18715. addKeyboard(): FreeCameraInputsManager;
  18716. /**
  18717. * Add mouse input support to the input manager.
  18718. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18719. * @returns the current input manager
  18720. */
  18721. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18722. /**
  18723. * Removes the mouse input support from the manager
  18724. * @returns the current input manager
  18725. */
  18726. removeMouse(): FreeCameraInputsManager;
  18727. /**
  18728. * Add touch input support to the input manager.
  18729. * @returns the current input manager
  18730. */
  18731. addTouch(): FreeCameraInputsManager;
  18732. /**
  18733. * Remove all attached input methods from a camera
  18734. */
  18735. clear(): void;
  18736. }
  18737. }
  18738. declare module BABYLON {
  18739. /**
  18740. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18741. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18742. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18743. */
  18744. export class FreeCamera extends TargetCamera {
  18745. /**
  18746. * Define the collision ellipsoid of the camera.
  18747. * This is helpful to simulate a camera body like the player body around the camera
  18748. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18749. */
  18750. ellipsoid: Vector3;
  18751. /**
  18752. * Define an offset for the position of the ellipsoid around the camera.
  18753. * This can be helpful to determine the center of the body near the gravity center of the body
  18754. * instead of its head.
  18755. */
  18756. ellipsoidOffset: Vector3;
  18757. /**
  18758. * Enable or disable collisions of the camera with the rest of the scene objects.
  18759. */
  18760. checkCollisions: boolean;
  18761. /**
  18762. * Enable or disable gravity on the camera.
  18763. */
  18764. applyGravity: boolean;
  18765. /**
  18766. * Define the input manager associated to the camera.
  18767. */
  18768. inputs: FreeCameraInputsManager;
  18769. /**
  18770. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18771. * Higher values reduce sensitivity.
  18772. */
  18773. get angularSensibility(): number;
  18774. /**
  18775. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18776. * Higher values reduce sensitivity.
  18777. */
  18778. set angularSensibility(value: number);
  18779. /**
  18780. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18781. */
  18782. get keysUp(): number[];
  18783. set keysUp(value: number[]);
  18784. /**
  18785. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18786. */
  18787. get keysUpward(): number[];
  18788. set keysUpward(value: number[]);
  18789. /**
  18790. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18791. */
  18792. get keysDown(): number[];
  18793. set keysDown(value: number[]);
  18794. /**
  18795. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18796. */
  18797. get keysDownward(): number[];
  18798. set keysDownward(value: number[]);
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18801. */
  18802. get keysLeft(): number[];
  18803. set keysLeft(value: number[]);
  18804. /**
  18805. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18806. */
  18807. get keysRight(): number[];
  18808. set keysRight(value: number[]);
  18809. /**
  18810. * Event raised when the camera collide with a mesh in the scene.
  18811. */
  18812. onCollide: (collidedMesh: AbstractMesh) => void;
  18813. private _collider;
  18814. private _needMoveForGravity;
  18815. private _oldPosition;
  18816. private _diffPosition;
  18817. private _newPosition;
  18818. /** @hidden */
  18819. _localDirection: Vector3;
  18820. /** @hidden */
  18821. _transformedDirection: Vector3;
  18822. /**
  18823. * Instantiates a Free Camera.
  18824. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18825. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18827. * @param name Define the name of the camera in the scene
  18828. * @param position Define the start position of the camera in the scene
  18829. * @param scene Define the scene the camera belongs to
  18830. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18831. */
  18832. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18833. /**
  18834. * Attached controls to the current camera.
  18835. * @param element Defines the element the controls should be listened from
  18836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18837. */
  18838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18839. /**
  18840. * Detach the current controls from the camera.
  18841. * The camera will stop reacting to inputs.
  18842. * @param element Defines the element to stop listening the inputs from
  18843. */
  18844. detachControl(element: HTMLElement): void;
  18845. private _collisionMask;
  18846. /**
  18847. * Define a collision mask to limit the list of object the camera can collide with
  18848. */
  18849. get collisionMask(): number;
  18850. set collisionMask(mask: number);
  18851. /** @hidden */
  18852. _collideWithWorld(displacement: Vector3): void;
  18853. private _onCollisionPositionChange;
  18854. /** @hidden */
  18855. _checkInputs(): void;
  18856. /** @hidden */
  18857. _decideIfNeedsToMove(): boolean;
  18858. /** @hidden */
  18859. _updatePosition(): void;
  18860. /**
  18861. * Destroy the camera and release the current resources hold by it.
  18862. */
  18863. dispose(): void;
  18864. /**
  18865. * Gets the current object class name.
  18866. * @return the class name
  18867. */
  18868. getClassName(): string;
  18869. }
  18870. }
  18871. declare module BABYLON {
  18872. /**
  18873. * Represents a gamepad control stick position
  18874. */
  18875. export class StickValues {
  18876. /**
  18877. * The x component of the control stick
  18878. */
  18879. x: number;
  18880. /**
  18881. * The y component of the control stick
  18882. */
  18883. y: number;
  18884. /**
  18885. * Initializes the gamepad x and y control stick values
  18886. * @param x The x component of the gamepad control stick value
  18887. * @param y The y component of the gamepad control stick value
  18888. */
  18889. constructor(
  18890. /**
  18891. * The x component of the control stick
  18892. */
  18893. x: number,
  18894. /**
  18895. * The y component of the control stick
  18896. */
  18897. y: number);
  18898. }
  18899. /**
  18900. * An interface which manages callbacks for gamepad button changes
  18901. */
  18902. export interface GamepadButtonChanges {
  18903. /**
  18904. * Called when a gamepad has been changed
  18905. */
  18906. changed: boolean;
  18907. /**
  18908. * Called when a gamepad press event has been triggered
  18909. */
  18910. pressChanged: boolean;
  18911. /**
  18912. * Called when a touch event has been triggered
  18913. */
  18914. touchChanged: boolean;
  18915. /**
  18916. * Called when a value has changed
  18917. */
  18918. valueChanged: boolean;
  18919. }
  18920. /**
  18921. * Represents a gamepad
  18922. */
  18923. export class Gamepad {
  18924. /**
  18925. * The id of the gamepad
  18926. */
  18927. id: string;
  18928. /**
  18929. * The index of the gamepad
  18930. */
  18931. index: number;
  18932. /**
  18933. * The browser gamepad
  18934. */
  18935. browserGamepad: any;
  18936. /**
  18937. * Specifies what type of gamepad this represents
  18938. */
  18939. type: number;
  18940. private _leftStick;
  18941. private _rightStick;
  18942. /** @hidden */
  18943. _isConnected: boolean;
  18944. private _leftStickAxisX;
  18945. private _leftStickAxisY;
  18946. private _rightStickAxisX;
  18947. private _rightStickAxisY;
  18948. /**
  18949. * Triggered when the left control stick has been changed
  18950. */
  18951. private _onleftstickchanged;
  18952. /**
  18953. * Triggered when the right control stick has been changed
  18954. */
  18955. private _onrightstickchanged;
  18956. /**
  18957. * Represents a gamepad controller
  18958. */
  18959. static GAMEPAD: number;
  18960. /**
  18961. * Represents a generic controller
  18962. */
  18963. static GENERIC: number;
  18964. /**
  18965. * Represents an XBox controller
  18966. */
  18967. static XBOX: number;
  18968. /**
  18969. * Represents a pose-enabled controller
  18970. */
  18971. static POSE_ENABLED: number;
  18972. /**
  18973. * Represents an Dual Shock controller
  18974. */
  18975. static DUALSHOCK: number;
  18976. /**
  18977. * Specifies whether the left control stick should be Y-inverted
  18978. */
  18979. protected _invertLeftStickY: boolean;
  18980. /**
  18981. * Specifies if the gamepad has been connected
  18982. */
  18983. get isConnected(): boolean;
  18984. /**
  18985. * Initializes the gamepad
  18986. * @param id The id of the gamepad
  18987. * @param index The index of the gamepad
  18988. * @param browserGamepad The browser gamepad
  18989. * @param leftStickX The x component of the left joystick
  18990. * @param leftStickY The y component of the left joystick
  18991. * @param rightStickX The x component of the right joystick
  18992. * @param rightStickY The y component of the right joystick
  18993. */
  18994. constructor(
  18995. /**
  18996. * The id of the gamepad
  18997. */
  18998. id: string,
  18999. /**
  19000. * The index of the gamepad
  19001. */
  19002. index: number,
  19003. /**
  19004. * The browser gamepad
  19005. */
  19006. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19007. /**
  19008. * Callback triggered when the left joystick has changed
  19009. * @param callback
  19010. */
  19011. onleftstickchanged(callback: (values: StickValues) => void): void;
  19012. /**
  19013. * Callback triggered when the right joystick has changed
  19014. * @param callback
  19015. */
  19016. onrightstickchanged(callback: (values: StickValues) => void): void;
  19017. /**
  19018. * Gets the left joystick
  19019. */
  19020. get leftStick(): StickValues;
  19021. /**
  19022. * Sets the left joystick values
  19023. */
  19024. set leftStick(newValues: StickValues);
  19025. /**
  19026. * Gets the right joystick
  19027. */
  19028. get rightStick(): StickValues;
  19029. /**
  19030. * Sets the right joystick value
  19031. */
  19032. set rightStick(newValues: StickValues);
  19033. /**
  19034. * Updates the gamepad joystick positions
  19035. */
  19036. update(): void;
  19037. /**
  19038. * Disposes the gamepad
  19039. */
  19040. dispose(): void;
  19041. }
  19042. /**
  19043. * Represents a generic gamepad
  19044. */
  19045. export class GenericPad extends Gamepad {
  19046. private _buttons;
  19047. private _onbuttondown;
  19048. private _onbuttonup;
  19049. /**
  19050. * Observable triggered when a button has been pressed
  19051. */
  19052. onButtonDownObservable: Observable<number>;
  19053. /**
  19054. * Observable triggered when a button has been released
  19055. */
  19056. onButtonUpObservable: Observable<number>;
  19057. /**
  19058. * Callback triggered when a button has been pressed
  19059. * @param callback Called when a button has been pressed
  19060. */
  19061. onbuttondown(callback: (buttonPressed: number) => void): void;
  19062. /**
  19063. * Callback triggered when a button has been released
  19064. * @param callback Called when a button has been released
  19065. */
  19066. onbuttonup(callback: (buttonReleased: number) => void): void;
  19067. /**
  19068. * Initializes the generic gamepad
  19069. * @param id The id of the generic gamepad
  19070. * @param index The index of the generic gamepad
  19071. * @param browserGamepad The browser gamepad
  19072. */
  19073. constructor(id: string, index: number, browserGamepad: any);
  19074. private _setButtonValue;
  19075. /**
  19076. * Updates the generic gamepad
  19077. */
  19078. update(): void;
  19079. /**
  19080. * Disposes the generic gamepad
  19081. */
  19082. dispose(): void;
  19083. }
  19084. }
  19085. declare module BABYLON {
  19086. /**
  19087. * Defines the types of pose enabled controllers that are supported
  19088. */
  19089. export enum PoseEnabledControllerType {
  19090. /**
  19091. * HTC Vive
  19092. */
  19093. VIVE = 0,
  19094. /**
  19095. * Oculus Rift
  19096. */
  19097. OCULUS = 1,
  19098. /**
  19099. * Windows mixed reality
  19100. */
  19101. WINDOWS = 2,
  19102. /**
  19103. * Samsung gear VR
  19104. */
  19105. GEAR_VR = 3,
  19106. /**
  19107. * Google Daydream
  19108. */
  19109. DAYDREAM = 4,
  19110. /**
  19111. * Generic
  19112. */
  19113. GENERIC = 5
  19114. }
  19115. /**
  19116. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19117. */
  19118. export interface MutableGamepadButton {
  19119. /**
  19120. * Value of the button/trigger
  19121. */
  19122. value: number;
  19123. /**
  19124. * If the button/trigger is currently touched
  19125. */
  19126. touched: boolean;
  19127. /**
  19128. * If the button/trigger is currently pressed
  19129. */
  19130. pressed: boolean;
  19131. }
  19132. /**
  19133. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19134. * @hidden
  19135. */
  19136. export interface ExtendedGamepadButton extends GamepadButton {
  19137. /**
  19138. * If the button/trigger is currently pressed
  19139. */
  19140. readonly pressed: boolean;
  19141. /**
  19142. * If the button/trigger is currently touched
  19143. */
  19144. readonly touched: boolean;
  19145. /**
  19146. * Value of the button/trigger
  19147. */
  19148. readonly value: number;
  19149. }
  19150. /** @hidden */
  19151. export interface _GamePadFactory {
  19152. /**
  19153. * Returns whether or not the current gamepad can be created for this type of controller.
  19154. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19155. * @returns true if it can be created, otherwise false
  19156. */
  19157. canCreate(gamepadInfo: any): boolean;
  19158. /**
  19159. * Creates a new instance of the Gamepad.
  19160. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19161. * @returns the new gamepad instance
  19162. */
  19163. create(gamepadInfo: any): Gamepad;
  19164. }
  19165. /**
  19166. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19167. */
  19168. export class PoseEnabledControllerHelper {
  19169. /** @hidden */
  19170. static _ControllerFactories: _GamePadFactory[];
  19171. /** @hidden */
  19172. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19173. /**
  19174. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19175. * @param vrGamepad the gamepad to initialized
  19176. * @returns a vr controller of the type the gamepad identified as
  19177. */
  19178. static InitiateController(vrGamepad: any): Gamepad;
  19179. }
  19180. /**
  19181. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19182. */
  19183. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19184. /**
  19185. * If the controller is used in a webXR session
  19186. */
  19187. isXR: boolean;
  19188. private _deviceRoomPosition;
  19189. private _deviceRoomRotationQuaternion;
  19190. /**
  19191. * The device position in babylon space
  19192. */
  19193. devicePosition: Vector3;
  19194. /**
  19195. * The device rotation in babylon space
  19196. */
  19197. deviceRotationQuaternion: Quaternion;
  19198. /**
  19199. * The scale factor of the device in babylon space
  19200. */
  19201. deviceScaleFactor: number;
  19202. /**
  19203. * (Likely devicePosition should be used instead) The device position in its room space
  19204. */
  19205. position: Vector3;
  19206. /**
  19207. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19208. */
  19209. rotationQuaternion: Quaternion;
  19210. /**
  19211. * The type of controller (Eg. Windows mixed reality)
  19212. */
  19213. controllerType: PoseEnabledControllerType;
  19214. protected _calculatedPosition: Vector3;
  19215. private _calculatedRotation;
  19216. /**
  19217. * The raw pose from the device
  19218. */
  19219. rawPose: DevicePose;
  19220. private _trackPosition;
  19221. private _maxRotationDistFromHeadset;
  19222. private _draggedRoomRotation;
  19223. /**
  19224. * @hidden
  19225. */
  19226. _disableTrackPosition(fixedPosition: Vector3): void;
  19227. /**
  19228. * Internal, the mesh attached to the controller
  19229. * @hidden
  19230. */
  19231. _mesh: Nullable<AbstractMesh>;
  19232. private _poseControlledCamera;
  19233. private _leftHandSystemQuaternion;
  19234. /**
  19235. * Internal, matrix used to convert room space to babylon space
  19236. * @hidden
  19237. */
  19238. _deviceToWorld: Matrix;
  19239. /**
  19240. * Node to be used when casting a ray from the controller
  19241. * @hidden
  19242. */
  19243. _pointingPoseNode: Nullable<TransformNode>;
  19244. /**
  19245. * Name of the child mesh that can be used to cast a ray from the controller
  19246. */
  19247. static readonly POINTING_POSE: string;
  19248. /**
  19249. * Creates a new PoseEnabledController from a gamepad
  19250. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19251. */
  19252. constructor(browserGamepad: any);
  19253. private _workingMatrix;
  19254. /**
  19255. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19256. */
  19257. update(): void;
  19258. /**
  19259. * Updates only the pose device and mesh without doing any button event checking
  19260. */
  19261. protected _updatePoseAndMesh(): void;
  19262. /**
  19263. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19264. * @param poseData raw pose fromthe device
  19265. */
  19266. updateFromDevice(poseData: DevicePose): void;
  19267. /**
  19268. * @hidden
  19269. */
  19270. _meshAttachedObservable: Observable<AbstractMesh>;
  19271. /**
  19272. * Attaches a mesh to the controller
  19273. * @param mesh the mesh to be attached
  19274. */
  19275. attachToMesh(mesh: AbstractMesh): void;
  19276. /**
  19277. * Attaches the controllers mesh to a camera
  19278. * @param camera the camera the mesh should be attached to
  19279. */
  19280. attachToPoseControlledCamera(camera: TargetCamera): void;
  19281. /**
  19282. * Disposes of the controller
  19283. */
  19284. dispose(): void;
  19285. /**
  19286. * The mesh that is attached to the controller
  19287. */
  19288. get mesh(): Nullable<AbstractMesh>;
  19289. /**
  19290. * Gets the ray of the controller in the direction the controller is pointing
  19291. * @param length the length the resulting ray should be
  19292. * @returns a ray in the direction the controller is pointing
  19293. */
  19294. getForwardRay(length?: number): Ray;
  19295. }
  19296. }
  19297. declare module BABYLON {
  19298. /**
  19299. * Defines the WebVRController object that represents controllers tracked in 3D space
  19300. */
  19301. export abstract class WebVRController extends PoseEnabledController {
  19302. /**
  19303. * Internal, the default controller model for the controller
  19304. */
  19305. protected _defaultModel: Nullable<AbstractMesh>;
  19306. /**
  19307. * Fired when the trigger state has changed
  19308. */
  19309. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19310. /**
  19311. * Fired when the main button state has changed
  19312. */
  19313. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19314. /**
  19315. * Fired when the secondary button state has changed
  19316. */
  19317. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19318. /**
  19319. * Fired when the pad state has changed
  19320. */
  19321. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19322. /**
  19323. * Fired when controllers stick values have changed
  19324. */
  19325. onPadValuesChangedObservable: Observable<StickValues>;
  19326. /**
  19327. * Array of button availible on the controller
  19328. */
  19329. protected _buttons: Array<MutableGamepadButton>;
  19330. private _onButtonStateChange;
  19331. /**
  19332. * Fired when a controller button's state has changed
  19333. * @param callback the callback containing the button that was modified
  19334. */
  19335. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19336. /**
  19337. * X and Y axis corresponding to the controllers joystick
  19338. */
  19339. pad: StickValues;
  19340. /**
  19341. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19342. */
  19343. hand: string;
  19344. /**
  19345. * The default controller model for the controller
  19346. */
  19347. get defaultModel(): Nullable<AbstractMesh>;
  19348. /**
  19349. * Creates a new WebVRController from a gamepad
  19350. * @param vrGamepad the gamepad that the WebVRController should be created from
  19351. */
  19352. constructor(vrGamepad: any);
  19353. /**
  19354. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19355. */
  19356. update(): void;
  19357. /**
  19358. * Function to be called when a button is modified
  19359. */
  19360. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19361. /**
  19362. * Loads a mesh and attaches it to the controller
  19363. * @param scene the scene the mesh should be added to
  19364. * @param meshLoaded callback for when the mesh has been loaded
  19365. */
  19366. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19367. private _setButtonValue;
  19368. private _changes;
  19369. private _checkChanges;
  19370. /**
  19371. * Disposes of th webVRCOntroller
  19372. */
  19373. dispose(): void;
  19374. }
  19375. }
  19376. declare module BABYLON {
  19377. /**
  19378. * The HemisphericLight simulates the ambient environment light,
  19379. * so the passed direction is the light reflection direction, not the incoming direction.
  19380. */
  19381. export class HemisphericLight extends Light {
  19382. /**
  19383. * The groundColor is the light in the opposite direction to the one specified during creation.
  19384. * 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.
  19385. */
  19386. groundColor: Color3;
  19387. /**
  19388. * The light reflection direction, not the incoming direction.
  19389. */
  19390. direction: Vector3;
  19391. /**
  19392. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19393. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19394. * The HemisphericLight can't cast shadows.
  19395. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19396. * @param name The friendly name of the light
  19397. * @param direction The direction of the light reflection
  19398. * @param scene The scene the light belongs to
  19399. */
  19400. constructor(name: string, direction: Vector3, scene: Scene);
  19401. protected _buildUniformLayout(): void;
  19402. /**
  19403. * Returns the string "HemisphericLight".
  19404. * @return The class name
  19405. */
  19406. getClassName(): string;
  19407. /**
  19408. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19409. * Returns the updated direction.
  19410. * @param target The target the direction should point to
  19411. * @return The computed direction
  19412. */
  19413. setDirectionToTarget(target: Vector3): Vector3;
  19414. /**
  19415. * Returns the shadow generator associated to the light.
  19416. * @returns Always null for hemispheric lights because it does not support shadows.
  19417. */
  19418. getShadowGenerator(): Nullable<IShadowGenerator>;
  19419. /**
  19420. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19421. * @param effect The effect to update
  19422. * @param lightIndex The index of the light in the effect to update
  19423. * @returns The hemispheric light
  19424. */
  19425. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19426. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19427. /**
  19428. * Computes the world matrix of the node
  19429. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19430. * @param useWasUpdatedFlag defines a reserved property
  19431. * @returns the world matrix
  19432. */
  19433. computeWorldMatrix(): Matrix;
  19434. /**
  19435. * Returns the integer 3.
  19436. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19437. */
  19438. getTypeID(): number;
  19439. /**
  19440. * Prepares the list of defines specific to the light type.
  19441. * @param defines the list of defines
  19442. * @param lightIndex defines the index of the light for the effect
  19443. */
  19444. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19445. }
  19446. }
  19447. declare module BABYLON {
  19448. /** @hidden */
  19449. export var vrMultiviewToSingleviewPixelShader: {
  19450. name: string;
  19451. shader: string;
  19452. };
  19453. }
  19454. declare module BABYLON {
  19455. /**
  19456. * Renders to multiple views with a single draw call
  19457. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19458. */
  19459. export class MultiviewRenderTarget extends RenderTargetTexture {
  19460. /**
  19461. * Creates a multiview render target
  19462. * @param scene scene used with the render target
  19463. * @param size the size of the render target (used for each view)
  19464. */
  19465. constructor(scene: Scene, size?: number | {
  19466. width: number;
  19467. height: number;
  19468. } | {
  19469. ratio: number;
  19470. });
  19471. /**
  19472. * @hidden
  19473. * @param faceIndex the face index, if its a cube texture
  19474. */
  19475. _bindFrameBuffer(faceIndex?: number): void;
  19476. /**
  19477. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19478. * @returns the view count
  19479. */
  19480. getViewCount(): number;
  19481. }
  19482. }
  19483. declare module BABYLON {
  19484. interface Engine {
  19485. /**
  19486. * Creates a new multiview render target
  19487. * @param width defines the width of the texture
  19488. * @param height defines the height of the texture
  19489. * @returns the created multiview texture
  19490. */
  19491. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19492. /**
  19493. * Binds a multiview framebuffer to be drawn to
  19494. * @param multiviewTexture texture to bind
  19495. */
  19496. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19497. }
  19498. interface Camera {
  19499. /**
  19500. * @hidden
  19501. * 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)
  19502. */
  19503. _useMultiviewToSingleView: boolean;
  19504. /**
  19505. * @hidden
  19506. * 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)
  19507. */
  19508. _multiviewTexture: Nullable<RenderTargetTexture>;
  19509. /**
  19510. * @hidden
  19511. * ensures the multiview texture of the camera exists and has the specified width/height
  19512. * @param width height to set on the multiview texture
  19513. * @param height width to set on the multiview texture
  19514. */
  19515. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19516. }
  19517. interface Scene {
  19518. /** @hidden */
  19519. _transformMatrixR: Matrix;
  19520. /** @hidden */
  19521. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19522. /** @hidden */
  19523. _createMultiviewUbo(): void;
  19524. /** @hidden */
  19525. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19526. /** @hidden */
  19527. _renderMultiviewToSingleView(camera: Camera): void;
  19528. }
  19529. }
  19530. declare module BABYLON {
  19531. /**
  19532. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19533. * This will not be used for webXR as it supports displaying texture arrays directly
  19534. */
  19535. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19536. /**
  19537. * Initializes a VRMultiviewToSingleview
  19538. * @param name name of the post process
  19539. * @param camera camera to be applied to
  19540. * @param scaleFactor scaling factor to the size of the output texture
  19541. */
  19542. constructor(name: string, camera: Camera, scaleFactor: number);
  19543. }
  19544. }
  19545. declare module BABYLON {
  19546. /**
  19547. * Interface used to define additional presentation attributes
  19548. */
  19549. export interface IVRPresentationAttributes {
  19550. /**
  19551. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19552. */
  19553. highRefreshRate: boolean;
  19554. /**
  19555. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19556. */
  19557. foveationLevel: number;
  19558. }
  19559. interface Engine {
  19560. /** @hidden */
  19561. _vrDisplay: any;
  19562. /** @hidden */
  19563. _vrSupported: boolean;
  19564. /** @hidden */
  19565. _oldSize: Size;
  19566. /** @hidden */
  19567. _oldHardwareScaleFactor: number;
  19568. /** @hidden */
  19569. _vrExclusivePointerMode: boolean;
  19570. /** @hidden */
  19571. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19572. /** @hidden */
  19573. _onVRDisplayPointerRestricted: () => void;
  19574. /** @hidden */
  19575. _onVRDisplayPointerUnrestricted: () => void;
  19576. /** @hidden */
  19577. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19578. /** @hidden */
  19579. _onVrDisplayDisconnect: Nullable<() => void>;
  19580. /** @hidden */
  19581. _onVrDisplayPresentChange: Nullable<() => void>;
  19582. /**
  19583. * Observable signaled when VR display mode changes
  19584. */
  19585. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19586. /**
  19587. * Observable signaled when VR request present is complete
  19588. */
  19589. onVRRequestPresentComplete: Observable<boolean>;
  19590. /**
  19591. * Observable signaled when VR request present starts
  19592. */
  19593. onVRRequestPresentStart: Observable<Engine>;
  19594. /**
  19595. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19596. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19597. */
  19598. isInVRExclusivePointerMode: boolean;
  19599. /**
  19600. * Gets a boolean indicating if a webVR device was detected
  19601. * @returns true if a webVR device was detected
  19602. */
  19603. isVRDevicePresent(): boolean;
  19604. /**
  19605. * Gets the current webVR device
  19606. * @returns the current webVR device (or null)
  19607. */
  19608. getVRDevice(): any;
  19609. /**
  19610. * Initializes a webVR display and starts listening to display change events
  19611. * The onVRDisplayChangedObservable will be notified upon these changes
  19612. * @returns A promise containing a VRDisplay and if vr is supported
  19613. */
  19614. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19615. /** @hidden */
  19616. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19617. /**
  19618. * Gets or sets the presentation attributes used to configure VR rendering
  19619. */
  19620. vrPresentationAttributes?: IVRPresentationAttributes;
  19621. /**
  19622. * Call this function to switch to webVR mode
  19623. * Will do nothing if webVR is not supported or if there is no webVR device
  19624. * @param options the webvr options provided to the camera. mainly used for multiview
  19625. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19626. */
  19627. enableVR(options: WebVROptions): void;
  19628. /** @hidden */
  19629. _onVRFullScreenTriggered(): void;
  19630. }
  19631. }
  19632. declare module BABYLON {
  19633. /**
  19634. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19635. * IMPORTANT!! The data is right-hand data.
  19636. * @export
  19637. * @interface DevicePose
  19638. */
  19639. export interface DevicePose {
  19640. /**
  19641. * The position of the device, values in array are [x,y,z].
  19642. */
  19643. readonly position: Nullable<Float32Array>;
  19644. /**
  19645. * The linearVelocity of the device, values in array are [x,y,z].
  19646. */
  19647. readonly linearVelocity: Nullable<Float32Array>;
  19648. /**
  19649. * The linearAcceleration of the device, values in array are [x,y,z].
  19650. */
  19651. readonly linearAcceleration: Nullable<Float32Array>;
  19652. /**
  19653. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19654. */
  19655. readonly orientation: Nullable<Float32Array>;
  19656. /**
  19657. * The angularVelocity of the device, values in array are [x,y,z].
  19658. */
  19659. readonly angularVelocity: Nullable<Float32Array>;
  19660. /**
  19661. * The angularAcceleration of the device, values in array are [x,y,z].
  19662. */
  19663. readonly angularAcceleration: Nullable<Float32Array>;
  19664. }
  19665. /**
  19666. * Interface representing a pose controlled object in Babylon.
  19667. * A pose controlled object has both regular pose values as well as pose values
  19668. * from an external device such as a VR head mounted display
  19669. */
  19670. export interface PoseControlled {
  19671. /**
  19672. * The position of the object in babylon space.
  19673. */
  19674. position: Vector3;
  19675. /**
  19676. * The rotation quaternion of the object in babylon space.
  19677. */
  19678. rotationQuaternion: Quaternion;
  19679. /**
  19680. * The position of the device in babylon space.
  19681. */
  19682. devicePosition?: Vector3;
  19683. /**
  19684. * The rotation quaternion of the device in babylon space.
  19685. */
  19686. deviceRotationQuaternion: Quaternion;
  19687. /**
  19688. * The raw pose coming from the device.
  19689. */
  19690. rawPose: Nullable<DevicePose>;
  19691. /**
  19692. * The scale of the device to be used when translating from device space to babylon space.
  19693. */
  19694. deviceScaleFactor: number;
  19695. /**
  19696. * Updates the poseControlled values based on the input device pose.
  19697. * @param poseData the pose data to update the object with
  19698. */
  19699. updateFromDevice(poseData: DevicePose): void;
  19700. }
  19701. /**
  19702. * Set of options to customize the webVRCamera
  19703. */
  19704. export interface WebVROptions {
  19705. /**
  19706. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19707. */
  19708. trackPosition?: boolean;
  19709. /**
  19710. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19711. */
  19712. positionScale?: number;
  19713. /**
  19714. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19715. */
  19716. displayName?: string;
  19717. /**
  19718. * Should the native controller meshes be initialized. (default: true)
  19719. */
  19720. controllerMeshes?: boolean;
  19721. /**
  19722. * Creating a default HemiLight only on controllers. (default: true)
  19723. */
  19724. defaultLightingOnControllers?: boolean;
  19725. /**
  19726. * If you don't want to use the default VR button of the helper. (default: false)
  19727. */
  19728. useCustomVRButton?: boolean;
  19729. /**
  19730. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19731. */
  19732. customVRButton?: HTMLButtonElement;
  19733. /**
  19734. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19735. */
  19736. rayLength?: number;
  19737. /**
  19738. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19739. */
  19740. defaultHeight?: number;
  19741. /**
  19742. * If multiview should be used if availible (default: false)
  19743. */
  19744. useMultiview?: boolean;
  19745. }
  19746. /**
  19747. * This represents a WebVR camera.
  19748. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19749. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19750. */
  19751. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19752. private webVROptions;
  19753. /**
  19754. * @hidden
  19755. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19756. */
  19757. _vrDevice: any;
  19758. /**
  19759. * The rawPose of the vrDevice.
  19760. */
  19761. rawPose: Nullable<DevicePose>;
  19762. private _onVREnabled;
  19763. private _specsVersion;
  19764. private _attached;
  19765. private _frameData;
  19766. protected _descendants: Array<Node>;
  19767. private _deviceRoomPosition;
  19768. /** @hidden */
  19769. _deviceRoomRotationQuaternion: Quaternion;
  19770. private _standingMatrix;
  19771. /**
  19772. * Represents device position in babylon space.
  19773. */
  19774. devicePosition: Vector3;
  19775. /**
  19776. * Represents device rotation in babylon space.
  19777. */
  19778. deviceRotationQuaternion: Quaternion;
  19779. /**
  19780. * The scale of the device to be used when translating from device space to babylon space.
  19781. */
  19782. deviceScaleFactor: number;
  19783. private _deviceToWorld;
  19784. private _worldToDevice;
  19785. /**
  19786. * References to the webVR controllers for the vrDevice.
  19787. */
  19788. controllers: Array<WebVRController>;
  19789. /**
  19790. * Emits an event when a controller is attached.
  19791. */
  19792. onControllersAttachedObservable: Observable<WebVRController[]>;
  19793. /**
  19794. * Emits an event when a controller's mesh has been loaded;
  19795. */
  19796. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19797. /**
  19798. * Emits an event when the HMD's pose has been updated.
  19799. */
  19800. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19801. private _poseSet;
  19802. /**
  19803. * If the rig cameras be used as parent instead of this camera.
  19804. */
  19805. rigParenting: boolean;
  19806. private _lightOnControllers;
  19807. private _defaultHeight?;
  19808. /**
  19809. * Instantiates a WebVRFreeCamera.
  19810. * @param name The name of the WebVRFreeCamera
  19811. * @param position The starting anchor position for the camera
  19812. * @param scene The scene the camera belongs to
  19813. * @param webVROptions a set of customizable options for the webVRCamera
  19814. */
  19815. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19816. /**
  19817. * Gets the device distance from the ground in meters.
  19818. * @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.
  19819. */
  19820. deviceDistanceToRoomGround(): number;
  19821. /**
  19822. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19823. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19824. */
  19825. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19826. /**
  19827. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19828. * @returns A promise with a boolean set to if the standing matrix is supported.
  19829. */
  19830. useStandingMatrixAsync(): Promise<boolean>;
  19831. /**
  19832. * Disposes the camera
  19833. */
  19834. dispose(): void;
  19835. /**
  19836. * Gets a vrController by name.
  19837. * @param name The name of the controller to retreive
  19838. * @returns the controller matching the name specified or null if not found
  19839. */
  19840. getControllerByName(name: string): Nullable<WebVRController>;
  19841. private _leftController;
  19842. /**
  19843. * The controller corresponding to the users left hand.
  19844. */
  19845. get leftController(): Nullable<WebVRController>;
  19846. private _rightController;
  19847. /**
  19848. * The controller corresponding to the users right hand.
  19849. */
  19850. get rightController(): Nullable<WebVRController>;
  19851. /**
  19852. * Casts a ray forward from the vrCamera's gaze.
  19853. * @param length Length of the ray (default: 100)
  19854. * @returns the ray corresponding to the gaze
  19855. */
  19856. getForwardRay(length?: number): Ray;
  19857. /**
  19858. * @hidden
  19859. * Updates the camera based on device's frame data
  19860. */
  19861. _checkInputs(): void;
  19862. /**
  19863. * Updates the poseControlled values based on the input device pose.
  19864. * @param poseData Pose coming from the device
  19865. */
  19866. updateFromDevice(poseData: DevicePose): void;
  19867. private _htmlElementAttached;
  19868. private _detachIfAttached;
  19869. /**
  19870. * WebVR's attach control will start broadcasting frames to the device.
  19871. * Note that in certain browsers (chrome for example) this function must be called
  19872. * within a user-interaction callback. Example:
  19873. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19874. *
  19875. * @param element html element to attach the vrDevice to
  19876. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19877. */
  19878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19879. /**
  19880. * Detaches the camera from the html element and disables VR
  19881. *
  19882. * @param element html element to detach from
  19883. */
  19884. detachControl(element: HTMLElement): void;
  19885. /**
  19886. * @returns the name of this class
  19887. */
  19888. getClassName(): string;
  19889. /**
  19890. * Calls resetPose on the vrDisplay
  19891. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19892. */
  19893. resetToCurrentRotation(): void;
  19894. /**
  19895. * @hidden
  19896. * Updates the rig cameras (left and right eye)
  19897. */
  19898. _updateRigCameras(): void;
  19899. private _workingVector;
  19900. private _oneVector;
  19901. private _workingMatrix;
  19902. private updateCacheCalled;
  19903. private _correctPositionIfNotTrackPosition;
  19904. /**
  19905. * @hidden
  19906. * Updates the cached values of the camera
  19907. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19908. */
  19909. _updateCache(ignoreParentClass?: boolean): void;
  19910. /**
  19911. * @hidden
  19912. * Get current device position in babylon world
  19913. */
  19914. _computeDevicePosition(): void;
  19915. /**
  19916. * Updates the current device position and rotation in the babylon world
  19917. */
  19918. update(): void;
  19919. /**
  19920. * @hidden
  19921. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19922. * @returns an identity matrix
  19923. */
  19924. _getViewMatrix(): Matrix;
  19925. private _tmpMatrix;
  19926. /**
  19927. * This function is called by the two RIG cameras.
  19928. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19929. * @hidden
  19930. */
  19931. _getWebVRViewMatrix(): Matrix;
  19932. /** @hidden */
  19933. _getWebVRProjectionMatrix(): Matrix;
  19934. private _onGamepadConnectedObserver;
  19935. private _onGamepadDisconnectedObserver;
  19936. private _updateCacheWhenTrackingDisabledObserver;
  19937. /**
  19938. * Initializes the controllers and their meshes
  19939. */
  19940. initControllers(): void;
  19941. }
  19942. }
  19943. declare module BABYLON {
  19944. /**
  19945. * "Static Class" containing the most commonly used helper while dealing with material for
  19946. * rendering purpose.
  19947. *
  19948. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19949. *
  19950. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19951. */
  19952. export class MaterialHelper {
  19953. /**
  19954. * Bind the current view position to an effect.
  19955. * @param effect The effect to be bound
  19956. * @param scene The scene the eyes position is used from
  19957. * @param variableName name of the shader variable that will hold the eye position
  19958. */
  19959. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19960. /**
  19961. * Helps preparing the defines values about the UVs in used in the effect.
  19962. * UVs are shared as much as we can accross channels in the shaders.
  19963. * @param texture The texture we are preparing the UVs for
  19964. * @param defines The defines to update
  19965. * @param key The channel key "diffuse", "specular"... used in the shader
  19966. */
  19967. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19968. /**
  19969. * Binds a texture matrix value to its corrsponding uniform
  19970. * @param texture The texture to bind the matrix for
  19971. * @param uniformBuffer The uniform buffer receivin the data
  19972. * @param key The channel key "diffuse", "specular"... used in the shader
  19973. */
  19974. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19975. /**
  19976. * Gets the current status of the fog (should it be enabled?)
  19977. * @param mesh defines the mesh to evaluate for fog support
  19978. * @param scene defines the hosting scene
  19979. * @returns true if fog must be enabled
  19980. */
  19981. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19982. /**
  19983. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19984. * @param mesh defines the current mesh
  19985. * @param scene defines the current scene
  19986. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19987. * @param pointsCloud defines if point cloud rendering has to be turned on
  19988. * @param fogEnabled defines if fog has to be turned on
  19989. * @param alphaTest defines if alpha testing has to be turned on
  19990. * @param defines defines the current list of defines
  19991. */
  19992. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19993. /**
  19994. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19995. * @param scene defines the current scene
  19996. * @param engine defines the current engine
  19997. * @param defines specifies the list of active defines
  19998. * @param useInstances defines if instances have to be turned on
  19999. * @param useClipPlane defines if clip plane have to be turned on
  20000. */
  20001. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  20002. /**
  20003. * Prepares the defines for bones
  20004. * @param mesh The mesh containing the geometry data we will draw
  20005. * @param defines The defines to update
  20006. */
  20007. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20008. /**
  20009. * Prepares the defines for morph targets
  20010. * @param mesh The mesh containing the geometry data we will draw
  20011. * @param defines The defines to update
  20012. */
  20013. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20014. /**
  20015. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20016. * @param mesh The mesh containing the geometry data we will draw
  20017. * @param defines The defines to update
  20018. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20019. * @param useBones Precise whether bones should be used or not (override mesh info)
  20020. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20021. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20022. * @returns false if defines are considered not dirty and have not been checked
  20023. */
  20024. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20025. /**
  20026. * Prepares the defines related to multiview
  20027. * @param scene The scene we are intending to draw
  20028. * @param defines The defines to update
  20029. */
  20030. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20031. /**
  20032. * Prepares the defines related to the light information passed in parameter
  20033. * @param scene The scene we are intending to draw
  20034. * @param mesh The mesh the effect is compiling for
  20035. * @param light The light the effect is compiling for
  20036. * @param lightIndex The index of the light
  20037. * @param defines The defines to update
  20038. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20039. * @param state Defines the current state regarding what is needed (normals, etc...)
  20040. */
  20041. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20042. needNormals: boolean;
  20043. needRebuild: boolean;
  20044. shadowEnabled: boolean;
  20045. specularEnabled: boolean;
  20046. lightmapMode: boolean;
  20047. }): void;
  20048. /**
  20049. * Prepares the defines related to the light information passed in parameter
  20050. * @param scene The scene we are intending to draw
  20051. * @param mesh The mesh the effect is compiling for
  20052. * @param defines The defines to update
  20053. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20054. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20055. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20056. * @returns true if normals will be required for the rest of the effect
  20057. */
  20058. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20059. /**
  20060. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20061. * @param lightIndex defines the light index
  20062. * @param uniformsList The uniform list
  20063. * @param samplersList The sampler list
  20064. * @param projectedLightTexture defines if projected texture must be used
  20065. * @param uniformBuffersList defines an optional list of uniform buffers
  20066. */
  20067. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20068. /**
  20069. * Prepares the uniforms and samplers list to be used in the effect
  20070. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20071. * @param samplersList The sampler list
  20072. * @param defines The defines helping in the list generation
  20073. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20074. */
  20075. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20076. /**
  20077. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20078. * @param defines The defines to update while falling back
  20079. * @param fallbacks The authorized effect fallbacks
  20080. * @param maxSimultaneousLights The maximum number of lights allowed
  20081. * @param rank the current rank of the Effect
  20082. * @returns The newly affected rank
  20083. */
  20084. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20085. private static _TmpMorphInfluencers;
  20086. /**
  20087. * Prepares the list of attributes required for morph targets according to the effect defines.
  20088. * @param attribs The current list of supported attribs
  20089. * @param mesh The mesh to prepare the morph targets attributes for
  20090. * @param influencers The number of influencers
  20091. */
  20092. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20093. /**
  20094. * Prepares the list of attributes required for morph targets according to the effect defines.
  20095. * @param attribs The current list of supported attribs
  20096. * @param mesh The mesh to prepare the morph targets attributes for
  20097. * @param defines The current Defines of the effect
  20098. */
  20099. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20100. /**
  20101. * Prepares the list of attributes required for bones according to the effect defines.
  20102. * @param attribs The current list of supported attribs
  20103. * @param mesh The mesh to prepare the bones attributes for
  20104. * @param defines The current Defines of the effect
  20105. * @param fallbacks The current efffect fallback strategy
  20106. */
  20107. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20108. /**
  20109. * Check and prepare the list of attributes required for instances according to the effect defines.
  20110. * @param attribs The current list of supported attribs
  20111. * @param defines The current MaterialDefines of the effect
  20112. */
  20113. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20114. /**
  20115. * Add the list of attributes required for instances to the attribs array.
  20116. * @param attribs The current list of supported attribs
  20117. */
  20118. static PushAttributesForInstances(attribs: string[]): void;
  20119. /**
  20120. * Binds the light information to the effect.
  20121. * @param light The light containing the generator
  20122. * @param effect The effect we are binding the data to
  20123. * @param lightIndex The light index in the effect used to render
  20124. */
  20125. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20126. /**
  20127. * Binds the lights information from the scene to the effect for the given mesh.
  20128. * @param light Light to bind
  20129. * @param lightIndex Light index
  20130. * @param scene The scene where the light belongs to
  20131. * @param effect The effect we are binding the data to
  20132. * @param useSpecular Defines if specular is supported
  20133. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20134. */
  20135. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20136. /**
  20137. * Binds the lights information from the scene to the effect for the given mesh.
  20138. * @param scene The scene the lights belongs to
  20139. * @param mesh The mesh we are binding the information to render
  20140. * @param effect The effect we are binding the data to
  20141. * @param defines The generated defines for the effect
  20142. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20143. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20144. */
  20145. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20146. private static _tempFogColor;
  20147. /**
  20148. * Binds the fog information from the scene to the effect for the given mesh.
  20149. * @param scene The scene the lights belongs to
  20150. * @param mesh The mesh we are binding the information to render
  20151. * @param effect The effect we are binding the data to
  20152. * @param linearSpace Defines if the fog effect is applied in linear space
  20153. */
  20154. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20155. /**
  20156. * Binds the bones information from the mesh to the effect.
  20157. * @param mesh The mesh we are binding the information to render
  20158. * @param effect The effect we are binding the data to
  20159. */
  20160. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20161. /**
  20162. * Binds the morph targets information from the mesh to the effect.
  20163. * @param abstractMesh The mesh we are binding the information to render
  20164. * @param effect The effect we are binding the data to
  20165. */
  20166. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20167. /**
  20168. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20169. * @param defines The generated defines used in the effect
  20170. * @param effect The effect we are binding the data to
  20171. * @param scene The scene we are willing to render with logarithmic scale for
  20172. */
  20173. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20174. /**
  20175. * Binds the clip plane information from the scene to the effect.
  20176. * @param scene The scene the clip plane information are extracted from
  20177. * @param effect The effect we are binding the data to
  20178. */
  20179. static BindClipPlane(effect: Effect, scene: Scene): void;
  20180. }
  20181. }
  20182. declare module BABYLON {
  20183. /**
  20184. * Block used to expose an input value
  20185. */
  20186. export class InputBlock extends NodeMaterialBlock {
  20187. private _mode;
  20188. private _associatedVariableName;
  20189. private _storedValue;
  20190. private _valueCallback;
  20191. private _type;
  20192. private _animationType;
  20193. /** Gets or set a value used to limit the range of float values */
  20194. min: number;
  20195. /** Gets or set a value used to limit the range of float values */
  20196. max: number;
  20197. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20198. isBoolean: boolean;
  20199. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20200. matrixMode: number;
  20201. /** @hidden */
  20202. _systemValue: Nullable<NodeMaterialSystemValues>;
  20203. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20204. visibleInInspector: boolean;
  20205. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20206. isConstant: boolean;
  20207. /** Gets or sets the group to use to display this block in the Inspector */
  20208. groupInInspector: string;
  20209. /** Gets an observable raised when the value is changed */
  20210. onValueChangedObservable: Observable<InputBlock>;
  20211. /**
  20212. * Gets or sets the connection point type (default is float)
  20213. */
  20214. get type(): NodeMaterialBlockConnectionPointTypes;
  20215. /**
  20216. * Creates a new InputBlock
  20217. * @param name defines the block name
  20218. * @param target defines the target of that block (Vertex by default)
  20219. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20220. */
  20221. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20222. /**
  20223. * Gets the output component
  20224. */
  20225. get output(): NodeMaterialConnectionPoint;
  20226. /**
  20227. * Set the source of this connection point to a vertex attribute
  20228. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20229. * @returns the current connection point
  20230. */
  20231. setAsAttribute(attributeName?: string): InputBlock;
  20232. /**
  20233. * Set the source of this connection point to a system value
  20234. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20235. * @returns the current connection point
  20236. */
  20237. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20238. /**
  20239. * Gets or sets the value of that point.
  20240. * Please note that this value will be ignored if valueCallback is defined
  20241. */
  20242. get value(): any;
  20243. set value(value: any);
  20244. /**
  20245. * Gets or sets a callback used to get the value of that point.
  20246. * Please note that setting this value will force the connection point to ignore the value property
  20247. */
  20248. get valueCallback(): () => any;
  20249. set valueCallback(value: () => any);
  20250. /**
  20251. * Gets or sets the associated variable name in the shader
  20252. */
  20253. get associatedVariableName(): string;
  20254. set associatedVariableName(value: string);
  20255. /** Gets or sets the type of animation applied to the input */
  20256. get animationType(): AnimatedInputBlockTypes;
  20257. set animationType(value: AnimatedInputBlockTypes);
  20258. /**
  20259. * Gets a boolean indicating that this connection point not defined yet
  20260. */
  20261. get isUndefined(): boolean;
  20262. /**
  20263. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20264. * In this case the connection point name must be the name of the uniform to use.
  20265. * Can only be set on inputs
  20266. */
  20267. get isUniform(): boolean;
  20268. set isUniform(value: boolean);
  20269. /**
  20270. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20271. * In this case the connection point name must be the name of the attribute to use
  20272. * Can only be set on inputs
  20273. */
  20274. get isAttribute(): boolean;
  20275. set isAttribute(value: boolean);
  20276. /**
  20277. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20278. * Can only be set on exit points
  20279. */
  20280. get isVarying(): boolean;
  20281. set isVarying(value: boolean);
  20282. /**
  20283. * Gets a boolean indicating that the current connection point is a system value
  20284. */
  20285. get isSystemValue(): boolean;
  20286. /**
  20287. * Gets or sets the current well known value or null if not defined as a system value
  20288. */
  20289. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20290. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20291. /**
  20292. * Gets the current class name
  20293. * @returns the class name
  20294. */
  20295. getClassName(): string;
  20296. /**
  20297. * Animate the input if animationType !== None
  20298. * @param scene defines the rendering scene
  20299. */
  20300. animate(scene: Scene): void;
  20301. private _emitDefine;
  20302. initialize(state: NodeMaterialBuildState): void;
  20303. /**
  20304. * Set the input block to its default value (based on its type)
  20305. */
  20306. setDefaultValue(): void;
  20307. private _emitConstant;
  20308. /** @hidden */
  20309. get _noContextSwitch(): boolean;
  20310. private _emit;
  20311. /** @hidden */
  20312. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20313. /** @hidden */
  20314. _transmit(effect: Effect, scene: Scene): void;
  20315. protected _buildBlock(state: NodeMaterialBuildState): void;
  20316. protected _dumpPropertiesCode(): string;
  20317. dispose(): void;
  20318. serialize(): any;
  20319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20320. }
  20321. }
  20322. declare module BABYLON {
  20323. /**
  20324. * Enum used to define the compatibility state between two connection points
  20325. */
  20326. export enum NodeMaterialConnectionPointCompatibilityStates {
  20327. /** Points are compatibles */
  20328. Compatible = 0,
  20329. /** Points are incompatible because of their types */
  20330. TypeIncompatible = 1,
  20331. /** Points are incompatible because of their targets (vertex vs fragment) */
  20332. TargetIncompatible = 2
  20333. }
  20334. /**
  20335. * Defines the direction of a connection point
  20336. */
  20337. export enum NodeMaterialConnectionPointDirection {
  20338. /** Input */
  20339. Input = 0,
  20340. /** Output */
  20341. Output = 1
  20342. }
  20343. /**
  20344. * Defines a connection point for a block
  20345. */
  20346. export class NodeMaterialConnectionPoint {
  20347. /** @hidden */
  20348. _ownerBlock: NodeMaterialBlock;
  20349. /** @hidden */
  20350. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20351. private _endpoints;
  20352. private _associatedVariableName;
  20353. private _direction;
  20354. /** @hidden */
  20355. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20356. /** @hidden */
  20357. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20358. private _type;
  20359. /** @hidden */
  20360. _enforceAssociatedVariableName: boolean;
  20361. /** Gets the direction of the point */
  20362. get direction(): NodeMaterialConnectionPointDirection;
  20363. /** Indicates that this connection point needs dual validation before being connected to another point */
  20364. needDualDirectionValidation: boolean;
  20365. /**
  20366. * Gets or sets the additional types supported by this connection point
  20367. */
  20368. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20369. /**
  20370. * Gets or sets the additional types excluded by this connection point
  20371. */
  20372. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20373. /**
  20374. * Observable triggered when this point is connected
  20375. */
  20376. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20377. /**
  20378. * Gets or sets the associated variable name in the shader
  20379. */
  20380. get associatedVariableName(): string;
  20381. set associatedVariableName(value: string);
  20382. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20383. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20384. /**
  20385. * Gets or sets the connection point type (default is float)
  20386. */
  20387. get type(): NodeMaterialBlockConnectionPointTypes;
  20388. set type(value: NodeMaterialBlockConnectionPointTypes);
  20389. /**
  20390. * Gets or sets the connection point name
  20391. */
  20392. name: string;
  20393. /**
  20394. * Gets or sets the connection point name
  20395. */
  20396. displayName: string;
  20397. /**
  20398. * Gets or sets a boolean indicating that this connection point can be omitted
  20399. */
  20400. isOptional: boolean;
  20401. /**
  20402. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20403. */
  20404. define: string;
  20405. /** @hidden */
  20406. _prioritizeVertex: boolean;
  20407. private _target;
  20408. /** Gets or sets the target of that connection point */
  20409. get target(): NodeMaterialBlockTargets;
  20410. set target(value: NodeMaterialBlockTargets);
  20411. /**
  20412. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20413. */
  20414. get isConnected(): boolean;
  20415. /**
  20416. * Gets a boolean indicating that the current point is connected to an input block
  20417. */
  20418. get isConnectedToInputBlock(): boolean;
  20419. /**
  20420. * Gets a the connected input block (if any)
  20421. */
  20422. get connectInputBlock(): Nullable<InputBlock>;
  20423. /** Get the other side of the connection (if any) */
  20424. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20425. /** Get the block that owns this connection point */
  20426. get ownerBlock(): NodeMaterialBlock;
  20427. /** Get the block connected on the other side of this connection (if any) */
  20428. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20429. /** Get the block connected on the endpoints of this connection (if any) */
  20430. get connectedBlocks(): Array<NodeMaterialBlock>;
  20431. /** Gets the list of connected endpoints */
  20432. get endpoints(): NodeMaterialConnectionPoint[];
  20433. /** Gets a boolean indicating if that output point is connected to at least one input */
  20434. get hasEndpoints(): boolean;
  20435. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20436. get isConnectedInVertexShader(): boolean;
  20437. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20438. get isConnectedInFragmentShader(): boolean;
  20439. /**
  20440. * Creates a block suitable to be used as an input for this input point.
  20441. * If null is returned, a block based on the point type will be created.
  20442. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20443. */
  20444. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20445. /**
  20446. * Creates a new connection point
  20447. * @param name defines the connection point name
  20448. * @param ownerBlock defines the block hosting this connection point
  20449. * @param direction defines the direction of the connection point
  20450. */
  20451. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20452. /**
  20453. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20454. * @returns the class name
  20455. */
  20456. getClassName(): string;
  20457. /**
  20458. * Gets a boolean indicating if the current point can be connected to another point
  20459. * @param connectionPoint defines the other connection point
  20460. * @returns a boolean
  20461. */
  20462. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20463. /**
  20464. * Gets a number indicating if the current point can be connected to another point
  20465. * @param connectionPoint defines the other connection point
  20466. * @returns a number defining the compatibility state
  20467. */
  20468. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20469. /**
  20470. * Connect this point to another connection point
  20471. * @param connectionPoint defines the other connection point
  20472. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20473. * @returns the current connection point
  20474. */
  20475. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20476. /**
  20477. * Disconnect this point from one of his endpoint
  20478. * @param endpoint defines the other connection point
  20479. * @returns the current connection point
  20480. */
  20481. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20482. /**
  20483. * Serializes this point in a JSON representation
  20484. * @param isInput defines if the connection point is an input (default is true)
  20485. * @returns the serialized point object
  20486. */
  20487. serialize(isInput?: boolean): any;
  20488. /**
  20489. * Release resources
  20490. */
  20491. dispose(): void;
  20492. }
  20493. }
  20494. declare module BABYLON {
  20495. /**
  20496. * Enum used to define the material modes
  20497. */
  20498. export enum NodeMaterialModes {
  20499. /** Regular material */
  20500. Material = 0,
  20501. /** For post process */
  20502. PostProcess = 1,
  20503. /** For particle system */
  20504. Particle = 2
  20505. }
  20506. }
  20507. declare module BABYLON {
  20508. /**
  20509. * Block used to read a texture from a sampler
  20510. */
  20511. export class TextureBlock extends NodeMaterialBlock {
  20512. private _defineName;
  20513. private _linearDefineName;
  20514. private _gammaDefineName;
  20515. private _tempTextureRead;
  20516. private _samplerName;
  20517. private _transformedUVName;
  20518. private _textureTransformName;
  20519. private _textureInfoName;
  20520. private _mainUVName;
  20521. private _mainUVDefineName;
  20522. private _fragmentOnly;
  20523. /**
  20524. * Gets or sets the texture associated with the node
  20525. */
  20526. texture: Nullable<Texture>;
  20527. /**
  20528. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20529. */
  20530. convertToGammaSpace: boolean;
  20531. /**
  20532. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20533. */
  20534. convertToLinearSpace: boolean;
  20535. /**
  20536. * Create a new TextureBlock
  20537. * @param name defines the block name
  20538. */
  20539. constructor(name: string, fragmentOnly?: boolean);
  20540. /**
  20541. * Gets the current class name
  20542. * @returns the class name
  20543. */
  20544. getClassName(): string;
  20545. /**
  20546. * Gets the uv input component
  20547. */
  20548. get uv(): NodeMaterialConnectionPoint;
  20549. /**
  20550. * Gets the rgba output component
  20551. */
  20552. get rgba(): NodeMaterialConnectionPoint;
  20553. /**
  20554. * Gets the rgb output component
  20555. */
  20556. get rgb(): NodeMaterialConnectionPoint;
  20557. /**
  20558. * Gets the r output component
  20559. */
  20560. get r(): NodeMaterialConnectionPoint;
  20561. /**
  20562. * Gets the g output component
  20563. */
  20564. get g(): NodeMaterialConnectionPoint;
  20565. /**
  20566. * Gets the b output component
  20567. */
  20568. get b(): NodeMaterialConnectionPoint;
  20569. /**
  20570. * Gets the a output component
  20571. */
  20572. get a(): NodeMaterialConnectionPoint;
  20573. get target(): NodeMaterialBlockTargets;
  20574. autoConfigure(material: NodeMaterial): void;
  20575. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20577. isReady(): boolean;
  20578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20579. private get _isMixed();
  20580. private _injectVertexCode;
  20581. private _writeTextureRead;
  20582. private _writeOutput;
  20583. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20584. protected _dumpPropertiesCode(): string;
  20585. serialize(): any;
  20586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20587. }
  20588. }
  20589. declare module BABYLON {
  20590. /** @hidden */
  20591. export var reflectionFunction: {
  20592. name: string;
  20593. shader: string;
  20594. };
  20595. }
  20596. declare module BABYLON {
  20597. /**
  20598. * Base block used to read a reflection texture from a sampler
  20599. */
  20600. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20601. /** @hidden */
  20602. _define3DName: string;
  20603. /** @hidden */
  20604. _defineCubicName: string;
  20605. /** @hidden */
  20606. _defineExplicitName: string;
  20607. /** @hidden */
  20608. _defineProjectionName: string;
  20609. /** @hidden */
  20610. _defineLocalCubicName: string;
  20611. /** @hidden */
  20612. _defineSphericalName: string;
  20613. /** @hidden */
  20614. _definePlanarName: string;
  20615. /** @hidden */
  20616. _defineEquirectangularName: string;
  20617. /** @hidden */
  20618. _defineMirroredEquirectangularFixedName: string;
  20619. /** @hidden */
  20620. _defineEquirectangularFixedName: string;
  20621. /** @hidden */
  20622. _defineSkyboxName: string;
  20623. /** @hidden */
  20624. _defineOppositeZ: string;
  20625. /** @hidden */
  20626. _cubeSamplerName: string;
  20627. /** @hidden */
  20628. _2DSamplerName: string;
  20629. protected _positionUVWName: string;
  20630. protected _directionWName: string;
  20631. protected _reflectionVectorName: string;
  20632. /** @hidden */
  20633. _reflectionCoordsName: string;
  20634. /** @hidden */
  20635. _reflectionMatrixName: string;
  20636. protected _reflectionColorName: string;
  20637. /**
  20638. * Gets or sets the texture associated with the node
  20639. */
  20640. texture: Nullable<BaseTexture>;
  20641. /**
  20642. * Create a new ReflectionTextureBaseBlock
  20643. * @param name defines the block name
  20644. */
  20645. constructor(name: string);
  20646. /**
  20647. * Gets the current class name
  20648. * @returns the class name
  20649. */
  20650. getClassName(): string;
  20651. /**
  20652. * Gets the world position input component
  20653. */
  20654. abstract get position(): NodeMaterialConnectionPoint;
  20655. /**
  20656. * Gets the world position input component
  20657. */
  20658. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20659. /**
  20660. * Gets the world normal input component
  20661. */
  20662. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20663. /**
  20664. * Gets the world input component
  20665. */
  20666. abstract get world(): NodeMaterialConnectionPoint;
  20667. /**
  20668. * Gets the camera (or eye) position component
  20669. */
  20670. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20671. /**
  20672. * Gets the view input component
  20673. */
  20674. abstract get view(): NodeMaterialConnectionPoint;
  20675. protected _getTexture(): Nullable<BaseTexture>;
  20676. autoConfigure(material: NodeMaterial): void;
  20677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20678. isReady(): boolean;
  20679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20680. /**
  20681. * Gets the code to inject in the vertex shader
  20682. * @param state current state of the node material building
  20683. * @returns the shader code
  20684. */
  20685. handleVertexSide(state: NodeMaterialBuildState): string;
  20686. /**
  20687. * Handles the inits for the fragment code path
  20688. * @param state node material build state
  20689. */
  20690. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20691. /**
  20692. * Generates the reflection coords code for the fragment code path
  20693. * @param worldNormalVarName name of the world normal variable
  20694. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20695. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20696. * @returns the shader code
  20697. */
  20698. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20699. /**
  20700. * Generates the reflection color code for the fragment code path
  20701. * @param lodVarName name of the lod variable
  20702. * @param swizzleLookupTexture swizzle to use for the final color variable
  20703. * @returns the shader code
  20704. */
  20705. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20706. /**
  20707. * Generates the code corresponding to the connected output points
  20708. * @param state node material build state
  20709. * @param varName name of the variable to output
  20710. * @returns the shader code
  20711. */
  20712. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20713. protected _buildBlock(state: NodeMaterialBuildState): this;
  20714. protected _dumpPropertiesCode(): string;
  20715. serialize(): any;
  20716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20717. }
  20718. }
  20719. declare module BABYLON {
  20720. /**
  20721. * Defines a connection point to be used for points with a custom object type
  20722. */
  20723. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20724. private _blockType;
  20725. private _blockName;
  20726. private _nameForCheking?;
  20727. /**
  20728. * Creates a new connection point
  20729. * @param name defines the connection point name
  20730. * @param ownerBlock defines the block hosting this connection point
  20731. * @param direction defines the direction of the connection point
  20732. */
  20733. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20734. /**
  20735. * Gets a number indicating if the current point can be connected to another point
  20736. * @param connectionPoint defines the other connection point
  20737. * @returns a number defining the compatibility state
  20738. */
  20739. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20740. /**
  20741. * Creates a block suitable to be used as an input for this input point.
  20742. * If null is returned, a block based on the point type will be created.
  20743. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20744. */
  20745. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20746. }
  20747. }
  20748. declare module BABYLON {
  20749. /**
  20750. * Enum defining the type of properties that can be edited in the property pages in the NME
  20751. */
  20752. export enum PropertyTypeForEdition {
  20753. /** property is a boolean */
  20754. Boolean = 0,
  20755. /** property is a float */
  20756. Float = 1,
  20757. /** property is a Vector2 */
  20758. Vector2 = 2,
  20759. /** property is a list of values */
  20760. List = 3
  20761. }
  20762. /**
  20763. * Interface that defines an option in a variable of type list
  20764. */
  20765. export interface IEditablePropertyListOption {
  20766. /** label of the option */
  20767. "label": string;
  20768. /** value of the option */
  20769. "value": number;
  20770. }
  20771. /**
  20772. * Interface that defines the options available for an editable property
  20773. */
  20774. export interface IEditablePropertyOption {
  20775. /** min value */
  20776. "min"?: number;
  20777. /** max value */
  20778. "max"?: number;
  20779. /** notifiers: indicates which actions to take when the property is changed */
  20780. "notifiers"?: {
  20781. /** the material should be rebuilt */
  20782. "rebuild"?: boolean;
  20783. /** the preview should be updated */
  20784. "update"?: boolean;
  20785. };
  20786. /** list of the options for a variable of type list */
  20787. "options"?: IEditablePropertyListOption[];
  20788. }
  20789. /**
  20790. * Interface that describes an editable property
  20791. */
  20792. export interface IPropertyDescriptionForEdition {
  20793. /** name of the property */
  20794. "propertyName": string;
  20795. /** display name of the property */
  20796. "displayName": string;
  20797. /** type of the property */
  20798. "type": PropertyTypeForEdition;
  20799. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20800. "groupName": string;
  20801. /** options for the property */
  20802. "options": IEditablePropertyOption;
  20803. }
  20804. /**
  20805. * Decorator that flags a property in a node material block as being editable
  20806. */
  20807. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20808. }
  20809. declare module BABYLON {
  20810. /**
  20811. * Block used to implement the refraction part of the sub surface module of the PBR material
  20812. */
  20813. export class RefractionBlock extends NodeMaterialBlock {
  20814. /** @hidden */
  20815. _define3DName: string;
  20816. /** @hidden */
  20817. _refractionMatrixName: string;
  20818. /** @hidden */
  20819. _defineLODRefractionAlpha: string;
  20820. /** @hidden */
  20821. _defineLinearSpecularRefraction: string;
  20822. /** @hidden */
  20823. _defineOppositeZ: string;
  20824. /** @hidden */
  20825. _cubeSamplerName: string;
  20826. /** @hidden */
  20827. _2DSamplerName: string;
  20828. /** @hidden */
  20829. _vRefractionMicrosurfaceInfosName: string;
  20830. /** @hidden */
  20831. _vRefractionInfosName: string;
  20832. private _scene;
  20833. /**
  20834. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20835. * Materials half opaque for instance using refraction could benefit from this control.
  20836. */
  20837. linkRefractionWithTransparency: boolean;
  20838. /**
  20839. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20840. */
  20841. invertRefractionY: boolean;
  20842. /**
  20843. * Gets or sets the texture associated with the node
  20844. */
  20845. texture: Nullable<BaseTexture>;
  20846. /**
  20847. * Create a new RefractionBlock
  20848. * @param name defines the block name
  20849. */
  20850. constructor(name: string);
  20851. /**
  20852. * Gets the current class name
  20853. * @returns the class name
  20854. */
  20855. getClassName(): string;
  20856. /**
  20857. * Gets the intensity input component
  20858. */
  20859. get intensity(): NodeMaterialConnectionPoint;
  20860. /**
  20861. * Gets the index of refraction input component
  20862. */
  20863. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20864. /**
  20865. * Gets the tint at distance input component
  20866. */
  20867. get tintAtDistance(): NodeMaterialConnectionPoint;
  20868. /**
  20869. * Gets the view input component
  20870. */
  20871. get view(): NodeMaterialConnectionPoint;
  20872. /**
  20873. * Gets the refraction object output component
  20874. */
  20875. get refraction(): NodeMaterialConnectionPoint;
  20876. /**
  20877. * Returns true if the block has a texture
  20878. */
  20879. get hasTexture(): boolean;
  20880. protected _getTexture(): Nullable<BaseTexture>;
  20881. autoConfigure(material: NodeMaterial): void;
  20882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20883. isReady(): boolean;
  20884. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20885. /**
  20886. * Gets the main code of the block (fragment side)
  20887. * @param state current state of the node material building
  20888. * @returns the shader code
  20889. */
  20890. getCode(state: NodeMaterialBuildState): string;
  20891. protected _buildBlock(state: NodeMaterialBuildState): this;
  20892. protected _dumpPropertiesCode(): string;
  20893. serialize(): any;
  20894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20895. }
  20896. }
  20897. declare module BABYLON {
  20898. /**
  20899. * Base block used as input for post process
  20900. */
  20901. export class CurrentScreenBlock extends NodeMaterialBlock {
  20902. private _samplerName;
  20903. private _linearDefineName;
  20904. private _gammaDefineName;
  20905. private _mainUVName;
  20906. private _tempTextureRead;
  20907. /**
  20908. * Gets or sets the texture associated with the node
  20909. */
  20910. texture: Nullable<BaseTexture>;
  20911. /**
  20912. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20913. */
  20914. convertToGammaSpace: boolean;
  20915. /**
  20916. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20917. */
  20918. convertToLinearSpace: boolean;
  20919. /**
  20920. * Create a new CurrentScreenBlock
  20921. * @param name defines the block name
  20922. */
  20923. constructor(name: string);
  20924. /**
  20925. * Gets the current class name
  20926. * @returns the class name
  20927. */
  20928. getClassName(): string;
  20929. /**
  20930. * Gets the uv input component
  20931. */
  20932. get uv(): NodeMaterialConnectionPoint;
  20933. /**
  20934. * Gets the rgba output component
  20935. */
  20936. get rgba(): NodeMaterialConnectionPoint;
  20937. /**
  20938. * Gets the rgb output component
  20939. */
  20940. get rgb(): NodeMaterialConnectionPoint;
  20941. /**
  20942. * Gets the r output component
  20943. */
  20944. get r(): NodeMaterialConnectionPoint;
  20945. /**
  20946. * Gets the g output component
  20947. */
  20948. get g(): NodeMaterialConnectionPoint;
  20949. /**
  20950. * Gets the b output component
  20951. */
  20952. get b(): NodeMaterialConnectionPoint;
  20953. /**
  20954. * Gets the a output component
  20955. */
  20956. get a(): NodeMaterialConnectionPoint;
  20957. /**
  20958. * Initialize the block and prepare the context for build
  20959. * @param state defines the state that will be used for the build
  20960. */
  20961. initialize(state: NodeMaterialBuildState): void;
  20962. get target(): NodeMaterialBlockTargets;
  20963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20964. isReady(): boolean;
  20965. private _injectVertexCode;
  20966. private _writeTextureRead;
  20967. private _writeOutput;
  20968. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20969. serialize(): any;
  20970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * Base block used for the particle texture
  20976. */
  20977. export class ParticleTextureBlock extends NodeMaterialBlock {
  20978. private _samplerName;
  20979. private _linearDefineName;
  20980. private _gammaDefineName;
  20981. private _tempTextureRead;
  20982. /**
  20983. * Gets or sets the texture associated with the node
  20984. */
  20985. texture: Nullable<BaseTexture>;
  20986. /**
  20987. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20988. */
  20989. convertToGammaSpace: boolean;
  20990. /**
  20991. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20992. */
  20993. convertToLinearSpace: boolean;
  20994. /**
  20995. * Create a new ParticleTextureBlock
  20996. * @param name defines the block name
  20997. */
  20998. constructor(name: string);
  20999. /**
  21000. * Gets the current class name
  21001. * @returns the class name
  21002. */
  21003. getClassName(): string;
  21004. /**
  21005. * Gets the uv input component
  21006. */
  21007. get uv(): NodeMaterialConnectionPoint;
  21008. /**
  21009. * Gets the rgba output component
  21010. */
  21011. get rgba(): NodeMaterialConnectionPoint;
  21012. /**
  21013. * Gets the rgb output component
  21014. */
  21015. get rgb(): NodeMaterialConnectionPoint;
  21016. /**
  21017. * Gets the r output component
  21018. */
  21019. get r(): NodeMaterialConnectionPoint;
  21020. /**
  21021. * Gets the g output component
  21022. */
  21023. get g(): NodeMaterialConnectionPoint;
  21024. /**
  21025. * Gets the b output component
  21026. */
  21027. get b(): NodeMaterialConnectionPoint;
  21028. /**
  21029. * Gets the a output component
  21030. */
  21031. get a(): NodeMaterialConnectionPoint;
  21032. /**
  21033. * Initialize the block and prepare the context for build
  21034. * @param state defines the state that will be used for the build
  21035. */
  21036. initialize(state: NodeMaterialBuildState): void;
  21037. autoConfigure(material: NodeMaterial): void;
  21038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21039. isReady(): boolean;
  21040. private _writeOutput;
  21041. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21042. serialize(): any;
  21043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21044. }
  21045. }
  21046. declare module BABYLON {
  21047. /**
  21048. * Class used to store shared data between 2 NodeMaterialBuildState
  21049. */
  21050. export class NodeMaterialBuildStateSharedData {
  21051. /**
  21052. * Gets the list of emitted varyings
  21053. */
  21054. temps: string[];
  21055. /**
  21056. * Gets the list of emitted varyings
  21057. */
  21058. varyings: string[];
  21059. /**
  21060. * Gets the varying declaration string
  21061. */
  21062. varyingDeclaration: string;
  21063. /**
  21064. * Input blocks
  21065. */
  21066. inputBlocks: InputBlock[];
  21067. /**
  21068. * Input blocks
  21069. */
  21070. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21071. /**
  21072. * Bindable blocks (Blocks that need to set data to the effect)
  21073. */
  21074. bindableBlocks: NodeMaterialBlock[];
  21075. /**
  21076. * List of blocks that can provide a compilation fallback
  21077. */
  21078. blocksWithFallbacks: NodeMaterialBlock[];
  21079. /**
  21080. * List of blocks that can provide a define update
  21081. */
  21082. blocksWithDefines: NodeMaterialBlock[];
  21083. /**
  21084. * List of blocks that can provide a repeatable content
  21085. */
  21086. repeatableContentBlocks: NodeMaterialBlock[];
  21087. /**
  21088. * List of blocks that can provide a dynamic list of uniforms
  21089. */
  21090. dynamicUniformBlocks: NodeMaterialBlock[];
  21091. /**
  21092. * List of blocks that can block the isReady function for the material
  21093. */
  21094. blockingBlocks: NodeMaterialBlock[];
  21095. /**
  21096. * Gets the list of animated inputs
  21097. */
  21098. animatedInputs: InputBlock[];
  21099. /**
  21100. * Build Id used to avoid multiple recompilations
  21101. */
  21102. buildId: number;
  21103. /** List of emitted variables */
  21104. variableNames: {
  21105. [key: string]: number;
  21106. };
  21107. /** List of emitted defines */
  21108. defineNames: {
  21109. [key: string]: number;
  21110. };
  21111. /** Should emit comments? */
  21112. emitComments: boolean;
  21113. /** Emit build activity */
  21114. verbose: boolean;
  21115. /** Gets or sets the hosting scene */
  21116. scene: Scene;
  21117. /**
  21118. * Gets the compilation hints emitted at compilation time
  21119. */
  21120. hints: {
  21121. needWorldViewMatrix: boolean;
  21122. needWorldViewProjectionMatrix: boolean;
  21123. needAlphaBlending: boolean;
  21124. needAlphaTesting: boolean;
  21125. };
  21126. /**
  21127. * List of compilation checks
  21128. */
  21129. checks: {
  21130. emitVertex: boolean;
  21131. emitFragment: boolean;
  21132. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21133. };
  21134. /**
  21135. * Is vertex program allowed to be empty?
  21136. */
  21137. allowEmptyVertexProgram: boolean;
  21138. /** Creates a new shared data */
  21139. constructor();
  21140. /**
  21141. * Emits console errors and exceptions if there is a failing check
  21142. */
  21143. emitErrors(): void;
  21144. }
  21145. }
  21146. declare module BABYLON {
  21147. /**
  21148. * Class used to store node based material build state
  21149. */
  21150. export class NodeMaterialBuildState {
  21151. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21152. supportUniformBuffers: boolean;
  21153. /**
  21154. * Gets the list of emitted attributes
  21155. */
  21156. attributes: string[];
  21157. /**
  21158. * Gets the list of emitted uniforms
  21159. */
  21160. uniforms: string[];
  21161. /**
  21162. * Gets the list of emitted constants
  21163. */
  21164. constants: string[];
  21165. /**
  21166. * Gets the list of emitted samplers
  21167. */
  21168. samplers: string[];
  21169. /**
  21170. * Gets the list of emitted functions
  21171. */
  21172. functions: {
  21173. [key: string]: string;
  21174. };
  21175. /**
  21176. * Gets the list of emitted extensions
  21177. */
  21178. extensions: {
  21179. [key: string]: string;
  21180. };
  21181. /**
  21182. * Gets the target of the compilation state
  21183. */
  21184. target: NodeMaterialBlockTargets;
  21185. /**
  21186. * Gets the list of emitted counters
  21187. */
  21188. counters: {
  21189. [key: string]: number;
  21190. };
  21191. /**
  21192. * Shared data between multiple NodeMaterialBuildState instances
  21193. */
  21194. sharedData: NodeMaterialBuildStateSharedData;
  21195. /** @hidden */
  21196. _vertexState: NodeMaterialBuildState;
  21197. /** @hidden */
  21198. _attributeDeclaration: string;
  21199. /** @hidden */
  21200. _uniformDeclaration: string;
  21201. /** @hidden */
  21202. _constantDeclaration: string;
  21203. /** @hidden */
  21204. _samplerDeclaration: string;
  21205. /** @hidden */
  21206. _varyingTransfer: string;
  21207. /** @hidden */
  21208. _injectAtEnd: string;
  21209. private _repeatableContentAnchorIndex;
  21210. /** @hidden */
  21211. _builtCompilationString: string;
  21212. /**
  21213. * Gets the emitted compilation strings
  21214. */
  21215. compilationString: string;
  21216. /**
  21217. * Finalize the compilation strings
  21218. * @param state defines the current compilation state
  21219. */
  21220. finalize(state: NodeMaterialBuildState): void;
  21221. /** @hidden */
  21222. get _repeatableContentAnchor(): string;
  21223. /** @hidden */
  21224. _getFreeVariableName(prefix: string): string;
  21225. /** @hidden */
  21226. _getFreeDefineName(prefix: string): string;
  21227. /** @hidden */
  21228. _excludeVariableName(name: string): void;
  21229. /** @hidden */
  21230. _emit2DSampler(name: string): void;
  21231. /** @hidden */
  21232. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21233. /** @hidden */
  21234. _emitExtension(name: string, extension: string, define?: string): void;
  21235. /** @hidden */
  21236. _emitFunction(name: string, code: string, comments: string): void;
  21237. /** @hidden */
  21238. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21239. replaceStrings?: {
  21240. search: RegExp;
  21241. replace: string;
  21242. }[];
  21243. repeatKey?: string;
  21244. }): string;
  21245. /** @hidden */
  21246. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21247. repeatKey?: string;
  21248. removeAttributes?: boolean;
  21249. removeUniforms?: boolean;
  21250. removeVaryings?: boolean;
  21251. removeIfDef?: boolean;
  21252. replaceStrings?: {
  21253. search: RegExp;
  21254. replace: string;
  21255. }[];
  21256. }, storeKey?: string): void;
  21257. /** @hidden */
  21258. _registerTempVariable(name: string): boolean;
  21259. /** @hidden */
  21260. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21261. /** @hidden */
  21262. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21263. /** @hidden */
  21264. _emitFloat(value: number): string;
  21265. }
  21266. }
  21267. declare module BABYLON {
  21268. /**
  21269. * Helper class used to generate session unique ID
  21270. */
  21271. export class UniqueIdGenerator {
  21272. private static _UniqueIdCounter;
  21273. /**
  21274. * Gets an unique (relatively to the current scene) Id
  21275. */
  21276. static get UniqueId(): number;
  21277. }
  21278. }
  21279. declare module BABYLON {
  21280. /**
  21281. * Defines a block that can be used inside a node based material
  21282. */
  21283. export class NodeMaterialBlock {
  21284. private _buildId;
  21285. private _buildTarget;
  21286. private _target;
  21287. private _isFinalMerger;
  21288. private _isInput;
  21289. protected _isUnique: boolean;
  21290. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21291. inputsAreExclusive: boolean;
  21292. /** @hidden */
  21293. _codeVariableName: string;
  21294. /** @hidden */
  21295. _inputs: NodeMaterialConnectionPoint[];
  21296. /** @hidden */
  21297. _outputs: NodeMaterialConnectionPoint[];
  21298. /** @hidden */
  21299. _preparationId: number;
  21300. /**
  21301. * Gets or sets the name of the block
  21302. */
  21303. name: string;
  21304. /**
  21305. * Gets or sets the unique id of the node
  21306. */
  21307. uniqueId: number;
  21308. /**
  21309. * Gets or sets the comments associated with this block
  21310. */
  21311. comments: string;
  21312. /**
  21313. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21314. */
  21315. get isUnique(): boolean;
  21316. /**
  21317. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21318. */
  21319. get isFinalMerger(): boolean;
  21320. /**
  21321. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21322. */
  21323. get isInput(): boolean;
  21324. /**
  21325. * Gets or sets the build Id
  21326. */
  21327. get buildId(): number;
  21328. set buildId(value: number);
  21329. /**
  21330. * Gets or sets the target of the block
  21331. */
  21332. get target(): NodeMaterialBlockTargets;
  21333. set target(value: NodeMaterialBlockTargets);
  21334. /**
  21335. * Gets the list of input points
  21336. */
  21337. get inputs(): NodeMaterialConnectionPoint[];
  21338. /** Gets the list of output points */
  21339. get outputs(): NodeMaterialConnectionPoint[];
  21340. /**
  21341. * Find an input by its name
  21342. * @param name defines the name of the input to look for
  21343. * @returns the input or null if not found
  21344. */
  21345. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21346. /**
  21347. * Find an output by its name
  21348. * @param name defines the name of the outputto look for
  21349. * @returns the output or null if not found
  21350. */
  21351. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21352. /**
  21353. * Creates a new NodeMaterialBlock
  21354. * @param name defines the block name
  21355. * @param target defines the target of that block (Vertex by default)
  21356. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21357. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21358. */
  21359. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21360. /**
  21361. * Initialize the block and prepare the context for build
  21362. * @param state defines the state that will be used for the build
  21363. */
  21364. initialize(state: NodeMaterialBuildState): void;
  21365. /**
  21366. * Bind data to effect. Will only be called for blocks with isBindable === true
  21367. * @param effect defines the effect to bind data to
  21368. * @param nodeMaterial defines the hosting NodeMaterial
  21369. * @param mesh defines the mesh that will be rendered
  21370. * @param subMesh defines the submesh that will be rendered
  21371. */
  21372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21373. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21374. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21375. protected _writeFloat(value: number): string;
  21376. /**
  21377. * Gets the current class name e.g. "NodeMaterialBlock"
  21378. * @returns the class name
  21379. */
  21380. getClassName(): string;
  21381. /**
  21382. * Register a new input. Must be called inside a block constructor
  21383. * @param name defines the connection point name
  21384. * @param type defines the connection point type
  21385. * @param isOptional defines a boolean indicating that this input can be omitted
  21386. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21387. * @param point an already created connection point. If not provided, create a new one
  21388. * @returns the current block
  21389. */
  21390. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21391. /**
  21392. * Register a new output. Must be called inside a block constructor
  21393. * @param name defines the connection point name
  21394. * @param type defines the connection point type
  21395. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21396. * @param point an already created connection point. If not provided, create a new one
  21397. * @returns the current block
  21398. */
  21399. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21400. /**
  21401. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21402. * @param forOutput defines an optional connection point to check compatibility with
  21403. * @returns the first available input or null
  21404. */
  21405. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21406. /**
  21407. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21408. * @param forBlock defines an optional block to check compatibility with
  21409. * @returns the first available input or null
  21410. */
  21411. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21412. /**
  21413. * Gets the sibling of the given output
  21414. * @param current defines the current output
  21415. * @returns the next output in the list or null
  21416. */
  21417. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21418. /**
  21419. * Connect current block with another block
  21420. * @param other defines the block to connect with
  21421. * @param options define the various options to help pick the right connections
  21422. * @returns the current block
  21423. */
  21424. connectTo(other: NodeMaterialBlock, options?: {
  21425. input?: string;
  21426. output?: string;
  21427. outputSwizzle?: string;
  21428. }): this | undefined;
  21429. protected _buildBlock(state: NodeMaterialBuildState): void;
  21430. /**
  21431. * Add uniforms, samplers and uniform buffers at compilation time
  21432. * @param state defines the state to update
  21433. * @param nodeMaterial defines the node material requesting the update
  21434. * @param defines defines the material defines to update
  21435. * @param uniformBuffers defines the list of uniform buffer names
  21436. */
  21437. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21438. /**
  21439. * Add potential fallbacks if shader compilation fails
  21440. * @param mesh defines the mesh to be rendered
  21441. * @param fallbacks defines the current prioritized list of fallbacks
  21442. */
  21443. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21444. /**
  21445. * Initialize defines for shader compilation
  21446. * @param mesh defines the mesh to be rendered
  21447. * @param nodeMaterial defines the node material requesting the update
  21448. * @param defines defines the material defines to update
  21449. * @param useInstances specifies that instances should be used
  21450. */
  21451. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21452. /**
  21453. * Update defines for shader compilation
  21454. * @param mesh defines the mesh to be rendered
  21455. * @param nodeMaterial defines the node material requesting the update
  21456. * @param defines defines the material defines to update
  21457. * @param useInstances specifies that instances should be used
  21458. */
  21459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21460. /**
  21461. * Lets the block try to connect some inputs automatically
  21462. * @param material defines the hosting NodeMaterial
  21463. */
  21464. autoConfigure(material: NodeMaterial): void;
  21465. /**
  21466. * Function called when a block is declared as repeatable content generator
  21467. * @param vertexShaderState defines the current compilation state for the vertex shader
  21468. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21469. * @param mesh defines the mesh to be rendered
  21470. * @param defines defines the material defines to update
  21471. */
  21472. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21473. /**
  21474. * Checks if the block is ready
  21475. * @param mesh defines the mesh to be rendered
  21476. * @param nodeMaterial defines the node material requesting the update
  21477. * @param defines defines the material defines to update
  21478. * @param useInstances specifies that instances should be used
  21479. * @returns true if the block is ready
  21480. */
  21481. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21482. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21483. private _processBuild;
  21484. /**
  21485. * Compile the current node and generate the shader code
  21486. * @param state defines the current compilation state (uniforms, samplers, current string)
  21487. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21488. * @returns true if already built
  21489. */
  21490. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21491. protected _inputRename(name: string): string;
  21492. protected _outputRename(name: string): string;
  21493. protected _dumpPropertiesCode(): string;
  21494. /** @hidden */
  21495. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21496. /** @hidden */
  21497. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21498. /**
  21499. * Clone the current block to a new identical block
  21500. * @param scene defines the hosting scene
  21501. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21502. * @returns a copy of the current block
  21503. */
  21504. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21505. /**
  21506. * Serializes this block in a JSON representation
  21507. * @returns the serialized block object
  21508. */
  21509. serialize(): any;
  21510. /** @hidden */
  21511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21512. private _deserializePortDisplayNames;
  21513. /**
  21514. * Release resources
  21515. */
  21516. dispose(): void;
  21517. }
  21518. }
  21519. declare module BABYLON {
  21520. /**
  21521. * Base class of materials working in push mode in babylon JS
  21522. * @hidden
  21523. */
  21524. export class PushMaterial extends Material {
  21525. protected _activeEffect: Effect;
  21526. protected _normalMatrix: Matrix;
  21527. /**
  21528. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21529. * This means that the material can keep using a previous shader while a new one is being compiled.
  21530. * This is mostly used when shader parallel compilation is supported (true by default)
  21531. */
  21532. allowShaderHotSwapping: boolean;
  21533. constructor(name: string, scene: Scene);
  21534. getEffect(): Effect;
  21535. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21536. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21537. /**
  21538. * Binds the given world matrix to the active effect
  21539. *
  21540. * @param world the matrix to bind
  21541. */
  21542. bindOnlyWorldMatrix(world: Matrix): void;
  21543. /**
  21544. * Binds the given normal matrix to the active effect
  21545. *
  21546. * @param normalMatrix the matrix to bind
  21547. */
  21548. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21549. bind(world: Matrix, mesh?: Mesh): void;
  21550. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21551. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21552. }
  21553. }
  21554. declare module BABYLON {
  21555. /**
  21556. * Root class for all node material optimizers
  21557. */
  21558. export class NodeMaterialOptimizer {
  21559. /**
  21560. * Function used to optimize a NodeMaterial graph
  21561. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21562. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21563. */
  21564. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21565. }
  21566. }
  21567. declare module BABYLON {
  21568. /**
  21569. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21570. */
  21571. export class TransformBlock extends NodeMaterialBlock {
  21572. /**
  21573. * Defines the value to use to complement W value to transform it to a Vector4
  21574. */
  21575. complementW: number;
  21576. /**
  21577. * Defines the value to use to complement z value to transform it to a Vector4
  21578. */
  21579. complementZ: number;
  21580. /**
  21581. * Creates a new TransformBlock
  21582. * @param name defines the block name
  21583. */
  21584. constructor(name: string);
  21585. /**
  21586. * Gets the current class name
  21587. * @returns the class name
  21588. */
  21589. getClassName(): string;
  21590. /**
  21591. * Gets the vector input
  21592. */
  21593. get vector(): NodeMaterialConnectionPoint;
  21594. /**
  21595. * Gets the output component
  21596. */
  21597. get output(): NodeMaterialConnectionPoint;
  21598. /**
  21599. * Gets the xyz output component
  21600. */
  21601. get xyz(): NodeMaterialConnectionPoint;
  21602. /**
  21603. * Gets the matrix transform input
  21604. */
  21605. get transform(): NodeMaterialConnectionPoint;
  21606. protected _buildBlock(state: NodeMaterialBuildState): this;
  21607. serialize(): any;
  21608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21609. protected _dumpPropertiesCode(): string;
  21610. }
  21611. }
  21612. declare module BABYLON {
  21613. /**
  21614. * Block used to output the vertex position
  21615. */
  21616. export class VertexOutputBlock extends NodeMaterialBlock {
  21617. /**
  21618. * Creates a new VertexOutputBlock
  21619. * @param name defines the block name
  21620. */
  21621. constructor(name: string);
  21622. /**
  21623. * Gets the current class name
  21624. * @returns the class name
  21625. */
  21626. getClassName(): string;
  21627. /**
  21628. * Gets the vector input component
  21629. */
  21630. get vector(): NodeMaterialConnectionPoint;
  21631. protected _buildBlock(state: NodeMaterialBuildState): this;
  21632. }
  21633. }
  21634. declare module BABYLON {
  21635. /**
  21636. * Block used to output the final color
  21637. */
  21638. export class FragmentOutputBlock extends NodeMaterialBlock {
  21639. /**
  21640. * Create a new FragmentOutputBlock
  21641. * @param name defines the block name
  21642. */
  21643. constructor(name: string);
  21644. /**
  21645. * Gets the current class name
  21646. * @returns the class name
  21647. */
  21648. getClassName(): string;
  21649. /**
  21650. * Gets the rgba input component
  21651. */
  21652. get rgba(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the rgb input component
  21655. */
  21656. get rgb(): NodeMaterialConnectionPoint;
  21657. /**
  21658. * Gets the a input component
  21659. */
  21660. get a(): NodeMaterialConnectionPoint;
  21661. protected _buildBlock(state: NodeMaterialBuildState): this;
  21662. }
  21663. }
  21664. declare module BABYLON {
  21665. /**
  21666. * Block used for the particle ramp gradient section
  21667. */
  21668. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21669. /**
  21670. * Create a new ParticleRampGradientBlock
  21671. * @param name defines the block name
  21672. */
  21673. constructor(name: string);
  21674. /**
  21675. * Gets the current class name
  21676. * @returns the class name
  21677. */
  21678. getClassName(): string;
  21679. /**
  21680. * Gets the color input component
  21681. */
  21682. get color(): NodeMaterialConnectionPoint;
  21683. /**
  21684. * Gets the rampColor output component
  21685. */
  21686. get rampColor(): NodeMaterialConnectionPoint;
  21687. /**
  21688. * Initialize the block and prepare the context for build
  21689. * @param state defines the state that will be used for the build
  21690. */
  21691. initialize(state: NodeMaterialBuildState): void;
  21692. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21693. }
  21694. }
  21695. declare module BABYLON {
  21696. /**
  21697. * Block used for the particle blend multiply section
  21698. */
  21699. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21700. /**
  21701. * Create a new ParticleBlendMultiplyBlock
  21702. * @param name defines the block name
  21703. */
  21704. constructor(name: string);
  21705. /**
  21706. * Gets the current class name
  21707. * @returns the class name
  21708. */
  21709. getClassName(): string;
  21710. /**
  21711. * Gets the color input component
  21712. */
  21713. get color(): NodeMaterialConnectionPoint;
  21714. /**
  21715. * Gets the alphaTexture input component
  21716. */
  21717. get alphaTexture(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the alphaColor input component
  21720. */
  21721. get alphaColor(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the blendColor output component
  21724. */
  21725. get blendColor(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Initialize the block and prepare the context for build
  21728. * @param state defines the state that will be used for the build
  21729. */
  21730. initialize(state: NodeMaterialBuildState): void;
  21731. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21732. }
  21733. }
  21734. declare module BABYLON {
  21735. /**
  21736. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21737. */
  21738. export class VectorMergerBlock extends NodeMaterialBlock {
  21739. /**
  21740. * Create a new VectorMergerBlock
  21741. * @param name defines the block name
  21742. */
  21743. constructor(name: string);
  21744. /**
  21745. * Gets the current class name
  21746. * @returns the class name
  21747. */
  21748. getClassName(): string;
  21749. /**
  21750. * Gets the xyz component (input)
  21751. */
  21752. get xyzIn(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the xy component (input)
  21755. */
  21756. get xyIn(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the x component (input)
  21759. */
  21760. get x(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the y component (input)
  21763. */
  21764. get y(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the z component (input)
  21767. */
  21768. get z(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the w component (input)
  21771. */
  21772. get w(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the xyzw component (output)
  21775. */
  21776. get xyzw(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the xyz component (output)
  21779. */
  21780. get xyzOut(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the xy component (output)
  21783. */
  21784. get xyOut(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the xy component (output)
  21787. * @deprecated Please use xyOut instead.
  21788. */
  21789. get xy(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the xyz component (output)
  21792. * @deprecated Please use xyzOut instead.
  21793. */
  21794. get xyz(): NodeMaterialConnectionPoint;
  21795. protected _buildBlock(state: NodeMaterialBuildState): this;
  21796. }
  21797. }
  21798. declare module BABYLON {
  21799. /**
  21800. * Block used to remap a float from a range to a new one
  21801. */
  21802. export class RemapBlock extends NodeMaterialBlock {
  21803. /**
  21804. * Gets or sets the source range
  21805. */
  21806. sourceRange: Vector2;
  21807. /**
  21808. * Gets or sets the target range
  21809. */
  21810. targetRange: Vector2;
  21811. /**
  21812. * Creates a new RemapBlock
  21813. * @param name defines the block name
  21814. */
  21815. constructor(name: string);
  21816. /**
  21817. * Gets the current class name
  21818. * @returns the class name
  21819. */
  21820. getClassName(): string;
  21821. /**
  21822. * Gets the input component
  21823. */
  21824. get input(): NodeMaterialConnectionPoint;
  21825. /**
  21826. * Gets the source min input component
  21827. */
  21828. get sourceMin(): NodeMaterialConnectionPoint;
  21829. /**
  21830. * Gets the source max input component
  21831. */
  21832. get sourceMax(): NodeMaterialConnectionPoint;
  21833. /**
  21834. * Gets the target min input component
  21835. */
  21836. get targetMin(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the target max input component
  21839. */
  21840. get targetMax(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the output component
  21843. */
  21844. get output(): NodeMaterialConnectionPoint;
  21845. protected _buildBlock(state: NodeMaterialBuildState): this;
  21846. protected _dumpPropertiesCode(): string;
  21847. serialize(): any;
  21848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21849. }
  21850. }
  21851. declare module BABYLON {
  21852. /**
  21853. * Block used to multiply 2 values
  21854. */
  21855. export class MultiplyBlock extends NodeMaterialBlock {
  21856. /**
  21857. * Creates a new MultiplyBlock
  21858. * @param name defines the block name
  21859. */
  21860. constructor(name: string);
  21861. /**
  21862. * Gets the current class name
  21863. * @returns the class name
  21864. */
  21865. getClassName(): string;
  21866. /**
  21867. * Gets the left operand input component
  21868. */
  21869. get left(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the right operand input component
  21872. */
  21873. get right(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the output component
  21876. */
  21877. get output(): NodeMaterialConnectionPoint;
  21878. protected _buildBlock(state: NodeMaterialBuildState): this;
  21879. }
  21880. }
  21881. declare module BABYLON {
  21882. /**
  21883. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21884. */
  21885. export class ColorSplitterBlock extends NodeMaterialBlock {
  21886. /**
  21887. * Create a new ColorSplitterBlock
  21888. * @param name defines the block name
  21889. */
  21890. constructor(name: string);
  21891. /**
  21892. * Gets the current class name
  21893. * @returns the class name
  21894. */
  21895. getClassName(): string;
  21896. /**
  21897. * Gets the rgba component (input)
  21898. */
  21899. get rgba(): NodeMaterialConnectionPoint;
  21900. /**
  21901. * Gets the rgb component (input)
  21902. */
  21903. get rgbIn(): NodeMaterialConnectionPoint;
  21904. /**
  21905. * Gets the rgb component (output)
  21906. */
  21907. get rgbOut(): NodeMaterialConnectionPoint;
  21908. /**
  21909. * Gets the r component (output)
  21910. */
  21911. get r(): NodeMaterialConnectionPoint;
  21912. /**
  21913. * Gets the g component (output)
  21914. */
  21915. get g(): NodeMaterialConnectionPoint;
  21916. /**
  21917. * Gets the b component (output)
  21918. */
  21919. get b(): NodeMaterialConnectionPoint;
  21920. /**
  21921. * Gets the a component (output)
  21922. */
  21923. get a(): NodeMaterialConnectionPoint;
  21924. protected _inputRename(name: string): string;
  21925. protected _outputRename(name: string): string;
  21926. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21927. }
  21928. }
  21929. declare module BABYLON {
  21930. /**
  21931. * Interface used to configure the node material editor
  21932. */
  21933. export interface INodeMaterialEditorOptions {
  21934. /** Define the URl to load node editor script */
  21935. editorURL?: string;
  21936. }
  21937. /** @hidden */
  21938. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21939. NORMAL: boolean;
  21940. TANGENT: boolean;
  21941. UV1: boolean;
  21942. /** BONES */
  21943. NUM_BONE_INFLUENCERS: number;
  21944. BonesPerMesh: number;
  21945. BONETEXTURE: boolean;
  21946. /** MORPH TARGETS */
  21947. MORPHTARGETS: boolean;
  21948. MORPHTARGETS_NORMAL: boolean;
  21949. MORPHTARGETS_TANGENT: boolean;
  21950. MORPHTARGETS_UV: boolean;
  21951. NUM_MORPH_INFLUENCERS: number;
  21952. /** IMAGE PROCESSING */
  21953. IMAGEPROCESSING: boolean;
  21954. VIGNETTE: boolean;
  21955. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21956. VIGNETTEBLENDMODEOPAQUE: boolean;
  21957. TONEMAPPING: boolean;
  21958. TONEMAPPING_ACES: boolean;
  21959. CONTRAST: boolean;
  21960. EXPOSURE: boolean;
  21961. COLORCURVES: boolean;
  21962. COLORGRADING: boolean;
  21963. COLORGRADING3D: boolean;
  21964. SAMPLER3DGREENDEPTH: boolean;
  21965. SAMPLER3DBGRMAP: boolean;
  21966. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21967. /** MISC. */
  21968. BUMPDIRECTUV: number;
  21969. constructor();
  21970. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21971. }
  21972. /**
  21973. * Class used to configure NodeMaterial
  21974. */
  21975. export interface INodeMaterialOptions {
  21976. /**
  21977. * Defines if blocks should emit comments
  21978. */
  21979. emitComments: boolean;
  21980. }
  21981. /**
  21982. * Class used to create a node based material built by assembling shader blocks
  21983. */
  21984. export class NodeMaterial extends PushMaterial {
  21985. private static _BuildIdGenerator;
  21986. private _options;
  21987. private _vertexCompilationState;
  21988. private _fragmentCompilationState;
  21989. private _sharedData;
  21990. private _buildId;
  21991. private _buildWasSuccessful;
  21992. private _cachedWorldViewMatrix;
  21993. private _cachedWorldViewProjectionMatrix;
  21994. private _optimizers;
  21995. private _animationFrame;
  21996. /** Define the Url to load node editor script */
  21997. static EditorURL: string;
  21998. /** Define the Url to load snippets */
  21999. static SnippetUrl: string;
  22000. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22001. static IgnoreTexturesAtLoadTime: boolean;
  22002. private BJSNODEMATERIALEDITOR;
  22003. /** Get the inspector from bundle or global */
  22004. private _getGlobalNodeMaterialEditor;
  22005. /**
  22006. * Snippet ID if the material was created from the snippet server
  22007. */
  22008. snippetId: string;
  22009. /**
  22010. * Gets or sets data used by visual editor
  22011. * @see https://nme.babylonjs.com
  22012. */
  22013. editorData: any;
  22014. /**
  22015. * 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)
  22016. */
  22017. ignoreAlpha: boolean;
  22018. /**
  22019. * Defines the maximum number of lights that can be used in the material
  22020. */
  22021. maxSimultaneousLights: number;
  22022. /**
  22023. * Observable raised when the material is built
  22024. */
  22025. onBuildObservable: Observable<NodeMaterial>;
  22026. /**
  22027. * Gets or sets the root nodes of the material vertex shader
  22028. */
  22029. _vertexOutputNodes: NodeMaterialBlock[];
  22030. /**
  22031. * Gets or sets the root nodes of the material fragment (pixel) shader
  22032. */
  22033. _fragmentOutputNodes: NodeMaterialBlock[];
  22034. /** Gets or sets options to control the node material overall behavior */
  22035. get options(): INodeMaterialOptions;
  22036. set options(options: INodeMaterialOptions);
  22037. /**
  22038. * Default configuration related to image processing available in the standard Material.
  22039. */
  22040. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22041. /**
  22042. * Gets the image processing configuration used either in this material.
  22043. */
  22044. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22045. /**
  22046. * Sets the Default image processing configuration used either in the this material.
  22047. *
  22048. * If sets to null, the scene one is in use.
  22049. */
  22050. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22051. /**
  22052. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22053. */
  22054. attachedBlocks: NodeMaterialBlock[];
  22055. /**
  22056. * Specifies the mode of the node material
  22057. * @hidden
  22058. */
  22059. _mode: NodeMaterialModes;
  22060. /**
  22061. * Gets the mode property
  22062. */
  22063. get mode(): NodeMaterialModes;
  22064. /**
  22065. * Create a new node based material
  22066. * @param name defines the material name
  22067. * @param scene defines the hosting scene
  22068. * @param options defines creation option
  22069. */
  22070. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22071. /**
  22072. * Gets the current class name of the material e.g. "NodeMaterial"
  22073. * @returns the class name
  22074. */
  22075. getClassName(): string;
  22076. /**
  22077. * Keep track of the image processing observer to allow dispose and replace.
  22078. */
  22079. private _imageProcessingObserver;
  22080. /**
  22081. * Attaches a new image processing configuration to the Standard Material.
  22082. * @param configuration
  22083. */
  22084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22085. /**
  22086. * Get a block by its name
  22087. * @param name defines the name of the block to retrieve
  22088. * @returns the required block or null if not found
  22089. */
  22090. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22091. /**
  22092. * Get a block by its name
  22093. * @param predicate defines the predicate used to find the good candidate
  22094. * @returns the required block or null if not found
  22095. */
  22096. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22097. /**
  22098. * Get an input block by its name
  22099. * @param predicate defines the predicate used to find the good candidate
  22100. * @returns the required input block or null if not found
  22101. */
  22102. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22103. /**
  22104. * Gets the list of input blocks attached to this material
  22105. * @returns an array of InputBlocks
  22106. */
  22107. getInputBlocks(): InputBlock[];
  22108. /**
  22109. * Adds a new optimizer to the list of optimizers
  22110. * @param optimizer defines the optimizers to add
  22111. * @returns the current material
  22112. */
  22113. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22114. /**
  22115. * Remove an optimizer from the list of optimizers
  22116. * @param optimizer defines the optimizers to remove
  22117. * @returns the current material
  22118. */
  22119. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22120. /**
  22121. * Add a new block to the list of output nodes
  22122. * @param node defines the node to add
  22123. * @returns the current material
  22124. */
  22125. addOutputNode(node: NodeMaterialBlock): this;
  22126. /**
  22127. * Remove a block from the list of root nodes
  22128. * @param node defines the node to remove
  22129. * @returns the current material
  22130. */
  22131. removeOutputNode(node: NodeMaterialBlock): this;
  22132. private _addVertexOutputNode;
  22133. private _removeVertexOutputNode;
  22134. private _addFragmentOutputNode;
  22135. private _removeFragmentOutputNode;
  22136. /**
  22137. * Specifies if the material will require alpha blending
  22138. * @returns a boolean specifying if alpha blending is needed
  22139. */
  22140. needAlphaBlending(): boolean;
  22141. /**
  22142. * Specifies if this material should be rendered in alpha test mode
  22143. * @returns a boolean specifying if an alpha test is needed.
  22144. */
  22145. needAlphaTesting(): boolean;
  22146. private _initializeBlock;
  22147. private _resetDualBlocks;
  22148. /**
  22149. * Remove a block from the current node material
  22150. * @param block defines the block to remove
  22151. */
  22152. removeBlock(block: NodeMaterialBlock): void;
  22153. /**
  22154. * Build the material and generates the inner effect
  22155. * @param verbose defines if the build should log activity
  22156. */
  22157. build(verbose?: boolean): void;
  22158. /**
  22159. * Runs an otpimization phase to try to improve the shader code
  22160. */
  22161. optimize(): void;
  22162. private _prepareDefinesForAttributes;
  22163. /**
  22164. * Create a post process from the material
  22165. * @param camera The camera to apply the render pass to.
  22166. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22168. * @param engine The engine which the post process will be applied. (default: current engine)
  22169. * @param reusable If the post process can be reused on the same frame. (default: false)
  22170. * @param textureType Type of textures used when performing the post process. (default: 0)
  22171. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22172. * @returns the post process created
  22173. */
  22174. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22175. /**
  22176. * Create the post process effect from the material
  22177. * @param postProcess The post process to create the effect for
  22178. */
  22179. createEffectForPostProcess(postProcess: PostProcess): void;
  22180. private _createEffectOrPostProcess;
  22181. private _createEffectForParticles;
  22182. /**
  22183. * Create the effect to be used as the custom effect for a particle system
  22184. * @param particleSystem Particle system to create the effect for
  22185. * @param onCompiled defines a function to call when the effect creation is successful
  22186. * @param onError defines a function to call when the effect creation has failed
  22187. */
  22188. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22189. private _processDefines;
  22190. /**
  22191. * Get if the submesh is ready to be used and all its information available.
  22192. * Child classes can use it to update shaders
  22193. * @param mesh defines the mesh to check
  22194. * @param subMesh defines which submesh to check
  22195. * @param useInstances specifies that instances should be used
  22196. * @returns a boolean indicating that the submesh is ready or not
  22197. */
  22198. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22199. /**
  22200. * Get a string representing the shaders built by the current node graph
  22201. */
  22202. get compiledShaders(): string;
  22203. /**
  22204. * Binds the world matrix to the material
  22205. * @param world defines the world transformation matrix
  22206. */
  22207. bindOnlyWorldMatrix(world: Matrix): void;
  22208. /**
  22209. * Binds the submesh to this material by preparing the effect and shader to draw
  22210. * @param world defines the world transformation matrix
  22211. * @param mesh defines the mesh containing the submesh
  22212. * @param subMesh defines the submesh to bind the material to
  22213. */
  22214. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22215. /**
  22216. * Gets the active textures from the material
  22217. * @returns an array of textures
  22218. */
  22219. getActiveTextures(): BaseTexture[];
  22220. /**
  22221. * Gets the list of texture blocks
  22222. * @returns an array of texture blocks
  22223. */
  22224. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22225. /**
  22226. * Specifies if the material uses a texture
  22227. * @param texture defines the texture to check against the material
  22228. * @returns a boolean specifying if the material uses the texture
  22229. */
  22230. hasTexture(texture: BaseTexture): boolean;
  22231. /**
  22232. * Disposes the material
  22233. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22234. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22235. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22236. */
  22237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22238. /** Creates the node editor window. */
  22239. private _createNodeEditor;
  22240. /**
  22241. * Launch the node material editor
  22242. * @param config Define the configuration of the editor
  22243. * @return a promise fulfilled when the node editor is visible
  22244. */
  22245. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22246. /**
  22247. * Clear the current material
  22248. */
  22249. clear(): void;
  22250. /**
  22251. * Clear the current material and set it to a default state
  22252. */
  22253. setToDefault(): void;
  22254. /**
  22255. * Clear the current material and set it to a default state for post process
  22256. */
  22257. setToDefaultPostProcess(): void;
  22258. /**
  22259. * Clear the current material and set it to a default state for particle
  22260. */
  22261. setToDefaultParticle(): void;
  22262. /**
  22263. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22264. * @param url defines the url to load from
  22265. * @returns a promise that will fullfil when the material is fully loaded
  22266. */
  22267. loadAsync(url: string): Promise<void>;
  22268. private _gatherBlocks;
  22269. /**
  22270. * Generate a string containing the code declaration required to create an equivalent of this material
  22271. * @returns a string
  22272. */
  22273. generateCode(): string;
  22274. /**
  22275. * Serializes this material in a JSON representation
  22276. * @returns the serialized material object
  22277. */
  22278. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22279. private _restoreConnections;
  22280. /**
  22281. * Clear the current graph and load a new one from a serialization object
  22282. * @param source defines the JSON representation of the material
  22283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22284. */
  22285. loadFromSerialization(source: any, rootUrl?: string): void;
  22286. /**
  22287. * Makes a duplicate of the current material.
  22288. * @param name - name to use for the new material.
  22289. */
  22290. clone(name: string): NodeMaterial;
  22291. /**
  22292. * Creates a node material from parsed material data
  22293. * @param source defines the JSON representation of the material
  22294. * @param scene defines the hosting scene
  22295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22296. * @returns a new node material
  22297. */
  22298. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22299. /**
  22300. * Creates a node material from a snippet saved in a remote file
  22301. * @param name defines the name of the material to create
  22302. * @param url defines the url to load from
  22303. * @param scene defines the hosting scene
  22304. * @returns a promise that will resolve to the new node material
  22305. */
  22306. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22307. /**
  22308. * Creates a node material from a snippet saved by the node material editor
  22309. * @param snippetId defines the snippet to load
  22310. * @param scene defines the hosting scene
  22311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22312. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22313. * @returns a promise that will resolve to the new node material
  22314. */
  22315. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22316. /**
  22317. * Creates a new node material set to default basic configuration
  22318. * @param name defines the name of the material
  22319. * @param scene defines the hosting scene
  22320. * @returns a new NodeMaterial
  22321. */
  22322. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22323. }
  22324. }
  22325. declare module BABYLON {
  22326. /**
  22327. * Size options for a post process
  22328. */
  22329. export type PostProcessOptions = {
  22330. width: number;
  22331. height: number;
  22332. };
  22333. /**
  22334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22336. */
  22337. export class PostProcess {
  22338. /** Name of the PostProcess. */
  22339. name: string;
  22340. /**
  22341. * Gets or sets the unique id of the post process
  22342. */
  22343. uniqueId: number;
  22344. /**
  22345. * Width of the texture to apply the post process on
  22346. */
  22347. width: number;
  22348. /**
  22349. * Height of the texture to apply the post process on
  22350. */
  22351. height: number;
  22352. /**
  22353. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22354. */
  22355. nodeMaterialSource: Nullable<NodeMaterial>;
  22356. /**
  22357. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22358. * @hidden
  22359. */
  22360. _outputTexture: Nullable<InternalTexture>;
  22361. /**
  22362. * Sampling mode used by the shader
  22363. * See https://doc.babylonjs.com/classes/3.1/texture
  22364. */
  22365. renderTargetSamplingMode: number;
  22366. /**
  22367. * Clear color to use when screen clearing
  22368. */
  22369. clearColor: Color4;
  22370. /**
  22371. * If the buffer needs to be cleared before applying the post process. (default: true)
  22372. * Should be set to false if shader will overwrite all previous pixels.
  22373. */
  22374. autoClear: boolean;
  22375. /**
  22376. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22377. */
  22378. alphaMode: number;
  22379. /**
  22380. * Sets the setAlphaBlendConstants of the babylon engine
  22381. */
  22382. alphaConstants: Color4;
  22383. /**
  22384. * Animations to be used for the post processing
  22385. */
  22386. animations: Animation[];
  22387. /**
  22388. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22389. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22390. */
  22391. enablePixelPerfectMode: boolean;
  22392. /**
  22393. * Force the postprocess to be applied without taking in account viewport
  22394. */
  22395. forceFullscreenViewport: boolean;
  22396. /**
  22397. * List of inspectable custom properties (used by the Inspector)
  22398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22399. */
  22400. inspectableCustomProperties: IInspectable[];
  22401. /**
  22402. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22403. *
  22404. * | Value | Type | Description |
  22405. * | ----- | ----------------------------------- | ----------- |
  22406. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22407. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22408. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22409. *
  22410. */
  22411. scaleMode: number;
  22412. /**
  22413. * Force textures to be a power of two (default: false)
  22414. */
  22415. alwaysForcePOT: boolean;
  22416. private _samples;
  22417. /**
  22418. * Number of sample textures (default: 1)
  22419. */
  22420. get samples(): number;
  22421. set samples(n: number);
  22422. /**
  22423. * Modify the scale of the post process to be the same as the viewport (default: false)
  22424. */
  22425. adaptScaleToCurrentViewport: boolean;
  22426. private _camera;
  22427. private _scene;
  22428. private _engine;
  22429. private _options;
  22430. private _reusable;
  22431. private _textureType;
  22432. private _textureFormat;
  22433. /**
  22434. * Smart array of input and output textures for the post process.
  22435. * @hidden
  22436. */
  22437. _textures: SmartArray<InternalTexture>;
  22438. /**
  22439. * The index in _textures that corresponds to the output texture.
  22440. * @hidden
  22441. */
  22442. _currentRenderTextureInd: number;
  22443. private _effect;
  22444. private _samplers;
  22445. private _fragmentUrl;
  22446. private _vertexUrl;
  22447. private _parameters;
  22448. private _scaleRatio;
  22449. protected _indexParameters: any;
  22450. private _shareOutputWithPostProcess;
  22451. private _texelSize;
  22452. private _forcedOutputTexture;
  22453. /**
  22454. * Returns the fragment url or shader name used in the post process.
  22455. * @returns the fragment url or name in the shader store.
  22456. */
  22457. getEffectName(): string;
  22458. /**
  22459. * An event triggered when the postprocess is activated.
  22460. */
  22461. onActivateObservable: Observable<Camera>;
  22462. private _onActivateObserver;
  22463. /**
  22464. * A function that is added to the onActivateObservable
  22465. */
  22466. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22467. /**
  22468. * An event triggered when the postprocess changes its size.
  22469. */
  22470. onSizeChangedObservable: Observable<PostProcess>;
  22471. private _onSizeChangedObserver;
  22472. /**
  22473. * A function that is added to the onSizeChangedObservable
  22474. */
  22475. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22476. /**
  22477. * An event triggered when the postprocess applies its effect.
  22478. */
  22479. onApplyObservable: Observable<Effect>;
  22480. private _onApplyObserver;
  22481. /**
  22482. * A function that is added to the onApplyObservable
  22483. */
  22484. set onApply(callback: (effect: Effect) => void);
  22485. /**
  22486. * An event triggered before rendering the postprocess
  22487. */
  22488. onBeforeRenderObservable: Observable<Effect>;
  22489. private _onBeforeRenderObserver;
  22490. /**
  22491. * A function that is added to the onBeforeRenderObservable
  22492. */
  22493. set onBeforeRender(callback: (effect: Effect) => void);
  22494. /**
  22495. * An event triggered after rendering the postprocess
  22496. */
  22497. onAfterRenderObservable: Observable<Effect>;
  22498. private _onAfterRenderObserver;
  22499. /**
  22500. * A function that is added to the onAfterRenderObservable
  22501. */
  22502. set onAfterRender(callback: (efect: Effect) => void);
  22503. /**
  22504. * 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
  22505. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22506. */
  22507. get inputTexture(): InternalTexture;
  22508. set inputTexture(value: InternalTexture);
  22509. /**
  22510. * Gets the camera which post process is applied to.
  22511. * @returns The camera the post process is applied to.
  22512. */
  22513. getCamera(): Camera;
  22514. /**
  22515. * Gets the texel size of the postprocess.
  22516. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22517. */
  22518. get texelSize(): Vector2;
  22519. /**
  22520. * Creates a new instance PostProcess
  22521. * @param name The name of the PostProcess.
  22522. * @param fragmentUrl The url of the fragment shader to be used.
  22523. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22524. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22525. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22526. * @param camera The camera to apply the render pass to.
  22527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22528. * @param engine The engine which the post process will be applied. (default: current engine)
  22529. * @param reusable If the post process can be reused on the same frame. (default: false)
  22530. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22531. * @param textureType Type of textures used when performing the post process. (default: 0)
  22532. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22533. * @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
  22534. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22535. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22536. */
  22537. constructor(
  22538. /** Name of the PostProcess. */
  22539. 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);
  22540. /**
  22541. * Gets a string idenfifying the name of the class
  22542. * @returns "PostProcess" string
  22543. */
  22544. getClassName(): string;
  22545. /**
  22546. * Gets the engine which this post process belongs to.
  22547. * @returns The engine the post process was enabled with.
  22548. */
  22549. getEngine(): Engine;
  22550. /**
  22551. * The effect that is created when initializing the post process.
  22552. * @returns The created effect corresponding the the postprocess.
  22553. */
  22554. getEffect(): Effect;
  22555. /**
  22556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22557. * @param postProcess The post process to share the output with.
  22558. * @returns This post process.
  22559. */
  22560. shareOutputWith(postProcess: PostProcess): PostProcess;
  22561. /**
  22562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22564. */
  22565. useOwnOutput(): void;
  22566. /**
  22567. * Updates the effect with the current post process compile time values and recompiles the shader.
  22568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22571. * @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
  22572. * @param onCompiled Called when the shader has been compiled.
  22573. * @param onError Called if there is an error when compiling a shader.
  22574. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22575. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22576. */
  22577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22578. /**
  22579. * The post process is reusable if it can be used multiple times within one frame.
  22580. * @returns If the post process is reusable
  22581. */
  22582. isReusable(): boolean;
  22583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22584. markTextureDirty(): void;
  22585. /**
  22586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22587. * 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.
  22588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22591. * @returns The target texture that was bound to be written to.
  22592. */
  22593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22594. /**
  22595. * If the post process is supported.
  22596. */
  22597. get isSupported(): boolean;
  22598. /**
  22599. * The aspect ratio of the output texture.
  22600. */
  22601. get aspectRatio(): number;
  22602. /**
  22603. * Get a value indicating if the post-process is ready to be used
  22604. * @returns true if the post-process is ready (shader is compiled)
  22605. */
  22606. isReady(): boolean;
  22607. /**
  22608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22609. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22610. */
  22611. apply(): Nullable<Effect>;
  22612. private _disposeTextures;
  22613. /**
  22614. * Disposes the post process.
  22615. * @param camera The camera to dispose the post process on.
  22616. */
  22617. dispose(camera?: Camera): void;
  22618. }
  22619. }
  22620. declare module BABYLON {
  22621. /** @hidden */
  22622. export var kernelBlurVaryingDeclaration: {
  22623. name: string;
  22624. shader: string;
  22625. };
  22626. }
  22627. declare module BABYLON {
  22628. /** @hidden */
  22629. export var kernelBlurFragment: {
  22630. name: string;
  22631. shader: string;
  22632. };
  22633. }
  22634. declare module BABYLON {
  22635. /** @hidden */
  22636. export var kernelBlurFragment2: {
  22637. name: string;
  22638. shader: string;
  22639. };
  22640. }
  22641. declare module BABYLON {
  22642. /** @hidden */
  22643. export var kernelBlurPixelShader: {
  22644. name: string;
  22645. shader: string;
  22646. };
  22647. }
  22648. declare module BABYLON {
  22649. /** @hidden */
  22650. export var kernelBlurVertex: {
  22651. name: string;
  22652. shader: string;
  22653. };
  22654. }
  22655. declare module BABYLON {
  22656. /** @hidden */
  22657. export var kernelBlurVertexShader: {
  22658. name: string;
  22659. shader: string;
  22660. };
  22661. }
  22662. declare module BABYLON {
  22663. /**
  22664. * The Blur Post Process which blurs an image based on a kernel and direction.
  22665. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22666. */
  22667. export class BlurPostProcess extends PostProcess {
  22668. /** The direction in which to blur the image. */
  22669. direction: Vector2;
  22670. private blockCompilation;
  22671. protected _kernel: number;
  22672. protected _idealKernel: number;
  22673. protected _packedFloat: boolean;
  22674. private _staticDefines;
  22675. /**
  22676. * Sets the length in pixels of the blur sample region
  22677. */
  22678. set kernel(v: number);
  22679. /**
  22680. * Gets the length in pixels of the blur sample region
  22681. */
  22682. get kernel(): number;
  22683. /**
  22684. * Sets wether or not the blur needs to unpack/repack floats
  22685. */
  22686. set packedFloat(v: boolean);
  22687. /**
  22688. * Gets wether or not the blur is unpacking/repacking floats
  22689. */
  22690. get packedFloat(): boolean;
  22691. /**
  22692. * Creates a new instance BlurPostProcess
  22693. * @param name The name of the effect.
  22694. * @param direction The direction in which to blur the image.
  22695. * @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.
  22696. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22697. * @param camera The camera to apply the render pass to.
  22698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22699. * @param engine The engine which the post process will be applied. (default: current engine)
  22700. * @param reusable If the post process can be reused on the same frame. (default: false)
  22701. * @param textureType Type of textures used when performing the post process. (default: 0)
  22702. * @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)
  22703. */
  22704. constructor(name: string,
  22705. /** The direction in which to blur the image. */
  22706. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22707. /**
  22708. * Updates the effect with the current post process compile time values and recompiles the shader.
  22709. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22710. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22711. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22712. * @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
  22713. * @param onCompiled Called when the shader has been compiled.
  22714. * @param onError Called if there is an error when compiling a shader.
  22715. */
  22716. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22717. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22718. /**
  22719. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22720. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22721. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22722. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22723. * The gaps between physical kernels are compensated for in the weighting of the samples
  22724. * @param idealKernel Ideal blur kernel.
  22725. * @return Nearest best kernel.
  22726. */
  22727. protected _nearestBestKernel(idealKernel: number): number;
  22728. /**
  22729. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22730. * @param x The point on the Gaussian distribution to sample.
  22731. * @return the value of the Gaussian function at x.
  22732. */
  22733. protected _gaussianWeight(x: number): number;
  22734. /**
  22735. * Generates a string that can be used as a floating point number in GLSL.
  22736. * @param x Value to print.
  22737. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22738. * @return GLSL float string.
  22739. */
  22740. protected _glslFloat(x: number, decimalFigures?: number): string;
  22741. }
  22742. }
  22743. declare module BABYLON {
  22744. /**
  22745. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22746. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22747. * You can then easily use it as a reflectionTexture on a flat surface.
  22748. * In case the surface is not a plane, please consider relying on reflection probes.
  22749. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22750. */
  22751. export class MirrorTexture extends RenderTargetTexture {
  22752. private scene;
  22753. /**
  22754. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22755. * 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.
  22756. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22757. */
  22758. mirrorPlane: Plane;
  22759. /**
  22760. * Define the blur ratio used to blur the reflection if needed.
  22761. */
  22762. set blurRatio(value: number);
  22763. get blurRatio(): number;
  22764. /**
  22765. * Define the adaptive blur kernel used to blur the reflection if needed.
  22766. * This will autocompute the closest best match for the `blurKernel`
  22767. */
  22768. set adaptiveBlurKernel(value: number);
  22769. /**
  22770. * Define the blur kernel used to blur the reflection if needed.
  22771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22772. */
  22773. set blurKernel(value: number);
  22774. /**
  22775. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22777. */
  22778. set blurKernelX(value: number);
  22779. get blurKernelX(): number;
  22780. /**
  22781. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22782. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22783. */
  22784. set blurKernelY(value: number);
  22785. get blurKernelY(): number;
  22786. private _autoComputeBlurKernel;
  22787. protected _onRatioRescale(): void;
  22788. private _updateGammaSpace;
  22789. private _imageProcessingConfigChangeObserver;
  22790. private _transformMatrix;
  22791. private _mirrorMatrix;
  22792. private _savedViewMatrix;
  22793. private _blurX;
  22794. private _blurY;
  22795. private _adaptiveBlurKernel;
  22796. private _blurKernelX;
  22797. private _blurKernelY;
  22798. private _blurRatio;
  22799. /**
  22800. * Instantiates a Mirror Texture.
  22801. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22802. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22803. * You can then easily use it as a reflectionTexture on a flat surface.
  22804. * In case the surface is not a plane, please consider relying on reflection probes.
  22805. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22806. * @param name
  22807. * @param size
  22808. * @param scene
  22809. * @param generateMipMaps
  22810. * @param type
  22811. * @param samplingMode
  22812. * @param generateDepthBuffer
  22813. */
  22814. constructor(name: string, size: number | {
  22815. width: number;
  22816. height: number;
  22817. } | {
  22818. ratio: number;
  22819. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22820. private _preparePostProcesses;
  22821. /**
  22822. * Clone the mirror texture.
  22823. * @returns the cloned texture
  22824. */
  22825. clone(): MirrorTexture;
  22826. /**
  22827. * Serialize the texture to a JSON representation you could use in Parse later on
  22828. * @returns the serialized JSON representation
  22829. */
  22830. serialize(): any;
  22831. /**
  22832. * Dispose the texture and release its associated resources.
  22833. */
  22834. dispose(): void;
  22835. }
  22836. }
  22837. declare module BABYLON {
  22838. /**
  22839. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22840. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22841. */
  22842. export class Texture extends BaseTexture {
  22843. /**
  22844. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22845. */
  22846. static SerializeBuffers: boolean;
  22847. /** @hidden */
  22848. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22849. /** @hidden */
  22850. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22851. /** @hidden */
  22852. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22853. /** nearest is mag = nearest and min = nearest and mip = linear */
  22854. static readonly NEAREST_SAMPLINGMODE: number;
  22855. /** nearest is mag = nearest and min = nearest and mip = linear */
  22856. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22858. static readonly BILINEAR_SAMPLINGMODE: number;
  22859. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22860. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22861. /** Trilinear is mag = linear and min = linear and mip = linear */
  22862. static readonly TRILINEAR_SAMPLINGMODE: number;
  22863. /** Trilinear is mag = linear and min = linear and mip = linear */
  22864. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22865. /** mag = nearest and min = nearest and mip = nearest */
  22866. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22867. /** mag = nearest and min = linear and mip = nearest */
  22868. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22869. /** mag = nearest and min = linear and mip = linear */
  22870. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22871. /** mag = nearest and min = linear and mip = none */
  22872. static readonly NEAREST_LINEAR: number;
  22873. /** mag = nearest and min = nearest and mip = none */
  22874. static readonly NEAREST_NEAREST: number;
  22875. /** mag = linear and min = nearest and mip = nearest */
  22876. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22877. /** mag = linear and min = nearest and mip = linear */
  22878. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22879. /** mag = linear and min = linear and mip = none */
  22880. static readonly LINEAR_LINEAR: number;
  22881. /** mag = linear and min = nearest and mip = none */
  22882. static readonly LINEAR_NEAREST: number;
  22883. /** Explicit coordinates mode */
  22884. static readonly EXPLICIT_MODE: number;
  22885. /** Spherical coordinates mode */
  22886. static readonly SPHERICAL_MODE: number;
  22887. /** Planar coordinates mode */
  22888. static readonly PLANAR_MODE: number;
  22889. /** Cubic coordinates mode */
  22890. static readonly CUBIC_MODE: number;
  22891. /** Projection coordinates mode */
  22892. static readonly PROJECTION_MODE: number;
  22893. /** Inverse Cubic coordinates mode */
  22894. static readonly SKYBOX_MODE: number;
  22895. /** Inverse Cubic coordinates mode */
  22896. static readonly INVCUBIC_MODE: number;
  22897. /** Equirectangular coordinates mode */
  22898. static readonly EQUIRECTANGULAR_MODE: number;
  22899. /** Equirectangular Fixed coordinates mode */
  22900. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22901. /** Equirectangular Fixed Mirrored coordinates mode */
  22902. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22903. /** Texture is not repeating outside of 0..1 UVs */
  22904. static readonly CLAMP_ADDRESSMODE: number;
  22905. /** Texture is repeating outside of 0..1 UVs */
  22906. static readonly WRAP_ADDRESSMODE: number;
  22907. /** Texture is repeating and mirrored */
  22908. static readonly MIRROR_ADDRESSMODE: number;
  22909. /**
  22910. * 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
  22911. */
  22912. static UseSerializedUrlIfAny: boolean;
  22913. /**
  22914. * Define the url of the texture.
  22915. */
  22916. url: Nullable<string>;
  22917. /**
  22918. * Define an offset on the texture to offset the u coordinates of the UVs
  22919. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22920. */
  22921. uOffset: number;
  22922. /**
  22923. * Define an offset on the texture to offset the v coordinates of the UVs
  22924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22925. */
  22926. vOffset: number;
  22927. /**
  22928. * Define an offset on the texture to scale the u coordinates of the UVs
  22929. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22930. */
  22931. uScale: number;
  22932. /**
  22933. * Define an offset on the texture to scale the v coordinates of the UVs
  22934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22935. */
  22936. vScale: number;
  22937. /**
  22938. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22939. * @see http://doc.babylonjs.com/how_to/more_materials
  22940. */
  22941. uAng: number;
  22942. /**
  22943. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22944. * @see http://doc.babylonjs.com/how_to/more_materials
  22945. */
  22946. vAng: number;
  22947. /**
  22948. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22949. * @see http://doc.babylonjs.com/how_to/more_materials
  22950. */
  22951. wAng: number;
  22952. /**
  22953. * Defines the center of rotation (U)
  22954. */
  22955. uRotationCenter: number;
  22956. /**
  22957. * Defines the center of rotation (V)
  22958. */
  22959. vRotationCenter: number;
  22960. /**
  22961. * Defines the center of rotation (W)
  22962. */
  22963. wRotationCenter: number;
  22964. /**
  22965. * Are mip maps generated for this texture or not.
  22966. */
  22967. get noMipmap(): boolean;
  22968. /**
  22969. * List of inspectable custom properties (used by the Inspector)
  22970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22971. */
  22972. inspectableCustomProperties: Nullable<IInspectable[]>;
  22973. private _noMipmap;
  22974. /** @hidden */
  22975. _invertY: boolean;
  22976. private _rowGenerationMatrix;
  22977. private _cachedTextureMatrix;
  22978. private _projectionModeMatrix;
  22979. private _t0;
  22980. private _t1;
  22981. private _t2;
  22982. private _cachedUOffset;
  22983. private _cachedVOffset;
  22984. private _cachedUScale;
  22985. private _cachedVScale;
  22986. private _cachedUAng;
  22987. private _cachedVAng;
  22988. private _cachedWAng;
  22989. private _cachedProjectionMatrixId;
  22990. private _cachedCoordinatesMode;
  22991. /** @hidden */
  22992. protected _initialSamplingMode: number;
  22993. /** @hidden */
  22994. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22995. private _deleteBuffer;
  22996. protected _format: Nullable<number>;
  22997. private _delayedOnLoad;
  22998. private _delayedOnError;
  22999. private _mimeType?;
  23000. /**
  23001. * Observable triggered once the texture has been loaded.
  23002. */
  23003. onLoadObservable: Observable<Texture>;
  23004. protected _isBlocking: boolean;
  23005. /**
  23006. * Is the texture preventing material to render while loading.
  23007. * If false, a default texture will be used instead of the loading one during the preparation step.
  23008. */
  23009. set isBlocking(value: boolean);
  23010. get isBlocking(): boolean;
  23011. /**
  23012. * Get the current sampling mode associated with the texture.
  23013. */
  23014. get samplingMode(): number;
  23015. /**
  23016. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23017. */
  23018. get invertY(): boolean;
  23019. /**
  23020. * Instantiates a new texture.
  23021. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23022. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23023. * @param url defines the url of the picture to load as a texture
  23024. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23025. * @param noMipmap defines if the texture will require mip maps or not
  23026. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23027. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23028. * @param onLoad defines a callback triggered when the texture has been loaded
  23029. * @param onError defines a callback triggered when an error occurred during the loading session
  23030. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23031. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23032. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23033. * @param mimeType defines an optional mime type information
  23034. */
  23035. 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);
  23036. /**
  23037. * Update the url (and optional buffer) of this texture if url was null during construction.
  23038. * @param url the url of the texture
  23039. * @param buffer the buffer of the texture (defaults to null)
  23040. * @param onLoad callback called when the texture is loaded (defaults to null)
  23041. */
  23042. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23043. /**
  23044. * Finish the loading sequence of a texture flagged as delayed load.
  23045. * @hidden
  23046. */
  23047. delayLoad(): void;
  23048. private _prepareRowForTextureGeneration;
  23049. /**
  23050. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23051. * @returns the transform matrix of the texture.
  23052. */
  23053. getTextureMatrix(uBase?: number): Matrix;
  23054. /**
  23055. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23056. * @returns The reflection texture transform
  23057. */
  23058. getReflectionTextureMatrix(): Matrix;
  23059. /**
  23060. * Clones the texture.
  23061. * @returns the cloned texture
  23062. */
  23063. clone(): Texture;
  23064. /**
  23065. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23066. * @returns The JSON representation of the texture
  23067. */
  23068. serialize(): any;
  23069. /**
  23070. * Get the current class name of the texture useful for serialization or dynamic coding.
  23071. * @returns "Texture"
  23072. */
  23073. getClassName(): string;
  23074. /**
  23075. * Dispose the texture and release its associated resources.
  23076. */
  23077. dispose(): void;
  23078. /**
  23079. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23080. * @param parsedTexture Define the JSON representation of the texture
  23081. * @param scene Define the scene the parsed texture should be instantiated in
  23082. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23083. * @returns The parsed texture if successful
  23084. */
  23085. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23086. /**
  23087. * Creates a texture from its base 64 representation.
  23088. * @param data Define the base64 payload without the data: prefix
  23089. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23090. * @param scene Define the scene the texture should belong to
  23091. * @param noMipmap Forces the texture to not create mip map information if true
  23092. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23093. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23094. * @param onLoad define a callback triggered when the texture has been loaded
  23095. * @param onError define a callback triggered when an error occurred during the loading session
  23096. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23097. * @returns the created texture
  23098. */
  23099. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23100. /**
  23101. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23102. * @param data Define the base64 payload without the data: prefix
  23103. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23104. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23105. * @param scene Define the scene the texture should belong to
  23106. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23107. * @param noMipmap Forces the texture to not create mip map information if true
  23108. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23109. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23110. * @param onLoad define a callback triggered when the texture has been loaded
  23111. * @param onError define a callback triggered when an error occurred during the loading session
  23112. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23113. * @returns the created texture
  23114. */
  23115. 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;
  23116. }
  23117. }
  23118. declare module BABYLON {
  23119. /**
  23120. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23121. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23122. */
  23123. export class PostProcessManager {
  23124. private _scene;
  23125. private _indexBuffer;
  23126. private _vertexBuffers;
  23127. /**
  23128. * Creates a new instance PostProcess
  23129. * @param scene The scene that the post process is associated with.
  23130. */
  23131. constructor(scene: Scene);
  23132. private _prepareBuffers;
  23133. private _buildIndexBuffer;
  23134. /**
  23135. * Rebuilds the vertex buffers of the manager.
  23136. * @hidden
  23137. */
  23138. _rebuild(): void;
  23139. /**
  23140. * Prepares a frame to be run through a post process.
  23141. * @param sourceTexture The input texture to the post procesess. (default: null)
  23142. * @param postProcesses An array of post processes to be run. (default: null)
  23143. * @returns True if the post processes were able to be run.
  23144. * @hidden
  23145. */
  23146. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23147. /**
  23148. * Manually render a set of post processes to a texture.
  23149. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23150. * @param postProcesses An array of post processes to be run.
  23151. * @param targetTexture The target texture to render to.
  23152. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23153. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23154. * @param lodLevel defines which lod of the texture to render to
  23155. */
  23156. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23157. /**
  23158. * Finalize the result of the output of the postprocesses.
  23159. * @param doNotPresent If true the result will not be displayed to the screen.
  23160. * @param targetTexture The target texture to render to.
  23161. * @param faceIndex The index of the face to bind the target texture to.
  23162. * @param postProcesses The array of post processes to render.
  23163. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23164. * @hidden
  23165. */
  23166. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23167. /**
  23168. * Disposes of the post process manager.
  23169. */
  23170. dispose(): void;
  23171. }
  23172. }
  23173. declare module BABYLON {
  23174. /**
  23175. * This Helps creating a texture that will be created from a camera in your scene.
  23176. * It is basically a dynamic texture that could be used to create special effects for instance.
  23177. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23178. */
  23179. export class RenderTargetTexture extends Texture {
  23180. isCube: boolean;
  23181. /**
  23182. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23183. */
  23184. static readonly REFRESHRATE_RENDER_ONCE: number;
  23185. /**
  23186. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23187. */
  23188. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23189. /**
  23190. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23191. * the central point of your effect and can save a lot of performances.
  23192. */
  23193. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23194. /**
  23195. * Use this predicate to dynamically define the list of mesh you want to render.
  23196. * If set, the renderList property will be overwritten.
  23197. */
  23198. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23199. private _renderList;
  23200. /**
  23201. * Use this list to define the list of mesh you want to render.
  23202. */
  23203. get renderList(): Nullable<Array<AbstractMesh>>;
  23204. set renderList(value: Nullable<Array<AbstractMesh>>);
  23205. /**
  23206. * Use this function to overload the renderList array at rendering time.
  23207. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23208. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23209. * the cube (if the RTT is a cube, else layerOrFace=0).
  23210. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23211. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23212. * hold dummy elements!
  23213. */
  23214. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23215. private _hookArray;
  23216. /**
  23217. * Define if particles should be rendered in your texture.
  23218. */
  23219. renderParticles: boolean;
  23220. /**
  23221. * Define if sprites should be rendered in your texture.
  23222. */
  23223. renderSprites: boolean;
  23224. /**
  23225. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23226. */
  23227. coordinatesMode: number;
  23228. /**
  23229. * Define the camera used to render the texture.
  23230. */
  23231. activeCamera: Nullable<Camera>;
  23232. /**
  23233. * Override the mesh isReady function with your own one.
  23234. */
  23235. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23236. /**
  23237. * Override the render function of the texture with your own one.
  23238. */
  23239. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23240. /**
  23241. * Define if camera post processes should be use while rendering the texture.
  23242. */
  23243. useCameraPostProcesses: boolean;
  23244. /**
  23245. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23246. */
  23247. ignoreCameraViewport: boolean;
  23248. private _postProcessManager;
  23249. private _postProcesses;
  23250. private _resizeObserver;
  23251. /**
  23252. * An event triggered when the texture is unbind.
  23253. */
  23254. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23255. /**
  23256. * An event triggered when the texture is unbind.
  23257. */
  23258. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23259. private _onAfterUnbindObserver;
  23260. /**
  23261. * Set a after unbind callback in the texture.
  23262. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23263. */
  23264. set onAfterUnbind(callback: () => void);
  23265. /**
  23266. * An event triggered before rendering the texture
  23267. */
  23268. onBeforeRenderObservable: Observable<number>;
  23269. private _onBeforeRenderObserver;
  23270. /**
  23271. * Set a before render callback in the texture.
  23272. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23273. */
  23274. set onBeforeRender(callback: (faceIndex: number) => void);
  23275. /**
  23276. * An event triggered after rendering the texture
  23277. */
  23278. onAfterRenderObservable: Observable<number>;
  23279. private _onAfterRenderObserver;
  23280. /**
  23281. * Set a after render callback in the texture.
  23282. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23283. */
  23284. set onAfterRender(callback: (faceIndex: number) => void);
  23285. /**
  23286. * An event triggered after the texture clear
  23287. */
  23288. onClearObservable: Observable<Engine>;
  23289. private _onClearObserver;
  23290. /**
  23291. * Set a clear callback in the texture.
  23292. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23293. */
  23294. set onClear(callback: (Engine: Engine) => void);
  23295. /**
  23296. * An event triggered when the texture is resized.
  23297. */
  23298. onResizeObservable: Observable<RenderTargetTexture>;
  23299. /**
  23300. * Define the clear color of the Render Target if it should be different from the scene.
  23301. */
  23302. clearColor: Color4;
  23303. protected _size: number | {
  23304. width: number;
  23305. height: number;
  23306. layers?: number;
  23307. };
  23308. protected _initialSizeParameter: number | {
  23309. width: number;
  23310. height: number;
  23311. } | {
  23312. ratio: number;
  23313. };
  23314. protected _sizeRatio: Nullable<number>;
  23315. /** @hidden */
  23316. _generateMipMaps: boolean;
  23317. protected _renderingManager: RenderingManager;
  23318. /** @hidden */
  23319. _waitingRenderList: string[];
  23320. protected _doNotChangeAspectRatio: boolean;
  23321. protected _currentRefreshId: number;
  23322. protected _refreshRate: number;
  23323. protected _textureMatrix: Matrix;
  23324. protected _samples: number;
  23325. protected _renderTargetOptions: RenderTargetCreationOptions;
  23326. /**
  23327. * Gets render target creation options that were used.
  23328. */
  23329. get renderTargetOptions(): RenderTargetCreationOptions;
  23330. protected _onRatioRescale(): void;
  23331. /**
  23332. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23333. * It must define where the camera used to render the texture is set
  23334. */
  23335. boundingBoxPosition: Vector3;
  23336. private _boundingBoxSize;
  23337. /**
  23338. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23339. * When defined, the cubemap will switch to local mode
  23340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23341. * @example https://www.babylonjs-playground.com/#RNASML
  23342. */
  23343. set boundingBoxSize(value: Vector3);
  23344. get boundingBoxSize(): Vector3;
  23345. /**
  23346. * In case the RTT has been created with a depth texture, get the associated
  23347. * depth texture.
  23348. * Otherwise, return null.
  23349. */
  23350. get depthStencilTexture(): Nullable<InternalTexture>;
  23351. /**
  23352. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23353. * or used a shadow, depth texture...
  23354. * @param name The friendly name of the texture
  23355. * @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)
  23356. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23357. * @param generateMipMaps True if mip maps need to be generated after render.
  23358. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23359. * @param type The type of the buffer in the RTT (int, half float, float...)
  23360. * @param isCube True if a cube texture needs to be created
  23361. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23362. * @param generateDepthBuffer True to generate a depth buffer
  23363. * @param generateStencilBuffer True to generate a stencil buffer
  23364. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23365. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23366. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23367. */
  23368. constructor(name: string, size: number | {
  23369. width: number;
  23370. height: number;
  23371. layers?: number;
  23372. } | {
  23373. ratio: number;
  23374. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23375. /**
  23376. * Creates a depth stencil texture.
  23377. * This is only available in WebGL 2 or with the depth texture extension available.
  23378. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23379. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23380. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23381. */
  23382. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23383. private _processSizeParameter;
  23384. /**
  23385. * Define the number of samples to use in case of MSAA.
  23386. * It defaults to one meaning no MSAA has been enabled.
  23387. */
  23388. get samples(): number;
  23389. set samples(value: number);
  23390. /**
  23391. * Resets the refresh counter of the texture and start bak from scratch.
  23392. * Could be useful to regenerate the texture if it is setup to render only once.
  23393. */
  23394. resetRefreshCounter(): void;
  23395. /**
  23396. * Define the refresh rate of the texture or the rendering frequency.
  23397. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23398. */
  23399. get refreshRate(): number;
  23400. set refreshRate(value: number);
  23401. /**
  23402. * Adds a post process to the render target rendering passes.
  23403. * @param postProcess define the post process to add
  23404. */
  23405. addPostProcess(postProcess: PostProcess): void;
  23406. /**
  23407. * Clear all the post processes attached to the render target
  23408. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23409. */
  23410. clearPostProcesses(dispose?: boolean): void;
  23411. /**
  23412. * Remove one of the post process from the list of attached post processes to the texture
  23413. * @param postProcess define the post process to remove from the list
  23414. */
  23415. removePostProcess(postProcess: PostProcess): void;
  23416. /** @hidden */
  23417. _shouldRender(): boolean;
  23418. /**
  23419. * Gets the actual render size of the texture.
  23420. * @returns the width of the render size
  23421. */
  23422. getRenderSize(): number;
  23423. /**
  23424. * Gets the actual render width of the texture.
  23425. * @returns the width of the render size
  23426. */
  23427. getRenderWidth(): number;
  23428. /**
  23429. * Gets the actual render height of the texture.
  23430. * @returns the height of the render size
  23431. */
  23432. getRenderHeight(): number;
  23433. /**
  23434. * Gets the actual number of layers of the texture.
  23435. * @returns the number of layers
  23436. */
  23437. getRenderLayers(): number;
  23438. /**
  23439. * Get if the texture can be rescaled or not.
  23440. */
  23441. get canRescale(): boolean;
  23442. /**
  23443. * Resize the texture using a ratio.
  23444. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23445. */
  23446. scale(ratio: number): void;
  23447. /**
  23448. * Get the texture reflection matrix used to rotate/transform the reflection.
  23449. * @returns the reflection matrix
  23450. */
  23451. getReflectionTextureMatrix(): Matrix;
  23452. /**
  23453. * Resize the texture to a new desired size.
  23454. * Be carrefull as it will recreate all the data in the new texture.
  23455. * @param size Define the new size. It can be:
  23456. * - a number for squared texture,
  23457. * - an object containing { width: number, height: number }
  23458. * - or an object containing a ratio { ratio: number }
  23459. */
  23460. resize(size: number | {
  23461. width: number;
  23462. height: number;
  23463. } | {
  23464. ratio: number;
  23465. }): void;
  23466. private _defaultRenderListPrepared;
  23467. /**
  23468. * Renders all the objects from the render list into the texture.
  23469. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23470. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23471. */
  23472. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23473. private _bestReflectionRenderTargetDimension;
  23474. private _prepareRenderingManager;
  23475. /**
  23476. * @hidden
  23477. * @param faceIndex face index to bind to if this is a cubetexture
  23478. * @param layer defines the index of the texture to bind in the array
  23479. */
  23480. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23481. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23482. private renderToTarget;
  23483. /**
  23484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23485. * This allowed control for front to back rendering or reversly depending of the special needs.
  23486. *
  23487. * @param renderingGroupId The rendering group id corresponding to its index
  23488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23491. */
  23492. 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;
  23493. /**
  23494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23495. *
  23496. * @param renderingGroupId The rendering group id corresponding to its index
  23497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23498. */
  23499. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23500. /**
  23501. * Clones the texture.
  23502. * @returns the cloned texture
  23503. */
  23504. clone(): RenderTargetTexture;
  23505. /**
  23506. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23507. * @returns The JSON representation of the texture
  23508. */
  23509. serialize(): any;
  23510. /**
  23511. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23512. */
  23513. disposeFramebufferObjects(): void;
  23514. /**
  23515. * Dispose the texture and release its associated resources.
  23516. */
  23517. dispose(): void;
  23518. /** @hidden */
  23519. _rebuild(): void;
  23520. /**
  23521. * Clear the info related to rendering groups preventing retention point in material dispose.
  23522. */
  23523. freeRenderingGroups(): void;
  23524. /**
  23525. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23526. * @returns the view count
  23527. */
  23528. getViewCount(): number;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * Class used to manipulate GUIDs
  23534. */
  23535. export class GUID {
  23536. /**
  23537. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23538. * Be aware Math.random() could cause collisions, but:
  23539. * "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"
  23540. * @returns a pseudo random id
  23541. */
  23542. static RandomId(): string;
  23543. }
  23544. }
  23545. declare module BABYLON {
  23546. /**
  23547. * Options to be used when creating a shadow depth material
  23548. */
  23549. export interface IIOptionShadowDepthMaterial {
  23550. /** Variables in the vertex shader code that need to have their names remapped.
  23551. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23552. * "var_name" should be either: worldPos or vNormalW
  23553. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23554. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23555. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23556. */
  23557. remappedVariables?: string[];
  23558. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23559. standalone?: boolean;
  23560. }
  23561. /**
  23562. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23563. */
  23564. export class ShadowDepthWrapper {
  23565. private _scene;
  23566. private _options?;
  23567. private _baseMaterial;
  23568. private _onEffectCreatedObserver;
  23569. private _subMeshToEffect;
  23570. private _subMeshToDepthEffect;
  23571. private _meshes;
  23572. /** @hidden */
  23573. _matriceNames: any;
  23574. /** Gets the standalone status of the wrapper */
  23575. get standalone(): boolean;
  23576. /** Gets the base material the wrapper is built upon */
  23577. get baseMaterial(): Material;
  23578. /**
  23579. * Instantiate a new shadow depth wrapper.
  23580. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23581. * generate the shadow depth map. For more information, please refer to the documentation:
  23582. * https://doc.babylonjs.com/babylon101/shadows
  23583. * @param baseMaterial Material to wrap
  23584. * @param scene Define the scene the material belongs to
  23585. * @param options Options used to create the wrapper
  23586. */
  23587. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23588. /**
  23589. * Gets the effect to use to generate the depth map
  23590. * @param subMesh subMesh to get the effect for
  23591. * @param shadowGenerator shadow generator to get the effect for
  23592. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23593. */
  23594. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23595. /**
  23596. * Specifies that the submesh is ready to be used for depth rendering
  23597. * @param subMesh submesh to check
  23598. * @param defines the list of defines to take into account when checking the effect
  23599. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23600. * @param useInstances specifies that instances should be used
  23601. * @returns a boolean indicating that the submesh is ready or not
  23602. */
  23603. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23604. /**
  23605. * Disposes the resources
  23606. */
  23607. dispose(): void;
  23608. private _makeEffect;
  23609. }
  23610. }
  23611. declare module BABYLON {
  23612. /**
  23613. * Options for compiling materials.
  23614. */
  23615. export interface IMaterialCompilationOptions {
  23616. /**
  23617. * Defines whether clip planes are enabled.
  23618. */
  23619. clipPlane: boolean;
  23620. /**
  23621. * Defines whether instances are enabled.
  23622. */
  23623. useInstances: boolean;
  23624. }
  23625. /**
  23626. * Options passed when calling customShaderNameResolve
  23627. */
  23628. export interface ICustomShaderNameResolveOptions {
  23629. /**
  23630. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  23631. */
  23632. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23633. }
  23634. /**
  23635. * Base class for the main features of a material in Babylon.js
  23636. */
  23637. export class Material implements IAnimatable {
  23638. /**
  23639. * Returns the triangle fill mode
  23640. */
  23641. static readonly TriangleFillMode: number;
  23642. /**
  23643. * Returns the wireframe mode
  23644. */
  23645. static readonly WireFrameFillMode: number;
  23646. /**
  23647. * Returns the point fill mode
  23648. */
  23649. static readonly PointFillMode: number;
  23650. /**
  23651. * Returns the point list draw mode
  23652. */
  23653. static readonly PointListDrawMode: number;
  23654. /**
  23655. * Returns the line list draw mode
  23656. */
  23657. static readonly LineListDrawMode: number;
  23658. /**
  23659. * Returns the line loop draw mode
  23660. */
  23661. static readonly LineLoopDrawMode: number;
  23662. /**
  23663. * Returns the line strip draw mode
  23664. */
  23665. static readonly LineStripDrawMode: number;
  23666. /**
  23667. * Returns the triangle strip draw mode
  23668. */
  23669. static readonly TriangleStripDrawMode: number;
  23670. /**
  23671. * Returns the triangle fan draw mode
  23672. */
  23673. static readonly TriangleFanDrawMode: number;
  23674. /**
  23675. * Stores the clock-wise side orientation
  23676. */
  23677. static readonly ClockWiseSideOrientation: number;
  23678. /**
  23679. * Stores the counter clock-wise side orientation
  23680. */
  23681. static readonly CounterClockWiseSideOrientation: number;
  23682. /**
  23683. * The dirty texture flag value
  23684. */
  23685. static readonly TextureDirtyFlag: number;
  23686. /**
  23687. * The dirty light flag value
  23688. */
  23689. static readonly LightDirtyFlag: number;
  23690. /**
  23691. * The dirty fresnel flag value
  23692. */
  23693. static readonly FresnelDirtyFlag: number;
  23694. /**
  23695. * The dirty attribute flag value
  23696. */
  23697. static readonly AttributesDirtyFlag: number;
  23698. /**
  23699. * The dirty misc flag value
  23700. */
  23701. static readonly MiscDirtyFlag: number;
  23702. /**
  23703. * The all dirty flag value
  23704. */
  23705. static readonly AllDirtyFlag: number;
  23706. /**
  23707. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23708. */
  23709. static readonly MATERIAL_OPAQUE: number;
  23710. /**
  23711. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23712. */
  23713. static readonly MATERIAL_ALPHATEST: number;
  23714. /**
  23715. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23716. */
  23717. static readonly MATERIAL_ALPHABLEND: number;
  23718. /**
  23719. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23720. * They are also discarded below the alpha cutoff threshold to improve performances.
  23721. */
  23722. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23723. /**
  23724. * Custom callback helping to override the default shader used in the material.
  23725. */
  23726. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23727. /**
  23728. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23729. */
  23730. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23731. /**
  23732. * The ID of the material
  23733. */
  23734. id: string;
  23735. /**
  23736. * Gets or sets the unique id of the material
  23737. */
  23738. uniqueId: number;
  23739. /**
  23740. * The name of the material
  23741. */
  23742. name: string;
  23743. /**
  23744. * Gets or sets user defined metadata
  23745. */
  23746. metadata: any;
  23747. /**
  23748. * For internal use only. Please do not use.
  23749. */
  23750. reservedDataStore: any;
  23751. /**
  23752. * Specifies if the ready state should be checked on each call
  23753. */
  23754. checkReadyOnEveryCall: boolean;
  23755. /**
  23756. * Specifies if the ready state should be checked once
  23757. */
  23758. checkReadyOnlyOnce: boolean;
  23759. /**
  23760. * The state of the material
  23761. */
  23762. state: string;
  23763. /**
  23764. * The alpha value of the material
  23765. */
  23766. protected _alpha: number;
  23767. /**
  23768. * List of inspectable custom properties (used by the Inspector)
  23769. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23770. */
  23771. inspectableCustomProperties: IInspectable[];
  23772. /**
  23773. * Sets the alpha value of the material
  23774. */
  23775. set alpha(value: number);
  23776. /**
  23777. * Gets the alpha value of the material
  23778. */
  23779. get alpha(): number;
  23780. /**
  23781. * Specifies if back face culling is enabled
  23782. */
  23783. protected _backFaceCulling: boolean;
  23784. /**
  23785. * Sets the back-face culling state
  23786. */
  23787. set backFaceCulling(value: boolean);
  23788. /**
  23789. * Gets the back-face culling state
  23790. */
  23791. get backFaceCulling(): boolean;
  23792. /**
  23793. * Stores the value for side orientation
  23794. */
  23795. sideOrientation: number;
  23796. /**
  23797. * Callback triggered when the material is compiled
  23798. */
  23799. onCompiled: Nullable<(effect: Effect) => void>;
  23800. /**
  23801. * Callback triggered when an error occurs
  23802. */
  23803. onError: Nullable<(effect: Effect, errors: string) => void>;
  23804. /**
  23805. * Callback triggered to get the render target textures
  23806. */
  23807. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23808. /**
  23809. * Gets a boolean indicating that current material needs to register RTT
  23810. */
  23811. get hasRenderTargetTextures(): boolean;
  23812. /**
  23813. * Specifies if the material should be serialized
  23814. */
  23815. doNotSerialize: boolean;
  23816. /**
  23817. * @hidden
  23818. */
  23819. _storeEffectOnSubMeshes: boolean;
  23820. /**
  23821. * Stores the animations for the material
  23822. */
  23823. animations: Nullable<Array<Animation>>;
  23824. /**
  23825. * An event triggered when the material is disposed
  23826. */
  23827. onDisposeObservable: Observable<Material>;
  23828. /**
  23829. * An observer which watches for dispose events
  23830. */
  23831. private _onDisposeObserver;
  23832. private _onUnBindObservable;
  23833. /**
  23834. * Called during a dispose event
  23835. */
  23836. set onDispose(callback: () => void);
  23837. private _onBindObservable;
  23838. /**
  23839. * An event triggered when the material is bound
  23840. */
  23841. get onBindObservable(): Observable<AbstractMesh>;
  23842. /**
  23843. * An observer which watches for bind events
  23844. */
  23845. private _onBindObserver;
  23846. /**
  23847. * Called during a bind event
  23848. */
  23849. set onBind(callback: (Mesh: AbstractMesh) => void);
  23850. /**
  23851. * An event triggered when the material is unbound
  23852. */
  23853. get onUnBindObservable(): Observable<Material>;
  23854. protected _onEffectCreatedObservable: Nullable<Observable<{
  23855. effect: Effect;
  23856. subMesh: Nullable<SubMesh>;
  23857. }>>;
  23858. /**
  23859. * An event triggered when the effect is (re)created
  23860. */
  23861. get onEffectCreatedObservable(): Observable<{
  23862. effect: Effect;
  23863. subMesh: Nullable<SubMesh>;
  23864. }>;
  23865. /**
  23866. * Stores the value of the alpha mode
  23867. */
  23868. private _alphaMode;
  23869. /**
  23870. * Sets the value of the alpha mode.
  23871. *
  23872. * | Value | Type | Description |
  23873. * | --- | --- | --- |
  23874. * | 0 | ALPHA_DISABLE | |
  23875. * | 1 | ALPHA_ADD | |
  23876. * | 2 | ALPHA_COMBINE | |
  23877. * | 3 | ALPHA_SUBTRACT | |
  23878. * | 4 | ALPHA_MULTIPLY | |
  23879. * | 5 | ALPHA_MAXIMIZED | |
  23880. * | 6 | ALPHA_ONEONE | |
  23881. * | 7 | ALPHA_PREMULTIPLIED | |
  23882. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23883. * | 9 | ALPHA_INTERPOLATE | |
  23884. * | 10 | ALPHA_SCREENMODE | |
  23885. *
  23886. */
  23887. set alphaMode(value: number);
  23888. /**
  23889. * Gets the value of the alpha mode
  23890. */
  23891. get alphaMode(): number;
  23892. /**
  23893. * Stores the state of the need depth pre-pass value
  23894. */
  23895. private _needDepthPrePass;
  23896. /**
  23897. * Sets the need depth pre-pass value
  23898. */
  23899. set needDepthPrePass(value: boolean);
  23900. /**
  23901. * Gets the depth pre-pass value
  23902. */
  23903. get needDepthPrePass(): boolean;
  23904. /**
  23905. * Specifies if depth writing should be disabled
  23906. */
  23907. disableDepthWrite: boolean;
  23908. /**
  23909. * Specifies if color writing should be disabled
  23910. */
  23911. disableColorWrite: boolean;
  23912. /**
  23913. * Specifies if depth writing should be forced
  23914. */
  23915. forceDepthWrite: boolean;
  23916. /**
  23917. * Specifies the depth function that should be used. 0 means the default engine function
  23918. */
  23919. depthFunction: number;
  23920. /**
  23921. * Specifies if there should be a separate pass for culling
  23922. */
  23923. separateCullingPass: boolean;
  23924. /**
  23925. * Stores the state specifing if fog should be enabled
  23926. */
  23927. private _fogEnabled;
  23928. /**
  23929. * Sets the state for enabling fog
  23930. */
  23931. set fogEnabled(value: boolean);
  23932. /**
  23933. * Gets the value of the fog enabled state
  23934. */
  23935. get fogEnabled(): boolean;
  23936. /**
  23937. * Stores the size of points
  23938. */
  23939. pointSize: number;
  23940. /**
  23941. * Stores the z offset value
  23942. */
  23943. zOffset: number;
  23944. get wireframe(): boolean;
  23945. /**
  23946. * Sets the state of wireframe mode
  23947. */
  23948. set wireframe(value: boolean);
  23949. /**
  23950. * Gets the value specifying if point clouds are enabled
  23951. */
  23952. get pointsCloud(): boolean;
  23953. /**
  23954. * Sets the state of point cloud mode
  23955. */
  23956. set pointsCloud(value: boolean);
  23957. /**
  23958. * Gets the material fill mode
  23959. */
  23960. get fillMode(): number;
  23961. /**
  23962. * Sets the material fill mode
  23963. */
  23964. set fillMode(value: number);
  23965. /**
  23966. * @hidden
  23967. * Stores the effects for the material
  23968. */
  23969. _effect: Nullable<Effect>;
  23970. /**
  23971. * Specifies if uniform buffers should be used
  23972. */
  23973. private _useUBO;
  23974. /**
  23975. * Stores a reference to the scene
  23976. */
  23977. private _scene;
  23978. /**
  23979. * Stores the fill mode state
  23980. */
  23981. private _fillMode;
  23982. /**
  23983. * Specifies if the depth write state should be cached
  23984. */
  23985. private _cachedDepthWriteState;
  23986. /**
  23987. * Specifies if the color write state should be cached
  23988. */
  23989. private _cachedColorWriteState;
  23990. /**
  23991. * Specifies if the depth function state should be cached
  23992. */
  23993. private _cachedDepthFunctionState;
  23994. /**
  23995. * Stores the uniform buffer
  23996. */
  23997. protected _uniformBuffer: UniformBuffer;
  23998. /** @hidden */
  23999. _indexInSceneMaterialArray: number;
  24000. /** @hidden */
  24001. meshMap: Nullable<{
  24002. [id: string]: AbstractMesh | undefined;
  24003. }>;
  24004. /**
  24005. * Creates a material instance
  24006. * @param name defines the name of the material
  24007. * @param scene defines the scene to reference
  24008. * @param doNotAdd specifies if the material should be added to the scene
  24009. */
  24010. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24011. /**
  24012. * Returns a string representation of the current material
  24013. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24014. * @returns a string with material information
  24015. */
  24016. toString(fullDetails?: boolean): string;
  24017. /**
  24018. * Gets the class name of the material
  24019. * @returns a string with the class name of the material
  24020. */
  24021. getClassName(): string;
  24022. /**
  24023. * Specifies if updates for the material been locked
  24024. */
  24025. get isFrozen(): boolean;
  24026. /**
  24027. * Locks updates for the material
  24028. */
  24029. freeze(): void;
  24030. /**
  24031. * Unlocks updates for the material
  24032. */
  24033. unfreeze(): void;
  24034. /**
  24035. * Specifies if the material is ready to be used
  24036. * @param mesh defines the mesh to check
  24037. * @param useInstances specifies if instances should be used
  24038. * @returns a boolean indicating if the material is ready to be used
  24039. */
  24040. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24041. /**
  24042. * Specifies that the submesh is ready to be used
  24043. * @param mesh defines the mesh to check
  24044. * @param subMesh defines which submesh to check
  24045. * @param useInstances specifies that instances should be used
  24046. * @returns a boolean indicating that the submesh is ready or not
  24047. */
  24048. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24049. /**
  24050. * Returns the material effect
  24051. * @returns the effect associated with the material
  24052. */
  24053. getEffect(): Nullable<Effect>;
  24054. /**
  24055. * Returns the current scene
  24056. * @returns a Scene
  24057. */
  24058. getScene(): Scene;
  24059. /**
  24060. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24061. */
  24062. protected _forceAlphaTest: boolean;
  24063. /**
  24064. * The transparency mode of the material.
  24065. */
  24066. protected _transparencyMode: Nullable<number>;
  24067. /**
  24068. * Gets the current transparency mode.
  24069. */
  24070. get transparencyMode(): Nullable<number>;
  24071. /**
  24072. * Sets the transparency mode of the material.
  24073. *
  24074. * | Value | Type | Description |
  24075. * | ----- | ----------------------------------- | ----------- |
  24076. * | 0 | OPAQUE | |
  24077. * | 1 | ALPHATEST | |
  24078. * | 2 | ALPHABLEND | |
  24079. * | 3 | ALPHATESTANDBLEND | |
  24080. *
  24081. */
  24082. set transparencyMode(value: Nullable<number>);
  24083. /**
  24084. * Returns true if alpha blending should be disabled.
  24085. */
  24086. protected get _disableAlphaBlending(): boolean;
  24087. /**
  24088. * Specifies whether or not this material should be rendered in alpha blend mode.
  24089. * @returns a boolean specifying if alpha blending is needed
  24090. */
  24091. needAlphaBlending(): boolean;
  24092. /**
  24093. * Specifies if the mesh will require alpha blending
  24094. * @param mesh defines the mesh to check
  24095. * @returns a boolean specifying if alpha blending is needed for the mesh
  24096. */
  24097. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24098. /**
  24099. * Specifies whether or not this material should be rendered in alpha test mode.
  24100. * @returns a boolean specifying if an alpha test is needed.
  24101. */
  24102. needAlphaTesting(): boolean;
  24103. /**
  24104. * Specifies if material alpha testing should be turned on for the mesh
  24105. * @param mesh defines the mesh to check
  24106. */
  24107. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24108. /**
  24109. * Gets the texture used for the alpha test
  24110. * @returns the texture to use for alpha testing
  24111. */
  24112. getAlphaTestTexture(): Nullable<BaseTexture>;
  24113. /**
  24114. * Marks the material to indicate that it needs to be re-calculated
  24115. */
  24116. markDirty(): void;
  24117. /** @hidden */
  24118. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24119. /**
  24120. * Binds the material to the mesh
  24121. * @param world defines the world transformation matrix
  24122. * @param mesh defines the mesh to bind the material to
  24123. */
  24124. bind(world: Matrix, mesh?: Mesh): void;
  24125. /**
  24126. * Binds the submesh to the material
  24127. * @param world defines the world transformation matrix
  24128. * @param mesh defines the mesh containing the submesh
  24129. * @param subMesh defines the submesh to bind the material to
  24130. */
  24131. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24132. /**
  24133. * Binds the world matrix to the material
  24134. * @param world defines the world transformation matrix
  24135. */
  24136. bindOnlyWorldMatrix(world: Matrix): void;
  24137. /**
  24138. * Binds the scene's uniform buffer to the effect.
  24139. * @param effect defines the effect to bind to the scene uniform buffer
  24140. * @param sceneUbo defines the uniform buffer storing scene data
  24141. */
  24142. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24143. /**
  24144. * Binds the view matrix to the effect
  24145. * @param effect defines the effect to bind the view matrix to
  24146. */
  24147. bindView(effect: Effect): void;
  24148. /**
  24149. * Binds the view projection matrix to the effect
  24150. * @param effect defines the effect to bind the view projection matrix to
  24151. */
  24152. bindViewProjection(effect: Effect): void;
  24153. /**
  24154. * Processes to execute after binding the material to a mesh
  24155. * @param mesh defines the rendered mesh
  24156. */
  24157. protected _afterBind(mesh?: Mesh): void;
  24158. /**
  24159. * Unbinds the material from the mesh
  24160. */
  24161. unbind(): void;
  24162. /**
  24163. * Gets the active textures from the material
  24164. * @returns an array of textures
  24165. */
  24166. getActiveTextures(): BaseTexture[];
  24167. /**
  24168. * Specifies if the material uses a texture
  24169. * @param texture defines the texture to check against the material
  24170. * @returns a boolean specifying if the material uses the texture
  24171. */
  24172. hasTexture(texture: BaseTexture): boolean;
  24173. /**
  24174. * Makes a duplicate of the material, and gives it a new name
  24175. * @param name defines the new name for the duplicated material
  24176. * @returns the cloned material
  24177. */
  24178. clone(name: string): Nullable<Material>;
  24179. /**
  24180. * Gets the meshes bound to the material
  24181. * @returns an array of meshes bound to the material
  24182. */
  24183. getBindedMeshes(): AbstractMesh[];
  24184. /**
  24185. * Force shader compilation
  24186. * @param mesh defines the mesh associated with this material
  24187. * @param onCompiled defines a function to execute once the material is compiled
  24188. * @param options defines the options to configure the compilation
  24189. * @param onError defines a function to execute if the material fails compiling
  24190. */
  24191. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24192. /**
  24193. * Force shader compilation
  24194. * @param mesh defines the mesh that will use this material
  24195. * @param options defines additional options for compiling the shaders
  24196. * @returns a promise that resolves when the compilation completes
  24197. */
  24198. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24199. private static readonly _AllDirtyCallBack;
  24200. private static readonly _ImageProcessingDirtyCallBack;
  24201. private static readonly _TextureDirtyCallBack;
  24202. private static readonly _FresnelDirtyCallBack;
  24203. private static readonly _MiscDirtyCallBack;
  24204. private static readonly _LightsDirtyCallBack;
  24205. private static readonly _AttributeDirtyCallBack;
  24206. private static _FresnelAndMiscDirtyCallBack;
  24207. private static _TextureAndMiscDirtyCallBack;
  24208. private static readonly _DirtyCallbackArray;
  24209. private static readonly _RunDirtyCallBacks;
  24210. /**
  24211. * Marks a define in the material to indicate that it needs to be re-computed
  24212. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24213. */
  24214. markAsDirty(flag: number): void;
  24215. /**
  24216. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24217. * @param func defines a function which checks material defines against the submeshes
  24218. */
  24219. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24220. /**
  24221. * Indicates that we need to re-calculated for all submeshes
  24222. */
  24223. protected _markAllSubMeshesAsAllDirty(): void;
  24224. /**
  24225. * Indicates that image processing needs to be re-calculated for all submeshes
  24226. */
  24227. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24228. /**
  24229. * Indicates that textures need to be re-calculated for all submeshes
  24230. */
  24231. protected _markAllSubMeshesAsTexturesDirty(): void;
  24232. /**
  24233. * Indicates that fresnel needs to be re-calculated for all submeshes
  24234. */
  24235. protected _markAllSubMeshesAsFresnelDirty(): void;
  24236. /**
  24237. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24238. */
  24239. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24240. /**
  24241. * Indicates that lights need to be re-calculated for all submeshes
  24242. */
  24243. protected _markAllSubMeshesAsLightsDirty(): void;
  24244. /**
  24245. * Indicates that attributes need to be re-calculated for all submeshes
  24246. */
  24247. protected _markAllSubMeshesAsAttributesDirty(): void;
  24248. /**
  24249. * Indicates that misc needs to be re-calculated for all submeshes
  24250. */
  24251. protected _markAllSubMeshesAsMiscDirty(): void;
  24252. /**
  24253. * Indicates that textures and misc need to be re-calculated for all submeshes
  24254. */
  24255. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24256. /**
  24257. * Disposes the material
  24258. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24259. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24260. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24261. */
  24262. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24263. /** @hidden */
  24264. private releaseVertexArrayObject;
  24265. /**
  24266. * Serializes this material
  24267. * @returns the serialized material object
  24268. */
  24269. serialize(): any;
  24270. /**
  24271. * Creates a material from parsed material data
  24272. * @param parsedMaterial defines parsed material data
  24273. * @param scene defines the hosting scene
  24274. * @param rootUrl defines the root URL to use to load textures
  24275. * @returns a new material
  24276. */
  24277. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24278. }
  24279. }
  24280. declare module BABYLON {
  24281. /**
  24282. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24283. * separate meshes. This can be use to improve performances.
  24284. * @see http://doc.babylonjs.com/how_to/multi_materials
  24285. */
  24286. export class MultiMaterial extends Material {
  24287. private _subMaterials;
  24288. /**
  24289. * Gets or Sets the list of Materials used within the multi material.
  24290. * They need to be ordered according to the submeshes order in the associated mesh
  24291. */
  24292. get subMaterials(): Nullable<Material>[];
  24293. set subMaterials(value: Nullable<Material>[]);
  24294. /**
  24295. * Function used to align with Node.getChildren()
  24296. * @returns the list of Materials used within the multi material
  24297. */
  24298. getChildren(): Nullable<Material>[];
  24299. /**
  24300. * Instantiates a new Multi Material
  24301. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24302. * separate meshes. This can be use to improve performances.
  24303. * @see http://doc.babylonjs.com/how_to/multi_materials
  24304. * @param name Define the name in the scene
  24305. * @param scene Define the scene the material belongs to
  24306. */
  24307. constructor(name: string, scene: Scene);
  24308. private _hookArray;
  24309. /**
  24310. * Get one of the submaterial by its index in the submaterials array
  24311. * @param index The index to look the sub material at
  24312. * @returns The Material if the index has been defined
  24313. */
  24314. getSubMaterial(index: number): Nullable<Material>;
  24315. /**
  24316. * Get the list of active textures for the whole sub materials list.
  24317. * @returns All the textures that will be used during the rendering
  24318. */
  24319. getActiveTextures(): BaseTexture[];
  24320. /**
  24321. * Gets the current class name of the material e.g. "MultiMaterial"
  24322. * Mainly use in serialization.
  24323. * @returns the class name
  24324. */
  24325. getClassName(): string;
  24326. /**
  24327. * Checks if the material is ready to render the requested sub mesh
  24328. * @param mesh Define the mesh the submesh belongs to
  24329. * @param subMesh Define the sub mesh to look readyness for
  24330. * @param useInstances Define whether or not the material is used with instances
  24331. * @returns true if ready, otherwise false
  24332. */
  24333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24334. /**
  24335. * Clones the current material and its related sub materials
  24336. * @param name Define the name of the newly cloned material
  24337. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24338. * @returns the cloned material
  24339. */
  24340. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24341. /**
  24342. * Serializes the materials into a JSON representation.
  24343. * @returns the JSON representation
  24344. */
  24345. serialize(): any;
  24346. /**
  24347. * Dispose the material and release its associated resources
  24348. * @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)
  24349. * @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)
  24350. * @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)
  24351. */
  24352. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24353. /**
  24354. * Creates a MultiMaterial from parsed MultiMaterial data.
  24355. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24356. * @param scene defines the hosting scene
  24357. * @returns a new MultiMaterial
  24358. */
  24359. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24360. }
  24361. }
  24362. declare module BABYLON {
  24363. /**
  24364. * Base class for submeshes
  24365. */
  24366. export class BaseSubMesh {
  24367. /** @hidden */
  24368. _materialDefines: Nullable<MaterialDefines>;
  24369. /** @hidden */
  24370. _materialEffect: Nullable<Effect>;
  24371. /** @hidden */
  24372. _effectOverride: Nullable<Effect>;
  24373. /**
  24374. * Gets material defines used by the effect associated to the sub mesh
  24375. */
  24376. get materialDefines(): Nullable<MaterialDefines>;
  24377. /**
  24378. * Sets material defines used by the effect associated to the sub mesh
  24379. */
  24380. set materialDefines(defines: Nullable<MaterialDefines>);
  24381. /**
  24382. * Gets associated effect
  24383. */
  24384. get effect(): Nullable<Effect>;
  24385. /**
  24386. * Sets associated effect (effect used to render this submesh)
  24387. * @param effect defines the effect to associate with
  24388. * @param defines defines the set of defines used to compile this effect
  24389. */
  24390. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24391. }
  24392. /**
  24393. * Defines a subdivision inside a mesh
  24394. */
  24395. export class SubMesh extends BaseSubMesh implements ICullable {
  24396. /** the material index to use */
  24397. materialIndex: number;
  24398. /** vertex index start */
  24399. verticesStart: number;
  24400. /** vertices count */
  24401. verticesCount: number;
  24402. /** index start */
  24403. indexStart: number;
  24404. /** indices count */
  24405. indexCount: number;
  24406. /** @hidden */
  24407. _linesIndexCount: number;
  24408. private _mesh;
  24409. private _renderingMesh;
  24410. private _boundingInfo;
  24411. private _linesIndexBuffer;
  24412. /** @hidden */
  24413. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24414. /** @hidden */
  24415. _trianglePlanes: Plane[];
  24416. /** @hidden */
  24417. _lastColliderTransformMatrix: Nullable<Matrix>;
  24418. /** @hidden */
  24419. _renderId: number;
  24420. /** @hidden */
  24421. _alphaIndex: number;
  24422. /** @hidden */
  24423. _distanceToCamera: number;
  24424. /** @hidden */
  24425. _id: number;
  24426. private _currentMaterial;
  24427. /**
  24428. * Add a new submesh to a mesh
  24429. * @param materialIndex defines the material index to use
  24430. * @param verticesStart defines vertex index start
  24431. * @param verticesCount defines vertices count
  24432. * @param indexStart defines index start
  24433. * @param indexCount defines indices count
  24434. * @param mesh defines the parent mesh
  24435. * @param renderingMesh defines an optional rendering mesh
  24436. * @param createBoundingBox defines if bounding box should be created for this submesh
  24437. * @returns the new submesh
  24438. */
  24439. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24440. /**
  24441. * Creates a new submesh
  24442. * @param materialIndex defines the material index to use
  24443. * @param verticesStart defines vertex index start
  24444. * @param verticesCount defines vertices count
  24445. * @param indexStart defines index start
  24446. * @param indexCount defines indices count
  24447. * @param mesh defines the parent mesh
  24448. * @param renderingMesh defines an optional rendering mesh
  24449. * @param createBoundingBox defines if bounding box should be created for this submesh
  24450. */
  24451. constructor(
  24452. /** the material index to use */
  24453. materialIndex: number,
  24454. /** vertex index start */
  24455. verticesStart: number,
  24456. /** vertices count */
  24457. verticesCount: number,
  24458. /** index start */
  24459. indexStart: number,
  24460. /** indices count */
  24461. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24462. /**
  24463. * Returns true if this submesh covers the entire parent mesh
  24464. * @ignorenaming
  24465. */
  24466. get IsGlobal(): boolean;
  24467. /**
  24468. * Returns the submesh BoudingInfo object
  24469. * @returns current bounding info (or mesh's one if the submesh is global)
  24470. */
  24471. getBoundingInfo(): BoundingInfo;
  24472. /**
  24473. * Sets the submesh BoundingInfo
  24474. * @param boundingInfo defines the new bounding info to use
  24475. * @returns the SubMesh
  24476. */
  24477. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24478. /**
  24479. * Returns the mesh of the current submesh
  24480. * @return the parent mesh
  24481. */
  24482. getMesh(): AbstractMesh;
  24483. /**
  24484. * Returns the rendering mesh of the submesh
  24485. * @returns the rendering mesh (could be different from parent mesh)
  24486. */
  24487. getRenderingMesh(): Mesh;
  24488. /**
  24489. * Returns the submesh material
  24490. * @returns null or the current material
  24491. */
  24492. getMaterial(): Nullable<Material>;
  24493. /**
  24494. * Sets a new updated BoundingInfo object to the submesh
  24495. * @param data defines an optional position array to use to determine the bounding info
  24496. * @returns the SubMesh
  24497. */
  24498. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24499. /** @hidden */
  24500. _checkCollision(collider: Collider): boolean;
  24501. /**
  24502. * Updates the submesh BoundingInfo
  24503. * @param world defines the world matrix to use to update the bounding info
  24504. * @returns the submesh
  24505. */
  24506. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24507. /**
  24508. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24509. * @param frustumPlanes defines the frustum planes
  24510. * @returns true if the submesh is intersecting with the frustum
  24511. */
  24512. isInFrustum(frustumPlanes: Plane[]): boolean;
  24513. /**
  24514. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24515. * @param frustumPlanes defines the frustum planes
  24516. * @returns true if the submesh is inside the frustum
  24517. */
  24518. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24519. /**
  24520. * Renders the submesh
  24521. * @param enableAlphaMode defines if alpha needs to be used
  24522. * @returns the submesh
  24523. */
  24524. render(enableAlphaMode: boolean): SubMesh;
  24525. /**
  24526. * @hidden
  24527. */
  24528. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24529. /**
  24530. * Checks if the submesh intersects with a ray
  24531. * @param ray defines the ray to test
  24532. * @returns true is the passed ray intersects the submesh bounding box
  24533. */
  24534. canIntersects(ray: Ray): boolean;
  24535. /**
  24536. * Intersects current submesh with a ray
  24537. * @param ray defines the ray to test
  24538. * @param positions defines mesh's positions array
  24539. * @param indices defines mesh's indices array
  24540. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24542. * @returns intersection info or null if no intersection
  24543. */
  24544. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24545. /** @hidden */
  24546. private _intersectLines;
  24547. /** @hidden */
  24548. private _intersectUnIndexedLines;
  24549. /** @hidden */
  24550. private _intersectTriangles;
  24551. /** @hidden */
  24552. private _intersectUnIndexedTriangles;
  24553. /** @hidden */
  24554. _rebuild(): void;
  24555. /**
  24556. * Creates a new submesh from the passed mesh
  24557. * @param newMesh defines the new hosting mesh
  24558. * @param newRenderingMesh defines an optional rendering mesh
  24559. * @returns the new submesh
  24560. */
  24561. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24562. /**
  24563. * Release associated resources
  24564. */
  24565. dispose(): void;
  24566. /**
  24567. * Gets the class name
  24568. * @returns the string "SubMesh".
  24569. */
  24570. getClassName(): string;
  24571. /**
  24572. * Creates a new submesh from indices data
  24573. * @param materialIndex the index of the main mesh material
  24574. * @param startIndex the index where to start the copy in the mesh indices array
  24575. * @param indexCount the number of indices to copy then from the startIndex
  24576. * @param mesh the main mesh to create the submesh from
  24577. * @param renderingMesh the optional rendering mesh
  24578. * @returns a new submesh
  24579. */
  24580. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24581. }
  24582. }
  24583. declare module BABYLON {
  24584. /**
  24585. * Class used to represent data loading progression
  24586. */
  24587. export class SceneLoaderFlags {
  24588. private static _ForceFullSceneLoadingForIncremental;
  24589. private static _ShowLoadingScreen;
  24590. private static _CleanBoneMatrixWeights;
  24591. private static _loggingLevel;
  24592. /**
  24593. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24594. */
  24595. static get ForceFullSceneLoadingForIncremental(): boolean;
  24596. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24597. /**
  24598. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24599. */
  24600. static get ShowLoadingScreen(): boolean;
  24601. static set ShowLoadingScreen(value: boolean);
  24602. /**
  24603. * Defines the current logging level (while loading the scene)
  24604. * @ignorenaming
  24605. */
  24606. static get loggingLevel(): number;
  24607. static set loggingLevel(value: number);
  24608. /**
  24609. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24610. */
  24611. static get CleanBoneMatrixWeights(): boolean;
  24612. static set CleanBoneMatrixWeights(value: boolean);
  24613. }
  24614. }
  24615. declare module BABYLON {
  24616. /**
  24617. * Class used to store geometry data (vertex buffers + index buffer)
  24618. */
  24619. export class Geometry implements IGetSetVerticesData {
  24620. /**
  24621. * Gets or sets the ID of the geometry
  24622. */
  24623. id: string;
  24624. /**
  24625. * Gets or sets the unique ID of the geometry
  24626. */
  24627. uniqueId: number;
  24628. /**
  24629. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24630. */
  24631. delayLoadState: number;
  24632. /**
  24633. * Gets the file containing the data to load when running in delay load state
  24634. */
  24635. delayLoadingFile: Nullable<string>;
  24636. /**
  24637. * Callback called when the geometry is updated
  24638. */
  24639. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24640. private _scene;
  24641. private _engine;
  24642. private _meshes;
  24643. private _totalVertices;
  24644. /** @hidden */
  24645. _indices: IndicesArray;
  24646. /** @hidden */
  24647. _vertexBuffers: {
  24648. [key: string]: VertexBuffer;
  24649. };
  24650. private _isDisposed;
  24651. private _extend;
  24652. private _boundingBias;
  24653. /** @hidden */
  24654. _delayInfo: Array<string>;
  24655. private _indexBuffer;
  24656. private _indexBufferIsUpdatable;
  24657. /** @hidden */
  24658. _boundingInfo: Nullable<BoundingInfo>;
  24659. /** @hidden */
  24660. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24661. /** @hidden */
  24662. _softwareSkinningFrameId: number;
  24663. private _vertexArrayObjects;
  24664. private _updatable;
  24665. /** @hidden */
  24666. _positions: Nullable<Vector3[]>;
  24667. /**
  24668. * 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
  24669. */
  24670. get boundingBias(): Vector2;
  24671. /**
  24672. * 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
  24673. */
  24674. set boundingBias(value: Vector2);
  24675. /**
  24676. * Static function used to attach a new empty geometry to a mesh
  24677. * @param mesh defines the mesh to attach the geometry to
  24678. * @returns the new Geometry
  24679. */
  24680. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24681. /** Get the list of meshes using this geometry */
  24682. get meshes(): Mesh[];
  24683. /**
  24684. * Creates a new geometry
  24685. * @param id defines the unique ID
  24686. * @param scene defines the hosting scene
  24687. * @param vertexData defines the VertexData used to get geometry data
  24688. * @param updatable defines if geometry must be updatable (false by default)
  24689. * @param mesh defines the mesh that will be associated with the geometry
  24690. */
  24691. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24692. /**
  24693. * Gets the current extend of the geometry
  24694. */
  24695. get extend(): {
  24696. minimum: Vector3;
  24697. maximum: Vector3;
  24698. };
  24699. /**
  24700. * Gets the hosting scene
  24701. * @returns the hosting Scene
  24702. */
  24703. getScene(): Scene;
  24704. /**
  24705. * Gets the hosting engine
  24706. * @returns the hosting Engine
  24707. */
  24708. getEngine(): Engine;
  24709. /**
  24710. * Defines if the geometry is ready to use
  24711. * @returns true if the geometry is ready to be used
  24712. */
  24713. isReady(): boolean;
  24714. /**
  24715. * Gets a value indicating that the geometry should not be serialized
  24716. */
  24717. get doNotSerialize(): boolean;
  24718. /** @hidden */
  24719. _rebuild(): void;
  24720. /**
  24721. * Affects all geometry data in one call
  24722. * @param vertexData defines the geometry data
  24723. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24724. */
  24725. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24726. /**
  24727. * Set specific vertex data
  24728. * @param kind defines the data kind (Position, normal, etc...)
  24729. * @param data defines the vertex data to use
  24730. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24731. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24732. */
  24733. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24734. /**
  24735. * Removes a specific vertex data
  24736. * @param kind defines the data kind (Position, normal, etc...)
  24737. */
  24738. removeVerticesData(kind: string): void;
  24739. /**
  24740. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24741. * @param buffer defines the vertex buffer to use
  24742. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24743. */
  24744. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24745. /**
  24746. * Update a specific vertex buffer
  24747. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24748. * It will do nothing if the buffer is not updatable
  24749. * @param kind defines the data kind (Position, normal, etc...)
  24750. * @param data defines the data to use
  24751. * @param offset defines the offset in the target buffer where to store the data
  24752. * @param useBytes set to true if the offset is in bytes
  24753. */
  24754. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24755. /**
  24756. * Update a specific vertex buffer
  24757. * This function will create a new buffer if the current one is not updatable
  24758. * @param kind defines the data kind (Position, normal, etc...)
  24759. * @param data defines the data to use
  24760. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24761. */
  24762. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24763. private _updateBoundingInfo;
  24764. /** @hidden */
  24765. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24766. /**
  24767. * Gets total number of vertices
  24768. * @returns the total number of vertices
  24769. */
  24770. getTotalVertices(): number;
  24771. /**
  24772. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24773. * @param kind defines the data kind (Position, normal, etc...)
  24774. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24775. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24776. * @returns a float array containing vertex data
  24777. */
  24778. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24779. /**
  24780. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24781. * @param kind defines the data kind (Position, normal, etc...)
  24782. * @returns true if the vertex buffer with the specified kind is updatable
  24783. */
  24784. isVertexBufferUpdatable(kind: string): boolean;
  24785. /**
  24786. * Gets a specific vertex buffer
  24787. * @param kind defines the data kind (Position, normal, etc...)
  24788. * @returns a VertexBuffer
  24789. */
  24790. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24791. /**
  24792. * Returns all vertex buffers
  24793. * @return an object holding all vertex buffers indexed by kind
  24794. */
  24795. getVertexBuffers(): Nullable<{
  24796. [key: string]: VertexBuffer;
  24797. }>;
  24798. /**
  24799. * Gets a boolean indicating if specific vertex buffer is present
  24800. * @param kind defines the data kind (Position, normal, etc...)
  24801. * @returns true if data is present
  24802. */
  24803. isVerticesDataPresent(kind: string): boolean;
  24804. /**
  24805. * Gets a list of all attached data kinds (Position, normal, etc...)
  24806. * @returns a list of string containing all kinds
  24807. */
  24808. getVerticesDataKinds(): string[];
  24809. /**
  24810. * Update index buffer
  24811. * @param indices defines the indices to store in the index buffer
  24812. * @param offset defines the offset in the target buffer where to store the data
  24813. * @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)
  24814. */
  24815. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24816. /**
  24817. * Creates a new index buffer
  24818. * @param indices defines the indices to store in the index buffer
  24819. * @param totalVertices defines the total number of vertices (could be null)
  24820. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24821. */
  24822. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24823. /**
  24824. * Return the total number of indices
  24825. * @returns the total number of indices
  24826. */
  24827. getTotalIndices(): number;
  24828. /**
  24829. * Gets the index buffer array
  24830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24832. * @returns the index buffer array
  24833. */
  24834. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24835. /**
  24836. * Gets the index buffer
  24837. * @return the index buffer
  24838. */
  24839. getIndexBuffer(): Nullable<DataBuffer>;
  24840. /** @hidden */
  24841. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24842. /**
  24843. * Release the associated resources for a specific mesh
  24844. * @param mesh defines the source mesh
  24845. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24846. */
  24847. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24848. /**
  24849. * Apply current geometry to a given mesh
  24850. * @param mesh defines the mesh to apply geometry to
  24851. */
  24852. applyToMesh(mesh: Mesh): void;
  24853. private _updateExtend;
  24854. private _applyToMesh;
  24855. private notifyUpdate;
  24856. /**
  24857. * Load the geometry if it was flagged as delay loaded
  24858. * @param scene defines the hosting scene
  24859. * @param onLoaded defines a callback called when the geometry is loaded
  24860. */
  24861. load(scene: Scene, onLoaded?: () => void): void;
  24862. private _queueLoad;
  24863. /**
  24864. * Invert the geometry to move from a right handed system to a left handed one.
  24865. */
  24866. toLeftHanded(): void;
  24867. /** @hidden */
  24868. _resetPointsArrayCache(): void;
  24869. /** @hidden */
  24870. _generatePointsArray(): boolean;
  24871. /**
  24872. * Gets a value indicating if the geometry is disposed
  24873. * @returns true if the geometry was disposed
  24874. */
  24875. isDisposed(): boolean;
  24876. private _disposeVertexArrayObjects;
  24877. /**
  24878. * Free all associated resources
  24879. */
  24880. dispose(): void;
  24881. /**
  24882. * Clone the current geometry into a new geometry
  24883. * @param id defines the unique ID of the new geometry
  24884. * @returns a new geometry object
  24885. */
  24886. copy(id: string): Geometry;
  24887. /**
  24888. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24889. * @return a JSON representation of the current geometry data (without the vertices data)
  24890. */
  24891. serialize(): any;
  24892. private toNumberArray;
  24893. /**
  24894. * Serialize all vertices data into a JSON oject
  24895. * @returns a JSON representation of the current geometry data
  24896. */
  24897. serializeVerticeData(): any;
  24898. /**
  24899. * Extracts a clone of a mesh geometry
  24900. * @param mesh defines the source mesh
  24901. * @param id defines the unique ID of the new geometry object
  24902. * @returns the new geometry object
  24903. */
  24904. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24905. /**
  24906. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24907. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24908. * Be aware Math.random() could cause collisions, but:
  24909. * "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"
  24910. * @returns a string containing a new GUID
  24911. */
  24912. static RandomId(): string;
  24913. /** @hidden */
  24914. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24915. private static _CleanMatricesWeights;
  24916. /**
  24917. * Create a new geometry from persisted data (Using .babylon file format)
  24918. * @param parsedVertexData defines the persisted data
  24919. * @param scene defines the hosting scene
  24920. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24921. * @returns the new geometry object
  24922. */
  24923. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24924. }
  24925. }
  24926. declare module BABYLON {
  24927. /**
  24928. * Define an interface for all classes that will get and set the data on vertices
  24929. */
  24930. export interface IGetSetVerticesData {
  24931. /**
  24932. * Gets a boolean indicating if specific vertex data is present
  24933. * @param kind defines the vertex data kind to use
  24934. * @returns true is data kind is present
  24935. */
  24936. isVerticesDataPresent(kind: string): boolean;
  24937. /**
  24938. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24939. * @param kind defines the data kind (Position, normal, etc...)
  24940. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24941. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24942. * @returns a float array containing vertex data
  24943. */
  24944. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24945. /**
  24946. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24947. * @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.
  24948. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24949. * @returns the indices array or an empty array if the mesh has no geometry
  24950. */
  24951. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24952. /**
  24953. * Set specific vertex data
  24954. * @param kind defines the data kind (Position, normal, etc...)
  24955. * @param data defines the vertex data to use
  24956. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24957. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24958. */
  24959. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24960. /**
  24961. * Update a specific associated vertex buffer
  24962. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24963. * - VertexBuffer.PositionKind
  24964. * - VertexBuffer.UVKind
  24965. * - VertexBuffer.UV2Kind
  24966. * - VertexBuffer.UV3Kind
  24967. * - VertexBuffer.UV4Kind
  24968. * - VertexBuffer.UV5Kind
  24969. * - VertexBuffer.UV6Kind
  24970. * - VertexBuffer.ColorKind
  24971. * - VertexBuffer.MatricesIndicesKind
  24972. * - VertexBuffer.MatricesIndicesExtraKind
  24973. * - VertexBuffer.MatricesWeightsKind
  24974. * - VertexBuffer.MatricesWeightsExtraKind
  24975. * @param data defines the data source
  24976. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24977. * @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)
  24978. */
  24979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24980. /**
  24981. * Creates a new index buffer
  24982. * @param indices defines the indices to store in the index buffer
  24983. * @param totalVertices defines the total number of vertices (could be null)
  24984. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24985. */
  24986. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24987. }
  24988. /**
  24989. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24990. */
  24991. export class VertexData {
  24992. /**
  24993. * Mesh side orientation : usually the external or front surface
  24994. */
  24995. static readonly FRONTSIDE: number;
  24996. /**
  24997. * Mesh side orientation : usually the internal or back surface
  24998. */
  24999. static readonly BACKSIDE: number;
  25000. /**
  25001. * Mesh side orientation : both internal and external or front and back surfaces
  25002. */
  25003. static readonly DOUBLESIDE: number;
  25004. /**
  25005. * Mesh side orientation : by default, `FRONTSIDE`
  25006. */
  25007. static readonly DEFAULTSIDE: number;
  25008. /**
  25009. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25010. */
  25011. positions: Nullable<FloatArray>;
  25012. /**
  25013. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25014. */
  25015. normals: Nullable<FloatArray>;
  25016. /**
  25017. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25018. */
  25019. tangents: Nullable<FloatArray>;
  25020. /**
  25021. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25022. */
  25023. uvs: Nullable<FloatArray>;
  25024. /**
  25025. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25026. */
  25027. uvs2: Nullable<FloatArray>;
  25028. /**
  25029. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25030. */
  25031. uvs3: Nullable<FloatArray>;
  25032. /**
  25033. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25034. */
  25035. uvs4: Nullable<FloatArray>;
  25036. /**
  25037. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25038. */
  25039. uvs5: Nullable<FloatArray>;
  25040. /**
  25041. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25042. */
  25043. uvs6: Nullable<FloatArray>;
  25044. /**
  25045. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25046. */
  25047. colors: Nullable<FloatArray>;
  25048. /**
  25049. * 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).
  25050. */
  25051. matricesIndices: Nullable<FloatArray>;
  25052. /**
  25053. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25054. */
  25055. matricesWeights: Nullable<FloatArray>;
  25056. /**
  25057. * An array extending the number of possible indices
  25058. */
  25059. matricesIndicesExtra: Nullable<FloatArray>;
  25060. /**
  25061. * An array extending the number of possible weights when the number of indices is extended
  25062. */
  25063. matricesWeightsExtra: Nullable<FloatArray>;
  25064. /**
  25065. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25066. */
  25067. indices: Nullable<IndicesArray>;
  25068. /**
  25069. * Uses the passed data array to set the set the values for the specified kind of data
  25070. * @param data a linear array of floating numbers
  25071. * @param kind the type of data that is being set, eg positions, colors etc
  25072. */
  25073. set(data: FloatArray, kind: string): void;
  25074. /**
  25075. * Associates the vertexData to the passed Mesh.
  25076. * Sets it as updatable or not (default `false`)
  25077. * @param mesh the mesh the vertexData is applied to
  25078. * @param updatable when used and having the value true allows new data to update the vertexData
  25079. * @returns the VertexData
  25080. */
  25081. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25082. /**
  25083. * Associates the vertexData to the passed Geometry.
  25084. * Sets it as updatable or not (default `false`)
  25085. * @param geometry the geometry the vertexData is applied to
  25086. * @param updatable when used and having the value true allows new data to update the vertexData
  25087. * @returns VertexData
  25088. */
  25089. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25090. /**
  25091. * Updates the associated mesh
  25092. * @param mesh the mesh to be updated
  25093. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25094. * @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
  25095. * @returns VertexData
  25096. */
  25097. updateMesh(mesh: Mesh): VertexData;
  25098. /**
  25099. * Updates the associated geometry
  25100. * @param geometry the geometry to be updated
  25101. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25102. * @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
  25103. * @returns VertexData.
  25104. */
  25105. updateGeometry(geometry: Geometry): VertexData;
  25106. private _applyTo;
  25107. private _update;
  25108. /**
  25109. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25110. * @param matrix the transforming matrix
  25111. * @returns the VertexData
  25112. */
  25113. transform(matrix: Matrix): VertexData;
  25114. /**
  25115. * Merges the passed VertexData into the current one
  25116. * @param other the VertexData to be merged into the current one
  25117. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25118. * @returns the modified VertexData
  25119. */
  25120. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25121. private _mergeElement;
  25122. private _validate;
  25123. /**
  25124. * Serializes the VertexData
  25125. * @returns a serialized object
  25126. */
  25127. serialize(): any;
  25128. /**
  25129. * Extracts the vertexData from a mesh
  25130. * @param mesh the mesh from which to extract the VertexData
  25131. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25132. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25133. * @returns the object VertexData associated to the passed mesh
  25134. */
  25135. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25136. /**
  25137. * Extracts the vertexData from the geometry
  25138. * @param geometry the geometry from which to extract the VertexData
  25139. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25140. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25141. * @returns the object VertexData associated to the passed mesh
  25142. */
  25143. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25144. private static _ExtractFrom;
  25145. /**
  25146. * Creates the VertexData for a Ribbon
  25147. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25148. * * pathArray array of paths, each of which an array of successive Vector3
  25149. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25150. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25151. * * 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
  25152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25153. * * 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)
  25154. * * 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)
  25155. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25156. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25157. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25158. * @returns the VertexData of the ribbon
  25159. */
  25160. static CreateRibbon(options: {
  25161. pathArray: Vector3[][];
  25162. closeArray?: boolean;
  25163. closePath?: boolean;
  25164. offset?: number;
  25165. sideOrientation?: number;
  25166. frontUVs?: Vector4;
  25167. backUVs?: Vector4;
  25168. invertUV?: boolean;
  25169. uvs?: Vector2[];
  25170. colors?: Color4[];
  25171. }): VertexData;
  25172. /**
  25173. * Creates the VertexData for a box
  25174. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25175. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25176. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25177. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25178. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25179. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25180. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25182. * * 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)
  25183. * * 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)
  25184. * @returns the VertexData of the box
  25185. */
  25186. static CreateBox(options: {
  25187. size?: number;
  25188. width?: number;
  25189. height?: number;
  25190. depth?: number;
  25191. faceUV?: Vector4[];
  25192. faceColors?: Color4[];
  25193. sideOrientation?: number;
  25194. frontUVs?: Vector4;
  25195. backUVs?: Vector4;
  25196. }): VertexData;
  25197. /**
  25198. * Creates the VertexData for a tiled box
  25199. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25200. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25201. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25202. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25204. * @returns the VertexData of the box
  25205. */
  25206. static CreateTiledBox(options: {
  25207. pattern?: number;
  25208. width?: number;
  25209. height?: number;
  25210. depth?: number;
  25211. tileSize?: number;
  25212. tileWidth?: number;
  25213. tileHeight?: number;
  25214. alignHorizontal?: number;
  25215. alignVertical?: number;
  25216. faceUV?: Vector4[];
  25217. faceColors?: Color4[];
  25218. sideOrientation?: number;
  25219. }): VertexData;
  25220. /**
  25221. * Creates the VertexData for a tiled plane
  25222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25223. * * pattern a limited pattern arrangement depending on the number
  25224. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25225. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25226. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25227. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25228. * * 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)
  25229. * * 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)
  25230. * @returns the VertexData of the tiled plane
  25231. */
  25232. static CreateTiledPlane(options: {
  25233. pattern?: number;
  25234. tileSize?: number;
  25235. tileWidth?: number;
  25236. tileHeight?: number;
  25237. size?: number;
  25238. width?: number;
  25239. height?: number;
  25240. alignHorizontal?: number;
  25241. alignVertical?: number;
  25242. sideOrientation?: number;
  25243. frontUVs?: Vector4;
  25244. backUVs?: Vector4;
  25245. }): VertexData;
  25246. /**
  25247. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25248. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25249. * * segments sets the number of horizontal strips optional, default 32
  25250. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25251. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25252. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25253. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25254. * * 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
  25255. * * 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
  25256. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25257. * * 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)
  25258. * * 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)
  25259. * @returns the VertexData of the ellipsoid
  25260. */
  25261. static CreateSphere(options: {
  25262. segments?: number;
  25263. diameter?: number;
  25264. diameterX?: number;
  25265. diameterY?: number;
  25266. diameterZ?: number;
  25267. arc?: number;
  25268. slice?: number;
  25269. sideOrientation?: number;
  25270. frontUVs?: Vector4;
  25271. backUVs?: Vector4;
  25272. }): VertexData;
  25273. /**
  25274. * Creates the VertexData for a cylinder, cone or prism
  25275. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25276. * * height sets the height (y direction) of the cylinder, optional, default 2
  25277. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25278. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25279. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25280. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25281. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25282. * * 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
  25283. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25284. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25285. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25286. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25287. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25288. * * 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)
  25289. * * 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)
  25290. * @returns the VertexData of the cylinder, cone or prism
  25291. */
  25292. static CreateCylinder(options: {
  25293. height?: number;
  25294. diameterTop?: number;
  25295. diameterBottom?: number;
  25296. diameter?: number;
  25297. tessellation?: number;
  25298. subdivisions?: number;
  25299. arc?: number;
  25300. faceColors?: Color4[];
  25301. faceUV?: Vector4[];
  25302. hasRings?: boolean;
  25303. enclose?: boolean;
  25304. sideOrientation?: number;
  25305. frontUVs?: Vector4;
  25306. backUVs?: Vector4;
  25307. }): VertexData;
  25308. /**
  25309. * Creates the VertexData for a torus
  25310. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25311. * * diameter the diameter of the torus, optional default 1
  25312. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25313. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25314. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25315. * * 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)
  25316. * * 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)
  25317. * @returns the VertexData of the torus
  25318. */
  25319. static CreateTorus(options: {
  25320. diameter?: number;
  25321. thickness?: number;
  25322. tessellation?: number;
  25323. sideOrientation?: number;
  25324. frontUVs?: Vector4;
  25325. backUVs?: Vector4;
  25326. }): VertexData;
  25327. /**
  25328. * Creates the VertexData of the LineSystem
  25329. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25330. * - lines an array of lines, each line being an array of successive Vector3
  25331. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25332. * @returns the VertexData of the LineSystem
  25333. */
  25334. static CreateLineSystem(options: {
  25335. lines: Vector3[][];
  25336. colors?: Nullable<Color4[][]>;
  25337. }): VertexData;
  25338. /**
  25339. * Create the VertexData for a DashedLines
  25340. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25341. * - points an array successive Vector3
  25342. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25343. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25344. * - dashNb the intended total number of dashes, optional, default 200
  25345. * @returns the VertexData for the DashedLines
  25346. */
  25347. static CreateDashedLines(options: {
  25348. points: Vector3[];
  25349. dashSize?: number;
  25350. gapSize?: number;
  25351. dashNb?: number;
  25352. }): VertexData;
  25353. /**
  25354. * Creates the VertexData for a Ground
  25355. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25356. * - width the width (x direction) of the ground, optional, default 1
  25357. * - height the height (z direction) of the ground, optional, default 1
  25358. * - subdivisions the number of subdivisions per side, optional, default 1
  25359. * @returns the VertexData of the Ground
  25360. */
  25361. static CreateGround(options: {
  25362. width?: number;
  25363. height?: number;
  25364. subdivisions?: number;
  25365. subdivisionsX?: number;
  25366. subdivisionsY?: number;
  25367. }): VertexData;
  25368. /**
  25369. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25370. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25371. * * xmin the ground minimum X coordinate, optional, default -1
  25372. * * zmin the ground minimum Z coordinate, optional, default -1
  25373. * * xmax the ground maximum X coordinate, optional, default 1
  25374. * * zmax the ground maximum Z coordinate, optional, default 1
  25375. * * 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}
  25376. * * 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}
  25377. * @returns the VertexData of the TiledGround
  25378. */
  25379. static CreateTiledGround(options: {
  25380. xmin: number;
  25381. zmin: number;
  25382. xmax: number;
  25383. zmax: number;
  25384. subdivisions?: {
  25385. w: number;
  25386. h: number;
  25387. };
  25388. precision?: {
  25389. w: number;
  25390. h: number;
  25391. };
  25392. }): VertexData;
  25393. /**
  25394. * Creates the VertexData of the Ground designed from a heightmap
  25395. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25396. * * width the width (x direction) of the ground
  25397. * * height the height (z direction) of the ground
  25398. * * subdivisions the number of subdivisions per side
  25399. * * minHeight the minimum altitude on the ground, optional, default 0
  25400. * * maxHeight the maximum altitude on the ground, optional default 1
  25401. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25402. * * buffer the array holding the image color data
  25403. * * bufferWidth the width of image
  25404. * * bufferHeight the height of image
  25405. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25406. * @returns the VertexData of the Ground designed from a heightmap
  25407. */
  25408. static CreateGroundFromHeightMap(options: {
  25409. width: number;
  25410. height: number;
  25411. subdivisions: number;
  25412. minHeight: number;
  25413. maxHeight: number;
  25414. colorFilter: Color3;
  25415. buffer: Uint8Array;
  25416. bufferWidth: number;
  25417. bufferHeight: number;
  25418. alphaFilter: number;
  25419. }): VertexData;
  25420. /**
  25421. * Creates the VertexData for a Plane
  25422. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25423. * * size sets the width and height of the plane to the value of size, optional default 1
  25424. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25425. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25427. * * 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)
  25428. * * 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)
  25429. * @returns the VertexData of the box
  25430. */
  25431. static CreatePlane(options: {
  25432. size?: number;
  25433. width?: number;
  25434. height?: number;
  25435. sideOrientation?: number;
  25436. frontUVs?: Vector4;
  25437. backUVs?: Vector4;
  25438. }): VertexData;
  25439. /**
  25440. * Creates the VertexData of the Disc or regular Polygon
  25441. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25442. * * radius the radius of the disc, optional default 0.5
  25443. * * tessellation the number of polygon sides, optional, default 64
  25444. * * 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
  25445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25446. * * 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)
  25447. * * 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)
  25448. * @returns the VertexData of the box
  25449. */
  25450. static CreateDisc(options: {
  25451. radius?: number;
  25452. tessellation?: number;
  25453. arc?: number;
  25454. sideOrientation?: number;
  25455. frontUVs?: Vector4;
  25456. backUVs?: Vector4;
  25457. }): VertexData;
  25458. /**
  25459. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25460. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25461. * @param polygon a mesh built from polygonTriangulation.build()
  25462. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25463. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25464. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25465. * @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)
  25466. * @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)
  25467. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25468. * @returns the VertexData of the Polygon
  25469. */
  25470. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25471. /**
  25472. * Creates the VertexData of the IcoSphere
  25473. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25474. * * radius the radius of the IcoSphere, optional default 1
  25475. * * radiusX allows stretching in the x direction, optional, default radius
  25476. * * radiusY allows stretching in the y direction, optional, default radius
  25477. * * radiusZ allows stretching in the z direction, optional, default radius
  25478. * * flat when true creates a flat shaded mesh, optional, default true
  25479. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25481. * * 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)
  25482. * * 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)
  25483. * @returns the VertexData of the IcoSphere
  25484. */
  25485. static CreateIcoSphere(options: {
  25486. radius?: number;
  25487. radiusX?: number;
  25488. radiusY?: number;
  25489. radiusZ?: number;
  25490. flat?: boolean;
  25491. subdivisions?: number;
  25492. sideOrientation?: number;
  25493. frontUVs?: Vector4;
  25494. backUVs?: Vector4;
  25495. }): VertexData;
  25496. /**
  25497. * Creates the VertexData for a Polyhedron
  25498. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25499. * * type provided types are:
  25500. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25501. * * 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)
  25502. * * size the size of the IcoSphere, optional default 1
  25503. * * sizeX allows stretching in the x direction, optional, default size
  25504. * * sizeY allows stretching in the y direction, optional, default size
  25505. * * sizeZ allows stretching in the z direction, optional, default size
  25506. * * 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
  25507. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25508. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25509. * * flat when true creates a flat shaded mesh, optional, default true
  25510. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25512. * * 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)
  25513. * * 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)
  25514. * @returns the VertexData of the Polyhedron
  25515. */
  25516. static CreatePolyhedron(options: {
  25517. type?: number;
  25518. size?: number;
  25519. sizeX?: number;
  25520. sizeY?: number;
  25521. sizeZ?: number;
  25522. custom?: any;
  25523. faceUV?: Vector4[];
  25524. faceColors?: Color4[];
  25525. flat?: boolean;
  25526. sideOrientation?: number;
  25527. frontUVs?: Vector4;
  25528. backUVs?: Vector4;
  25529. }): VertexData;
  25530. /**
  25531. * Creates the VertexData for a TorusKnot
  25532. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25533. * * radius the radius of the torus knot, optional, default 2
  25534. * * tube the thickness of the tube, optional, default 0.5
  25535. * * radialSegments the number of sides on each tube segments, optional, default 32
  25536. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25537. * * p the number of windings around the z axis, optional, default 2
  25538. * * q the number of windings around the x axis, optional, default 3
  25539. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25540. * * 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)
  25541. * * 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)
  25542. * @returns the VertexData of the Torus Knot
  25543. */
  25544. static CreateTorusKnot(options: {
  25545. radius?: number;
  25546. tube?: number;
  25547. radialSegments?: number;
  25548. tubularSegments?: number;
  25549. p?: number;
  25550. q?: number;
  25551. sideOrientation?: number;
  25552. frontUVs?: Vector4;
  25553. backUVs?: Vector4;
  25554. }): VertexData;
  25555. /**
  25556. * Compute normals for given positions and indices
  25557. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25558. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25559. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25560. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25561. * * facetNormals : optional array of facet normals (vector3)
  25562. * * facetPositions : optional array of facet positions (vector3)
  25563. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25564. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25565. * * bInfo : optional bounding info, required for facetPartitioning computation
  25566. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25567. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25568. * * useRightHandedSystem: optional boolean to for right handed system computation
  25569. * * depthSort : optional boolean to enable the facet depth sort computation
  25570. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25571. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25572. */
  25573. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25574. facetNormals?: any;
  25575. facetPositions?: any;
  25576. facetPartitioning?: any;
  25577. ratio?: number;
  25578. bInfo?: any;
  25579. bbSize?: Vector3;
  25580. subDiv?: any;
  25581. useRightHandedSystem?: boolean;
  25582. depthSort?: boolean;
  25583. distanceTo?: Vector3;
  25584. depthSortedFacets?: any;
  25585. }): void;
  25586. /** @hidden */
  25587. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25588. /**
  25589. * Applies VertexData created from the imported parameters to the geometry
  25590. * @param parsedVertexData the parsed data from an imported file
  25591. * @param geometry the geometry to apply the VertexData to
  25592. */
  25593. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25594. }
  25595. }
  25596. declare module BABYLON {
  25597. /**
  25598. * Defines a target to use with MorphTargetManager
  25599. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25600. */
  25601. export class MorphTarget implements IAnimatable {
  25602. /** defines the name of the target */
  25603. name: string;
  25604. /**
  25605. * Gets or sets the list of animations
  25606. */
  25607. animations: Animation[];
  25608. private _scene;
  25609. private _positions;
  25610. private _normals;
  25611. private _tangents;
  25612. private _uvs;
  25613. private _influence;
  25614. private _uniqueId;
  25615. /**
  25616. * Observable raised when the influence changes
  25617. */
  25618. onInfluenceChanged: Observable<boolean>;
  25619. /** @hidden */
  25620. _onDataLayoutChanged: Observable<void>;
  25621. /**
  25622. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25623. */
  25624. get influence(): number;
  25625. set influence(influence: number);
  25626. /**
  25627. * Gets or sets the id of the morph Target
  25628. */
  25629. id: string;
  25630. private _animationPropertiesOverride;
  25631. /**
  25632. * Gets or sets the animation properties override
  25633. */
  25634. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25635. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25636. /**
  25637. * Creates a new MorphTarget
  25638. * @param name defines the name of the target
  25639. * @param influence defines the influence to use
  25640. * @param scene defines the scene the morphtarget belongs to
  25641. */
  25642. constructor(
  25643. /** defines the name of the target */
  25644. name: string, influence?: number, scene?: Nullable<Scene>);
  25645. /**
  25646. * Gets the unique ID of this manager
  25647. */
  25648. get uniqueId(): number;
  25649. /**
  25650. * Gets a boolean defining if the target contains position data
  25651. */
  25652. get hasPositions(): boolean;
  25653. /**
  25654. * Gets a boolean defining if the target contains normal data
  25655. */
  25656. get hasNormals(): boolean;
  25657. /**
  25658. * Gets a boolean defining if the target contains tangent data
  25659. */
  25660. get hasTangents(): boolean;
  25661. /**
  25662. * Gets a boolean defining if the target contains texture coordinates data
  25663. */
  25664. get hasUVs(): boolean;
  25665. /**
  25666. * Affects position data to this target
  25667. * @param data defines the position data to use
  25668. */
  25669. setPositions(data: Nullable<FloatArray>): void;
  25670. /**
  25671. * Gets the position data stored in this target
  25672. * @returns a FloatArray containing the position data (or null if not present)
  25673. */
  25674. getPositions(): Nullable<FloatArray>;
  25675. /**
  25676. * Affects normal data to this target
  25677. * @param data defines the normal data to use
  25678. */
  25679. setNormals(data: Nullable<FloatArray>): void;
  25680. /**
  25681. * Gets the normal data stored in this target
  25682. * @returns a FloatArray containing the normal data (or null if not present)
  25683. */
  25684. getNormals(): Nullable<FloatArray>;
  25685. /**
  25686. * Affects tangent data to this target
  25687. * @param data defines the tangent data to use
  25688. */
  25689. setTangents(data: Nullable<FloatArray>): void;
  25690. /**
  25691. * Gets the tangent data stored in this target
  25692. * @returns a FloatArray containing the tangent data (or null if not present)
  25693. */
  25694. getTangents(): Nullable<FloatArray>;
  25695. /**
  25696. * Affects texture coordinates data to this target
  25697. * @param data defines the texture coordinates data to use
  25698. */
  25699. setUVs(data: Nullable<FloatArray>): void;
  25700. /**
  25701. * Gets the texture coordinates data stored in this target
  25702. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25703. */
  25704. getUVs(): Nullable<FloatArray>;
  25705. /**
  25706. * Clone the current target
  25707. * @returns a new MorphTarget
  25708. */
  25709. clone(): MorphTarget;
  25710. /**
  25711. * Serializes the current target into a Serialization object
  25712. * @returns the serialized object
  25713. */
  25714. serialize(): any;
  25715. /**
  25716. * Returns the string "MorphTarget"
  25717. * @returns "MorphTarget"
  25718. */
  25719. getClassName(): string;
  25720. /**
  25721. * Creates a new target from serialized data
  25722. * @param serializationObject defines the serialized data to use
  25723. * @returns a new MorphTarget
  25724. */
  25725. static Parse(serializationObject: any): MorphTarget;
  25726. /**
  25727. * Creates a MorphTarget from mesh data
  25728. * @param mesh defines the source mesh
  25729. * @param name defines the name to use for the new target
  25730. * @param influence defines the influence to attach to the target
  25731. * @returns a new MorphTarget
  25732. */
  25733. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25734. }
  25735. }
  25736. declare module BABYLON {
  25737. /**
  25738. * This class is used to deform meshes using morphing between different targets
  25739. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25740. */
  25741. export class MorphTargetManager {
  25742. private _targets;
  25743. private _targetInfluenceChangedObservers;
  25744. private _targetDataLayoutChangedObservers;
  25745. private _activeTargets;
  25746. private _scene;
  25747. private _influences;
  25748. private _supportsNormals;
  25749. private _supportsTangents;
  25750. private _supportsUVs;
  25751. private _vertexCount;
  25752. private _uniqueId;
  25753. private _tempInfluences;
  25754. /**
  25755. * Gets or sets a boolean indicating if normals must be morphed
  25756. */
  25757. enableNormalMorphing: boolean;
  25758. /**
  25759. * Gets or sets a boolean indicating if tangents must be morphed
  25760. */
  25761. enableTangentMorphing: boolean;
  25762. /**
  25763. * Gets or sets a boolean indicating if UV must be morphed
  25764. */
  25765. enableUVMorphing: boolean;
  25766. /**
  25767. * Creates a new MorphTargetManager
  25768. * @param scene defines the current scene
  25769. */
  25770. constructor(scene?: Nullable<Scene>);
  25771. /**
  25772. * Gets the unique ID of this manager
  25773. */
  25774. get uniqueId(): number;
  25775. /**
  25776. * Gets the number of vertices handled by this manager
  25777. */
  25778. get vertexCount(): number;
  25779. /**
  25780. * Gets a boolean indicating if this manager supports morphing of normals
  25781. */
  25782. get supportsNormals(): boolean;
  25783. /**
  25784. * Gets a boolean indicating if this manager supports morphing of tangents
  25785. */
  25786. get supportsTangents(): boolean;
  25787. /**
  25788. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25789. */
  25790. get supportsUVs(): boolean;
  25791. /**
  25792. * Gets the number of targets stored in this manager
  25793. */
  25794. get numTargets(): number;
  25795. /**
  25796. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25797. */
  25798. get numInfluencers(): number;
  25799. /**
  25800. * Gets the list of influences (one per target)
  25801. */
  25802. get influences(): Float32Array;
  25803. /**
  25804. * Gets the active target at specified index. An active target is a target with an influence > 0
  25805. * @param index defines the index to check
  25806. * @returns the requested target
  25807. */
  25808. getActiveTarget(index: number): MorphTarget;
  25809. /**
  25810. * Gets the target at specified index
  25811. * @param index defines the index to check
  25812. * @returns the requested target
  25813. */
  25814. getTarget(index: number): MorphTarget;
  25815. /**
  25816. * Add a new target to this manager
  25817. * @param target defines the target to add
  25818. */
  25819. addTarget(target: MorphTarget): void;
  25820. /**
  25821. * Removes a target from the manager
  25822. * @param target defines the target to remove
  25823. */
  25824. removeTarget(target: MorphTarget): void;
  25825. /**
  25826. * Clone the current manager
  25827. * @returns a new MorphTargetManager
  25828. */
  25829. clone(): MorphTargetManager;
  25830. /**
  25831. * Serializes the current manager into a Serialization object
  25832. * @returns the serialized object
  25833. */
  25834. serialize(): any;
  25835. private _syncActiveTargets;
  25836. /**
  25837. * Syncrhonize the targets with all the meshes using this morph target manager
  25838. */
  25839. synchronize(): void;
  25840. /**
  25841. * Creates a new MorphTargetManager from serialized data
  25842. * @param serializationObject defines the serialized data
  25843. * @param scene defines the hosting scene
  25844. * @returns the new MorphTargetManager
  25845. */
  25846. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25847. }
  25848. }
  25849. declare module BABYLON {
  25850. /**
  25851. * Class used to represent a specific level of detail of a mesh
  25852. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25853. */
  25854. export class MeshLODLevel {
  25855. /** Defines the distance where this level should start being displayed */
  25856. distance: number;
  25857. /** Defines the mesh to use to render this level */
  25858. mesh: Nullable<Mesh>;
  25859. /**
  25860. * Creates a new LOD level
  25861. * @param distance defines the distance where this level should star being displayed
  25862. * @param mesh defines the mesh to use to render this level
  25863. */
  25864. constructor(
  25865. /** Defines the distance where this level should start being displayed */
  25866. distance: number,
  25867. /** Defines the mesh to use to render this level */
  25868. mesh: Nullable<Mesh>);
  25869. }
  25870. }
  25871. declare module BABYLON {
  25872. /**
  25873. * Mesh representing the gorund
  25874. */
  25875. export class GroundMesh extends Mesh {
  25876. /** If octree should be generated */
  25877. generateOctree: boolean;
  25878. private _heightQuads;
  25879. /** @hidden */
  25880. _subdivisionsX: number;
  25881. /** @hidden */
  25882. _subdivisionsY: number;
  25883. /** @hidden */
  25884. _width: number;
  25885. /** @hidden */
  25886. _height: number;
  25887. /** @hidden */
  25888. _minX: number;
  25889. /** @hidden */
  25890. _maxX: number;
  25891. /** @hidden */
  25892. _minZ: number;
  25893. /** @hidden */
  25894. _maxZ: number;
  25895. constructor(name: string, scene: Scene);
  25896. /**
  25897. * "GroundMesh"
  25898. * @returns "GroundMesh"
  25899. */
  25900. getClassName(): string;
  25901. /**
  25902. * The minimum of x and y subdivisions
  25903. */
  25904. get subdivisions(): number;
  25905. /**
  25906. * X subdivisions
  25907. */
  25908. get subdivisionsX(): number;
  25909. /**
  25910. * Y subdivisions
  25911. */
  25912. get subdivisionsY(): number;
  25913. /**
  25914. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25915. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25916. * @param chunksCount the number of subdivisions for x and y
  25917. * @param octreeBlocksSize (Default: 32)
  25918. */
  25919. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25920. /**
  25921. * Returns a height (y) value in the Worl system :
  25922. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25923. * @param x x coordinate
  25924. * @param z z coordinate
  25925. * @returns the ground y position if (x, z) are outside the ground surface.
  25926. */
  25927. getHeightAtCoordinates(x: number, z: number): number;
  25928. /**
  25929. * Returns a normalized vector (Vector3) orthogonal to the ground
  25930. * at the ground coordinates (x, z) expressed in the World system.
  25931. * @param x x coordinate
  25932. * @param z z coordinate
  25933. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25934. */
  25935. getNormalAtCoordinates(x: number, z: number): Vector3;
  25936. /**
  25937. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25938. * at the ground coordinates (x, z) expressed in the World system.
  25939. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25940. * @param x x coordinate
  25941. * @param z z coordinate
  25942. * @param ref vector to store the result
  25943. * @returns the GroundMesh.
  25944. */
  25945. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25946. /**
  25947. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25948. * if the ground has been updated.
  25949. * This can be used in the render loop.
  25950. * @returns the GroundMesh.
  25951. */
  25952. updateCoordinateHeights(): GroundMesh;
  25953. private _getFacetAt;
  25954. private _initHeightQuads;
  25955. private _computeHeightQuads;
  25956. /**
  25957. * Serializes this ground mesh
  25958. * @param serializationObject object to write serialization to
  25959. */
  25960. serialize(serializationObject: any): void;
  25961. /**
  25962. * Parses a serialized ground mesh
  25963. * @param parsedMesh the serialized mesh
  25964. * @param scene the scene to create the ground mesh in
  25965. * @returns the created ground mesh
  25966. */
  25967. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25968. }
  25969. }
  25970. declare module BABYLON {
  25971. /**
  25972. * Interface for Physics-Joint data
  25973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25974. */
  25975. export interface PhysicsJointData {
  25976. /**
  25977. * The main pivot of the joint
  25978. */
  25979. mainPivot?: Vector3;
  25980. /**
  25981. * The connected pivot of the joint
  25982. */
  25983. connectedPivot?: Vector3;
  25984. /**
  25985. * The main axis of the joint
  25986. */
  25987. mainAxis?: Vector3;
  25988. /**
  25989. * The connected axis of the joint
  25990. */
  25991. connectedAxis?: Vector3;
  25992. /**
  25993. * The collision of the joint
  25994. */
  25995. collision?: boolean;
  25996. /**
  25997. * Native Oimo/Cannon/Energy data
  25998. */
  25999. nativeParams?: any;
  26000. }
  26001. /**
  26002. * This is a holder class for the physics joint created by the physics plugin
  26003. * It holds a set of functions to control the underlying joint
  26004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26005. */
  26006. export class PhysicsJoint {
  26007. /**
  26008. * The type of the physics joint
  26009. */
  26010. type: number;
  26011. /**
  26012. * The data for the physics joint
  26013. */
  26014. jointData: PhysicsJointData;
  26015. private _physicsJoint;
  26016. protected _physicsPlugin: IPhysicsEnginePlugin;
  26017. /**
  26018. * Initializes the physics joint
  26019. * @param type The type of the physics joint
  26020. * @param jointData The data for the physics joint
  26021. */
  26022. constructor(
  26023. /**
  26024. * The type of the physics joint
  26025. */
  26026. type: number,
  26027. /**
  26028. * The data for the physics joint
  26029. */
  26030. jointData: PhysicsJointData);
  26031. /**
  26032. * Gets the physics joint
  26033. */
  26034. get physicsJoint(): any;
  26035. /**
  26036. * Sets the physics joint
  26037. */
  26038. set physicsJoint(newJoint: any);
  26039. /**
  26040. * Sets the physics plugin
  26041. */
  26042. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26043. /**
  26044. * Execute a function that is physics-plugin specific.
  26045. * @param {Function} func the function that will be executed.
  26046. * It accepts two parameters: the physics world and the physics joint
  26047. */
  26048. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26049. /**
  26050. * Distance-Joint type
  26051. */
  26052. static DistanceJoint: number;
  26053. /**
  26054. * Hinge-Joint type
  26055. */
  26056. static HingeJoint: number;
  26057. /**
  26058. * Ball-and-Socket joint type
  26059. */
  26060. static BallAndSocketJoint: number;
  26061. /**
  26062. * Wheel-Joint type
  26063. */
  26064. static WheelJoint: number;
  26065. /**
  26066. * Slider-Joint type
  26067. */
  26068. static SliderJoint: number;
  26069. /**
  26070. * Prismatic-Joint type
  26071. */
  26072. static PrismaticJoint: number;
  26073. /**
  26074. * Universal-Joint type
  26075. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26076. */
  26077. static UniversalJoint: number;
  26078. /**
  26079. * Hinge-Joint 2 type
  26080. */
  26081. static Hinge2Joint: number;
  26082. /**
  26083. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26084. */
  26085. static PointToPointJoint: number;
  26086. /**
  26087. * Spring-Joint type
  26088. */
  26089. static SpringJoint: number;
  26090. /**
  26091. * Lock-Joint type
  26092. */
  26093. static LockJoint: number;
  26094. }
  26095. /**
  26096. * A class representing a physics distance joint
  26097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26098. */
  26099. export class DistanceJoint extends PhysicsJoint {
  26100. /**
  26101. *
  26102. * @param jointData The data for the Distance-Joint
  26103. */
  26104. constructor(jointData: DistanceJointData);
  26105. /**
  26106. * Update the predefined distance.
  26107. * @param maxDistance The maximum preferred distance
  26108. * @param minDistance The minimum preferred distance
  26109. */
  26110. updateDistance(maxDistance: number, minDistance?: number): void;
  26111. }
  26112. /**
  26113. * Represents a Motor-Enabled Joint
  26114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26115. */
  26116. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26117. /**
  26118. * Initializes the Motor-Enabled Joint
  26119. * @param type The type of the joint
  26120. * @param jointData The physica joint data for the joint
  26121. */
  26122. constructor(type: number, jointData: PhysicsJointData);
  26123. /**
  26124. * Set the motor values.
  26125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26126. * @param force the force to apply
  26127. * @param maxForce max force for this motor.
  26128. */
  26129. setMotor(force?: number, maxForce?: number): void;
  26130. /**
  26131. * Set the motor's limits.
  26132. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26133. * @param upperLimit The upper limit of the motor
  26134. * @param lowerLimit The lower limit of the motor
  26135. */
  26136. setLimit(upperLimit: number, lowerLimit?: number): void;
  26137. }
  26138. /**
  26139. * This class represents a single physics Hinge-Joint
  26140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26141. */
  26142. export class HingeJoint extends MotorEnabledJoint {
  26143. /**
  26144. * Initializes the Hinge-Joint
  26145. * @param jointData The joint data for the Hinge-Joint
  26146. */
  26147. constructor(jointData: PhysicsJointData);
  26148. /**
  26149. * Set the motor values.
  26150. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26151. * @param {number} force the force to apply
  26152. * @param {number} maxForce max force for this motor.
  26153. */
  26154. setMotor(force?: number, maxForce?: number): void;
  26155. /**
  26156. * Set the motor's limits.
  26157. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26158. * @param upperLimit The upper limit of the motor
  26159. * @param lowerLimit The lower limit of the motor
  26160. */
  26161. setLimit(upperLimit: number, lowerLimit?: number): void;
  26162. }
  26163. /**
  26164. * This class represents a dual hinge physics joint (same as wheel joint)
  26165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26166. */
  26167. export class Hinge2Joint extends MotorEnabledJoint {
  26168. /**
  26169. * Initializes the Hinge2-Joint
  26170. * @param jointData The joint data for the Hinge2-Joint
  26171. */
  26172. constructor(jointData: PhysicsJointData);
  26173. /**
  26174. * Set the motor values.
  26175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26176. * @param {number} targetSpeed the speed the motor is to reach
  26177. * @param {number} maxForce max force for this motor.
  26178. * @param {motorIndex} the motor's index, 0 or 1.
  26179. */
  26180. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26181. /**
  26182. * Set the motor limits.
  26183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26184. * @param {number} upperLimit the upper limit
  26185. * @param {number} lowerLimit lower limit
  26186. * @param {motorIndex} the motor's index, 0 or 1.
  26187. */
  26188. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26189. }
  26190. /**
  26191. * Interface for a motor enabled joint
  26192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26193. */
  26194. export interface IMotorEnabledJoint {
  26195. /**
  26196. * Physics joint
  26197. */
  26198. physicsJoint: any;
  26199. /**
  26200. * Sets the motor of the motor-enabled joint
  26201. * @param force The force of the motor
  26202. * @param maxForce The maximum force of the motor
  26203. * @param motorIndex The index of the motor
  26204. */
  26205. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26206. /**
  26207. * Sets the limit of the motor
  26208. * @param upperLimit The upper limit of the motor
  26209. * @param lowerLimit The lower limit of the motor
  26210. * @param motorIndex The index of the motor
  26211. */
  26212. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26213. }
  26214. /**
  26215. * Joint data for a Distance-Joint
  26216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26217. */
  26218. export interface DistanceJointData extends PhysicsJointData {
  26219. /**
  26220. * Max distance the 2 joint objects can be apart
  26221. */
  26222. maxDistance: number;
  26223. }
  26224. /**
  26225. * Joint data from a spring joint
  26226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26227. */
  26228. export interface SpringJointData extends PhysicsJointData {
  26229. /**
  26230. * Length of the spring
  26231. */
  26232. length: number;
  26233. /**
  26234. * Stiffness of the spring
  26235. */
  26236. stiffness: number;
  26237. /**
  26238. * Damping of the spring
  26239. */
  26240. damping: number;
  26241. /** this callback will be called when applying the force to the impostors. */
  26242. forceApplicationCallback: () => void;
  26243. }
  26244. }
  26245. declare module BABYLON {
  26246. /**
  26247. * Holds the data for the raycast result
  26248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26249. */
  26250. export class PhysicsRaycastResult {
  26251. private _hasHit;
  26252. private _hitDistance;
  26253. private _hitNormalWorld;
  26254. private _hitPointWorld;
  26255. private _rayFromWorld;
  26256. private _rayToWorld;
  26257. /**
  26258. * Gets if there was a hit
  26259. */
  26260. get hasHit(): boolean;
  26261. /**
  26262. * Gets the distance from the hit
  26263. */
  26264. get hitDistance(): number;
  26265. /**
  26266. * Gets the hit normal/direction in the world
  26267. */
  26268. get hitNormalWorld(): Vector3;
  26269. /**
  26270. * Gets the hit point in the world
  26271. */
  26272. get hitPointWorld(): Vector3;
  26273. /**
  26274. * Gets the ray "start point" of the ray in the world
  26275. */
  26276. get rayFromWorld(): Vector3;
  26277. /**
  26278. * Gets the ray "end point" of the ray in the world
  26279. */
  26280. get rayToWorld(): Vector3;
  26281. /**
  26282. * Sets the hit data (normal & point in world space)
  26283. * @param hitNormalWorld defines the normal in world space
  26284. * @param hitPointWorld defines the point in world space
  26285. */
  26286. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26287. /**
  26288. * Sets the distance from the start point to the hit point
  26289. * @param distance
  26290. */
  26291. setHitDistance(distance: number): void;
  26292. /**
  26293. * Calculates the distance manually
  26294. */
  26295. calculateHitDistance(): void;
  26296. /**
  26297. * Resets all the values to default
  26298. * @param from The from point on world space
  26299. * @param to The to point on world space
  26300. */
  26301. reset(from?: Vector3, to?: Vector3): void;
  26302. }
  26303. /**
  26304. * Interface for the size containing width and height
  26305. */
  26306. interface IXYZ {
  26307. /**
  26308. * X
  26309. */
  26310. x: number;
  26311. /**
  26312. * Y
  26313. */
  26314. y: number;
  26315. /**
  26316. * Z
  26317. */
  26318. z: number;
  26319. }
  26320. }
  26321. declare module BABYLON {
  26322. /**
  26323. * Interface used to describe a physics joint
  26324. */
  26325. export interface PhysicsImpostorJoint {
  26326. /** Defines the main impostor to which the joint is linked */
  26327. mainImpostor: PhysicsImpostor;
  26328. /** Defines the impostor that is connected to the main impostor using this joint */
  26329. connectedImpostor: PhysicsImpostor;
  26330. /** Defines the joint itself */
  26331. joint: PhysicsJoint;
  26332. }
  26333. /** @hidden */
  26334. export interface IPhysicsEnginePlugin {
  26335. world: any;
  26336. name: string;
  26337. setGravity(gravity: Vector3): void;
  26338. setTimeStep(timeStep: number): void;
  26339. getTimeStep(): number;
  26340. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26341. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26342. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26343. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26344. removePhysicsBody(impostor: PhysicsImpostor): void;
  26345. generateJoint(joint: PhysicsImpostorJoint): void;
  26346. removeJoint(joint: PhysicsImpostorJoint): void;
  26347. isSupported(): boolean;
  26348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26350. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26351. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26352. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26353. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26354. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26355. getBodyMass(impostor: PhysicsImpostor): number;
  26356. getBodyFriction(impostor: PhysicsImpostor): number;
  26357. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26358. getBodyRestitution(impostor: PhysicsImpostor): number;
  26359. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26360. getBodyPressure?(impostor: PhysicsImpostor): number;
  26361. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26362. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26363. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26364. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26365. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26366. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26367. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26368. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26369. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26370. sleepBody(impostor: PhysicsImpostor): void;
  26371. wakeUpBody(impostor: PhysicsImpostor): void;
  26372. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26373. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26374. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26375. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26376. getRadius(impostor: PhysicsImpostor): number;
  26377. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26378. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26379. dispose(): void;
  26380. }
  26381. /**
  26382. * Interface used to define a physics engine
  26383. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26384. */
  26385. export interface IPhysicsEngine {
  26386. /**
  26387. * Gets the gravity vector used by the simulation
  26388. */
  26389. gravity: Vector3;
  26390. /**
  26391. * Sets the gravity vector used by the simulation
  26392. * @param gravity defines the gravity vector to use
  26393. */
  26394. setGravity(gravity: Vector3): void;
  26395. /**
  26396. * Set the time step of the physics engine.
  26397. * Default is 1/60.
  26398. * To slow it down, enter 1/600 for example.
  26399. * To speed it up, 1/30
  26400. * @param newTimeStep the new timestep to apply to this world.
  26401. */
  26402. setTimeStep(newTimeStep: number): void;
  26403. /**
  26404. * Get the time step of the physics engine.
  26405. * @returns the current time step
  26406. */
  26407. getTimeStep(): number;
  26408. /**
  26409. * Set the sub time step of the physics engine.
  26410. * Default is 0 meaning there is no sub steps
  26411. * To increase physics resolution precision, set a small value (like 1 ms)
  26412. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26413. */
  26414. setSubTimeStep(subTimeStep: number): void;
  26415. /**
  26416. * Get the sub time step of the physics engine.
  26417. * @returns the current sub time step
  26418. */
  26419. getSubTimeStep(): number;
  26420. /**
  26421. * Release all resources
  26422. */
  26423. dispose(): void;
  26424. /**
  26425. * Gets the name of the current physics plugin
  26426. * @returns the name of the plugin
  26427. */
  26428. getPhysicsPluginName(): string;
  26429. /**
  26430. * Adding a new impostor for the impostor tracking.
  26431. * This will be done by the impostor itself.
  26432. * @param impostor the impostor to add
  26433. */
  26434. addImpostor(impostor: PhysicsImpostor): void;
  26435. /**
  26436. * Remove an impostor from the engine.
  26437. * This impostor and its mesh will not longer be updated by the physics engine.
  26438. * @param impostor the impostor to remove
  26439. */
  26440. removeImpostor(impostor: PhysicsImpostor): void;
  26441. /**
  26442. * Add a joint to the physics engine
  26443. * @param mainImpostor defines the main impostor to which the joint is added.
  26444. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26445. * @param joint defines the joint that will connect both impostors.
  26446. */
  26447. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26448. /**
  26449. * Removes a joint from the simulation
  26450. * @param mainImpostor defines the impostor used with the joint
  26451. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26452. * @param joint defines the joint to remove
  26453. */
  26454. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26455. /**
  26456. * Gets the current plugin used to run the simulation
  26457. * @returns current plugin
  26458. */
  26459. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26460. /**
  26461. * Gets the list of physic impostors
  26462. * @returns an array of PhysicsImpostor
  26463. */
  26464. getImpostors(): Array<PhysicsImpostor>;
  26465. /**
  26466. * Gets the impostor for a physics enabled object
  26467. * @param object defines the object impersonated by the impostor
  26468. * @returns the PhysicsImpostor or null if not found
  26469. */
  26470. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26471. /**
  26472. * Gets the impostor for a physics body object
  26473. * @param body defines physics body used by the impostor
  26474. * @returns the PhysicsImpostor or null if not found
  26475. */
  26476. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26477. /**
  26478. * Does a raycast in the physics world
  26479. * @param from when should the ray start?
  26480. * @param to when should the ray end?
  26481. * @returns PhysicsRaycastResult
  26482. */
  26483. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26484. /**
  26485. * Called by the scene. No need to call it.
  26486. * @param delta defines the timespam between frames
  26487. */
  26488. _step(delta: number): void;
  26489. }
  26490. }
  26491. declare module BABYLON {
  26492. /**
  26493. * The interface for the physics imposter parameters
  26494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26495. */
  26496. export interface PhysicsImpostorParameters {
  26497. /**
  26498. * The mass of the physics imposter
  26499. */
  26500. mass: number;
  26501. /**
  26502. * The friction of the physics imposter
  26503. */
  26504. friction?: number;
  26505. /**
  26506. * The coefficient of restitution of the physics imposter
  26507. */
  26508. restitution?: number;
  26509. /**
  26510. * The native options of the physics imposter
  26511. */
  26512. nativeOptions?: any;
  26513. /**
  26514. * Specifies if the parent should be ignored
  26515. */
  26516. ignoreParent?: boolean;
  26517. /**
  26518. * Specifies if bi-directional transformations should be disabled
  26519. */
  26520. disableBidirectionalTransformation?: boolean;
  26521. /**
  26522. * The pressure inside the physics imposter, soft object only
  26523. */
  26524. pressure?: number;
  26525. /**
  26526. * The stiffness the physics imposter, soft object only
  26527. */
  26528. stiffness?: number;
  26529. /**
  26530. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26531. */
  26532. velocityIterations?: number;
  26533. /**
  26534. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26535. */
  26536. positionIterations?: number;
  26537. /**
  26538. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26539. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26540. * Add to fix multiple points
  26541. */
  26542. fixedPoints?: number;
  26543. /**
  26544. * The collision margin around a soft object
  26545. */
  26546. margin?: number;
  26547. /**
  26548. * The collision margin around a soft object
  26549. */
  26550. damping?: number;
  26551. /**
  26552. * The path for a rope based on an extrusion
  26553. */
  26554. path?: any;
  26555. /**
  26556. * The shape of an extrusion used for a rope based on an extrusion
  26557. */
  26558. shape?: any;
  26559. }
  26560. /**
  26561. * Interface for a physics-enabled object
  26562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26563. */
  26564. export interface IPhysicsEnabledObject {
  26565. /**
  26566. * The position of the physics-enabled object
  26567. */
  26568. position: Vector3;
  26569. /**
  26570. * The rotation of the physics-enabled object
  26571. */
  26572. rotationQuaternion: Nullable<Quaternion>;
  26573. /**
  26574. * The scale of the physics-enabled object
  26575. */
  26576. scaling: Vector3;
  26577. /**
  26578. * The rotation of the physics-enabled object
  26579. */
  26580. rotation?: Vector3;
  26581. /**
  26582. * The parent of the physics-enabled object
  26583. */
  26584. parent?: any;
  26585. /**
  26586. * The bounding info of the physics-enabled object
  26587. * @returns The bounding info of the physics-enabled object
  26588. */
  26589. getBoundingInfo(): BoundingInfo;
  26590. /**
  26591. * Computes the world matrix
  26592. * @param force Specifies if the world matrix should be computed by force
  26593. * @returns A world matrix
  26594. */
  26595. computeWorldMatrix(force: boolean): Matrix;
  26596. /**
  26597. * Gets the world matrix
  26598. * @returns A world matrix
  26599. */
  26600. getWorldMatrix?(): Matrix;
  26601. /**
  26602. * Gets the child meshes
  26603. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26604. * @returns An array of abstract meshes
  26605. */
  26606. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26607. /**
  26608. * Gets the vertex data
  26609. * @param kind The type of vertex data
  26610. * @returns A nullable array of numbers, or a float32 array
  26611. */
  26612. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26613. /**
  26614. * Gets the indices from the mesh
  26615. * @returns A nullable array of index arrays
  26616. */
  26617. getIndices?(): Nullable<IndicesArray>;
  26618. /**
  26619. * Gets the scene from the mesh
  26620. * @returns the indices array or null
  26621. */
  26622. getScene?(): Scene;
  26623. /**
  26624. * Gets the absolute position from the mesh
  26625. * @returns the absolute position
  26626. */
  26627. getAbsolutePosition(): Vector3;
  26628. /**
  26629. * Gets the absolute pivot point from the mesh
  26630. * @returns the absolute pivot point
  26631. */
  26632. getAbsolutePivotPoint(): Vector3;
  26633. /**
  26634. * Rotates the mesh
  26635. * @param axis The axis of rotation
  26636. * @param amount The amount of rotation
  26637. * @param space The space of the rotation
  26638. * @returns The rotation transform node
  26639. */
  26640. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26641. /**
  26642. * Translates the mesh
  26643. * @param axis The axis of translation
  26644. * @param distance The distance of translation
  26645. * @param space The space of the translation
  26646. * @returns The transform node
  26647. */
  26648. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26649. /**
  26650. * Sets the absolute position of the mesh
  26651. * @param absolutePosition The absolute position of the mesh
  26652. * @returns The transform node
  26653. */
  26654. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26655. /**
  26656. * Gets the class name of the mesh
  26657. * @returns The class name
  26658. */
  26659. getClassName(): string;
  26660. }
  26661. /**
  26662. * Represents a physics imposter
  26663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26664. */
  26665. export class PhysicsImpostor {
  26666. /**
  26667. * The physics-enabled object used as the physics imposter
  26668. */
  26669. object: IPhysicsEnabledObject;
  26670. /**
  26671. * The type of the physics imposter
  26672. */
  26673. type: number;
  26674. private _options;
  26675. private _scene?;
  26676. /**
  26677. * The default object size of the imposter
  26678. */
  26679. static DEFAULT_OBJECT_SIZE: Vector3;
  26680. /**
  26681. * The identity quaternion of the imposter
  26682. */
  26683. static IDENTITY_QUATERNION: Quaternion;
  26684. /** @hidden */
  26685. _pluginData: any;
  26686. private _physicsEngine;
  26687. private _physicsBody;
  26688. private _bodyUpdateRequired;
  26689. private _onBeforePhysicsStepCallbacks;
  26690. private _onAfterPhysicsStepCallbacks;
  26691. /** @hidden */
  26692. _onPhysicsCollideCallbacks: Array<{
  26693. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26694. otherImpostors: Array<PhysicsImpostor>;
  26695. }>;
  26696. private _deltaPosition;
  26697. private _deltaRotation;
  26698. private _deltaRotationConjugated;
  26699. /** @hidden */
  26700. _isFromLine: boolean;
  26701. private _parent;
  26702. private _isDisposed;
  26703. private static _tmpVecs;
  26704. private static _tmpQuat;
  26705. /**
  26706. * Specifies if the physics imposter is disposed
  26707. */
  26708. get isDisposed(): boolean;
  26709. /**
  26710. * Gets the mass of the physics imposter
  26711. */
  26712. get mass(): number;
  26713. set mass(value: number);
  26714. /**
  26715. * Gets the coefficient of friction
  26716. */
  26717. get friction(): number;
  26718. /**
  26719. * Sets the coefficient of friction
  26720. */
  26721. set friction(value: number);
  26722. /**
  26723. * Gets the coefficient of restitution
  26724. */
  26725. get restitution(): number;
  26726. /**
  26727. * Sets the coefficient of restitution
  26728. */
  26729. set restitution(value: number);
  26730. /**
  26731. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26732. */
  26733. get pressure(): number;
  26734. /**
  26735. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26736. */
  26737. set pressure(value: number);
  26738. /**
  26739. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26740. */
  26741. get stiffness(): number;
  26742. /**
  26743. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26744. */
  26745. set stiffness(value: number);
  26746. /**
  26747. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26748. */
  26749. get velocityIterations(): number;
  26750. /**
  26751. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26752. */
  26753. set velocityIterations(value: number);
  26754. /**
  26755. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26756. */
  26757. get positionIterations(): number;
  26758. /**
  26759. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26760. */
  26761. set positionIterations(value: number);
  26762. /**
  26763. * The unique id of the physics imposter
  26764. * set by the physics engine when adding this impostor to the array
  26765. */
  26766. uniqueId: number;
  26767. /**
  26768. * @hidden
  26769. */
  26770. soft: boolean;
  26771. /**
  26772. * @hidden
  26773. */
  26774. segments: number;
  26775. private _joints;
  26776. /**
  26777. * Initializes the physics imposter
  26778. * @param object The physics-enabled object used as the physics imposter
  26779. * @param type The type of the physics imposter
  26780. * @param _options The options for the physics imposter
  26781. * @param _scene The Babylon scene
  26782. */
  26783. constructor(
  26784. /**
  26785. * The physics-enabled object used as the physics imposter
  26786. */
  26787. object: IPhysicsEnabledObject,
  26788. /**
  26789. * The type of the physics imposter
  26790. */
  26791. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26792. /**
  26793. * This function will completly initialize this impostor.
  26794. * It will create a new body - but only if this mesh has no parent.
  26795. * If it has, this impostor will not be used other than to define the impostor
  26796. * of the child mesh.
  26797. * @hidden
  26798. */
  26799. _init(): void;
  26800. private _getPhysicsParent;
  26801. /**
  26802. * Should a new body be generated.
  26803. * @returns boolean specifying if body initialization is required
  26804. */
  26805. isBodyInitRequired(): boolean;
  26806. /**
  26807. * Sets the updated scaling
  26808. * @param updated Specifies if the scaling is updated
  26809. */
  26810. setScalingUpdated(): void;
  26811. /**
  26812. * Force a regeneration of this or the parent's impostor's body.
  26813. * Use under cautious - This will remove all joints already implemented.
  26814. */
  26815. forceUpdate(): void;
  26816. /**
  26817. * Gets the body that holds this impostor. Either its own, or its parent.
  26818. */
  26819. get physicsBody(): any;
  26820. /**
  26821. * Get the parent of the physics imposter
  26822. * @returns Physics imposter or null
  26823. */
  26824. get parent(): Nullable<PhysicsImpostor>;
  26825. /**
  26826. * Sets the parent of the physics imposter
  26827. */
  26828. set parent(value: Nullable<PhysicsImpostor>);
  26829. /**
  26830. * Set the physics body. Used mainly by the physics engine/plugin
  26831. */
  26832. set physicsBody(physicsBody: any);
  26833. /**
  26834. * Resets the update flags
  26835. */
  26836. resetUpdateFlags(): void;
  26837. /**
  26838. * Gets the object extend size
  26839. * @returns the object extend size
  26840. */
  26841. getObjectExtendSize(): Vector3;
  26842. /**
  26843. * Gets the object center
  26844. * @returns The object center
  26845. */
  26846. getObjectCenter(): Vector3;
  26847. /**
  26848. * Get a specific parameter from the options parameters
  26849. * @param paramName The object parameter name
  26850. * @returns The object parameter
  26851. */
  26852. getParam(paramName: string): any;
  26853. /**
  26854. * Sets a specific parameter in the options given to the physics plugin
  26855. * @param paramName The parameter name
  26856. * @param value The value of the parameter
  26857. */
  26858. setParam(paramName: string, value: number): void;
  26859. /**
  26860. * Specifically change the body's mass option. Won't recreate the physics body object
  26861. * @param mass The mass of the physics imposter
  26862. */
  26863. setMass(mass: number): void;
  26864. /**
  26865. * Gets the linear velocity
  26866. * @returns linear velocity or null
  26867. */
  26868. getLinearVelocity(): Nullable<Vector3>;
  26869. /**
  26870. * Sets the linear velocity
  26871. * @param velocity linear velocity or null
  26872. */
  26873. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26874. /**
  26875. * Gets the angular velocity
  26876. * @returns angular velocity or null
  26877. */
  26878. getAngularVelocity(): Nullable<Vector3>;
  26879. /**
  26880. * Sets the angular velocity
  26881. * @param velocity The velocity or null
  26882. */
  26883. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26884. /**
  26885. * Execute a function with the physics plugin native code
  26886. * Provide a function the will have two variables - the world object and the physics body object
  26887. * @param func The function to execute with the physics plugin native code
  26888. */
  26889. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26890. /**
  26891. * Register a function that will be executed before the physics world is stepping forward
  26892. * @param func The function to execute before the physics world is stepped forward
  26893. */
  26894. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26895. /**
  26896. * Unregister a function that will be executed before the physics world is stepping forward
  26897. * @param func The function to execute before the physics world is stepped forward
  26898. */
  26899. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26900. /**
  26901. * Register a function that will be executed after the physics step
  26902. * @param func The function to execute after physics step
  26903. */
  26904. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26905. /**
  26906. * Unregisters a function that will be executed after the physics step
  26907. * @param func The function to execute after physics step
  26908. */
  26909. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26910. /**
  26911. * register a function that will be executed when this impostor collides against a different body
  26912. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26913. * @param func Callback that is executed on collision
  26914. */
  26915. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26916. /**
  26917. * Unregisters the physics imposter on contact
  26918. * @param collideAgainst The physics object to collide against
  26919. * @param func Callback to execute on collision
  26920. */
  26921. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26922. private _tmpQuat;
  26923. private _tmpQuat2;
  26924. /**
  26925. * Get the parent rotation
  26926. * @returns The parent rotation
  26927. */
  26928. getParentsRotation(): Quaternion;
  26929. /**
  26930. * this function is executed by the physics engine.
  26931. */
  26932. beforeStep: () => void;
  26933. /**
  26934. * this function is executed by the physics engine
  26935. */
  26936. afterStep: () => void;
  26937. /**
  26938. * Legacy collision detection event support
  26939. */
  26940. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26941. /**
  26942. * event and body object due to cannon's event-based architecture.
  26943. */
  26944. onCollide: (e: {
  26945. body: any;
  26946. }) => void;
  26947. /**
  26948. * Apply a force
  26949. * @param force The force to apply
  26950. * @param contactPoint The contact point for the force
  26951. * @returns The physics imposter
  26952. */
  26953. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26954. /**
  26955. * Apply an impulse
  26956. * @param force The impulse force
  26957. * @param contactPoint The contact point for the impulse force
  26958. * @returns The physics imposter
  26959. */
  26960. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26961. /**
  26962. * A help function to create a joint
  26963. * @param otherImpostor A physics imposter used to create a joint
  26964. * @param jointType The type of joint
  26965. * @param jointData The data for the joint
  26966. * @returns The physics imposter
  26967. */
  26968. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26969. /**
  26970. * Add a joint to this impostor with a different impostor
  26971. * @param otherImpostor A physics imposter used to add a joint
  26972. * @param joint The joint to add
  26973. * @returns The physics imposter
  26974. */
  26975. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26976. /**
  26977. * Add an anchor to a cloth impostor
  26978. * @param otherImpostor rigid impostor to anchor to
  26979. * @param width ratio across width from 0 to 1
  26980. * @param height ratio up height from 0 to 1
  26981. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26982. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26983. * @returns impostor the soft imposter
  26984. */
  26985. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26986. /**
  26987. * Add a hook to a rope impostor
  26988. * @param otherImpostor rigid impostor to anchor to
  26989. * @param length ratio across rope from 0 to 1
  26990. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26991. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26992. * @returns impostor the rope imposter
  26993. */
  26994. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26995. /**
  26996. * Will keep this body still, in a sleep mode.
  26997. * @returns the physics imposter
  26998. */
  26999. sleep(): PhysicsImpostor;
  27000. /**
  27001. * Wake the body up.
  27002. * @returns The physics imposter
  27003. */
  27004. wakeUp(): PhysicsImpostor;
  27005. /**
  27006. * Clones the physics imposter
  27007. * @param newObject The physics imposter clones to this physics-enabled object
  27008. * @returns A nullable physics imposter
  27009. */
  27010. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27011. /**
  27012. * Disposes the physics imposter
  27013. */
  27014. dispose(): void;
  27015. /**
  27016. * Sets the delta position
  27017. * @param position The delta position amount
  27018. */
  27019. setDeltaPosition(position: Vector3): void;
  27020. /**
  27021. * Sets the delta rotation
  27022. * @param rotation The delta rotation amount
  27023. */
  27024. setDeltaRotation(rotation: Quaternion): void;
  27025. /**
  27026. * Gets the box size of the physics imposter and stores the result in the input parameter
  27027. * @param result Stores the box size
  27028. * @returns The physics imposter
  27029. */
  27030. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27031. /**
  27032. * Gets the radius of the physics imposter
  27033. * @returns Radius of the physics imposter
  27034. */
  27035. getRadius(): number;
  27036. /**
  27037. * Sync a bone with this impostor
  27038. * @param bone The bone to sync to the impostor.
  27039. * @param boneMesh The mesh that the bone is influencing.
  27040. * @param jointPivot The pivot of the joint / bone in local space.
  27041. * @param distToJoint Optional distance from the impostor to the joint.
  27042. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27043. */
  27044. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27045. /**
  27046. * Sync impostor to a bone
  27047. * @param bone The bone that the impostor will be synced to.
  27048. * @param boneMesh The mesh that the bone is influencing.
  27049. * @param jointPivot The pivot of the joint / bone in local space.
  27050. * @param distToJoint Optional distance from the impostor to the joint.
  27051. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27052. * @param boneAxis Optional vector3 axis the bone is aligned with
  27053. */
  27054. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27055. /**
  27056. * No-Imposter type
  27057. */
  27058. static NoImpostor: number;
  27059. /**
  27060. * Sphere-Imposter type
  27061. */
  27062. static SphereImpostor: number;
  27063. /**
  27064. * Box-Imposter type
  27065. */
  27066. static BoxImpostor: number;
  27067. /**
  27068. * Plane-Imposter type
  27069. */
  27070. static PlaneImpostor: number;
  27071. /**
  27072. * Mesh-imposter type
  27073. */
  27074. static MeshImpostor: number;
  27075. /**
  27076. * Capsule-Impostor type (Ammo.js plugin only)
  27077. */
  27078. static CapsuleImpostor: number;
  27079. /**
  27080. * Cylinder-Imposter type
  27081. */
  27082. static CylinderImpostor: number;
  27083. /**
  27084. * Particle-Imposter type
  27085. */
  27086. static ParticleImpostor: number;
  27087. /**
  27088. * Heightmap-Imposter type
  27089. */
  27090. static HeightmapImpostor: number;
  27091. /**
  27092. * ConvexHull-Impostor type (Ammo.js plugin only)
  27093. */
  27094. static ConvexHullImpostor: number;
  27095. /**
  27096. * Custom-Imposter type (Ammo.js plugin only)
  27097. */
  27098. static CustomImpostor: number;
  27099. /**
  27100. * Rope-Imposter type
  27101. */
  27102. static RopeImpostor: number;
  27103. /**
  27104. * Cloth-Imposter type
  27105. */
  27106. static ClothImpostor: number;
  27107. /**
  27108. * Softbody-Imposter type
  27109. */
  27110. static SoftbodyImpostor: number;
  27111. }
  27112. }
  27113. declare module BABYLON {
  27114. /**
  27115. * @hidden
  27116. **/
  27117. export class _CreationDataStorage {
  27118. closePath?: boolean;
  27119. closeArray?: boolean;
  27120. idx: number[];
  27121. dashSize: number;
  27122. gapSize: number;
  27123. path3D: Path3D;
  27124. pathArray: Vector3[][];
  27125. arc: number;
  27126. radius: number;
  27127. cap: number;
  27128. tessellation: number;
  27129. }
  27130. /**
  27131. * @hidden
  27132. **/
  27133. class _InstanceDataStorage {
  27134. visibleInstances: any;
  27135. batchCache: _InstancesBatch;
  27136. instancesBufferSize: number;
  27137. instancesBuffer: Nullable<Buffer>;
  27138. instancesData: Float32Array;
  27139. overridenInstanceCount: number;
  27140. isFrozen: boolean;
  27141. previousBatch: Nullable<_InstancesBatch>;
  27142. hardwareInstancedRendering: boolean;
  27143. sideOrientation: number;
  27144. manualUpdate: boolean;
  27145. }
  27146. /**
  27147. * @hidden
  27148. **/
  27149. export class _InstancesBatch {
  27150. mustReturn: boolean;
  27151. visibleInstances: Nullable<InstancedMesh[]>[];
  27152. renderSelf: boolean[];
  27153. hardwareInstancedRendering: boolean[];
  27154. }
  27155. /**
  27156. * Class used to represent renderable models
  27157. */
  27158. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27159. /**
  27160. * Mesh side orientation : usually the external or front surface
  27161. */
  27162. static readonly FRONTSIDE: number;
  27163. /**
  27164. * Mesh side orientation : usually the internal or back surface
  27165. */
  27166. static readonly BACKSIDE: number;
  27167. /**
  27168. * Mesh side orientation : both internal and external or front and back surfaces
  27169. */
  27170. static readonly DOUBLESIDE: number;
  27171. /**
  27172. * Mesh side orientation : by default, `FRONTSIDE`
  27173. */
  27174. static readonly DEFAULTSIDE: number;
  27175. /**
  27176. * Mesh cap setting : no cap
  27177. */
  27178. static readonly NO_CAP: number;
  27179. /**
  27180. * Mesh cap setting : one cap at the beginning of the mesh
  27181. */
  27182. static readonly CAP_START: number;
  27183. /**
  27184. * Mesh cap setting : one cap at the end of the mesh
  27185. */
  27186. static readonly CAP_END: number;
  27187. /**
  27188. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27189. */
  27190. static readonly CAP_ALL: number;
  27191. /**
  27192. * Mesh pattern setting : no flip or rotate
  27193. */
  27194. static readonly NO_FLIP: number;
  27195. /**
  27196. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27197. */
  27198. static readonly FLIP_TILE: number;
  27199. /**
  27200. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27201. */
  27202. static readonly ROTATE_TILE: number;
  27203. /**
  27204. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27205. */
  27206. static readonly FLIP_ROW: number;
  27207. /**
  27208. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27209. */
  27210. static readonly ROTATE_ROW: number;
  27211. /**
  27212. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27213. */
  27214. static readonly FLIP_N_ROTATE_TILE: number;
  27215. /**
  27216. * Mesh pattern setting : rotate pattern and rotate
  27217. */
  27218. static readonly FLIP_N_ROTATE_ROW: number;
  27219. /**
  27220. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27221. */
  27222. static readonly CENTER: number;
  27223. /**
  27224. * Mesh tile positioning : part tiles on left
  27225. */
  27226. static readonly LEFT: number;
  27227. /**
  27228. * Mesh tile positioning : part tiles on right
  27229. */
  27230. static readonly RIGHT: number;
  27231. /**
  27232. * Mesh tile positioning : part tiles on top
  27233. */
  27234. static readonly TOP: number;
  27235. /**
  27236. * Mesh tile positioning : part tiles on bottom
  27237. */
  27238. static readonly BOTTOM: number;
  27239. /**
  27240. * Gets the default side orientation.
  27241. * @param orientation the orientation to value to attempt to get
  27242. * @returns the default orientation
  27243. * @hidden
  27244. */
  27245. static _GetDefaultSideOrientation(orientation?: number): number;
  27246. private _internalMeshDataInfo;
  27247. /**
  27248. * An event triggered before rendering the mesh
  27249. */
  27250. get onBeforeRenderObservable(): Observable<Mesh>;
  27251. /**
  27252. * An event triggered before binding the mesh
  27253. */
  27254. get onBeforeBindObservable(): Observable<Mesh>;
  27255. /**
  27256. * An event triggered after rendering the mesh
  27257. */
  27258. get onAfterRenderObservable(): Observable<Mesh>;
  27259. /**
  27260. * An event triggered before drawing the mesh
  27261. */
  27262. get onBeforeDrawObservable(): Observable<Mesh>;
  27263. private _onBeforeDrawObserver;
  27264. /**
  27265. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27266. */
  27267. set onBeforeDraw(callback: () => void);
  27268. get hasInstances(): boolean;
  27269. /**
  27270. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27271. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27272. */
  27273. delayLoadState: number;
  27274. /**
  27275. * Gets the list of instances created from this mesh
  27276. * it is not supposed to be modified manually.
  27277. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27278. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27279. */
  27280. instances: InstancedMesh[];
  27281. /**
  27282. * Gets the file containing delay loading data for this mesh
  27283. */
  27284. delayLoadingFile: string;
  27285. /** @hidden */
  27286. _binaryInfo: any;
  27287. /**
  27288. * User defined function used to change how LOD level selection is done
  27289. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27290. */
  27291. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27292. /**
  27293. * Gets or sets the morph target manager
  27294. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27295. */
  27296. get morphTargetManager(): Nullable<MorphTargetManager>;
  27297. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27298. /** @hidden */
  27299. _creationDataStorage: Nullable<_CreationDataStorage>;
  27300. /** @hidden */
  27301. _geometry: Nullable<Geometry>;
  27302. /** @hidden */
  27303. _delayInfo: Array<string>;
  27304. /** @hidden */
  27305. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27306. /** @hidden */
  27307. _instanceDataStorage: _InstanceDataStorage;
  27308. private _effectiveMaterial;
  27309. /** @hidden */
  27310. _shouldGenerateFlatShading: boolean;
  27311. /** @hidden */
  27312. _originalBuilderSideOrientation: number;
  27313. /**
  27314. * Use this property to change the original side orientation defined at construction time
  27315. */
  27316. overrideMaterialSideOrientation: Nullable<number>;
  27317. /**
  27318. * Gets the source mesh (the one used to clone this one from)
  27319. */
  27320. get source(): Nullable<Mesh>;
  27321. /**
  27322. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27323. */
  27324. get isUnIndexed(): boolean;
  27325. set isUnIndexed(value: boolean);
  27326. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27327. get worldMatrixInstancedBuffer(): Float32Array;
  27328. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27329. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27330. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27331. /**
  27332. * @constructor
  27333. * @param name The value used by scene.getMeshByName() to do a lookup.
  27334. * @param scene The scene to add this mesh to.
  27335. * @param parent The parent of this mesh, if it has one
  27336. * @param source An optional Mesh from which geometry is shared, cloned.
  27337. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27338. * When false, achieved by calling a clone(), also passing False.
  27339. * This will make creation of children, recursive.
  27340. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27341. */
  27342. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27343. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27344. doNotInstantiate: boolean;
  27345. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27346. /**
  27347. * Gets the class name
  27348. * @returns the string "Mesh".
  27349. */
  27350. getClassName(): string;
  27351. /** @hidden */
  27352. get _isMesh(): boolean;
  27353. /**
  27354. * Returns a description of this mesh
  27355. * @param fullDetails define if full details about this mesh must be used
  27356. * @returns a descriptive string representing this mesh
  27357. */
  27358. toString(fullDetails?: boolean): string;
  27359. /** @hidden */
  27360. _unBindEffect(): void;
  27361. /**
  27362. * Gets a boolean indicating if this mesh has LOD
  27363. */
  27364. get hasLODLevels(): boolean;
  27365. /**
  27366. * Gets the list of MeshLODLevel associated with the current mesh
  27367. * @returns an array of MeshLODLevel
  27368. */
  27369. getLODLevels(): MeshLODLevel[];
  27370. private _sortLODLevels;
  27371. /**
  27372. * Add a mesh as LOD level triggered at the given distance.
  27373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27374. * @param distance The distance from the center of the object to show this level
  27375. * @param mesh The mesh to be added as LOD level (can be null)
  27376. * @return This mesh (for chaining)
  27377. */
  27378. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27379. /**
  27380. * Returns the LOD level mesh at the passed distance or null if not found.
  27381. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27382. * @param distance The distance from the center of the object to show this level
  27383. * @returns a Mesh or `null`
  27384. */
  27385. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27386. /**
  27387. * Remove a mesh from the LOD array
  27388. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27389. * @param mesh defines the mesh to be removed
  27390. * @return This mesh (for chaining)
  27391. */
  27392. removeLODLevel(mesh: Mesh): Mesh;
  27393. /**
  27394. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27395. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27396. * @param camera defines the camera to use to compute distance
  27397. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27398. * @return This mesh (for chaining)
  27399. */
  27400. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27401. /**
  27402. * Gets the mesh internal Geometry object
  27403. */
  27404. get geometry(): Nullable<Geometry>;
  27405. /**
  27406. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27407. * @returns the total number of vertices
  27408. */
  27409. getTotalVertices(): number;
  27410. /**
  27411. * Returns the content of an associated vertex buffer
  27412. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27413. * - VertexBuffer.PositionKind
  27414. * - VertexBuffer.UVKind
  27415. * - VertexBuffer.UV2Kind
  27416. * - VertexBuffer.UV3Kind
  27417. * - VertexBuffer.UV4Kind
  27418. * - VertexBuffer.UV5Kind
  27419. * - VertexBuffer.UV6Kind
  27420. * - VertexBuffer.ColorKind
  27421. * - VertexBuffer.MatricesIndicesKind
  27422. * - VertexBuffer.MatricesIndicesExtraKind
  27423. * - VertexBuffer.MatricesWeightsKind
  27424. * - VertexBuffer.MatricesWeightsExtraKind
  27425. * @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
  27426. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27427. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27428. */
  27429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27430. /**
  27431. * Returns the mesh VertexBuffer object from the requested `kind`
  27432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27433. * - VertexBuffer.PositionKind
  27434. * - VertexBuffer.NormalKind
  27435. * - VertexBuffer.UVKind
  27436. * - VertexBuffer.UV2Kind
  27437. * - VertexBuffer.UV3Kind
  27438. * - VertexBuffer.UV4Kind
  27439. * - VertexBuffer.UV5Kind
  27440. * - VertexBuffer.UV6Kind
  27441. * - VertexBuffer.ColorKind
  27442. * - VertexBuffer.MatricesIndicesKind
  27443. * - VertexBuffer.MatricesIndicesExtraKind
  27444. * - VertexBuffer.MatricesWeightsKind
  27445. * - VertexBuffer.MatricesWeightsExtraKind
  27446. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27447. */
  27448. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27449. /**
  27450. * Tests if a specific vertex buffer is associated with this mesh
  27451. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27452. * - VertexBuffer.PositionKind
  27453. * - VertexBuffer.NormalKind
  27454. * - VertexBuffer.UVKind
  27455. * - VertexBuffer.UV2Kind
  27456. * - VertexBuffer.UV3Kind
  27457. * - VertexBuffer.UV4Kind
  27458. * - VertexBuffer.UV5Kind
  27459. * - VertexBuffer.UV6Kind
  27460. * - VertexBuffer.ColorKind
  27461. * - VertexBuffer.MatricesIndicesKind
  27462. * - VertexBuffer.MatricesIndicesExtraKind
  27463. * - VertexBuffer.MatricesWeightsKind
  27464. * - VertexBuffer.MatricesWeightsExtraKind
  27465. * @returns a boolean
  27466. */
  27467. isVerticesDataPresent(kind: string): boolean;
  27468. /**
  27469. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27470. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27471. * - VertexBuffer.PositionKind
  27472. * - VertexBuffer.UVKind
  27473. * - VertexBuffer.UV2Kind
  27474. * - VertexBuffer.UV3Kind
  27475. * - VertexBuffer.UV4Kind
  27476. * - VertexBuffer.UV5Kind
  27477. * - VertexBuffer.UV6Kind
  27478. * - VertexBuffer.ColorKind
  27479. * - VertexBuffer.MatricesIndicesKind
  27480. * - VertexBuffer.MatricesIndicesExtraKind
  27481. * - VertexBuffer.MatricesWeightsKind
  27482. * - VertexBuffer.MatricesWeightsExtraKind
  27483. * @returns a boolean
  27484. */
  27485. isVertexBufferUpdatable(kind: string): boolean;
  27486. /**
  27487. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27488. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27489. * - VertexBuffer.PositionKind
  27490. * - VertexBuffer.NormalKind
  27491. * - VertexBuffer.UVKind
  27492. * - VertexBuffer.UV2Kind
  27493. * - VertexBuffer.UV3Kind
  27494. * - VertexBuffer.UV4Kind
  27495. * - VertexBuffer.UV5Kind
  27496. * - VertexBuffer.UV6Kind
  27497. * - VertexBuffer.ColorKind
  27498. * - VertexBuffer.MatricesIndicesKind
  27499. * - VertexBuffer.MatricesIndicesExtraKind
  27500. * - VertexBuffer.MatricesWeightsKind
  27501. * - VertexBuffer.MatricesWeightsExtraKind
  27502. * @returns an array of strings
  27503. */
  27504. getVerticesDataKinds(): string[];
  27505. /**
  27506. * Returns a positive integer : the total number of indices in this mesh geometry.
  27507. * @returns the numner of indices or zero if the mesh has no geometry.
  27508. */
  27509. getTotalIndices(): number;
  27510. /**
  27511. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27512. * @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.
  27513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27514. * @returns the indices array or an empty array if the mesh has no geometry
  27515. */
  27516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27517. get isBlocked(): boolean;
  27518. /**
  27519. * Determine if the current mesh is ready to be rendered
  27520. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27521. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27522. * @returns true if all associated assets are ready (material, textures, shaders)
  27523. */
  27524. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27525. /**
  27526. * 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.
  27527. */
  27528. get areNormalsFrozen(): boolean;
  27529. /**
  27530. * 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.
  27531. * @returns the current mesh
  27532. */
  27533. freezeNormals(): Mesh;
  27534. /**
  27535. * 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
  27536. * @returns the current mesh
  27537. */
  27538. unfreezeNormals(): Mesh;
  27539. /**
  27540. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27541. */
  27542. set overridenInstanceCount(count: number);
  27543. /** @hidden */
  27544. _preActivate(): Mesh;
  27545. /** @hidden */
  27546. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27547. /** @hidden */
  27548. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27549. /**
  27550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27551. * This means the mesh underlying bounding box and sphere are recomputed.
  27552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27553. * @returns the current mesh
  27554. */
  27555. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27556. /** @hidden */
  27557. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27558. /**
  27559. * This function will subdivide the mesh into multiple submeshes
  27560. * @param count defines the expected number of submeshes
  27561. */
  27562. subdivide(count: number): void;
  27563. /**
  27564. * Copy a FloatArray into a specific associated vertex buffer
  27565. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27566. * - VertexBuffer.PositionKind
  27567. * - VertexBuffer.UVKind
  27568. * - VertexBuffer.UV2Kind
  27569. * - VertexBuffer.UV3Kind
  27570. * - VertexBuffer.UV4Kind
  27571. * - VertexBuffer.UV5Kind
  27572. * - VertexBuffer.UV6Kind
  27573. * - VertexBuffer.ColorKind
  27574. * - VertexBuffer.MatricesIndicesKind
  27575. * - VertexBuffer.MatricesIndicesExtraKind
  27576. * - VertexBuffer.MatricesWeightsKind
  27577. * - VertexBuffer.MatricesWeightsExtraKind
  27578. * @param data defines the data source
  27579. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27580. * @param stride defines the data stride size (can be null)
  27581. * @returns the current mesh
  27582. */
  27583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27584. /**
  27585. * Delete a vertex buffer associated with this mesh
  27586. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27587. * - VertexBuffer.PositionKind
  27588. * - VertexBuffer.UVKind
  27589. * - VertexBuffer.UV2Kind
  27590. * - VertexBuffer.UV3Kind
  27591. * - VertexBuffer.UV4Kind
  27592. * - VertexBuffer.UV5Kind
  27593. * - VertexBuffer.UV6Kind
  27594. * - VertexBuffer.ColorKind
  27595. * - VertexBuffer.MatricesIndicesKind
  27596. * - VertexBuffer.MatricesIndicesExtraKind
  27597. * - VertexBuffer.MatricesWeightsKind
  27598. * - VertexBuffer.MatricesWeightsExtraKind
  27599. */
  27600. removeVerticesData(kind: string): void;
  27601. /**
  27602. * Flags an associated vertex buffer as updatable
  27603. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27604. * - VertexBuffer.PositionKind
  27605. * - VertexBuffer.UVKind
  27606. * - VertexBuffer.UV2Kind
  27607. * - VertexBuffer.UV3Kind
  27608. * - VertexBuffer.UV4Kind
  27609. * - VertexBuffer.UV5Kind
  27610. * - VertexBuffer.UV6Kind
  27611. * - VertexBuffer.ColorKind
  27612. * - VertexBuffer.MatricesIndicesKind
  27613. * - VertexBuffer.MatricesIndicesExtraKind
  27614. * - VertexBuffer.MatricesWeightsKind
  27615. * - VertexBuffer.MatricesWeightsExtraKind
  27616. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27617. */
  27618. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27619. /**
  27620. * Sets the mesh global Vertex Buffer
  27621. * @param buffer defines the buffer to use
  27622. * @returns the current mesh
  27623. */
  27624. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27625. /**
  27626. * Update a specific associated vertex buffer
  27627. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27628. * - VertexBuffer.PositionKind
  27629. * - VertexBuffer.UVKind
  27630. * - VertexBuffer.UV2Kind
  27631. * - VertexBuffer.UV3Kind
  27632. * - VertexBuffer.UV4Kind
  27633. * - VertexBuffer.UV5Kind
  27634. * - VertexBuffer.UV6Kind
  27635. * - VertexBuffer.ColorKind
  27636. * - VertexBuffer.MatricesIndicesKind
  27637. * - VertexBuffer.MatricesIndicesExtraKind
  27638. * - VertexBuffer.MatricesWeightsKind
  27639. * - VertexBuffer.MatricesWeightsExtraKind
  27640. * @param data defines the data source
  27641. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27642. * @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)
  27643. * @returns the current mesh
  27644. */
  27645. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27646. /**
  27647. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27648. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27649. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27650. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27651. * @returns the current mesh
  27652. */
  27653. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27654. /**
  27655. * Creates a un-shared specific occurence of the geometry for the mesh.
  27656. * @returns the current mesh
  27657. */
  27658. makeGeometryUnique(): Mesh;
  27659. /**
  27660. * Set the index buffer of this mesh
  27661. * @param indices defines the source data
  27662. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27663. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27664. * @returns the current mesh
  27665. */
  27666. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27667. /**
  27668. * Update the current index buffer
  27669. * @param indices defines the source data
  27670. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27671. * @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)
  27672. * @returns the current mesh
  27673. */
  27674. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27675. /**
  27676. * Invert the geometry to move from a right handed system to a left handed one.
  27677. * @returns the current mesh
  27678. */
  27679. toLeftHanded(): Mesh;
  27680. /** @hidden */
  27681. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27682. /** @hidden */
  27683. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27684. /**
  27685. * Registers for this mesh a javascript function called just before the rendering process
  27686. * @param func defines the function to call before rendering this mesh
  27687. * @returns the current mesh
  27688. */
  27689. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27690. /**
  27691. * Disposes a previously registered javascript function called before the rendering
  27692. * @param func defines the function to remove
  27693. * @returns the current mesh
  27694. */
  27695. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27696. /**
  27697. * Registers for this mesh a javascript function called just after the rendering is complete
  27698. * @param func defines the function to call after rendering this mesh
  27699. * @returns the current mesh
  27700. */
  27701. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27702. /**
  27703. * Disposes a previously registered javascript function called after the rendering.
  27704. * @param func defines the function to remove
  27705. * @returns the current mesh
  27706. */
  27707. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27708. /** @hidden */
  27709. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27710. /** @hidden */
  27711. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27712. /** @hidden */
  27713. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27714. /** @hidden */
  27715. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27716. /** @hidden */
  27717. _rebuild(): void;
  27718. /** @hidden */
  27719. _freeze(): void;
  27720. /** @hidden */
  27721. _unFreeze(): void;
  27722. /**
  27723. * 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
  27724. * @param subMesh defines the subMesh to render
  27725. * @param enableAlphaMode defines if alpha mode can be changed
  27726. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27727. * @returns the current mesh
  27728. */
  27729. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27730. private _onBeforeDraw;
  27731. /**
  27732. * Renormalize the mesh and patch it up if there are no weights
  27733. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27734. * However in the case of zero weights then we set just a single influence to 1.
  27735. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27736. */
  27737. cleanMatrixWeights(): void;
  27738. private normalizeSkinFourWeights;
  27739. private normalizeSkinWeightsAndExtra;
  27740. /**
  27741. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27742. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27743. * the user know there was an issue with importing the mesh
  27744. * @returns a validation object with skinned, valid and report string
  27745. */
  27746. validateSkinning(): {
  27747. skinned: boolean;
  27748. valid: boolean;
  27749. report: string;
  27750. };
  27751. /** @hidden */
  27752. _checkDelayState(): Mesh;
  27753. private _queueLoad;
  27754. /**
  27755. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27756. * A mesh is in the frustum if its bounding box intersects the frustum
  27757. * @param frustumPlanes defines the frustum to test
  27758. * @returns true if the mesh is in the frustum planes
  27759. */
  27760. isInFrustum(frustumPlanes: Plane[]): boolean;
  27761. /**
  27762. * Sets the mesh material by the material or multiMaterial `id` property
  27763. * @param id is a string identifying the material or the multiMaterial
  27764. * @returns the current mesh
  27765. */
  27766. setMaterialByID(id: string): Mesh;
  27767. /**
  27768. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27769. * @returns an array of IAnimatable
  27770. */
  27771. getAnimatables(): IAnimatable[];
  27772. /**
  27773. * Modifies the mesh geometry according to the passed transformation matrix.
  27774. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27775. * The mesh normals are modified using the same transformation.
  27776. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27777. * @param transform defines the transform matrix to use
  27778. * @see http://doc.babylonjs.com/resources/baking_transformations
  27779. * @returns the current mesh
  27780. */
  27781. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27782. /**
  27783. * Modifies the mesh geometry according to its own current World Matrix.
  27784. * The mesh World Matrix is then reset.
  27785. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27786. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27787. * @see http://doc.babylonjs.com/resources/baking_transformations
  27788. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27789. * @returns the current mesh
  27790. */
  27791. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27792. /** @hidden */
  27793. get _positions(): Nullable<Vector3[]>;
  27794. /** @hidden */
  27795. _resetPointsArrayCache(): Mesh;
  27796. /** @hidden */
  27797. _generatePointsArray(): boolean;
  27798. /**
  27799. * Returns a new Mesh object generated from the current mesh properties.
  27800. * This method must not get confused with createInstance()
  27801. * @param name is a string, the name given to the new mesh
  27802. * @param newParent can be any Node object (default `null`)
  27803. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27804. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27805. * @returns a new mesh
  27806. */
  27807. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27808. /**
  27809. * Releases resources associated with this mesh.
  27810. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27811. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27812. */
  27813. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27814. /** @hidden */
  27815. _disposeInstanceSpecificData(): void;
  27816. /**
  27817. * Modifies the mesh geometry according to a displacement map.
  27818. * 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.
  27819. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27820. * @param url is a string, the URL from the image file is to be downloaded.
  27821. * @param minHeight is the lower limit of the displacement.
  27822. * @param maxHeight is the upper limit of the displacement.
  27823. * @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.
  27824. * @param uvOffset is an optional vector2 used to offset UV.
  27825. * @param uvScale is an optional vector2 used to scale UV.
  27826. * @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.
  27827. * @returns the Mesh.
  27828. */
  27829. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27830. /**
  27831. * Modifies the mesh geometry according to a displacementMap buffer.
  27832. * 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.
  27833. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27834. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27835. * @param heightMapWidth is the width of the buffer image.
  27836. * @param heightMapHeight is the height of the buffer image.
  27837. * @param minHeight is the lower limit of the displacement.
  27838. * @param maxHeight is the upper limit of the displacement.
  27839. * @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.
  27840. * @param uvOffset is an optional vector2 used to offset UV.
  27841. * @param uvScale is an optional vector2 used to scale UV.
  27842. * @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.
  27843. * @returns the Mesh.
  27844. */
  27845. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27846. /**
  27847. * Modify the mesh to get a flat shading rendering.
  27848. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27849. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27850. * @returns current mesh
  27851. */
  27852. convertToFlatShadedMesh(): Mesh;
  27853. /**
  27854. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27855. * In other words, more vertices, no more indices and a single bigger VBO.
  27856. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27857. * @returns current mesh
  27858. */
  27859. convertToUnIndexedMesh(): Mesh;
  27860. /**
  27861. * Inverses facet orientations.
  27862. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27863. * @param flipNormals will also inverts the normals
  27864. * @returns current mesh
  27865. */
  27866. flipFaces(flipNormals?: boolean): Mesh;
  27867. /**
  27868. * Increase the number of facets and hence vertices in a mesh
  27869. * Vertex normals are interpolated from existing vertex normals
  27870. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27871. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27872. */
  27873. increaseVertices(numberPerEdge: number): void;
  27874. /**
  27875. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27876. * This will undo any application of covertToFlatShadedMesh
  27877. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27878. */
  27879. forceSharedVertices(): void;
  27880. /** @hidden */
  27881. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27882. /** @hidden */
  27883. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27884. /**
  27885. * Creates a new InstancedMesh object from the mesh model.
  27886. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27887. * @param name defines the name of the new instance
  27888. * @returns a new InstancedMesh
  27889. */
  27890. createInstance(name: string): InstancedMesh;
  27891. /**
  27892. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27893. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27894. * @returns the current mesh
  27895. */
  27896. synchronizeInstances(): Mesh;
  27897. /**
  27898. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27899. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27900. * This should be used together with the simplification to avoid disappearing triangles.
  27901. * @param successCallback an optional success callback to be called after the optimization finished.
  27902. * @returns the current mesh
  27903. */
  27904. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27905. /**
  27906. * Serialize current mesh
  27907. * @param serializationObject defines the object which will receive the serialization data
  27908. */
  27909. serialize(serializationObject: any): void;
  27910. /** @hidden */
  27911. _syncGeometryWithMorphTargetManager(): void;
  27912. /** @hidden */
  27913. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27914. /**
  27915. * Returns a new Mesh object parsed from the source provided.
  27916. * @param parsedMesh is the source
  27917. * @param scene defines the hosting scene
  27918. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27919. * @returns a new Mesh
  27920. */
  27921. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27922. /**
  27923. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27924. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27925. * @param name defines the name of the mesh to create
  27926. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27927. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27928. * @param closePath creates a seam between the first and the last points of each path of the path array
  27929. * @param offset is taken in account only if the `pathArray` is containing a single path
  27930. * @param scene defines the hosting scene
  27931. * @param updatable defines if the mesh must be flagged as updatable
  27932. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27933. * @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)
  27934. * @returns a new Mesh
  27935. */
  27936. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27937. /**
  27938. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27939. * @param name defines the name of the mesh to create
  27940. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27941. * @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
  27942. * @param scene defines the hosting scene
  27943. * @param updatable defines if the mesh must be flagged as updatable
  27944. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27945. * @returns a new Mesh
  27946. */
  27947. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27948. /**
  27949. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27950. * @param name defines the name of the mesh to create
  27951. * @param size sets the size (float) of each box side (default 1)
  27952. * @param scene defines the hosting scene
  27953. * @param updatable defines if the mesh must be flagged as updatable
  27954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27955. * @returns a new Mesh
  27956. */
  27957. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27958. /**
  27959. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27960. * @param name defines the name of the mesh to create
  27961. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27962. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27963. * @param scene defines the hosting scene
  27964. * @param updatable defines if the mesh must be flagged as updatable
  27965. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27966. * @returns a new Mesh
  27967. */
  27968. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27969. /**
  27970. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27971. * @param name defines the name of the mesh to create
  27972. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27973. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27974. * @param scene defines the hosting scene
  27975. * @returns a new Mesh
  27976. */
  27977. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27978. /**
  27979. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27980. * @param name defines the name of the mesh to create
  27981. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27982. * @param diameterTop set the top cap diameter (floats, default 1)
  27983. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27984. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27985. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27986. * @param scene defines the hosting scene
  27987. * @param updatable defines if the mesh must be flagged as updatable
  27988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27989. * @returns a new Mesh
  27990. */
  27991. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27992. /**
  27993. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27994. * @param name defines the name of the mesh to create
  27995. * @param diameter sets the diameter size (float) of the torus (default 1)
  27996. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27997. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27998. * @param scene defines the hosting scene
  27999. * @param updatable defines if the mesh must be flagged as updatable
  28000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28001. * @returns a new Mesh
  28002. */
  28003. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28004. /**
  28005. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28006. * @param name defines the name of the mesh to create
  28007. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28008. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28009. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28010. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28011. * @param p the number of windings on X axis (positive integers, default 2)
  28012. * @param q the number of windings on Y axis (positive integers, default 3)
  28013. * @param scene defines the hosting scene
  28014. * @param updatable defines if the mesh must be flagged as updatable
  28015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28016. * @returns a new Mesh
  28017. */
  28018. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28019. /**
  28020. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28021. * @param name defines the name of the mesh to create
  28022. * @param points is an array successive Vector3
  28023. * @param scene defines the hosting scene
  28024. * @param updatable defines if the mesh must be flagged as updatable
  28025. * @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).
  28026. * @returns a new Mesh
  28027. */
  28028. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28029. /**
  28030. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28031. * @param name defines the name of the mesh to create
  28032. * @param points is an array successive Vector3
  28033. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28034. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28035. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28036. * @param scene defines the hosting scene
  28037. * @param updatable defines if the mesh must be flagged as updatable
  28038. * @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)
  28039. * @returns a new Mesh
  28040. */
  28041. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28042. /**
  28043. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28044. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28045. * 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.
  28046. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28047. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28048. * Remember you can only change the shape positions, not their number when updating a polygon.
  28049. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28050. * @param name defines the name of the mesh to create
  28051. * @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
  28052. * @param scene defines the hosting scene
  28053. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28054. * @param updatable defines if the mesh must be flagged as updatable
  28055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28056. * @param earcutInjection can be used to inject your own earcut reference
  28057. * @returns a new Mesh
  28058. */
  28059. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28060. /**
  28061. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28062. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28063. * @param name defines the name of the mesh to create
  28064. * @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
  28065. * @param depth defines the height of extrusion
  28066. * @param scene defines the hosting scene
  28067. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28068. * @param updatable defines if the mesh must be flagged as updatable
  28069. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28070. * @param earcutInjection can be used to inject your own earcut reference
  28071. * @returns a new Mesh
  28072. */
  28073. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28074. /**
  28075. * Creates an extruded shape mesh.
  28076. * 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
  28077. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28079. * @param name defines the name of the mesh to create
  28080. * @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
  28081. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28082. * @param scale is the value to scale the shape
  28083. * @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
  28084. * @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
  28085. * @param scene defines the hosting scene
  28086. * @param updatable defines if the mesh must be flagged as updatable
  28087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28088. * @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)
  28089. * @returns a new Mesh
  28090. */
  28091. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28092. /**
  28093. * Creates an custom extruded shape mesh.
  28094. * The custom extrusion is a parametric shape.
  28095. * It has no predefined shape. Its final shape will depend on the input parameters.
  28096. * Please consider using the same method from the MeshBuilder class instead
  28097. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28098. * @param name defines the name of the mesh to create
  28099. * @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
  28100. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28101. * @param scaleFunction is a custom Javascript function called on each path point
  28102. * @param rotationFunction is a custom Javascript function called on each path point
  28103. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28104. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28105. * @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
  28106. * @param scene defines the hosting scene
  28107. * @param updatable defines if the mesh must be flagged as updatable
  28108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28109. * @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)
  28110. * @returns a new Mesh
  28111. */
  28112. 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;
  28113. /**
  28114. * Creates lathe mesh.
  28115. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28116. * Please consider using the same method from the MeshBuilder class instead
  28117. * @param name defines the name of the mesh to create
  28118. * @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
  28119. * @param radius is the radius value of the lathe
  28120. * @param tessellation is the side number of the lathe.
  28121. * @param scene defines the hosting scene
  28122. * @param updatable defines if the mesh must be flagged as updatable
  28123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28124. * @returns a new Mesh
  28125. */
  28126. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28127. /**
  28128. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28129. * @param name defines the name of the mesh to create
  28130. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28131. * @param scene defines the hosting scene
  28132. * @param updatable defines if the mesh must be flagged as updatable
  28133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28134. * @returns a new Mesh
  28135. */
  28136. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28137. /**
  28138. * Creates a ground mesh.
  28139. * Please consider using the same method from the MeshBuilder class instead
  28140. * @param name defines the name of the mesh to create
  28141. * @param width set the width of the ground
  28142. * @param height set the height of the ground
  28143. * @param subdivisions sets the number of subdivisions per side
  28144. * @param scene defines the hosting scene
  28145. * @param updatable defines if the mesh must be flagged as updatable
  28146. * @returns a new Mesh
  28147. */
  28148. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28149. /**
  28150. * Creates a tiled ground mesh.
  28151. * Please consider using the same method from the MeshBuilder class instead
  28152. * @param name defines the name of the mesh to create
  28153. * @param xmin set the ground minimum X coordinate
  28154. * @param zmin set the ground minimum Y coordinate
  28155. * @param xmax set the ground maximum X coordinate
  28156. * @param zmax set the ground maximum Z coordinate
  28157. * @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
  28158. * @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
  28159. * @param scene defines the hosting scene
  28160. * @param updatable defines if the mesh must be flagged as updatable
  28161. * @returns a new Mesh
  28162. */
  28163. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28164. w: number;
  28165. h: number;
  28166. }, precision: {
  28167. w: number;
  28168. h: number;
  28169. }, scene: Scene, updatable?: boolean): Mesh;
  28170. /**
  28171. * Creates a ground mesh from a height map.
  28172. * Please consider using the same method from the MeshBuilder class instead
  28173. * @see http://doc.babylonjs.com/babylon101/height_map
  28174. * @param name defines the name of the mesh to create
  28175. * @param url sets the URL of the height map image resource
  28176. * @param width set the ground width size
  28177. * @param height set the ground height size
  28178. * @param subdivisions sets the number of subdivision per side
  28179. * @param minHeight is the minimum altitude on the ground
  28180. * @param maxHeight is the maximum altitude on the ground
  28181. * @param scene defines the hosting scene
  28182. * @param updatable defines if the mesh must be flagged as updatable
  28183. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28184. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28185. * @returns a new Mesh
  28186. */
  28187. 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;
  28188. /**
  28189. * Creates a tube mesh.
  28190. * The tube is a parametric shape.
  28191. * It has no predefined shape. Its final shape will depend on the input parameters.
  28192. * Please consider using the same method from the MeshBuilder class instead
  28193. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28194. * @param name defines the name of the mesh to create
  28195. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28196. * @param radius sets the tube radius size
  28197. * @param tessellation is the number of sides on the tubular surface
  28198. * @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
  28199. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  28200. * @param scene defines the hosting scene
  28201. * @param updatable defines if the mesh must be flagged as updatable
  28202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28203. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  28204. * @returns a new Mesh
  28205. */
  28206. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28207. (i: number, distance: number): number;
  28208. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28209. /**
  28210. * Creates a polyhedron mesh.
  28211. * Please consider using the same method from the MeshBuilder class instead.
  28212. * * 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
  28213. * * The parameter `size` (positive float, default 1) sets the polygon size
  28214. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28215. * * 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`
  28216. * * 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
  28217. * * 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)`)
  28218. * * 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
  28219. * * 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
  28220. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28221. * * 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
  28222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28223. * @param name defines the name of the mesh to create
  28224. * @param options defines the options used to create the mesh
  28225. * @param scene defines the hosting scene
  28226. * @returns a new Mesh
  28227. */
  28228. static CreatePolyhedron(name: string, options: {
  28229. type?: number;
  28230. size?: number;
  28231. sizeX?: number;
  28232. sizeY?: number;
  28233. sizeZ?: number;
  28234. custom?: any;
  28235. faceUV?: Vector4[];
  28236. faceColors?: Color4[];
  28237. updatable?: boolean;
  28238. sideOrientation?: number;
  28239. }, scene: Scene): Mesh;
  28240. /**
  28241. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28242. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28243. * * 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`)
  28244. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28245. * * 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
  28246. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28247. * * 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
  28248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28249. * @param name defines the name of the mesh
  28250. * @param options defines the options used to create the mesh
  28251. * @param scene defines the hosting scene
  28252. * @returns a new Mesh
  28253. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28254. */
  28255. static CreateIcoSphere(name: string, options: {
  28256. radius?: number;
  28257. flat?: boolean;
  28258. subdivisions?: number;
  28259. sideOrientation?: number;
  28260. updatable?: boolean;
  28261. }, scene: Scene): Mesh;
  28262. /**
  28263. * Creates a decal mesh.
  28264. * Please consider using the same method from the MeshBuilder class instead.
  28265. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28266. * @param name defines the name of the mesh
  28267. * @param sourceMesh defines the mesh receiving the decal
  28268. * @param position sets the position of the decal in world coordinates
  28269. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28270. * @param size sets the decal scaling
  28271. * @param angle sets the angle to rotate the decal
  28272. * @returns a new Mesh
  28273. */
  28274. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28275. /**
  28276. * Prepare internal position array for software CPU skinning
  28277. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28278. */
  28279. setPositionsForCPUSkinning(): Float32Array;
  28280. /**
  28281. * Prepare internal normal array for software CPU skinning
  28282. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28283. */
  28284. setNormalsForCPUSkinning(): Float32Array;
  28285. /**
  28286. * Updates the vertex buffer by applying transformation from the bones
  28287. * @param skeleton defines the skeleton to apply to current mesh
  28288. * @returns the current mesh
  28289. */
  28290. applySkeleton(skeleton: Skeleton): Mesh;
  28291. /**
  28292. * 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
  28293. * @param meshes defines the list of meshes to scan
  28294. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28295. */
  28296. static MinMax(meshes: AbstractMesh[]): {
  28297. min: Vector3;
  28298. max: Vector3;
  28299. };
  28300. /**
  28301. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28302. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28303. * @returns a vector3
  28304. */
  28305. static Center(meshesOrMinMaxVector: {
  28306. min: Vector3;
  28307. max: Vector3;
  28308. } | AbstractMesh[]): Vector3;
  28309. /**
  28310. * Merge the array of meshes into a single mesh for performance reasons.
  28311. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28312. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28313. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28314. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28315. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28316. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28317. * @returns a new mesh
  28318. */
  28319. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28320. /** @hidden */
  28321. addInstance(instance: InstancedMesh): void;
  28322. /** @hidden */
  28323. removeInstance(instance: InstancedMesh): void;
  28324. }
  28325. }
  28326. declare module BABYLON {
  28327. /**
  28328. * This is the base class of all the camera used in the application.
  28329. * @see http://doc.babylonjs.com/features/cameras
  28330. */
  28331. export class Camera extends Node {
  28332. /** @hidden */
  28333. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28334. /**
  28335. * This is the default projection mode used by the cameras.
  28336. * It helps recreating a feeling of perspective and better appreciate depth.
  28337. * This is the best way to simulate real life cameras.
  28338. */
  28339. static readonly PERSPECTIVE_CAMERA: number;
  28340. /**
  28341. * This helps creating camera with an orthographic mode.
  28342. * 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.
  28343. */
  28344. static readonly ORTHOGRAPHIC_CAMERA: number;
  28345. /**
  28346. * This is the default FOV mode for perspective cameras.
  28347. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28348. */
  28349. static readonly FOVMODE_VERTICAL_FIXED: number;
  28350. /**
  28351. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28352. */
  28353. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28354. /**
  28355. * This specifies ther is no need for a camera rig.
  28356. * Basically only one eye is rendered corresponding to the camera.
  28357. */
  28358. static readonly RIG_MODE_NONE: number;
  28359. /**
  28360. * Simulates a camera Rig with one blue eye and one red eye.
  28361. * This can be use with 3d blue and red glasses.
  28362. */
  28363. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28364. /**
  28365. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28366. */
  28367. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28368. /**
  28369. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28370. */
  28371. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28372. /**
  28373. * Defines that both eyes of the camera will be rendered over under each other.
  28374. */
  28375. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28376. /**
  28377. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28378. */
  28379. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28380. /**
  28381. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28382. */
  28383. static readonly RIG_MODE_VR: number;
  28384. /**
  28385. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28386. */
  28387. static readonly RIG_MODE_WEBVR: number;
  28388. /**
  28389. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28390. */
  28391. static readonly RIG_MODE_CUSTOM: number;
  28392. /**
  28393. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28394. */
  28395. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28396. /**
  28397. * Define the input manager associated with the camera.
  28398. */
  28399. inputs: CameraInputsManager<Camera>;
  28400. /** @hidden */
  28401. _position: Vector3;
  28402. /**
  28403. * Define the current local position of the camera in the scene
  28404. */
  28405. get position(): Vector3;
  28406. set position(newPosition: Vector3);
  28407. /**
  28408. * The vector the camera should consider as up.
  28409. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28410. */
  28411. upVector: Vector3;
  28412. /**
  28413. * Define the current limit on the left side for an orthographic camera
  28414. * In scene unit
  28415. */
  28416. orthoLeft: Nullable<number>;
  28417. /**
  28418. * Define the current limit on the right side for an orthographic camera
  28419. * In scene unit
  28420. */
  28421. orthoRight: Nullable<number>;
  28422. /**
  28423. * Define the current limit on the bottom side for an orthographic camera
  28424. * In scene unit
  28425. */
  28426. orthoBottom: Nullable<number>;
  28427. /**
  28428. * Define the current limit on the top side for an orthographic camera
  28429. * In scene unit
  28430. */
  28431. orthoTop: Nullable<number>;
  28432. /**
  28433. * Field Of View is set in Radians. (default is 0.8)
  28434. */
  28435. fov: number;
  28436. /**
  28437. * Define the minimum distance the camera can see from.
  28438. * This is important to note that the depth buffer are not infinite and the closer it starts
  28439. * the more your scene might encounter depth fighting issue.
  28440. */
  28441. minZ: number;
  28442. /**
  28443. * Define the maximum distance the camera can see to.
  28444. * This is important to note that the depth buffer are not infinite and the further it end
  28445. * the more your scene might encounter depth fighting issue.
  28446. */
  28447. maxZ: number;
  28448. /**
  28449. * Define the default inertia of the camera.
  28450. * This helps giving a smooth feeling to the camera movement.
  28451. */
  28452. inertia: number;
  28453. /**
  28454. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28455. */
  28456. mode: number;
  28457. /**
  28458. * Define whether the camera is intermediate.
  28459. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28460. */
  28461. isIntermediate: boolean;
  28462. /**
  28463. * Define the viewport of the camera.
  28464. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28465. */
  28466. viewport: Viewport;
  28467. /**
  28468. * Restricts the camera to viewing objects with the same layerMask.
  28469. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28470. */
  28471. layerMask: number;
  28472. /**
  28473. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28474. */
  28475. fovMode: number;
  28476. /**
  28477. * Rig mode of the camera.
  28478. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28479. * This is normally controlled byt the camera themselves as internal use.
  28480. */
  28481. cameraRigMode: number;
  28482. /**
  28483. * Defines the distance between both "eyes" in case of a RIG
  28484. */
  28485. interaxialDistance: number;
  28486. /**
  28487. * Defines if stereoscopic rendering is done side by side or over under.
  28488. */
  28489. isStereoscopicSideBySide: boolean;
  28490. /**
  28491. * 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
  28492. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28493. * else in the scene. (Eg. security camera)
  28494. *
  28495. * 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)
  28496. */
  28497. customRenderTargets: RenderTargetTexture[];
  28498. /**
  28499. * When set, the camera will render to this render target instead of the default canvas
  28500. *
  28501. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28502. */
  28503. outputRenderTarget: Nullable<RenderTargetTexture>;
  28504. /**
  28505. * Observable triggered when the camera view matrix has changed.
  28506. */
  28507. onViewMatrixChangedObservable: Observable<Camera>;
  28508. /**
  28509. * Observable triggered when the camera Projection matrix has changed.
  28510. */
  28511. onProjectionMatrixChangedObservable: Observable<Camera>;
  28512. /**
  28513. * Observable triggered when the inputs have been processed.
  28514. */
  28515. onAfterCheckInputsObservable: Observable<Camera>;
  28516. /**
  28517. * Observable triggered when reset has been called and applied to the camera.
  28518. */
  28519. onRestoreStateObservable: Observable<Camera>;
  28520. /**
  28521. * Is this camera a part of a rig system?
  28522. */
  28523. isRigCamera: boolean;
  28524. /**
  28525. * If isRigCamera set to true this will be set with the parent camera.
  28526. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28527. */
  28528. rigParent?: Camera;
  28529. /** @hidden */
  28530. _cameraRigParams: any;
  28531. /** @hidden */
  28532. _rigCameras: Camera[];
  28533. /** @hidden */
  28534. _rigPostProcess: Nullable<PostProcess>;
  28535. protected _webvrViewMatrix: Matrix;
  28536. /** @hidden */
  28537. _skipRendering: boolean;
  28538. /** @hidden */
  28539. _projectionMatrix: Matrix;
  28540. /** @hidden */
  28541. _postProcesses: Nullable<PostProcess>[];
  28542. /** @hidden */
  28543. _activeMeshes: SmartArray<AbstractMesh>;
  28544. protected _globalPosition: Vector3;
  28545. /** @hidden */
  28546. _computedViewMatrix: Matrix;
  28547. private _doNotComputeProjectionMatrix;
  28548. private _transformMatrix;
  28549. private _frustumPlanes;
  28550. private _refreshFrustumPlanes;
  28551. private _storedFov;
  28552. private _stateStored;
  28553. /**
  28554. * Instantiates a new camera object.
  28555. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28556. * @see http://doc.babylonjs.com/features/cameras
  28557. * @param name Defines the name of the camera in the scene
  28558. * @param position Defines the position of the camera
  28559. * @param scene Defines the scene the camera belongs too
  28560. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28561. */
  28562. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28563. /**
  28564. * Store current camera state (fov, position, etc..)
  28565. * @returns the camera
  28566. */
  28567. storeState(): Camera;
  28568. /**
  28569. * Restores the camera state values if it has been stored. You must call storeState() first
  28570. */
  28571. protected _restoreStateValues(): boolean;
  28572. /**
  28573. * Restored camera state. You must call storeState() first.
  28574. * @returns true if restored and false otherwise
  28575. */
  28576. restoreState(): boolean;
  28577. /**
  28578. * Gets the class name of the camera.
  28579. * @returns the class name
  28580. */
  28581. getClassName(): string;
  28582. /** @hidden */
  28583. readonly _isCamera: boolean;
  28584. /**
  28585. * Gets a string representation of the camera useful for debug purpose.
  28586. * @param fullDetails Defines that a more verboe level of logging is required
  28587. * @returns the string representation
  28588. */
  28589. toString(fullDetails?: boolean): string;
  28590. /**
  28591. * Gets the current world space position of the camera.
  28592. */
  28593. get globalPosition(): Vector3;
  28594. /**
  28595. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28596. * @returns the active meshe list
  28597. */
  28598. getActiveMeshes(): SmartArray<AbstractMesh>;
  28599. /**
  28600. * Check whether a mesh is part of the current active mesh list of the camera
  28601. * @param mesh Defines the mesh to check
  28602. * @returns true if active, false otherwise
  28603. */
  28604. isActiveMesh(mesh: Mesh): boolean;
  28605. /**
  28606. * Is this camera ready to be used/rendered
  28607. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28608. * @return true if the camera is ready
  28609. */
  28610. isReady(completeCheck?: boolean): boolean;
  28611. /** @hidden */
  28612. _initCache(): void;
  28613. /** @hidden */
  28614. _updateCache(ignoreParentClass?: boolean): void;
  28615. /** @hidden */
  28616. _isSynchronized(): boolean;
  28617. /** @hidden */
  28618. _isSynchronizedViewMatrix(): boolean;
  28619. /** @hidden */
  28620. _isSynchronizedProjectionMatrix(): boolean;
  28621. /**
  28622. * Attach the input controls to a specific dom element to get the input from.
  28623. * @param element Defines the element the controls should be listened from
  28624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28625. */
  28626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28627. /**
  28628. * Detach the current controls from the specified dom element.
  28629. * @param element Defines the element to stop listening the inputs from
  28630. */
  28631. detachControl(element: HTMLElement): void;
  28632. /**
  28633. * Update the camera state according to the different inputs gathered during the frame.
  28634. */
  28635. update(): void;
  28636. /** @hidden */
  28637. _checkInputs(): void;
  28638. /** @hidden */
  28639. get rigCameras(): Camera[];
  28640. /**
  28641. * Gets the post process used by the rig cameras
  28642. */
  28643. get rigPostProcess(): Nullable<PostProcess>;
  28644. /**
  28645. * Internal, gets the first post proces.
  28646. * @returns the first post process to be run on this camera.
  28647. */
  28648. _getFirstPostProcess(): Nullable<PostProcess>;
  28649. private _cascadePostProcessesToRigCams;
  28650. /**
  28651. * Attach a post process to the camera.
  28652. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28653. * @param postProcess The post process to attach to the camera
  28654. * @param insertAt The position of the post process in case several of them are in use in the scene
  28655. * @returns the position the post process has been inserted at
  28656. */
  28657. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28658. /**
  28659. * Detach a post process to the camera.
  28660. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28661. * @param postProcess The post process to detach from the camera
  28662. */
  28663. detachPostProcess(postProcess: PostProcess): void;
  28664. /**
  28665. * Gets the current world matrix of the camera
  28666. */
  28667. getWorldMatrix(): Matrix;
  28668. /** @hidden */
  28669. _getViewMatrix(): Matrix;
  28670. /**
  28671. * Gets the current view matrix of the camera.
  28672. * @param force forces the camera to recompute the matrix without looking at the cached state
  28673. * @returns the view matrix
  28674. */
  28675. getViewMatrix(force?: boolean): Matrix;
  28676. /**
  28677. * Freeze the projection matrix.
  28678. * It will prevent the cache check of the camera projection compute and can speed up perf
  28679. * if no parameter of the camera are meant to change
  28680. * @param projection Defines manually a projection if necessary
  28681. */
  28682. freezeProjectionMatrix(projection?: Matrix): void;
  28683. /**
  28684. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28685. */
  28686. unfreezeProjectionMatrix(): void;
  28687. /**
  28688. * Gets the current projection matrix of the camera.
  28689. * @param force forces the camera to recompute the matrix without looking at the cached state
  28690. * @returns the projection matrix
  28691. */
  28692. getProjectionMatrix(force?: boolean): Matrix;
  28693. /**
  28694. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28695. * @returns a Matrix
  28696. */
  28697. getTransformationMatrix(): Matrix;
  28698. private _updateFrustumPlanes;
  28699. /**
  28700. * Checks if a cullable object (mesh...) is in the camera frustum
  28701. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28702. * @param target The object to check
  28703. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28704. * @returns true if the object is in frustum otherwise false
  28705. */
  28706. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28707. /**
  28708. * Checks if a cullable object (mesh...) is in the camera frustum
  28709. * Unlike isInFrustum this cheks the full bounding box
  28710. * @param target The object to check
  28711. * @returns true if the object is in frustum otherwise false
  28712. */
  28713. isCompletelyInFrustum(target: ICullable): boolean;
  28714. /**
  28715. * Gets a ray in the forward direction from the camera.
  28716. * @param length Defines the length of the ray to create
  28717. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28718. * @param origin Defines the start point of the ray which defaults to the camera position
  28719. * @returns the forward ray
  28720. */
  28721. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28722. /**
  28723. * Releases resources associated with this node.
  28724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28726. */
  28727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28728. /** @hidden */
  28729. _isLeftCamera: boolean;
  28730. /**
  28731. * Gets the left camera of a rig setup in case of Rigged Camera
  28732. */
  28733. get isLeftCamera(): boolean;
  28734. /** @hidden */
  28735. _isRightCamera: boolean;
  28736. /**
  28737. * Gets the right camera of a rig setup in case of Rigged Camera
  28738. */
  28739. get isRightCamera(): boolean;
  28740. /**
  28741. * Gets the left camera of a rig setup in case of Rigged Camera
  28742. */
  28743. get leftCamera(): Nullable<FreeCamera>;
  28744. /**
  28745. * Gets the right camera of a rig setup in case of Rigged Camera
  28746. */
  28747. get rightCamera(): Nullable<FreeCamera>;
  28748. /**
  28749. * Gets the left camera target of a rig setup in case of Rigged Camera
  28750. * @returns the target position
  28751. */
  28752. getLeftTarget(): Nullable<Vector3>;
  28753. /**
  28754. * Gets the right camera target of a rig setup in case of Rigged Camera
  28755. * @returns the target position
  28756. */
  28757. getRightTarget(): Nullable<Vector3>;
  28758. /**
  28759. * @hidden
  28760. */
  28761. setCameraRigMode(mode: number, rigParams: any): void;
  28762. /** @hidden */
  28763. static _setStereoscopicRigMode(camera: Camera): void;
  28764. /** @hidden */
  28765. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28766. /** @hidden */
  28767. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28768. /** @hidden */
  28769. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28770. /** @hidden */
  28771. _getVRProjectionMatrix(): Matrix;
  28772. protected _updateCameraRotationMatrix(): void;
  28773. protected _updateWebVRCameraRotationMatrix(): void;
  28774. /**
  28775. * This function MUST be overwritten by the different WebVR cameras available.
  28776. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28777. * @hidden
  28778. */
  28779. _getWebVRProjectionMatrix(): Matrix;
  28780. /**
  28781. * This function MUST be overwritten by the different WebVR cameras available.
  28782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28783. * @hidden
  28784. */
  28785. _getWebVRViewMatrix(): Matrix;
  28786. /** @hidden */
  28787. setCameraRigParameter(name: string, value: any): void;
  28788. /**
  28789. * needs to be overridden by children so sub has required properties to be copied
  28790. * @hidden
  28791. */
  28792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28793. /**
  28794. * May need to be overridden by children
  28795. * @hidden
  28796. */
  28797. _updateRigCameras(): void;
  28798. /** @hidden */
  28799. _setupInputs(): void;
  28800. /**
  28801. * Serialiaze the camera setup to a json represention
  28802. * @returns the JSON representation
  28803. */
  28804. serialize(): any;
  28805. /**
  28806. * Clones the current camera.
  28807. * @param name The cloned camera name
  28808. * @returns the cloned camera
  28809. */
  28810. clone(name: string): Camera;
  28811. /**
  28812. * Gets the direction of the camera relative to a given local axis.
  28813. * @param localAxis Defines the reference axis to provide a relative direction.
  28814. * @return the direction
  28815. */
  28816. getDirection(localAxis: Vector3): Vector3;
  28817. /**
  28818. * Returns the current camera absolute rotation
  28819. */
  28820. get absoluteRotation(): Quaternion;
  28821. /**
  28822. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28823. * @param localAxis Defines the reference axis to provide a relative direction.
  28824. * @param result Defines the vector to store the result in
  28825. */
  28826. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28827. /**
  28828. * Gets a camera constructor for a given camera type
  28829. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28830. * @param name The name of the camera the result will be able to instantiate
  28831. * @param scene The scene the result will construct the camera in
  28832. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28833. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28834. * @returns a factory method to construc the camera
  28835. */
  28836. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28837. /**
  28838. * Compute the world matrix of the camera.
  28839. * @returns the camera world matrix
  28840. */
  28841. computeWorldMatrix(): Matrix;
  28842. /**
  28843. * Parse a JSON and creates the camera from the parsed information
  28844. * @param parsedCamera The JSON to parse
  28845. * @param scene The scene to instantiate the camera in
  28846. * @returns the newly constructed camera
  28847. */
  28848. static Parse(parsedCamera: any, scene: Scene): Camera;
  28849. }
  28850. }
  28851. declare module BABYLON {
  28852. /**
  28853. * Class containing static functions to help procedurally build meshes
  28854. */
  28855. export class DiscBuilder {
  28856. /**
  28857. * Creates a plane polygonal mesh. By default, this is a disc
  28858. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28859. * * 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
  28860. * * 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
  28861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28862. * * 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
  28863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28864. * @param name defines the name of the mesh
  28865. * @param options defines the options used to create the mesh
  28866. * @param scene defines the hosting scene
  28867. * @returns the plane polygonal mesh
  28868. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28869. */
  28870. static CreateDisc(name: string, options: {
  28871. radius?: number;
  28872. tessellation?: number;
  28873. arc?: number;
  28874. updatable?: boolean;
  28875. sideOrientation?: number;
  28876. frontUVs?: Vector4;
  28877. backUVs?: Vector4;
  28878. }, scene?: Nullable<Scene>): Mesh;
  28879. }
  28880. }
  28881. declare module BABYLON {
  28882. /**
  28883. * Options to be used when creating a FresnelParameters.
  28884. */
  28885. export type IFresnelParametersCreationOptions = {
  28886. /**
  28887. * Define the color used on edges (grazing angle)
  28888. */
  28889. leftColor?: Color3;
  28890. /**
  28891. * Define the color used on center
  28892. */
  28893. rightColor?: Color3;
  28894. /**
  28895. * Define bias applied to computed fresnel term
  28896. */
  28897. bias?: number;
  28898. /**
  28899. * Defined the power exponent applied to fresnel term
  28900. */
  28901. power?: number;
  28902. /**
  28903. * Define if the fresnel effect is enable or not.
  28904. */
  28905. isEnabled?: boolean;
  28906. };
  28907. /**
  28908. * Serialized format for FresnelParameters.
  28909. */
  28910. export type IFresnelParametersSerialized = {
  28911. /**
  28912. * Define the color used on edges (grazing angle) [as an array]
  28913. */
  28914. leftColor: number[];
  28915. /**
  28916. * Define the color used on center [as an array]
  28917. */
  28918. rightColor: number[];
  28919. /**
  28920. * Define bias applied to computed fresnel term
  28921. */
  28922. bias: number;
  28923. /**
  28924. * Defined the power exponent applied to fresnel term
  28925. */
  28926. power?: number;
  28927. /**
  28928. * Define if the fresnel effect is enable or not.
  28929. */
  28930. isEnabled: boolean;
  28931. };
  28932. /**
  28933. * This represents all the required information to add a fresnel effect on a material:
  28934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28935. */
  28936. export class FresnelParameters {
  28937. private _isEnabled;
  28938. /**
  28939. * Define if the fresnel effect is enable or not.
  28940. */
  28941. get isEnabled(): boolean;
  28942. set isEnabled(value: boolean);
  28943. /**
  28944. * Define the color used on edges (grazing angle)
  28945. */
  28946. leftColor: Color3;
  28947. /**
  28948. * Define the color used on center
  28949. */
  28950. rightColor: Color3;
  28951. /**
  28952. * Define bias applied to computed fresnel term
  28953. */
  28954. bias: number;
  28955. /**
  28956. * Defined the power exponent applied to fresnel term
  28957. */
  28958. power: number;
  28959. /**
  28960. * Creates a new FresnelParameters object.
  28961. *
  28962. * @param options provide your own settings to optionally to override defaults
  28963. */
  28964. constructor(options?: IFresnelParametersCreationOptions);
  28965. /**
  28966. * Clones the current fresnel and its valuues
  28967. * @returns a clone fresnel configuration
  28968. */
  28969. clone(): FresnelParameters;
  28970. /**
  28971. * Determines equality between FresnelParameters objects
  28972. * @param otherFresnelParameters defines the second operand
  28973. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28974. */
  28975. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28976. /**
  28977. * Serializes the current fresnel parameters to a JSON representation.
  28978. * @return the JSON serialization
  28979. */
  28980. serialize(): IFresnelParametersSerialized;
  28981. /**
  28982. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28983. * @param parsedFresnelParameters Define the JSON representation
  28984. * @returns the parsed parameters
  28985. */
  28986. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28987. }
  28988. }
  28989. declare module BABYLON {
  28990. /**
  28991. * This groups all the flags used to control the materials channel.
  28992. */
  28993. export class MaterialFlags {
  28994. private static _DiffuseTextureEnabled;
  28995. /**
  28996. * Are diffuse textures enabled in the application.
  28997. */
  28998. static get DiffuseTextureEnabled(): boolean;
  28999. static set DiffuseTextureEnabled(value: boolean);
  29000. private static _AmbientTextureEnabled;
  29001. /**
  29002. * Are ambient textures enabled in the application.
  29003. */
  29004. static get AmbientTextureEnabled(): boolean;
  29005. static set AmbientTextureEnabled(value: boolean);
  29006. private static _OpacityTextureEnabled;
  29007. /**
  29008. * Are opacity textures enabled in the application.
  29009. */
  29010. static get OpacityTextureEnabled(): boolean;
  29011. static set OpacityTextureEnabled(value: boolean);
  29012. private static _ReflectionTextureEnabled;
  29013. /**
  29014. * Are reflection textures enabled in the application.
  29015. */
  29016. static get ReflectionTextureEnabled(): boolean;
  29017. static set ReflectionTextureEnabled(value: boolean);
  29018. private static _EmissiveTextureEnabled;
  29019. /**
  29020. * Are emissive textures enabled in the application.
  29021. */
  29022. static get EmissiveTextureEnabled(): boolean;
  29023. static set EmissiveTextureEnabled(value: boolean);
  29024. private static _SpecularTextureEnabled;
  29025. /**
  29026. * Are specular textures enabled in the application.
  29027. */
  29028. static get SpecularTextureEnabled(): boolean;
  29029. static set SpecularTextureEnabled(value: boolean);
  29030. private static _BumpTextureEnabled;
  29031. /**
  29032. * Are bump textures enabled in the application.
  29033. */
  29034. static get BumpTextureEnabled(): boolean;
  29035. static set BumpTextureEnabled(value: boolean);
  29036. private static _LightmapTextureEnabled;
  29037. /**
  29038. * Are lightmap textures enabled in the application.
  29039. */
  29040. static get LightmapTextureEnabled(): boolean;
  29041. static set LightmapTextureEnabled(value: boolean);
  29042. private static _RefractionTextureEnabled;
  29043. /**
  29044. * Are refraction textures enabled in the application.
  29045. */
  29046. static get RefractionTextureEnabled(): boolean;
  29047. static set RefractionTextureEnabled(value: boolean);
  29048. private static _ColorGradingTextureEnabled;
  29049. /**
  29050. * Are color grading textures enabled in the application.
  29051. */
  29052. static get ColorGradingTextureEnabled(): boolean;
  29053. static set ColorGradingTextureEnabled(value: boolean);
  29054. private static _FresnelEnabled;
  29055. /**
  29056. * Are fresnels enabled in the application.
  29057. */
  29058. static get FresnelEnabled(): boolean;
  29059. static set FresnelEnabled(value: boolean);
  29060. private static _ClearCoatTextureEnabled;
  29061. /**
  29062. * Are clear coat textures enabled in the application.
  29063. */
  29064. static get ClearCoatTextureEnabled(): boolean;
  29065. static set ClearCoatTextureEnabled(value: boolean);
  29066. private static _ClearCoatBumpTextureEnabled;
  29067. /**
  29068. * Are clear coat bump textures enabled in the application.
  29069. */
  29070. static get ClearCoatBumpTextureEnabled(): boolean;
  29071. static set ClearCoatBumpTextureEnabled(value: boolean);
  29072. private static _ClearCoatTintTextureEnabled;
  29073. /**
  29074. * Are clear coat tint textures enabled in the application.
  29075. */
  29076. static get ClearCoatTintTextureEnabled(): boolean;
  29077. static set ClearCoatTintTextureEnabled(value: boolean);
  29078. private static _SheenTextureEnabled;
  29079. /**
  29080. * Are sheen textures enabled in the application.
  29081. */
  29082. static get SheenTextureEnabled(): boolean;
  29083. static set SheenTextureEnabled(value: boolean);
  29084. private static _AnisotropicTextureEnabled;
  29085. /**
  29086. * Are anisotropic textures enabled in the application.
  29087. */
  29088. static get AnisotropicTextureEnabled(): boolean;
  29089. static set AnisotropicTextureEnabled(value: boolean);
  29090. private static _ThicknessTextureEnabled;
  29091. /**
  29092. * Are thickness textures enabled in the application.
  29093. */
  29094. static get ThicknessTextureEnabled(): boolean;
  29095. static set ThicknessTextureEnabled(value: boolean);
  29096. }
  29097. }
  29098. declare module BABYLON {
  29099. /** @hidden */
  29100. export var defaultFragmentDeclaration: {
  29101. name: string;
  29102. shader: string;
  29103. };
  29104. }
  29105. declare module BABYLON {
  29106. /** @hidden */
  29107. export var defaultUboDeclaration: {
  29108. name: string;
  29109. shader: string;
  29110. };
  29111. }
  29112. declare module BABYLON {
  29113. /** @hidden */
  29114. export var lightFragmentDeclaration: {
  29115. name: string;
  29116. shader: string;
  29117. };
  29118. }
  29119. declare module BABYLON {
  29120. /** @hidden */
  29121. export var lightUboDeclaration: {
  29122. name: string;
  29123. shader: string;
  29124. };
  29125. }
  29126. declare module BABYLON {
  29127. /** @hidden */
  29128. export var lightsFragmentFunctions: {
  29129. name: string;
  29130. shader: string;
  29131. };
  29132. }
  29133. declare module BABYLON {
  29134. /** @hidden */
  29135. export var shadowsFragmentFunctions: {
  29136. name: string;
  29137. shader: string;
  29138. };
  29139. }
  29140. declare module BABYLON {
  29141. /** @hidden */
  29142. export var fresnelFunction: {
  29143. name: string;
  29144. shader: string;
  29145. };
  29146. }
  29147. declare module BABYLON {
  29148. /** @hidden */
  29149. export var bumpFragmentMainFunctions: {
  29150. name: string;
  29151. shader: string;
  29152. };
  29153. }
  29154. declare module BABYLON {
  29155. /** @hidden */
  29156. export var bumpFragmentFunctions: {
  29157. name: string;
  29158. shader: string;
  29159. };
  29160. }
  29161. declare module BABYLON {
  29162. /** @hidden */
  29163. export var logDepthDeclaration: {
  29164. name: string;
  29165. shader: string;
  29166. };
  29167. }
  29168. declare module BABYLON {
  29169. /** @hidden */
  29170. export var bumpFragment: {
  29171. name: string;
  29172. shader: string;
  29173. };
  29174. }
  29175. declare module BABYLON {
  29176. /** @hidden */
  29177. export var depthPrePass: {
  29178. name: string;
  29179. shader: string;
  29180. };
  29181. }
  29182. declare module BABYLON {
  29183. /** @hidden */
  29184. export var lightFragment: {
  29185. name: string;
  29186. shader: string;
  29187. };
  29188. }
  29189. declare module BABYLON {
  29190. /** @hidden */
  29191. export var logDepthFragment: {
  29192. name: string;
  29193. shader: string;
  29194. };
  29195. }
  29196. declare module BABYLON {
  29197. /** @hidden */
  29198. export var defaultPixelShader: {
  29199. name: string;
  29200. shader: string;
  29201. };
  29202. }
  29203. declare module BABYLON {
  29204. /** @hidden */
  29205. export var defaultVertexDeclaration: {
  29206. name: string;
  29207. shader: string;
  29208. };
  29209. }
  29210. declare module BABYLON {
  29211. /** @hidden */
  29212. export var bumpVertexDeclaration: {
  29213. name: string;
  29214. shader: string;
  29215. };
  29216. }
  29217. declare module BABYLON {
  29218. /** @hidden */
  29219. export var bumpVertex: {
  29220. name: string;
  29221. shader: string;
  29222. };
  29223. }
  29224. declare module BABYLON {
  29225. /** @hidden */
  29226. export var fogVertex: {
  29227. name: string;
  29228. shader: string;
  29229. };
  29230. }
  29231. declare module BABYLON {
  29232. /** @hidden */
  29233. export var shadowsVertex: {
  29234. name: string;
  29235. shader: string;
  29236. };
  29237. }
  29238. declare module BABYLON {
  29239. /** @hidden */
  29240. export var pointCloudVertex: {
  29241. name: string;
  29242. shader: string;
  29243. };
  29244. }
  29245. declare module BABYLON {
  29246. /** @hidden */
  29247. export var logDepthVertex: {
  29248. name: string;
  29249. shader: string;
  29250. };
  29251. }
  29252. declare module BABYLON {
  29253. /** @hidden */
  29254. export var defaultVertexShader: {
  29255. name: string;
  29256. shader: string;
  29257. };
  29258. }
  29259. declare module BABYLON {
  29260. /** @hidden */
  29261. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29262. MAINUV1: boolean;
  29263. MAINUV2: boolean;
  29264. DIFFUSE: boolean;
  29265. DIFFUSEDIRECTUV: number;
  29266. AMBIENT: boolean;
  29267. AMBIENTDIRECTUV: number;
  29268. OPACITY: boolean;
  29269. OPACITYDIRECTUV: number;
  29270. OPACITYRGB: boolean;
  29271. REFLECTION: boolean;
  29272. EMISSIVE: boolean;
  29273. EMISSIVEDIRECTUV: number;
  29274. SPECULAR: boolean;
  29275. SPECULARDIRECTUV: number;
  29276. BUMP: boolean;
  29277. BUMPDIRECTUV: number;
  29278. PARALLAX: boolean;
  29279. PARALLAXOCCLUSION: boolean;
  29280. SPECULAROVERALPHA: boolean;
  29281. CLIPPLANE: boolean;
  29282. CLIPPLANE2: boolean;
  29283. CLIPPLANE3: boolean;
  29284. CLIPPLANE4: boolean;
  29285. CLIPPLANE5: boolean;
  29286. CLIPPLANE6: boolean;
  29287. ALPHATEST: boolean;
  29288. DEPTHPREPASS: boolean;
  29289. ALPHAFROMDIFFUSE: boolean;
  29290. POINTSIZE: boolean;
  29291. FOG: boolean;
  29292. SPECULARTERM: boolean;
  29293. DIFFUSEFRESNEL: boolean;
  29294. OPACITYFRESNEL: boolean;
  29295. REFLECTIONFRESNEL: boolean;
  29296. REFRACTIONFRESNEL: boolean;
  29297. EMISSIVEFRESNEL: boolean;
  29298. FRESNEL: boolean;
  29299. NORMAL: boolean;
  29300. UV1: boolean;
  29301. UV2: boolean;
  29302. VERTEXCOLOR: boolean;
  29303. VERTEXALPHA: boolean;
  29304. NUM_BONE_INFLUENCERS: number;
  29305. BonesPerMesh: number;
  29306. BONETEXTURE: boolean;
  29307. INSTANCES: boolean;
  29308. GLOSSINESS: boolean;
  29309. ROUGHNESS: boolean;
  29310. EMISSIVEASILLUMINATION: boolean;
  29311. LINKEMISSIVEWITHDIFFUSE: boolean;
  29312. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29313. LIGHTMAP: boolean;
  29314. LIGHTMAPDIRECTUV: number;
  29315. OBJECTSPACE_NORMALMAP: boolean;
  29316. USELIGHTMAPASSHADOWMAP: boolean;
  29317. REFLECTIONMAP_3D: boolean;
  29318. REFLECTIONMAP_SPHERICAL: boolean;
  29319. REFLECTIONMAP_PLANAR: boolean;
  29320. REFLECTIONMAP_CUBIC: boolean;
  29321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29322. REFLECTIONMAP_PROJECTION: boolean;
  29323. REFLECTIONMAP_SKYBOX: boolean;
  29324. REFLECTIONMAP_EXPLICIT: boolean;
  29325. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29326. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29327. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29328. INVERTCUBICMAP: boolean;
  29329. LOGARITHMICDEPTH: boolean;
  29330. REFRACTION: boolean;
  29331. REFRACTIONMAP_3D: boolean;
  29332. REFLECTIONOVERALPHA: boolean;
  29333. TWOSIDEDLIGHTING: boolean;
  29334. SHADOWFLOAT: boolean;
  29335. MORPHTARGETS: boolean;
  29336. MORPHTARGETS_NORMAL: boolean;
  29337. MORPHTARGETS_TANGENT: boolean;
  29338. MORPHTARGETS_UV: boolean;
  29339. NUM_MORPH_INFLUENCERS: number;
  29340. NONUNIFORMSCALING: boolean;
  29341. PREMULTIPLYALPHA: boolean;
  29342. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29343. ALPHABLEND: boolean;
  29344. RGBDLIGHTMAP: boolean;
  29345. RGBDREFLECTION: boolean;
  29346. RGBDREFRACTION: boolean;
  29347. IMAGEPROCESSING: boolean;
  29348. VIGNETTE: boolean;
  29349. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29350. VIGNETTEBLENDMODEOPAQUE: boolean;
  29351. TONEMAPPING: boolean;
  29352. TONEMAPPING_ACES: boolean;
  29353. CONTRAST: boolean;
  29354. COLORCURVES: boolean;
  29355. COLORGRADING: boolean;
  29356. COLORGRADING3D: boolean;
  29357. SAMPLER3DGREENDEPTH: boolean;
  29358. SAMPLER3DBGRMAP: boolean;
  29359. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29360. MULTIVIEW: boolean;
  29361. /**
  29362. * If the reflection texture on this material is in linear color space
  29363. * @hidden
  29364. */
  29365. IS_REFLECTION_LINEAR: boolean;
  29366. /**
  29367. * If the refraction texture on this material is in linear color space
  29368. * @hidden
  29369. */
  29370. IS_REFRACTION_LINEAR: boolean;
  29371. EXPOSURE: boolean;
  29372. constructor();
  29373. setReflectionMode(modeToEnable: string): void;
  29374. }
  29375. /**
  29376. * This is the default material used in Babylon. It is the best trade off between quality
  29377. * and performances.
  29378. * @see http://doc.babylonjs.com/babylon101/materials
  29379. */
  29380. export class StandardMaterial extends PushMaterial {
  29381. private _diffuseTexture;
  29382. /**
  29383. * The basic texture of the material as viewed under a light.
  29384. */
  29385. diffuseTexture: Nullable<BaseTexture>;
  29386. private _ambientTexture;
  29387. /**
  29388. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29389. */
  29390. ambientTexture: Nullable<BaseTexture>;
  29391. private _opacityTexture;
  29392. /**
  29393. * Define the transparency of the material from a texture.
  29394. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29395. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29396. */
  29397. opacityTexture: Nullable<BaseTexture>;
  29398. private _reflectionTexture;
  29399. /**
  29400. * Define the texture used to display the reflection.
  29401. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29402. */
  29403. reflectionTexture: Nullable<BaseTexture>;
  29404. private _emissiveTexture;
  29405. /**
  29406. * Define texture of the material as if self lit.
  29407. * This will be mixed in the final result even in the absence of light.
  29408. */
  29409. emissiveTexture: Nullable<BaseTexture>;
  29410. private _specularTexture;
  29411. /**
  29412. * Define how the color and intensity of the highlight given by the light in the material.
  29413. */
  29414. specularTexture: Nullable<BaseTexture>;
  29415. private _bumpTexture;
  29416. /**
  29417. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29418. * 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.
  29419. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29420. */
  29421. bumpTexture: Nullable<BaseTexture>;
  29422. private _lightmapTexture;
  29423. /**
  29424. * Complex lighting can be computationally expensive to compute at runtime.
  29425. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29426. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29427. */
  29428. lightmapTexture: Nullable<BaseTexture>;
  29429. private _refractionTexture;
  29430. /**
  29431. * Define the texture used to display the refraction.
  29432. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29433. */
  29434. refractionTexture: Nullable<BaseTexture>;
  29435. /**
  29436. * The color of the material lit by the environmental background lighting.
  29437. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29438. */
  29439. ambientColor: Color3;
  29440. /**
  29441. * The basic color of the material as viewed under a light.
  29442. */
  29443. diffuseColor: Color3;
  29444. /**
  29445. * Define how the color and intensity of the highlight given by the light in the material.
  29446. */
  29447. specularColor: Color3;
  29448. /**
  29449. * Define the color of the material as if self lit.
  29450. * This will be mixed in the final result even in the absence of light.
  29451. */
  29452. emissiveColor: Color3;
  29453. /**
  29454. * Defines how sharp are the highlights in the material.
  29455. * The bigger the value the sharper giving a more glossy feeling to the result.
  29456. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29457. */
  29458. specularPower: number;
  29459. private _useAlphaFromDiffuseTexture;
  29460. /**
  29461. * Does the transparency come from the diffuse texture alpha channel.
  29462. */
  29463. useAlphaFromDiffuseTexture: boolean;
  29464. private _useEmissiveAsIllumination;
  29465. /**
  29466. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29467. */
  29468. useEmissiveAsIllumination: boolean;
  29469. private _linkEmissiveWithDiffuse;
  29470. /**
  29471. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29472. * the emissive level when the final color is close to one.
  29473. */
  29474. linkEmissiveWithDiffuse: boolean;
  29475. private _useSpecularOverAlpha;
  29476. /**
  29477. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29478. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29479. */
  29480. useSpecularOverAlpha: boolean;
  29481. private _useReflectionOverAlpha;
  29482. /**
  29483. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29484. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29485. */
  29486. useReflectionOverAlpha: boolean;
  29487. private _disableLighting;
  29488. /**
  29489. * Does lights from the scene impacts this material.
  29490. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29491. */
  29492. disableLighting: boolean;
  29493. private _useObjectSpaceNormalMap;
  29494. /**
  29495. * Allows using an object space normal map (instead of tangent space).
  29496. */
  29497. useObjectSpaceNormalMap: boolean;
  29498. private _useParallax;
  29499. /**
  29500. * Is parallax enabled or not.
  29501. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29502. */
  29503. useParallax: boolean;
  29504. private _useParallaxOcclusion;
  29505. /**
  29506. * Is parallax occlusion enabled or not.
  29507. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29508. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29509. */
  29510. useParallaxOcclusion: boolean;
  29511. /**
  29512. * 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.
  29513. */
  29514. parallaxScaleBias: number;
  29515. private _roughness;
  29516. /**
  29517. * Helps to define how blurry the reflections should appears in the material.
  29518. */
  29519. roughness: number;
  29520. /**
  29521. * In case of refraction, define the value of the index of refraction.
  29522. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29523. */
  29524. indexOfRefraction: number;
  29525. /**
  29526. * Invert the refraction texture alongside the y axis.
  29527. * It can be useful with procedural textures or probe for instance.
  29528. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29529. */
  29530. invertRefractionY: boolean;
  29531. /**
  29532. * Defines the alpha limits in alpha test mode.
  29533. */
  29534. alphaCutOff: number;
  29535. private _useLightmapAsShadowmap;
  29536. /**
  29537. * In case of light mapping, define whether the map contains light or shadow informations.
  29538. */
  29539. useLightmapAsShadowmap: boolean;
  29540. private _diffuseFresnelParameters;
  29541. /**
  29542. * Define the diffuse fresnel parameters of the material.
  29543. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29544. */
  29545. diffuseFresnelParameters: FresnelParameters;
  29546. private _opacityFresnelParameters;
  29547. /**
  29548. * Define the opacity fresnel parameters of the material.
  29549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29550. */
  29551. opacityFresnelParameters: FresnelParameters;
  29552. private _reflectionFresnelParameters;
  29553. /**
  29554. * Define the reflection fresnel parameters of the material.
  29555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29556. */
  29557. reflectionFresnelParameters: FresnelParameters;
  29558. private _refractionFresnelParameters;
  29559. /**
  29560. * Define the refraction fresnel parameters of the material.
  29561. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29562. */
  29563. refractionFresnelParameters: FresnelParameters;
  29564. private _emissiveFresnelParameters;
  29565. /**
  29566. * Define the emissive fresnel parameters of the material.
  29567. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29568. */
  29569. emissiveFresnelParameters: FresnelParameters;
  29570. private _useReflectionFresnelFromSpecular;
  29571. /**
  29572. * If true automatically deducts the fresnels values from the material specularity.
  29573. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29574. */
  29575. useReflectionFresnelFromSpecular: boolean;
  29576. private _useGlossinessFromSpecularMapAlpha;
  29577. /**
  29578. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29579. */
  29580. useGlossinessFromSpecularMapAlpha: boolean;
  29581. private _maxSimultaneousLights;
  29582. /**
  29583. * Defines the maximum number of lights that can be used in the material
  29584. */
  29585. maxSimultaneousLights: number;
  29586. private _invertNormalMapX;
  29587. /**
  29588. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29589. */
  29590. invertNormalMapX: boolean;
  29591. private _invertNormalMapY;
  29592. /**
  29593. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29594. */
  29595. invertNormalMapY: boolean;
  29596. private _twoSidedLighting;
  29597. /**
  29598. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29599. */
  29600. twoSidedLighting: boolean;
  29601. /**
  29602. * Default configuration related to image processing available in the standard Material.
  29603. */
  29604. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29605. /**
  29606. * Gets the image processing configuration used either in this material.
  29607. */
  29608. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29609. /**
  29610. * Sets the Default image processing configuration used either in the this material.
  29611. *
  29612. * If sets to null, the scene one is in use.
  29613. */
  29614. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29615. /**
  29616. * Keep track of the image processing observer to allow dispose and replace.
  29617. */
  29618. private _imageProcessingObserver;
  29619. /**
  29620. * Attaches a new image processing configuration to the Standard Material.
  29621. * @param configuration
  29622. */
  29623. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29624. /**
  29625. * Gets wether the color curves effect is enabled.
  29626. */
  29627. get cameraColorCurvesEnabled(): boolean;
  29628. /**
  29629. * Sets wether the color curves effect is enabled.
  29630. */
  29631. set cameraColorCurvesEnabled(value: boolean);
  29632. /**
  29633. * Gets wether the color grading effect is enabled.
  29634. */
  29635. get cameraColorGradingEnabled(): boolean;
  29636. /**
  29637. * Gets wether the color grading effect is enabled.
  29638. */
  29639. set cameraColorGradingEnabled(value: boolean);
  29640. /**
  29641. * Gets wether tonemapping is enabled or not.
  29642. */
  29643. get cameraToneMappingEnabled(): boolean;
  29644. /**
  29645. * Sets wether tonemapping is enabled or not
  29646. */
  29647. set cameraToneMappingEnabled(value: boolean);
  29648. /**
  29649. * The camera exposure used on this material.
  29650. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29651. * This corresponds to a photographic exposure.
  29652. */
  29653. get cameraExposure(): number;
  29654. /**
  29655. * The camera exposure used on this material.
  29656. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29657. * This corresponds to a photographic exposure.
  29658. */
  29659. set cameraExposure(value: number);
  29660. /**
  29661. * Gets The camera contrast used on this material.
  29662. */
  29663. get cameraContrast(): number;
  29664. /**
  29665. * Sets The camera contrast used on this material.
  29666. */
  29667. set cameraContrast(value: number);
  29668. /**
  29669. * Gets the Color Grading 2D Lookup Texture.
  29670. */
  29671. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29672. /**
  29673. * Sets the Color Grading 2D Lookup Texture.
  29674. */
  29675. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29676. /**
  29677. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29678. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29679. * 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;
  29680. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29681. */
  29682. get cameraColorCurves(): Nullable<ColorCurves>;
  29683. /**
  29684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29686. * 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;
  29687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29688. */
  29689. set cameraColorCurves(value: Nullable<ColorCurves>);
  29690. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29691. protected _worldViewProjectionMatrix: Matrix;
  29692. protected _globalAmbientColor: Color3;
  29693. protected _useLogarithmicDepth: boolean;
  29694. protected _rebuildInParallel: boolean;
  29695. /**
  29696. * Instantiates a new standard material.
  29697. * This is the default material used in Babylon. It is the best trade off between quality
  29698. * and performances.
  29699. * @see http://doc.babylonjs.com/babylon101/materials
  29700. * @param name Define the name of the material in the scene
  29701. * @param scene Define the scene the material belong to
  29702. */
  29703. constructor(name: string, scene: Scene);
  29704. /**
  29705. * Gets a boolean indicating that current material needs to register RTT
  29706. */
  29707. get hasRenderTargetTextures(): boolean;
  29708. /**
  29709. * Gets the current class name of the material e.g. "StandardMaterial"
  29710. * Mainly use in serialization.
  29711. * @returns the class name
  29712. */
  29713. getClassName(): string;
  29714. /**
  29715. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29716. * You can try switching to logarithmic depth.
  29717. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29718. */
  29719. get useLogarithmicDepth(): boolean;
  29720. set useLogarithmicDepth(value: boolean);
  29721. /**
  29722. * Specifies if the material will require alpha blending
  29723. * @returns a boolean specifying if alpha blending is needed
  29724. */
  29725. needAlphaBlending(): boolean;
  29726. /**
  29727. * Specifies if this material should be rendered in alpha test mode
  29728. * @returns a boolean specifying if an alpha test is needed.
  29729. */
  29730. needAlphaTesting(): boolean;
  29731. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29732. /**
  29733. * Get the texture used for alpha test purpose.
  29734. * @returns the diffuse texture in case of the standard material.
  29735. */
  29736. getAlphaTestTexture(): Nullable<BaseTexture>;
  29737. /**
  29738. * Get if the submesh is ready to be used and all its information available.
  29739. * Child classes can use it to update shaders
  29740. * @param mesh defines the mesh to check
  29741. * @param subMesh defines which submesh to check
  29742. * @param useInstances specifies that instances should be used
  29743. * @returns a boolean indicating that the submesh is ready or not
  29744. */
  29745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29746. /**
  29747. * Builds the material UBO layouts.
  29748. * Used internally during the effect preparation.
  29749. */
  29750. buildUniformLayout(): void;
  29751. /**
  29752. * Unbinds the material from the mesh
  29753. */
  29754. unbind(): void;
  29755. /**
  29756. * Binds the submesh to this material by preparing the effect and shader to draw
  29757. * @param world defines the world transformation matrix
  29758. * @param mesh defines the mesh containing the submesh
  29759. * @param subMesh defines the submesh to bind the material to
  29760. */
  29761. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29762. /**
  29763. * Get the list of animatables in the material.
  29764. * @returns the list of animatables object used in the material
  29765. */
  29766. getAnimatables(): IAnimatable[];
  29767. /**
  29768. * Gets the active textures from the material
  29769. * @returns an array of textures
  29770. */
  29771. getActiveTextures(): BaseTexture[];
  29772. /**
  29773. * Specifies if the material uses a texture
  29774. * @param texture defines the texture to check against the material
  29775. * @returns a boolean specifying if the material uses the texture
  29776. */
  29777. hasTexture(texture: BaseTexture): boolean;
  29778. /**
  29779. * Disposes the material
  29780. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29781. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29782. */
  29783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29784. /**
  29785. * Makes a duplicate of the material, and gives it a new name
  29786. * @param name defines the new name for the duplicated material
  29787. * @returns the cloned material
  29788. */
  29789. clone(name: string): StandardMaterial;
  29790. /**
  29791. * Serializes this material in a JSON representation
  29792. * @returns the serialized material object
  29793. */
  29794. serialize(): any;
  29795. /**
  29796. * Creates a standard material from parsed material data
  29797. * @param source defines the JSON representation of the material
  29798. * @param scene defines the hosting scene
  29799. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29800. * @returns a new standard material
  29801. */
  29802. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29803. /**
  29804. * Are diffuse textures enabled in the application.
  29805. */
  29806. static get DiffuseTextureEnabled(): boolean;
  29807. static set DiffuseTextureEnabled(value: boolean);
  29808. /**
  29809. * Are ambient textures enabled in the application.
  29810. */
  29811. static get AmbientTextureEnabled(): boolean;
  29812. static set AmbientTextureEnabled(value: boolean);
  29813. /**
  29814. * Are opacity textures enabled in the application.
  29815. */
  29816. static get OpacityTextureEnabled(): boolean;
  29817. static set OpacityTextureEnabled(value: boolean);
  29818. /**
  29819. * Are reflection textures enabled in the application.
  29820. */
  29821. static get ReflectionTextureEnabled(): boolean;
  29822. static set ReflectionTextureEnabled(value: boolean);
  29823. /**
  29824. * Are emissive textures enabled in the application.
  29825. */
  29826. static get EmissiveTextureEnabled(): boolean;
  29827. static set EmissiveTextureEnabled(value: boolean);
  29828. /**
  29829. * Are specular textures enabled in the application.
  29830. */
  29831. static get SpecularTextureEnabled(): boolean;
  29832. static set SpecularTextureEnabled(value: boolean);
  29833. /**
  29834. * Are bump textures enabled in the application.
  29835. */
  29836. static get BumpTextureEnabled(): boolean;
  29837. static set BumpTextureEnabled(value: boolean);
  29838. /**
  29839. * Are lightmap textures enabled in the application.
  29840. */
  29841. static get LightmapTextureEnabled(): boolean;
  29842. static set LightmapTextureEnabled(value: boolean);
  29843. /**
  29844. * Are refraction textures enabled in the application.
  29845. */
  29846. static get RefractionTextureEnabled(): boolean;
  29847. static set RefractionTextureEnabled(value: boolean);
  29848. /**
  29849. * Are color grading textures enabled in the application.
  29850. */
  29851. static get ColorGradingTextureEnabled(): boolean;
  29852. static set ColorGradingTextureEnabled(value: boolean);
  29853. /**
  29854. * Are fresnels enabled in the application.
  29855. */
  29856. static get FresnelEnabled(): boolean;
  29857. static set FresnelEnabled(value: boolean);
  29858. }
  29859. }
  29860. declare module BABYLON {
  29861. /**
  29862. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29863. *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.
  29864. * The SPS is also a particle system. It provides some methods to manage the particles.
  29865. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29866. *
  29867. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29868. */
  29869. export class SolidParticleSystem implements IDisposable {
  29870. /**
  29871. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29872. * Example : var p = SPS.particles[i];
  29873. */
  29874. particles: SolidParticle[];
  29875. /**
  29876. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29877. */
  29878. nbParticles: number;
  29879. /**
  29880. * If the particles must ever face the camera (default false). Useful for planar particles.
  29881. */
  29882. billboard: boolean;
  29883. /**
  29884. * Recompute normals when adding a shape
  29885. */
  29886. recomputeNormals: boolean;
  29887. /**
  29888. * This a counter ofr your own usage. It's not set by any SPS functions.
  29889. */
  29890. counter: number;
  29891. /**
  29892. * The SPS name. This name is also given to the underlying mesh.
  29893. */
  29894. name: string;
  29895. /**
  29896. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29897. */
  29898. mesh: Mesh;
  29899. /**
  29900. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29901. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29902. */
  29903. vars: any;
  29904. /**
  29905. * This array is populated when the SPS is set as 'pickable'.
  29906. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29907. * Each element of this array is an object `{idx: int, faceId: int}`.
  29908. * `idx` is the picked particle index in the `SPS.particles` array
  29909. * `faceId` is the picked face index counted within this particle.
  29910. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29911. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29912. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29913. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29914. */
  29915. pickedParticles: {
  29916. idx: number;
  29917. faceId: number;
  29918. }[];
  29919. /**
  29920. * This array is populated when the SPS is set as 'pickable'
  29921. * Each key of this array is a submesh index.
  29922. * Each element of this array is a second array defined like this :
  29923. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29924. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29925. * `idx` is the picked particle index in the `SPS.particles` array
  29926. * `faceId` is the picked face index counted within this particle.
  29927. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29928. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29929. */
  29930. pickedBySubMesh: {
  29931. idx: number;
  29932. faceId: number;
  29933. }[][];
  29934. /**
  29935. * This array is populated when `enableDepthSort` is set to true.
  29936. * Each element of this array is an instance of the class DepthSortedParticle.
  29937. */
  29938. depthSortedParticles: DepthSortedParticle[];
  29939. /**
  29940. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29941. * @hidden
  29942. */
  29943. _bSphereOnly: boolean;
  29944. /**
  29945. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29946. * @hidden
  29947. */
  29948. _bSphereRadiusFactor: number;
  29949. private _scene;
  29950. private _positions;
  29951. private _indices;
  29952. private _normals;
  29953. private _colors;
  29954. private _uvs;
  29955. private _indices32;
  29956. private _positions32;
  29957. private _normals32;
  29958. private _fixedNormal32;
  29959. private _colors32;
  29960. private _uvs32;
  29961. private _index;
  29962. private _updatable;
  29963. private _pickable;
  29964. private _isVisibilityBoxLocked;
  29965. private _alwaysVisible;
  29966. private _depthSort;
  29967. private _expandable;
  29968. private _shapeCounter;
  29969. private _copy;
  29970. private _color;
  29971. private _computeParticleColor;
  29972. private _computeParticleTexture;
  29973. private _computeParticleRotation;
  29974. private _computeParticleVertex;
  29975. private _computeBoundingBox;
  29976. private _depthSortParticles;
  29977. private _camera;
  29978. private _mustUnrotateFixedNormals;
  29979. private _particlesIntersect;
  29980. private _needs32Bits;
  29981. private _isNotBuilt;
  29982. private _lastParticleId;
  29983. private _idxOfId;
  29984. private _multimaterialEnabled;
  29985. private _useModelMaterial;
  29986. private _indicesByMaterial;
  29987. private _materialIndexes;
  29988. private _depthSortFunction;
  29989. private _materialSortFunction;
  29990. private _materials;
  29991. private _multimaterial;
  29992. private _materialIndexesById;
  29993. private _defaultMaterial;
  29994. private _autoUpdateSubMeshes;
  29995. private _tmpVertex;
  29996. /**
  29997. * Creates a SPS (Solid Particle System) object.
  29998. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29999. * @param scene (Scene) is the scene in which the SPS is added.
  30000. * @param options defines the options of the sps e.g.
  30001. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30002. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30003. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30004. * * 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.
  30005. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30006. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30007. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30008. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30009. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30010. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30011. */
  30012. constructor(name: string, scene: Scene, options?: {
  30013. updatable?: boolean;
  30014. isPickable?: boolean;
  30015. enableDepthSort?: boolean;
  30016. particleIntersection?: boolean;
  30017. boundingSphereOnly?: boolean;
  30018. bSphereRadiusFactor?: number;
  30019. expandable?: boolean;
  30020. useModelMaterial?: boolean;
  30021. enableMultiMaterial?: boolean;
  30022. });
  30023. /**
  30024. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30025. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30026. * @returns the created mesh
  30027. */
  30028. buildMesh(): Mesh;
  30029. /**
  30030. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30031. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30032. * Thus the particles generated from `digest()` have their property `position` set yet.
  30033. * @param mesh ( Mesh ) is the mesh to be digested
  30034. * @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
  30035. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30036. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30037. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30038. * @returns the current SPS
  30039. */
  30040. digest(mesh: Mesh, options?: {
  30041. facetNb?: number;
  30042. number?: number;
  30043. delta?: number;
  30044. storage?: [];
  30045. }): SolidParticleSystem;
  30046. /**
  30047. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30048. * @hidden
  30049. */
  30050. private _unrotateFixedNormals;
  30051. /**
  30052. * Resets the temporary working copy particle
  30053. * @hidden
  30054. */
  30055. private _resetCopy;
  30056. /**
  30057. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30058. * @param p the current index in the positions array to be updated
  30059. * @param ind the current index in the indices array
  30060. * @param shape a Vector3 array, the shape geometry
  30061. * @param positions the positions array to be updated
  30062. * @param meshInd the shape indices array
  30063. * @param indices the indices array to be updated
  30064. * @param meshUV the shape uv array
  30065. * @param uvs the uv array to be updated
  30066. * @param meshCol the shape color array
  30067. * @param colors the color array to be updated
  30068. * @param meshNor the shape normals array
  30069. * @param normals the normals array to be updated
  30070. * @param idx the particle index
  30071. * @param idxInShape the particle index in its shape
  30072. * @param options the addShape() method passed options
  30073. * @model the particle model
  30074. * @hidden
  30075. */
  30076. private _meshBuilder;
  30077. /**
  30078. * Returns a shape Vector3 array from positions float array
  30079. * @param positions float array
  30080. * @returns a vector3 array
  30081. * @hidden
  30082. */
  30083. private _posToShape;
  30084. /**
  30085. * Returns a shapeUV array from a float uvs (array deep copy)
  30086. * @param uvs as a float array
  30087. * @returns a shapeUV array
  30088. * @hidden
  30089. */
  30090. private _uvsToShapeUV;
  30091. /**
  30092. * Adds a new particle object in the particles array
  30093. * @param idx particle index in particles array
  30094. * @param id particle id
  30095. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30096. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30097. * @param model particle ModelShape object
  30098. * @param shapeId model shape identifier
  30099. * @param idxInShape index of the particle in the current model
  30100. * @param bInfo model bounding info object
  30101. * @param storage target storage array, if any
  30102. * @hidden
  30103. */
  30104. private _addParticle;
  30105. /**
  30106. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30107. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30108. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30109. * @param nb (positive integer) the number of particles to be created from this model
  30110. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30111. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30112. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30113. * @returns the number of shapes in the system
  30114. */
  30115. addShape(mesh: Mesh, nb: number, options?: {
  30116. positionFunction?: any;
  30117. vertexFunction?: any;
  30118. storage?: [];
  30119. }): number;
  30120. /**
  30121. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30122. * @hidden
  30123. */
  30124. private _rebuildParticle;
  30125. /**
  30126. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30127. * @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.
  30128. * @returns the SPS.
  30129. */
  30130. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30131. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30132. * Returns an array with the removed particles.
  30133. * 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.
  30134. * The SPS can't be empty so at least one particle needs to remain in place.
  30135. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30136. * @param start index of the first particle to remove
  30137. * @param end index of the last particle to remove (included)
  30138. * @returns an array populated with the removed particles
  30139. */
  30140. removeParticles(start: number, end: number): SolidParticle[];
  30141. /**
  30142. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30143. * @param solidParticleArray an array populated with Solid Particles objects
  30144. * @returns the SPS
  30145. */
  30146. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30147. /**
  30148. * Creates a new particle and modifies the SPS mesh geometry :
  30149. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30150. * - calls _addParticle() to populate the particle array
  30151. * factorized code from addShape() and insertParticlesFromArray()
  30152. * @param idx particle index in the particles array
  30153. * @param i particle index in its shape
  30154. * @param modelShape particle ModelShape object
  30155. * @param shape shape vertex array
  30156. * @param meshInd shape indices array
  30157. * @param meshUV shape uv array
  30158. * @param meshCol shape color array
  30159. * @param meshNor shape normals array
  30160. * @param bbInfo shape bounding info
  30161. * @param storage target particle storage
  30162. * @options addShape() passed options
  30163. * @hidden
  30164. */
  30165. private _insertNewParticle;
  30166. /**
  30167. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30168. * This method calls `updateParticle()` for each particle of the SPS.
  30169. * For an animated SPS, it is usually called within the render loop.
  30170. * 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.
  30171. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30172. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30173. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30174. * @returns the SPS.
  30175. */
  30176. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30177. /**
  30178. * Disposes the SPS.
  30179. */
  30180. dispose(): void;
  30181. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30182. * idx is the particle index in the SPS
  30183. * faceId is the picked face index counted within this particle.
  30184. * Returns null if the pickInfo can't identify a picked particle.
  30185. * @param pickingInfo (PickingInfo object)
  30186. * @returns {idx: number, faceId: number} or null
  30187. */
  30188. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30189. idx: number;
  30190. faceId: number;
  30191. }>;
  30192. /**
  30193. * Returns a SolidParticle object from its identifier : particle.id
  30194. * @param id (integer) the particle Id
  30195. * @returns the searched particle or null if not found in the SPS.
  30196. */
  30197. getParticleById(id: number): Nullable<SolidParticle>;
  30198. /**
  30199. * Returns a new array populated with the particles having the passed shapeId.
  30200. * @param shapeId (integer) the shape identifier
  30201. * @returns a new solid particle array
  30202. */
  30203. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30204. /**
  30205. * Populates the passed array "ref" with the particles having the passed shapeId.
  30206. * @param shapeId the shape identifier
  30207. * @returns the SPS
  30208. * @param ref
  30209. */
  30210. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30211. /**
  30212. * Computes the required SubMeshes according the materials assigned to the particles.
  30213. * @returns the solid particle system.
  30214. * Does nothing if called before the SPS mesh is built.
  30215. */
  30216. computeSubMeshes(): SolidParticleSystem;
  30217. /**
  30218. * Sorts the solid particles by material when MultiMaterial is enabled.
  30219. * Updates the indices32 array.
  30220. * Updates the indicesByMaterial array.
  30221. * Updates the mesh indices array.
  30222. * @returns the SPS
  30223. * @hidden
  30224. */
  30225. private _sortParticlesByMaterial;
  30226. /**
  30227. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30228. * @hidden
  30229. */
  30230. private _setMaterialIndexesById;
  30231. /**
  30232. * Returns an array with unique values of Materials from the passed array
  30233. * @param array the material array to be checked and filtered
  30234. * @hidden
  30235. */
  30236. private _filterUniqueMaterialId;
  30237. /**
  30238. * Sets a new Standard Material as _defaultMaterial if not already set.
  30239. * @hidden
  30240. */
  30241. private _setDefaultMaterial;
  30242. /**
  30243. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30244. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30245. * @returns the SPS.
  30246. */
  30247. refreshVisibleSize(): SolidParticleSystem;
  30248. /**
  30249. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30250. * @param size the size (float) of the visibility box
  30251. * note : this doesn't lock the SPS mesh bounding box.
  30252. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30253. */
  30254. setVisibilityBox(size: number): void;
  30255. /**
  30256. * Gets whether the SPS as always visible or not
  30257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30258. */
  30259. get isAlwaysVisible(): boolean;
  30260. /**
  30261. * Sets the SPS as always visible or not
  30262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30263. */
  30264. set isAlwaysVisible(val: boolean);
  30265. /**
  30266. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30267. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30268. */
  30269. set isVisibilityBoxLocked(val: boolean);
  30270. /**
  30271. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30272. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30273. */
  30274. get isVisibilityBoxLocked(): boolean;
  30275. /**
  30276. * Tells to `setParticles()` to compute the particle rotations or not.
  30277. * Default value : true. The SPS is faster when it's set to false.
  30278. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30279. */
  30280. set computeParticleRotation(val: boolean);
  30281. /**
  30282. * Tells to `setParticles()` to compute the particle colors or not.
  30283. * Default value : true. The SPS is faster when it's set to false.
  30284. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30285. */
  30286. set computeParticleColor(val: boolean);
  30287. set computeParticleTexture(val: boolean);
  30288. /**
  30289. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30290. * Default value : false. The SPS is faster when it's set to false.
  30291. * Note : the particle custom vertex positions aren't stored values.
  30292. */
  30293. set computeParticleVertex(val: boolean);
  30294. /**
  30295. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30296. */
  30297. set computeBoundingBox(val: boolean);
  30298. /**
  30299. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30300. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30301. * Default : `true`
  30302. */
  30303. set depthSortParticles(val: boolean);
  30304. /**
  30305. * Gets if `setParticles()` computes the particle rotations or not.
  30306. * Default value : true. The SPS is faster when it's set to false.
  30307. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30308. */
  30309. get computeParticleRotation(): boolean;
  30310. /**
  30311. * Gets if `setParticles()` computes the particle colors or not.
  30312. * Default value : true. The SPS is faster when it's set to false.
  30313. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30314. */
  30315. get computeParticleColor(): boolean;
  30316. /**
  30317. * Gets if `setParticles()` computes the particle textures or not.
  30318. * Default value : true. The SPS is faster when it's set to false.
  30319. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30320. */
  30321. get computeParticleTexture(): boolean;
  30322. /**
  30323. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30324. * Default value : false. The SPS is faster when it's set to false.
  30325. * Note : the particle custom vertex positions aren't stored values.
  30326. */
  30327. get computeParticleVertex(): boolean;
  30328. /**
  30329. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30330. */
  30331. get computeBoundingBox(): boolean;
  30332. /**
  30333. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30334. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30335. * Default : `true`
  30336. */
  30337. get depthSortParticles(): boolean;
  30338. /**
  30339. * Gets if the SPS is created as expandable at construction time.
  30340. * Default : `false`
  30341. */
  30342. get expandable(): boolean;
  30343. /**
  30344. * Gets if the SPS supports the Multi Materials
  30345. */
  30346. get multimaterialEnabled(): boolean;
  30347. /**
  30348. * Gets if the SPS uses the model materials for its own multimaterial.
  30349. */
  30350. get useModelMaterial(): boolean;
  30351. /**
  30352. * The SPS used material array.
  30353. */
  30354. get materials(): Material[];
  30355. /**
  30356. * Sets the SPS MultiMaterial from the passed materials.
  30357. * Note : the passed array is internally copied and not used then by reference.
  30358. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30359. */
  30360. setMultiMaterial(materials: Material[]): void;
  30361. /**
  30362. * The SPS computed multimaterial object
  30363. */
  30364. get multimaterial(): MultiMaterial;
  30365. set multimaterial(mm: MultiMaterial);
  30366. /**
  30367. * If the subMeshes must be updated on the next call to setParticles()
  30368. */
  30369. get autoUpdateSubMeshes(): boolean;
  30370. set autoUpdateSubMeshes(val: boolean);
  30371. /**
  30372. * This function does nothing. It may be overwritten to set all the particle first values.
  30373. * The SPS doesn't call this function, you may have to call it by your own.
  30374. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30375. */
  30376. initParticles(): void;
  30377. /**
  30378. * This function does nothing. It may be overwritten to recycle a particle.
  30379. * The SPS doesn't call this function, you may have to call it by your own.
  30380. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30381. * @param particle The particle to recycle
  30382. * @returns the recycled particle
  30383. */
  30384. recycleParticle(particle: SolidParticle): SolidParticle;
  30385. /**
  30386. * Updates a particle : this function should be overwritten by the user.
  30387. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30388. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30389. * @example : just set a particle position or velocity and recycle conditions
  30390. * @param particle The particle to update
  30391. * @returns the updated particle
  30392. */
  30393. updateParticle(particle: SolidParticle): SolidParticle;
  30394. /**
  30395. * Updates a vertex of a particle : it can be overwritten by the user.
  30396. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30397. * @param particle the current particle
  30398. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30399. * @param pt the index of the current vertex in the particle shape
  30400. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30401. * @example : just set a vertex particle position or color
  30402. * @returns the sps
  30403. */
  30404. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30405. /**
  30406. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30407. * This does nothing and may be overwritten by the user.
  30408. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30409. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30410. * @param update the boolean update value actually passed to setParticles()
  30411. */
  30412. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30413. /**
  30414. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30415. * This will be passed three parameters.
  30416. * This does nothing and may be overwritten by the user.
  30417. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30418. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30419. * @param update the boolean update value actually passed to setParticles()
  30420. */
  30421. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30422. }
  30423. }
  30424. declare module BABYLON {
  30425. /**
  30426. * Represents one particle of a solid particle system.
  30427. */
  30428. export class SolidParticle {
  30429. /**
  30430. * particle global index
  30431. */
  30432. idx: number;
  30433. /**
  30434. * particle identifier
  30435. */
  30436. id: number;
  30437. /**
  30438. * The color of the particle
  30439. */
  30440. color: Nullable<Color4>;
  30441. /**
  30442. * The world space position of the particle.
  30443. */
  30444. position: Vector3;
  30445. /**
  30446. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30447. */
  30448. rotation: Vector3;
  30449. /**
  30450. * The world space rotation quaternion of the particle.
  30451. */
  30452. rotationQuaternion: Nullable<Quaternion>;
  30453. /**
  30454. * The scaling of the particle.
  30455. */
  30456. scaling: Vector3;
  30457. /**
  30458. * The uvs of the particle.
  30459. */
  30460. uvs: Vector4;
  30461. /**
  30462. * The current speed of the particle.
  30463. */
  30464. velocity: Vector3;
  30465. /**
  30466. * The pivot point in the particle local space.
  30467. */
  30468. pivot: Vector3;
  30469. /**
  30470. * Must the particle be translated from its pivot point in its local space ?
  30471. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30472. * Default : false
  30473. */
  30474. translateFromPivot: boolean;
  30475. /**
  30476. * Is the particle active or not ?
  30477. */
  30478. alive: boolean;
  30479. /**
  30480. * Is the particle visible or not ?
  30481. */
  30482. isVisible: boolean;
  30483. /**
  30484. * Index of this particle in the global "positions" array (Internal use)
  30485. * @hidden
  30486. */
  30487. _pos: number;
  30488. /**
  30489. * @hidden Index of this particle in the global "indices" array (Internal use)
  30490. */
  30491. _ind: number;
  30492. /**
  30493. * @hidden ModelShape of this particle (Internal use)
  30494. */
  30495. _model: ModelShape;
  30496. /**
  30497. * ModelShape id of this particle
  30498. */
  30499. shapeId: number;
  30500. /**
  30501. * Index of the particle in its shape id
  30502. */
  30503. idxInShape: number;
  30504. /**
  30505. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30506. */
  30507. _modelBoundingInfo: BoundingInfo;
  30508. /**
  30509. * @hidden Particle BoundingInfo object (Internal use)
  30510. */
  30511. _boundingInfo: BoundingInfo;
  30512. /**
  30513. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30514. */
  30515. _sps: SolidParticleSystem;
  30516. /**
  30517. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30518. */
  30519. _stillInvisible: boolean;
  30520. /**
  30521. * @hidden Last computed particle rotation matrix
  30522. */
  30523. _rotationMatrix: number[];
  30524. /**
  30525. * Parent particle Id, if any.
  30526. * Default null.
  30527. */
  30528. parentId: Nullable<number>;
  30529. /**
  30530. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30531. */
  30532. materialIndex: Nullable<number>;
  30533. /**
  30534. * Custom object or properties.
  30535. */
  30536. props: Nullable<any>;
  30537. /**
  30538. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30539. * The possible values are :
  30540. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30541. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30542. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30543. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30544. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30545. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30546. * */
  30547. cullingStrategy: number;
  30548. /**
  30549. * @hidden Internal global position in the SPS.
  30550. */
  30551. _globalPosition: Vector3;
  30552. /**
  30553. * Creates a Solid Particle object.
  30554. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30555. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30556. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30557. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30558. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30559. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30560. * @param shapeId (integer) is the model shape identifier in the SPS.
  30561. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30562. * @param sps defines the sps it is associated to
  30563. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30564. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30565. */
  30566. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30567. /**
  30568. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30569. * @param target the particle target
  30570. * @returns the current particle
  30571. */
  30572. copyToRef(target: SolidParticle): SolidParticle;
  30573. /**
  30574. * Legacy support, changed scale to scaling
  30575. */
  30576. get scale(): Vector3;
  30577. /**
  30578. * Legacy support, changed scale to scaling
  30579. */
  30580. set scale(scale: Vector3);
  30581. /**
  30582. * Legacy support, changed quaternion to rotationQuaternion
  30583. */
  30584. get quaternion(): Nullable<Quaternion>;
  30585. /**
  30586. * Legacy support, changed quaternion to rotationQuaternion
  30587. */
  30588. set quaternion(q: Nullable<Quaternion>);
  30589. /**
  30590. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30591. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30592. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30593. * @returns true if it intersects
  30594. */
  30595. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30596. /**
  30597. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30598. * A particle is in the frustum if its bounding box intersects the frustum
  30599. * @param frustumPlanes defines the frustum to test
  30600. * @returns true if the particle is in the frustum planes
  30601. */
  30602. isInFrustum(frustumPlanes: Plane[]): boolean;
  30603. /**
  30604. * get the rotation matrix of the particle
  30605. * @hidden
  30606. */
  30607. getRotationMatrix(m: Matrix): void;
  30608. }
  30609. /**
  30610. * Represents the shape of the model used by one particle of a solid particle system.
  30611. * SPS internal tool, don't use it manually.
  30612. */
  30613. export class ModelShape {
  30614. /**
  30615. * The shape id
  30616. * @hidden
  30617. */
  30618. shapeID: number;
  30619. /**
  30620. * flat array of model positions (internal use)
  30621. * @hidden
  30622. */
  30623. _shape: Vector3[];
  30624. /**
  30625. * flat array of model UVs (internal use)
  30626. * @hidden
  30627. */
  30628. _shapeUV: number[];
  30629. /**
  30630. * color array of the model
  30631. * @hidden
  30632. */
  30633. _shapeColors: number[];
  30634. /**
  30635. * indices array of the model
  30636. * @hidden
  30637. */
  30638. _indices: number[];
  30639. /**
  30640. * normals array of the model
  30641. * @hidden
  30642. */
  30643. _normals: number[];
  30644. /**
  30645. * length of the shape in the model indices array (internal use)
  30646. * @hidden
  30647. */
  30648. _indicesLength: number;
  30649. /**
  30650. * Custom position function (internal use)
  30651. * @hidden
  30652. */
  30653. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30654. /**
  30655. * Custom vertex function (internal use)
  30656. * @hidden
  30657. */
  30658. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30659. /**
  30660. * Model material (internal use)
  30661. * @hidden
  30662. */
  30663. _material: Nullable<Material>;
  30664. /**
  30665. * 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.
  30666. * SPS internal tool, don't use it manually.
  30667. * @hidden
  30668. */
  30669. 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>);
  30670. }
  30671. /**
  30672. * Represents a Depth Sorted Particle in the solid particle system.
  30673. * @hidden
  30674. */
  30675. export class DepthSortedParticle {
  30676. /**
  30677. * Particle index
  30678. */
  30679. idx: number;
  30680. /**
  30681. * Index of the particle in the "indices" array
  30682. */
  30683. ind: number;
  30684. /**
  30685. * Length of the particle shape in the "indices" array
  30686. */
  30687. indicesLength: number;
  30688. /**
  30689. * Squared distance from the particle to the camera
  30690. */
  30691. sqDistance: number;
  30692. /**
  30693. * Material index when used with MultiMaterials
  30694. */
  30695. materialIndex: number;
  30696. /**
  30697. * Creates a new sorted particle
  30698. * @param materialIndex
  30699. */
  30700. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30701. }
  30702. /**
  30703. * Represents a solid particle vertex
  30704. */
  30705. export class SolidParticleVertex {
  30706. /**
  30707. * Vertex position
  30708. */
  30709. position: Vector3;
  30710. /**
  30711. * Vertex color
  30712. */
  30713. color: Color4;
  30714. /**
  30715. * Vertex UV
  30716. */
  30717. uv: Vector2;
  30718. /**
  30719. * Creates a new solid particle vertex
  30720. */
  30721. constructor();
  30722. /** Vertex x coordinate */
  30723. get x(): number;
  30724. set x(val: number);
  30725. /** Vertex y coordinate */
  30726. get y(): number;
  30727. set y(val: number);
  30728. /** Vertex z coordinate */
  30729. get z(): number;
  30730. set z(val: number);
  30731. }
  30732. }
  30733. declare module BABYLON {
  30734. /**
  30735. * @hidden
  30736. */
  30737. export class _MeshCollisionData {
  30738. _checkCollisions: boolean;
  30739. _collisionMask: number;
  30740. _collisionGroup: number;
  30741. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30742. _collider: Nullable<Collider>;
  30743. _oldPositionForCollisions: Vector3;
  30744. _diffPositionForCollisions: Vector3;
  30745. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30746. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30747. }
  30748. }
  30749. declare module BABYLON {
  30750. /** @hidden */
  30751. class _FacetDataStorage {
  30752. facetPositions: Vector3[];
  30753. facetNormals: Vector3[];
  30754. facetPartitioning: number[][];
  30755. facetNb: number;
  30756. partitioningSubdivisions: number;
  30757. partitioningBBoxRatio: number;
  30758. facetDataEnabled: boolean;
  30759. facetParameters: any;
  30760. bbSize: Vector3;
  30761. subDiv: {
  30762. max: number;
  30763. X: number;
  30764. Y: number;
  30765. Z: number;
  30766. };
  30767. facetDepthSort: boolean;
  30768. facetDepthSortEnabled: boolean;
  30769. depthSortedIndices: IndicesArray;
  30770. depthSortedFacets: {
  30771. ind: number;
  30772. sqDistance: number;
  30773. }[];
  30774. facetDepthSortFunction: (f1: {
  30775. ind: number;
  30776. sqDistance: number;
  30777. }, f2: {
  30778. ind: number;
  30779. sqDistance: number;
  30780. }) => number;
  30781. facetDepthSortFrom: Vector3;
  30782. facetDepthSortOrigin: Vector3;
  30783. invertedMatrix: Matrix;
  30784. }
  30785. /**
  30786. * @hidden
  30787. **/
  30788. class _InternalAbstractMeshDataInfo {
  30789. _hasVertexAlpha: boolean;
  30790. _useVertexColors: boolean;
  30791. _numBoneInfluencers: number;
  30792. _applyFog: boolean;
  30793. _receiveShadows: boolean;
  30794. _facetData: _FacetDataStorage;
  30795. _visibility: number;
  30796. _skeleton: Nullable<Skeleton>;
  30797. _layerMask: number;
  30798. _computeBonesUsingShaders: boolean;
  30799. _isActive: boolean;
  30800. _onlyForInstances: boolean;
  30801. _isActiveIntermediate: boolean;
  30802. _onlyForInstancesIntermediate: boolean;
  30803. _actAsRegularMesh: boolean;
  30804. }
  30805. /**
  30806. * Class used to store all common mesh properties
  30807. */
  30808. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30809. /** No occlusion */
  30810. static OCCLUSION_TYPE_NONE: number;
  30811. /** Occlusion set to optimisitic */
  30812. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30813. /** Occlusion set to strict */
  30814. static OCCLUSION_TYPE_STRICT: number;
  30815. /** Use an accurante occlusion algorithm */
  30816. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30817. /** Use a conservative occlusion algorithm */
  30818. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30819. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30820. * Test order :
  30821. * Is the bounding sphere outside the frustum ?
  30822. * If not, are the bounding box vertices outside the frustum ?
  30823. * It not, then the cullable object is in the frustum.
  30824. */
  30825. static readonly CULLINGSTRATEGY_STANDARD: number;
  30826. /** Culling strategy : Bounding Sphere Only.
  30827. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30828. * It's also less accurate than the standard because some not visible objects can still be selected.
  30829. * Test : is the bounding sphere outside the frustum ?
  30830. * If not, then the cullable object is in the frustum.
  30831. */
  30832. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30833. /** Culling strategy : Optimistic Inclusion.
  30834. * This in an inclusion test first, then the standard exclusion test.
  30835. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30836. * 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.
  30837. * Anyway, it's as accurate as the standard strategy.
  30838. * Test :
  30839. * Is the cullable object bounding sphere center in the frustum ?
  30840. * If not, apply the default culling strategy.
  30841. */
  30842. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30843. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30844. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30845. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30846. * 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.
  30847. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30848. * Test :
  30849. * Is the cullable object bounding sphere center in the frustum ?
  30850. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30851. */
  30852. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30853. /**
  30854. * No billboard
  30855. */
  30856. static get BILLBOARDMODE_NONE(): number;
  30857. /** Billboard on X axis */
  30858. static get BILLBOARDMODE_X(): number;
  30859. /** Billboard on Y axis */
  30860. static get BILLBOARDMODE_Y(): number;
  30861. /** Billboard on Z axis */
  30862. static get BILLBOARDMODE_Z(): number;
  30863. /** Billboard on all axes */
  30864. static get BILLBOARDMODE_ALL(): number;
  30865. /** Billboard on using position instead of orientation */
  30866. static get BILLBOARDMODE_USE_POSITION(): number;
  30867. /** @hidden */
  30868. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30869. /**
  30870. * The culling strategy to use to check whether the mesh must be rendered or not.
  30871. * This value can be changed at any time and will be used on the next render mesh selection.
  30872. * The possible values are :
  30873. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30874. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30875. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30876. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30877. * Please read each static variable documentation to get details about the culling process.
  30878. * */
  30879. cullingStrategy: number;
  30880. /**
  30881. * Gets the number of facets in the mesh
  30882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30883. */
  30884. get facetNb(): number;
  30885. /**
  30886. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30888. */
  30889. get partitioningSubdivisions(): number;
  30890. set partitioningSubdivisions(nb: number);
  30891. /**
  30892. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30893. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30895. */
  30896. get partitioningBBoxRatio(): number;
  30897. set partitioningBBoxRatio(ratio: number);
  30898. /**
  30899. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30900. * Works only for updatable meshes.
  30901. * Doesn't work with multi-materials
  30902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30903. */
  30904. get mustDepthSortFacets(): boolean;
  30905. set mustDepthSortFacets(sort: boolean);
  30906. /**
  30907. * The location (Vector3) where the facet depth sort must be computed from.
  30908. * By default, the active camera position.
  30909. * Used only when facet depth sort is enabled
  30910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30911. */
  30912. get facetDepthSortFrom(): Vector3;
  30913. set facetDepthSortFrom(location: Vector3);
  30914. /**
  30915. * gets a boolean indicating if facetData is enabled
  30916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30917. */
  30918. get isFacetDataEnabled(): boolean;
  30919. /** @hidden */
  30920. _updateNonUniformScalingState(value: boolean): boolean;
  30921. /**
  30922. * An event triggered when this mesh collides with another one
  30923. */
  30924. onCollideObservable: Observable<AbstractMesh>;
  30925. /** Set a function to call when this mesh collides with another one */
  30926. set onCollide(callback: () => void);
  30927. /**
  30928. * An event triggered when the collision's position changes
  30929. */
  30930. onCollisionPositionChangeObservable: Observable<Vector3>;
  30931. /** Set a function to call when the collision's position changes */
  30932. set onCollisionPositionChange(callback: () => void);
  30933. /**
  30934. * An event triggered when material is changed
  30935. */
  30936. onMaterialChangedObservable: Observable<AbstractMesh>;
  30937. /**
  30938. * Gets or sets the orientation for POV movement & rotation
  30939. */
  30940. definedFacingForward: boolean;
  30941. /** @hidden */
  30942. _occlusionQuery: Nullable<WebGLQuery>;
  30943. /** @hidden */
  30944. _renderingGroup: Nullable<RenderingGroup>;
  30945. /**
  30946. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30947. */
  30948. get visibility(): number;
  30949. /**
  30950. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30951. */
  30952. set visibility(value: number);
  30953. /** Gets or sets the alpha index used to sort transparent meshes
  30954. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30955. */
  30956. alphaIndex: number;
  30957. /**
  30958. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30959. */
  30960. isVisible: boolean;
  30961. /**
  30962. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30963. */
  30964. isPickable: boolean;
  30965. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30966. showSubMeshesBoundingBox: boolean;
  30967. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30968. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30969. */
  30970. isBlocker: boolean;
  30971. /**
  30972. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30973. */
  30974. enablePointerMoveEvents: boolean;
  30975. /**
  30976. * Specifies the rendering group id for this mesh (0 by default)
  30977. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30978. */
  30979. renderingGroupId: number;
  30980. private _material;
  30981. /** Gets or sets current material */
  30982. get material(): Nullable<Material>;
  30983. set material(value: Nullable<Material>);
  30984. /**
  30985. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30986. * @see http://doc.babylonjs.com/babylon101/shadows
  30987. */
  30988. get receiveShadows(): boolean;
  30989. set receiveShadows(value: boolean);
  30990. /** Defines color to use when rendering outline */
  30991. outlineColor: Color3;
  30992. /** Define width to use when rendering outline */
  30993. outlineWidth: number;
  30994. /** Defines color to use when rendering overlay */
  30995. overlayColor: Color3;
  30996. /** Defines alpha to use when rendering overlay */
  30997. overlayAlpha: number;
  30998. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  30999. get hasVertexAlpha(): boolean;
  31000. set hasVertexAlpha(value: boolean);
  31001. /** 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) */
  31002. get useVertexColors(): boolean;
  31003. set useVertexColors(value: boolean);
  31004. /**
  31005. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31006. */
  31007. get computeBonesUsingShaders(): boolean;
  31008. set computeBonesUsingShaders(value: boolean);
  31009. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31010. get numBoneInfluencers(): number;
  31011. set numBoneInfluencers(value: number);
  31012. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31013. get applyFog(): boolean;
  31014. set applyFog(value: boolean);
  31015. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31016. useOctreeForRenderingSelection: boolean;
  31017. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31018. useOctreeForPicking: boolean;
  31019. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31020. useOctreeForCollisions: boolean;
  31021. /**
  31022. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31023. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31024. */
  31025. get layerMask(): number;
  31026. set layerMask(value: number);
  31027. /**
  31028. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31029. */
  31030. alwaysSelectAsActiveMesh: boolean;
  31031. /**
  31032. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31033. */
  31034. doNotSyncBoundingInfo: boolean;
  31035. /**
  31036. * Gets or sets the current action manager
  31037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31038. */
  31039. actionManager: Nullable<AbstractActionManager>;
  31040. private _meshCollisionData;
  31041. /**
  31042. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31044. */
  31045. ellipsoid: Vector3;
  31046. /**
  31047. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31049. */
  31050. ellipsoidOffset: Vector3;
  31051. /**
  31052. * Gets or sets a collision mask used to mask collisions (default is -1).
  31053. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31054. */
  31055. get collisionMask(): number;
  31056. set collisionMask(mask: number);
  31057. /**
  31058. * Gets or sets the current collision group mask (-1 by default).
  31059. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31060. */
  31061. get collisionGroup(): number;
  31062. set collisionGroup(mask: number);
  31063. /**
  31064. * Gets or sets current surrounding meshes (null by default).
  31065. *
  31066. * By default collision detection is tested against every mesh in the scene.
  31067. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31068. * meshes will be tested for the collision.
  31069. *
  31070. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31071. */
  31072. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31073. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31074. /**
  31075. * Defines edge width used when edgesRenderer is enabled
  31076. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31077. */
  31078. edgesWidth: number;
  31079. /**
  31080. * Defines edge color used when edgesRenderer is enabled
  31081. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31082. */
  31083. edgesColor: Color4;
  31084. /** @hidden */
  31085. _edgesRenderer: Nullable<IEdgesRenderer>;
  31086. /** @hidden */
  31087. _masterMesh: Nullable<AbstractMesh>;
  31088. /** @hidden */
  31089. _boundingInfo: Nullable<BoundingInfo>;
  31090. /** @hidden */
  31091. _renderId: number;
  31092. /**
  31093. * Gets or sets the list of subMeshes
  31094. * @see http://doc.babylonjs.com/how_to/multi_materials
  31095. */
  31096. subMeshes: SubMesh[];
  31097. /** @hidden */
  31098. _intersectionsInProgress: AbstractMesh[];
  31099. /** @hidden */
  31100. _unIndexed: boolean;
  31101. /** @hidden */
  31102. _lightSources: Light[];
  31103. /** Gets the list of lights affecting that mesh */
  31104. get lightSources(): Light[];
  31105. /** @hidden */
  31106. get _positions(): Nullable<Vector3[]>;
  31107. /** @hidden */
  31108. _waitingData: {
  31109. lods: Nullable<any>;
  31110. actions: Nullable<any>;
  31111. freezeWorldMatrix: Nullable<boolean>;
  31112. };
  31113. /** @hidden */
  31114. _bonesTransformMatrices: Nullable<Float32Array>;
  31115. /** @hidden */
  31116. _transformMatrixTexture: Nullable<RawTexture>;
  31117. /**
  31118. * Gets or sets a skeleton to apply skining transformations
  31119. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31120. */
  31121. set skeleton(value: Nullable<Skeleton>);
  31122. get skeleton(): Nullable<Skeleton>;
  31123. /**
  31124. * An event triggered when the mesh is rebuilt.
  31125. */
  31126. onRebuildObservable: Observable<AbstractMesh>;
  31127. /**
  31128. * Creates a new AbstractMesh
  31129. * @param name defines the name of the mesh
  31130. * @param scene defines the hosting scene
  31131. */
  31132. constructor(name: string, scene?: Nullable<Scene>);
  31133. /**
  31134. * Returns the string "AbstractMesh"
  31135. * @returns "AbstractMesh"
  31136. */
  31137. getClassName(): string;
  31138. /**
  31139. * Gets a string representation of the current mesh
  31140. * @param fullDetails defines a boolean indicating if full details must be included
  31141. * @returns a string representation of the current mesh
  31142. */
  31143. toString(fullDetails?: boolean): string;
  31144. /**
  31145. * @hidden
  31146. */
  31147. protected _getEffectiveParent(): Nullable<Node>;
  31148. /** @hidden */
  31149. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31150. /** @hidden */
  31151. _rebuild(): void;
  31152. /** @hidden */
  31153. _resyncLightSources(): void;
  31154. /** @hidden */
  31155. _resyncLightSource(light: Light): void;
  31156. /** @hidden */
  31157. _unBindEffect(): void;
  31158. /** @hidden */
  31159. _removeLightSource(light: Light, dispose: boolean): void;
  31160. private _markSubMeshesAsDirty;
  31161. /** @hidden */
  31162. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31163. /** @hidden */
  31164. _markSubMeshesAsAttributesDirty(): void;
  31165. /** @hidden */
  31166. _markSubMeshesAsMiscDirty(): void;
  31167. /**
  31168. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31169. */
  31170. get scaling(): Vector3;
  31171. set scaling(newScaling: Vector3);
  31172. /**
  31173. * Returns true if the mesh is blocked. Implemented by child classes
  31174. */
  31175. get isBlocked(): boolean;
  31176. /**
  31177. * Returns the mesh itself by default. Implemented by child classes
  31178. * @param camera defines the camera to use to pick the right LOD level
  31179. * @returns the currentAbstractMesh
  31180. */
  31181. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31182. /**
  31183. * Returns 0 by default. Implemented by child classes
  31184. * @returns an integer
  31185. */
  31186. getTotalVertices(): number;
  31187. /**
  31188. * Returns a positive integer : the total number of indices in this mesh geometry.
  31189. * @returns the numner of indices or zero if the mesh has no geometry.
  31190. */
  31191. getTotalIndices(): number;
  31192. /**
  31193. * Returns null by default. Implemented by child classes
  31194. * @returns null
  31195. */
  31196. getIndices(): Nullable<IndicesArray>;
  31197. /**
  31198. * Returns the array of the requested vertex data kind. Implemented by child classes
  31199. * @param kind defines the vertex data kind to use
  31200. * @returns null
  31201. */
  31202. getVerticesData(kind: string): Nullable<FloatArray>;
  31203. /**
  31204. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31205. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31206. * Note that a new underlying VertexBuffer object is created each call.
  31207. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31208. * @param kind defines vertex data kind:
  31209. * * VertexBuffer.PositionKind
  31210. * * VertexBuffer.UVKind
  31211. * * VertexBuffer.UV2Kind
  31212. * * VertexBuffer.UV3Kind
  31213. * * VertexBuffer.UV4Kind
  31214. * * VertexBuffer.UV5Kind
  31215. * * VertexBuffer.UV6Kind
  31216. * * VertexBuffer.ColorKind
  31217. * * VertexBuffer.MatricesIndicesKind
  31218. * * VertexBuffer.MatricesIndicesExtraKind
  31219. * * VertexBuffer.MatricesWeightsKind
  31220. * * VertexBuffer.MatricesWeightsExtraKind
  31221. * @param data defines the data source
  31222. * @param updatable defines if the data must be flagged as updatable (or static)
  31223. * @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
  31224. * @returns the current mesh
  31225. */
  31226. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31227. /**
  31228. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31229. * If the mesh has no geometry, it is simply returned as it is.
  31230. * @param kind defines vertex data kind:
  31231. * * VertexBuffer.PositionKind
  31232. * * VertexBuffer.UVKind
  31233. * * VertexBuffer.UV2Kind
  31234. * * VertexBuffer.UV3Kind
  31235. * * VertexBuffer.UV4Kind
  31236. * * VertexBuffer.UV5Kind
  31237. * * VertexBuffer.UV6Kind
  31238. * * VertexBuffer.ColorKind
  31239. * * VertexBuffer.MatricesIndicesKind
  31240. * * VertexBuffer.MatricesIndicesExtraKind
  31241. * * VertexBuffer.MatricesWeightsKind
  31242. * * VertexBuffer.MatricesWeightsExtraKind
  31243. * @param data defines the data source
  31244. * @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
  31245. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31246. * @returns the current mesh
  31247. */
  31248. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31249. /**
  31250. * Sets the mesh indices,
  31251. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31252. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31253. * @param totalVertices Defines the total number of vertices
  31254. * @returns the current mesh
  31255. */
  31256. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31257. /**
  31258. * Gets a boolean indicating if specific vertex data is present
  31259. * @param kind defines the vertex data kind to use
  31260. * @returns true is data kind is present
  31261. */
  31262. isVerticesDataPresent(kind: string): boolean;
  31263. /**
  31264. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31265. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31266. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31267. * @returns a BoundingInfo
  31268. */
  31269. getBoundingInfo(): BoundingInfo;
  31270. /**
  31271. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31272. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31273. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31274. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31275. * @returns the current mesh
  31276. */
  31277. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31278. /**
  31279. * Overwrite the current bounding info
  31280. * @param boundingInfo defines the new bounding info
  31281. * @returns the current mesh
  31282. */
  31283. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31284. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31285. get useBones(): boolean;
  31286. /** @hidden */
  31287. _preActivate(): void;
  31288. /** @hidden */
  31289. _preActivateForIntermediateRendering(renderId: number): void;
  31290. /** @hidden */
  31291. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31292. /** @hidden */
  31293. _postActivate(): void;
  31294. /** @hidden */
  31295. _freeze(): void;
  31296. /** @hidden */
  31297. _unFreeze(): void;
  31298. /**
  31299. * Gets the current world matrix
  31300. * @returns a Matrix
  31301. */
  31302. getWorldMatrix(): Matrix;
  31303. /** @hidden */
  31304. _getWorldMatrixDeterminant(): number;
  31305. /**
  31306. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31307. */
  31308. get isAnInstance(): boolean;
  31309. /**
  31310. * Gets a boolean indicating if this mesh has instances
  31311. */
  31312. get hasInstances(): boolean;
  31313. /**
  31314. * Perform relative position change from the point of view of behind the front of the mesh.
  31315. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31316. * Supports definition of mesh facing forward or backward
  31317. * @param amountRight defines the distance on the right axis
  31318. * @param amountUp defines the distance on the up axis
  31319. * @param amountForward defines the distance on the forward axis
  31320. * @returns the current mesh
  31321. */
  31322. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31323. /**
  31324. * Calculate relative position change from the point of view of behind the front of the mesh.
  31325. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31326. * Supports definition of mesh facing forward or backward
  31327. * @param amountRight defines the distance on the right axis
  31328. * @param amountUp defines the distance on the up axis
  31329. * @param amountForward defines the distance on the forward axis
  31330. * @returns the new displacement vector
  31331. */
  31332. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31333. /**
  31334. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31335. * Supports definition of mesh facing forward or backward
  31336. * @param flipBack defines the flip
  31337. * @param twirlClockwise defines the twirl
  31338. * @param tiltRight defines the tilt
  31339. * @returns the current mesh
  31340. */
  31341. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31342. /**
  31343. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31344. * Supports definition of mesh facing forward or backward.
  31345. * @param flipBack defines the flip
  31346. * @param twirlClockwise defines the twirl
  31347. * @param tiltRight defines the tilt
  31348. * @returns the new rotation vector
  31349. */
  31350. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31351. /**
  31352. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31353. * This means the mesh underlying bounding box and sphere are recomputed.
  31354. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31355. * @returns the current mesh
  31356. */
  31357. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31358. /** @hidden */
  31359. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31360. /** @hidden */
  31361. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31362. /** @hidden */
  31363. _updateBoundingInfo(): AbstractMesh;
  31364. /** @hidden */
  31365. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31366. /** @hidden */
  31367. protected _afterComputeWorldMatrix(): void;
  31368. /** @hidden */
  31369. get _effectiveMesh(): AbstractMesh;
  31370. /**
  31371. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31372. * A mesh is in the frustum if its bounding box intersects the frustum
  31373. * @param frustumPlanes defines the frustum to test
  31374. * @returns true if the mesh is in the frustum planes
  31375. */
  31376. isInFrustum(frustumPlanes: Plane[]): boolean;
  31377. /**
  31378. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31379. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31380. * @param frustumPlanes defines the frustum to test
  31381. * @returns true if the mesh is completely in the frustum planes
  31382. */
  31383. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31384. /**
  31385. * True if the mesh intersects another mesh or a SolidParticle object
  31386. * @param mesh defines a target mesh or SolidParticle to test
  31387. * @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)
  31388. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31389. * @returns true if there is an intersection
  31390. */
  31391. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31392. /**
  31393. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31394. * @param point defines the point to test
  31395. * @returns true if there is an intersection
  31396. */
  31397. intersectsPoint(point: Vector3): boolean;
  31398. /**
  31399. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31400. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31401. */
  31402. get checkCollisions(): boolean;
  31403. set checkCollisions(collisionEnabled: boolean);
  31404. /**
  31405. * Gets Collider object used to compute collisions (not physics)
  31406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31407. */
  31408. get collider(): Nullable<Collider>;
  31409. /**
  31410. * Move the mesh using collision engine
  31411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31412. * @param displacement defines the requested displacement vector
  31413. * @returns the current mesh
  31414. */
  31415. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31416. private _onCollisionPositionChange;
  31417. /** @hidden */
  31418. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31419. /** @hidden */
  31420. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31421. /** @hidden */
  31422. _checkCollision(collider: Collider): AbstractMesh;
  31423. /** @hidden */
  31424. _generatePointsArray(): boolean;
  31425. /**
  31426. * Checks if the passed Ray intersects with the mesh
  31427. * @param ray defines the ray to use
  31428. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31429. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31430. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31431. * @returns the picking info
  31432. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31433. */
  31434. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31435. /**
  31436. * Clones the current mesh
  31437. * @param name defines the mesh name
  31438. * @param newParent defines the new mesh parent
  31439. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31440. * @returns the new mesh
  31441. */
  31442. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31443. /**
  31444. * Disposes all the submeshes of the current meshnp
  31445. * @returns the current mesh
  31446. */
  31447. releaseSubMeshes(): AbstractMesh;
  31448. /**
  31449. * Releases resources associated with this abstract mesh.
  31450. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31451. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31452. */
  31453. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31454. /**
  31455. * Adds the passed mesh as a child to the current mesh
  31456. * @param mesh defines the child mesh
  31457. * @returns the current mesh
  31458. */
  31459. addChild(mesh: AbstractMesh): AbstractMesh;
  31460. /**
  31461. * Removes the passed mesh from the current mesh children list
  31462. * @param mesh defines the child mesh
  31463. * @returns the current mesh
  31464. */
  31465. removeChild(mesh: AbstractMesh): AbstractMesh;
  31466. /** @hidden */
  31467. private _initFacetData;
  31468. /**
  31469. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31470. * This method can be called within the render loop.
  31471. * 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
  31472. * @returns the current mesh
  31473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31474. */
  31475. updateFacetData(): AbstractMesh;
  31476. /**
  31477. * Returns the facetLocalNormals array.
  31478. * The normals are expressed in the mesh local spac
  31479. * @returns an array of Vector3
  31480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31481. */
  31482. getFacetLocalNormals(): Vector3[];
  31483. /**
  31484. * Returns the facetLocalPositions array.
  31485. * The facet positions are expressed in the mesh local space
  31486. * @returns an array of Vector3
  31487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31488. */
  31489. getFacetLocalPositions(): Vector3[];
  31490. /**
  31491. * Returns the facetLocalPartioning array
  31492. * @returns an array of array of numbers
  31493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31494. */
  31495. getFacetLocalPartitioning(): number[][];
  31496. /**
  31497. * Returns the i-th facet position in the world system.
  31498. * This method allocates a new Vector3 per call
  31499. * @param i defines the facet index
  31500. * @returns a new Vector3
  31501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31502. */
  31503. getFacetPosition(i: number): Vector3;
  31504. /**
  31505. * Sets the reference Vector3 with the i-th facet position in the world system
  31506. * @param i defines the facet index
  31507. * @param ref defines the target vector
  31508. * @returns the current mesh
  31509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31510. */
  31511. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31512. /**
  31513. * Returns the i-th facet normal in the world system.
  31514. * This method allocates a new Vector3 per call
  31515. * @param i defines the facet index
  31516. * @returns a new Vector3
  31517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31518. */
  31519. getFacetNormal(i: number): Vector3;
  31520. /**
  31521. * Sets the reference Vector3 with the i-th facet normal in the world system
  31522. * @param i defines the facet index
  31523. * @param ref defines the target vector
  31524. * @returns the current mesh
  31525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31526. */
  31527. getFacetNormalToRef(i: number, ref: Vector3): this;
  31528. /**
  31529. * 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)
  31530. * @param x defines x coordinate
  31531. * @param y defines y coordinate
  31532. * @param z defines z coordinate
  31533. * @returns the array of facet indexes
  31534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31535. */
  31536. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31537. /**
  31538. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31539. * @param projected sets as the (x,y,z) world projection on the facet
  31540. * @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
  31541. * @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
  31542. * @param x defines x coordinate
  31543. * @param y defines y coordinate
  31544. * @param z defines z coordinate
  31545. * @returns the face index if found (or null instead)
  31546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31547. */
  31548. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31549. /**
  31550. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31551. * @param projected sets as the (x,y,z) local projection on the facet
  31552. * @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
  31553. * @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
  31554. * @param x defines x coordinate
  31555. * @param y defines y coordinate
  31556. * @param z defines z coordinate
  31557. * @returns the face index if found (or null instead)
  31558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31559. */
  31560. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31561. /**
  31562. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31563. * @returns the parameters
  31564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31565. */
  31566. getFacetDataParameters(): any;
  31567. /**
  31568. * Disables the feature FacetData and frees the related memory
  31569. * @returns the current mesh
  31570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31571. */
  31572. disableFacetData(): AbstractMesh;
  31573. /**
  31574. * Updates the AbstractMesh indices array
  31575. * @param indices defines the data source
  31576. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31577. * @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)
  31578. * @returns the current mesh
  31579. */
  31580. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31581. /**
  31582. * Creates new normals data for the mesh
  31583. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31584. * @returns the current mesh
  31585. */
  31586. createNormals(updatable: boolean): AbstractMesh;
  31587. /**
  31588. * Align the mesh with a normal
  31589. * @param normal defines the normal to use
  31590. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31591. * @returns the current mesh
  31592. */
  31593. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31594. /** @hidden */
  31595. _checkOcclusionQuery(): boolean;
  31596. /**
  31597. * Disables the mesh edge rendering mode
  31598. * @returns the currentAbstractMesh
  31599. */
  31600. disableEdgesRendering(): AbstractMesh;
  31601. /**
  31602. * Enables the edge rendering mode on the mesh.
  31603. * This mode makes the mesh edges visible
  31604. * @param epsilon defines the maximal distance between two angles to detect a face
  31605. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31606. * @returns the currentAbstractMesh
  31607. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31608. */
  31609. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31610. }
  31611. }
  31612. declare module BABYLON {
  31613. /**
  31614. * Interface used to define ActionEvent
  31615. */
  31616. export interface IActionEvent {
  31617. /** The mesh or sprite that triggered the action */
  31618. source: any;
  31619. /** The X mouse cursor position at the time of the event */
  31620. pointerX: number;
  31621. /** The Y mouse cursor position at the time of the event */
  31622. pointerY: number;
  31623. /** The mesh that is currently pointed at (can be null) */
  31624. meshUnderPointer: Nullable<AbstractMesh>;
  31625. /** the original (browser) event that triggered the ActionEvent */
  31626. sourceEvent?: any;
  31627. /** additional data for the event */
  31628. additionalData?: any;
  31629. }
  31630. /**
  31631. * ActionEvent is the event being sent when an action is triggered.
  31632. */
  31633. export class ActionEvent implements IActionEvent {
  31634. /** The mesh or sprite that triggered the action */
  31635. source: any;
  31636. /** The X mouse cursor position at the time of the event */
  31637. pointerX: number;
  31638. /** The Y mouse cursor position at the time of the event */
  31639. pointerY: number;
  31640. /** The mesh that is currently pointed at (can be null) */
  31641. meshUnderPointer: Nullable<AbstractMesh>;
  31642. /** the original (browser) event that triggered the ActionEvent */
  31643. sourceEvent?: any;
  31644. /** additional data for the event */
  31645. additionalData?: any;
  31646. /**
  31647. * Creates a new ActionEvent
  31648. * @param source The mesh or sprite that triggered the action
  31649. * @param pointerX The X mouse cursor position at the time of the event
  31650. * @param pointerY The Y mouse cursor position at the time of the event
  31651. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31652. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31653. * @param additionalData additional data for the event
  31654. */
  31655. constructor(
  31656. /** The mesh or sprite that triggered the action */
  31657. source: any,
  31658. /** The X mouse cursor position at the time of the event */
  31659. pointerX: number,
  31660. /** The Y mouse cursor position at the time of the event */
  31661. pointerY: number,
  31662. /** The mesh that is currently pointed at (can be null) */
  31663. meshUnderPointer: Nullable<AbstractMesh>,
  31664. /** the original (browser) event that triggered the ActionEvent */
  31665. sourceEvent?: any,
  31666. /** additional data for the event */
  31667. additionalData?: any);
  31668. /**
  31669. * Helper function to auto-create an ActionEvent from a source mesh.
  31670. * @param source The source mesh that triggered the event
  31671. * @param evt The original (browser) event
  31672. * @param additionalData additional data for the event
  31673. * @returns the new ActionEvent
  31674. */
  31675. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31676. /**
  31677. * Helper function to auto-create an ActionEvent from a source sprite
  31678. * @param source The source sprite that triggered the event
  31679. * @param scene Scene associated with the sprite
  31680. * @param evt The original (browser) event
  31681. * @param additionalData additional data for the event
  31682. * @returns the new ActionEvent
  31683. */
  31684. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31685. /**
  31686. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31687. * @param scene the scene where the event occurred
  31688. * @param evt The original (browser) event
  31689. * @returns the new ActionEvent
  31690. */
  31691. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31692. /**
  31693. * Helper function to auto-create an ActionEvent from a primitive
  31694. * @param prim defines the target primitive
  31695. * @param pointerPos defines the pointer position
  31696. * @param evt The original (browser) event
  31697. * @param additionalData additional data for the event
  31698. * @returns the new ActionEvent
  31699. */
  31700. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31701. }
  31702. }
  31703. declare module BABYLON {
  31704. /**
  31705. * Abstract class used to decouple action Manager from scene and meshes.
  31706. * Do not instantiate.
  31707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31708. */
  31709. export abstract class AbstractActionManager implements IDisposable {
  31710. /** Gets the list of active triggers */
  31711. static Triggers: {
  31712. [key: string]: number;
  31713. };
  31714. /** Gets the cursor to use when hovering items */
  31715. hoverCursor: string;
  31716. /** Gets the list of actions */
  31717. actions: IAction[];
  31718. /**
  31719. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31720. */
  31721. isRecursive: boolean;
  31722. /**
  31723. * Releases all associated resources
  31724. */
  31725. abstract dispose(): void;
  31726. /**
  31727. * Does this action manager has pointer triggers
  31728. */
  31729. abstract get hasPointerTriggers(): boolean;
  31730. /**
  31731. * Does this action manager has pick triggers
  31732. */
  31733. abstract get hasPickTriggers(): boolean;
  31734. /**
  31735. * Process a specific trigger
  31736. * @param trigger defines the trigger to process
  31737. * @param evt defines the event details to be processed
  31738. */
  31739. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31740. /**
  31741. * Does this action manager handles actions of any of the given triggers
  31742. * @param triggers defines the triggers to be tested
  31743. * @return a boolean indicating whether one (or more) of the triggers is handled
  31744. */
  31745. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31746. /**
  31747. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31748. * speed.
  31749. * @param triggerA defines the trigger to be tested
  31750. * @param triggerB defines the trigger to be tested
  31751. * @return a boolean indicating whether one (or more) of the triggers is handled
  31752. */
  31753. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31754. /**
  31755. * Does this action manager handles actions of a given trigger
  31756. * @param trigger defines the trigger to be tested
  31757. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31758. * @return whether the trigger is handled
  31759. */
  31760. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31761. /**
  31762. * Serialize this manager to a JSON object
  31763. * @param name defines the property name to store this manager
  31764. * @returns a JSON representation of this manager
  31765. */
  31766. abstract serialize(name: string): any;
  31767. /**
  31768. * Registers an action to this action manager
  31769. * @param action defines the action to be registered
  31770. * @return the action amended (prepared) after registration
  31771. */
  31772. abstract registerAction(action: IAction): Nullable<IAction>;
  31773. /**
  31774. * Unregisters an action to this action manager
  31775. * @param action defines the action to be unregistered
  31776. * @return a boolean indicating whether the action has been unregistered
  31777. */
  31778. abstract unregisterAction(action: IAction): Boolean;
  31779. /**
  31780. * Does exist one action manager with at least one trigger
  31781. **/
  31782. static get HasTriggers(): boolean;
  31783. /**
  31784. * Does exist one action manager with at least one pick trigger
  31785. **/
  31786. static get HasPickTriggers(): boolean;
  31787. /**
  31788. * Does exist one action manager that handles actions of a given trigger
  31789. * @param trigger defines the trigger to be tested
  31790. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31791. **/
  31792. static HasSpecificTrigger(trigger: number): boolean;
  31793. }
  31794. }
  31795. declare module BABYLON {
  31796. /**
  31797. * Defines how a node can be built from a string name.
  31798. */
  31799. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31800. /**
  31801. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31802. */
  31803. export class Node implements IBehaviorAware<Node> {
  31804. /** @hidden */
  31805. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31806. private static _NodeConstructors;
  31807. /**
  31808. * Add a new node constructor
  31809. * @param type defines the type name of the node to construct
  31810. * @param constructorFunc defines the constructor function
  31811. */
  31812. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31813. /**
  31814. * Returns a node constructor based on type name
  31815. * @param type defines the type name
  31816. * @param name defines the new node name
  31817. * @param scene defines the hosting scene
  31818. * @param options defines optional options to transmit to constructors
  31819. * @returns the new constructor or null
  31820. */
  31821. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31822. /**
  31823. * Gets or sets the name of the node
  31824. */
  31825. name: string;
  31826. /**
  31827. * Gets or sets the id of the node
  31828. */
  31829. id: string;
  31830. /**
  31831. * Gets or sets the unique id of the node
  31832. */
  31833. uniqueId: number;
  31834. /**
  31835. * Gets or sets a string used to store user defined state for the node
  31836. */
  31837. state: string;
  31838. /**
  31839. * Gets or sets an object used to store user defined information for the node
  31840. */
  31841. metadata: any;
  31842. /**
  31843. * For internal use only. Please do not use.
  31844. */
  31845. reservedDataStore: any;
  31846. /**
  31847. * List of inspectable custom properties (used by the Inspector)
  31848. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31849. */
  31850. inspectableCustomProperties: IInspectable[];
  31851. private _doNotSerialize;
  31852. /**
  31853. * Gets or sets a boolean used to define if the node must be serialized
  31854. */
  31855. get doNotSerialize(): boolean;
  31856. set doNotSerialize(value: boolean);
  31857. /** @hidden */
  31858. _isDisposed: boolean;
  31859. /**
  31860. * Gets a list of Animations associated with the node
  31861. */
  31862. animations: Animation[];
  31863. protected _ranges: {
  31864. [name: string]: Nullable<AnimationRange>;
  31865. };
  31866. /**
  31867. * Callback raised when the node is ready to be used
  31868. */
  31869. onReady: Nullable<(node: Node) => void>;
  31870. private _isEnabled;
  31871. private _isParentEnabled;
  31872. private _isReady;
  31873. /** @hidden */
  31874. _currentRenderId: number;
  31875. private _parentUpdateId;
  31876. /** @hidden */
  31877. _childUpdateId: number;
  31878. /** @hidden */
  31879. _waitingParentId: Nullable<string>;
  31880. /** @hidden */
  31881. _scene: Scene;
  31882. /** @hidden */
  31883. _cache: any;
  31884. private _parentNode;
  31885. private _children;
  31886. /** @hidden */
  31887. _worldMatrix: Matrix;
  31888. /** @hidden */
  31889. _worldMatrixDeterminant: number;
  31890. /** @hidden */
  31891. _worldMatrixDeterminantIsDirty: boolean;
  31892. /** @hidden */
  31893. private _sceneRootNodesIndex;
  31894. /**
  31895. * Gets a boolean indicating if the node has been disposed
  31896. * @returns true if the node was disposed
  31897. */
  31898. isDisposed(): boolean;
  31899. /**
  31900. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31901. * @see https://doc.babylonjs.com/how_to/parenting
  31902. */
  31903. set parent(parent: Nullable<Node>);
  31904. get parent(): Nullable<Node>;
  31905. /** @hidden */
  31906. _addToSceneRootNodes(): void;
  31907. /** @hidden */
  31908. _removeFromSceneRootNodes(): void;
  31909. private _animationPropertiesOverride;
  31910. /**
  31911. * Gets or sets the animation properties override
  31912. */
  31913. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31914. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31915. /**
  31916. * Gets a string idenfifying the name of the class
  31917. * @returns "Node" string
  31918. */
  31919. getClassName(): string;
  31920. /** @hidden */
  31921. readonly _isNode: boolean;
  31922. /**
  31923. * An event triggered when the mesh is disposed
  31924. */
  31925. onDisposeObservable: Observable<Node>;
  31926. private _onDisposeObserver;
  31927. /**
  31928. * Sets a callback that will be raised when the node will be disposed
  31929. */
  31930. set onDispose(callback: () => void);
  31931. /**
  31932. * Creates a new Node
  31933. * @param name the name and id to be given to this node
  31934. * @param scene the scene this node will be added to
  31935. */
  31936. constructor(name: string, scene?: Nullable<Scene>);
  31937. /**
  31938. * Gets the scene of the node
  31939. * @returns a scene
  31940. */
  31941. getScene(): Scene;
  31942. /**
  31943. * Gets the engine of the node
  31944. * @returns a Engine
  31945. */
  31946. getEngine(): Engine;
  31947. private _behaviors;
  31948. /**
  31949. * Attach a behavior to the node
  31950. * @see http://doc.babylonjs.com/features/behaviour
  31951. * @param behavior defines the behavior to attach
  31952. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31953. * @returns the current Node
  31954. */
  31955. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31956. /**
  31957. * Remove an attached behavior
  31958. * @see http://doc.babylonjs.com/features/behaviour
  31959. * @param behavior defines the behavior to attach
  31960. * @returns the current Node
  31961. */
  31962. removeBehavior(behavior: Behavior<Node>): Node;
  31963. /**
  31964. * Gets the list of attached behaviors
  31965. * @see http://doc.babylonjs.com/features/behaviour
  31966. */
  31967. get behaviors(): Behavior<Node>[];
  31968. /**
  31969. * Gets an attached behavior by name
  31970. * @param name defines the name of the behavior to look for
  31971. * @see http://doc.babylonjs.com/features/behaviour
  31972. * @returns null if behavior was not found else the requested behavior
  31973. */
  31974. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31975. /**
  31976. * Returns the latest update of the World matrix
  31977. * @returns a Matrix
  31978. */
  31979. getWorldMatrix(): Matrix;
  31980. /** @hidden */
  31981. _getWorldMatrixDeterminant(): number;
  31982. /**
  31983. * Returns directly the latest state of the mesh World matrix.
  31984. * A Matrix is returned.
  31985. */
  31986. get worldMatrixFromCache(): Matrix;
  31987. /** @hidden */
  31988. _initCache(): void;
  31989. /** @hidden */
  31990. updateCache(force?: boolean): void;
  31991. /** @hidden */
  31992. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31993. /** @hidden */
  31994. _updateCache(ignoreParentClass?: boolean): void;
  31995. /** @hidden */
  31996. _isSynchronized(): boolean;
  31997. /** @hidden */
  31998. _markSyncedWithParent(): void;
  31999. /** @hidden */
  32000. isSynchronizedWithParent(): boolean;
  32001. /** @hidden */
  32002. isSynchronized(): boolean;
  32003. /**
  32004. * Is this node ready to be used/rendered
  32005. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32006. * @return true if the node is ready
  32007. */
  32008. isReady(completeCheck?: boolean): boolean;
  32009. /**
  32010. * Is this node enabled?
  32011. * 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
  32012. * @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
  32013. * @return whether this node (and its parent) is enabled
  32014. */
  32015. isEnabled(checkAncestors?: boolean): boolean;
  32016. /** @hidden */
  32017. protected _syncParentEnabledState(): void;
  32018. /**
  32019. * Set the enabled state of this node
  32020. * @param value defines the new enabled state
  32021. */
  32022. setEnabled(value: boolean): void;
  32023. /**
  32024. * Is this node a descendant of the given node?
  32025. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32026. * @param ancestor defines the parent node to inspect
  32027. * @returns a boolean indicating if this node is a descendant of the given node
  32028. */
  32029. isDescendantOf(ancestor: Node): boolean;
  32030. /** @hidden */
  32031. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32032. /**
  32033. * Will return all nodes that have this node as ascendant
  32034. * @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
  32035. * @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
  32036. * @return all children nodes of all types
  32037. */
  32038. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32039. /**
  32040. * Get all child-meshes of this node
  32041. * @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)
  32042. * @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
  32043. * @returns an array of AbstractMesh
  32044. */
  32045. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32046. /**
  32047. * Get all direct children of this node
  32048. * @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
  32049. * @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)
  32050. * @returns an array of Node
  32051. */
  32052. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32053. /** @hidden */
  32054. _setReady(state: boolean): void;
  32055. /**
  32056. * Get an animation by name
  32057. * @param name defines the name of the animation to look for
  32058. * @returns null if not found else the requested animation
  32059. */
  32060. getAnimationByName(name: string): Nullable<Animation>;
  32061. /**
  32062. * Creates an animation range for this node
  32063. * @param name defines the name of the range
  32064. * @param from defines the starting key
  32065. * @param to defines the end key
  32066. */
  32067. createAnimationRange(name: string, from: number, to: number): void;
  32068. /**
  32069. * Delete a specific animation range
  32070. * @param name defines the name of the range to delete
  32071. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32072. */
  32073. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32074. /**
  32075. * Get an animation range by name
  32076. * @param name defines the name of the animation range to look for
  32077. * @returns null if not found else the requested animation range
  32078. */
  32079. getAnimationRange(name: string): Nullable<AnimationRange>;
  32080. /**
  32081. * Gets the list of all animation ranges defined on this node
  32082. * @returns an array
  32083. */
  32084. getAnimationRanges(): Nullable<AnimationRange>[];
  32085. /**
  32086. * Will start the animation sequence
  32087. * @param name defines the range frames for animation sequence
  32088. * @param loop defines if the animation should loop (false by default)
  32089. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32090. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32091. * @returns the object created for this animation. If range does not exist, it will return null
  32092. */
  32093. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32094. /**
  32095. * Serialize animation ranges into a JSON compatible object
  32096. * @returns serialization object
  32097. */
  32098. serializeAnimationRanges(): any;
  32099. /**
  32100. * Computes the world matrix of the node
  32101. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32102. * @returns the world matrix
  32103. */
  32104. computeWorldMatrix(force?: boolean): Matrix;
  32105. /**
  32106. * Releases resources associated with this node.
  32107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32109. */
  32110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32111. /**
  32112. * Parse animation range data from a serialization object and store them into a given node
  32113. * @param node defines where to store the animation ranges
  32114. * @param parsedNode defines the serialization object to read data from
  32115. * @param scene defines the hosting scene
  32116. */
  32117. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32118. /**
  32119. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32120. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32121. * @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
  32122. * @returns the new bounding vectors
  32123. */
  32124. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32125. min: Vector3;
  32126. max: Vector3;
  32127. };
  32128. }
  32129. }
  32130. declare module BABYLON {
  32131. /**
  32132. * @hidden
  32133. */
  32134. export class _IAnimationState {
  32135. key: number;
  32136. repeatCount: number;
  32137. workValue?: any;
  32138. loopMode?: number;
  32139. offsetValue?: any;
  32140. highLimitValue?: any;
  32141. }
  32142. /**
  32143. * Class used to store any kind of animation
  32144. */
  32145. export class Animation {
  32146. /**Name of the animation */
  32147. name: string;
  32148. /**Property to animate */
  32149. targetProperty: string;
  32150. /**The frames per second of the animation */
  32151. framePerSecond: number;
  32152. /**The data type of the animation */
  32153. dataType: number;
  32154. /**The loop mode of the animation */
  32155. loopMode?: number | undefined;
  32156. /**Specifies if blending should be enabled */
  32157. enableBlending?: boolean | undefined;
  32158. /**
  32159. * Use matrix interpolation instead of using direct key value when animating matrices
  32160. */
  32161. static AllowMatricesInterpolation: boolean;
  32162. /**
  32163. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32164. */
  32165. static AllowMatrixDecomposeForInterpolation: boolean;
  32166. /**
  32167. * Stores the key frames of the animation
  32168. */
  32169. private _keys;
  32170. /**
  32171. * Stores the easing function of the animation
  32172. */
  32173. private _easingFunction;
  32174. /**
  32175. * @hidden Internal use only
  32176. */
  32177. _runtimeAnimations: RuntimeAnimation[];
  32178. /**
  32179. * The set of event that will be linked to this animation
  32180. */
  32181. private _events;
  32182. /**
  32183. * Stores an array of target property paths
  32184. */
  32185. targetPropertyPath: string[];
  32186. /**
  32187. * Stores the blending speed of the animation
  32188. */
  32189. blendingSpeed: number;
  32190. /**
  32191. * Stores the animation ranges for the animation
  32192. */
  32193. private _ranges;
  32194. /**
  32195. * @hidden Internal use
  32196. */
  32197. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32198. /**
  32199. * Sets up an animation
  32200. * @param property The property to animate
  32201. * @param animationType The animation type to apply
  32202. * @param framePerSecond The frames per second of the animation
  32203. * @param easingFunction The easing function used in the animation
  32204. * @returns The created animation
  32205. */
  32206. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32207. /**
  32208. * Create and start an animation on a node
  32209. * @param name defines the name of the global animation that will be run on all nodes
  32210. * @param node defines the root node where the animation will take place
  32211. * @param targetProperty defines property to animate
  32212. * @param framePerSecond defines the number of frame per second yo use
  32213. * @param totalFrame defines the number of frames in total
  32214. * @param from defines the initial value
  32215. * @param to defines the final value
  32216. * @param loopMode defines which loop mode you want to use (off by default)
  32217. * @param easingFunction defines the easing function to use (linear by default)
  32218. * @param onAnimationEnd defines the callback to call when animation end
  32219. * @returns the animatable created for this animation
  32220. */
  32221. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32222. /**
  32223. * Create and start an animation on a node and its descendants
  32224. * @param name defines the name of the global animation that will be run on all nodes
  32225. * @param node defines the root node where the animation will take place
  32226. * @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
  32227. * @param targetProperty defines property to animate
  32228. * @param framePerSecond defines the number of frame per second to use
  32229. * @param totalFrame defines the number of frames in total
  32230. * @param from defines the initial value
  32231. * @param to defines the final value
  32232. * @param loopMode defines which loop mode you want to use (off by default)
  32233. * @param easingFunction defines the easing function to use (linear by default)
  32234. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32235. * @returns the list of animatables created for all nodes
  32236. * @example https://www.babylonjs-playground.com/#MH0VLI
  32237. */
  32238. 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[]>;
  32239. /**
  32240. * Creates a new animation, merges it with the existing animations and starts it
  32241. * @param name Name of the animation
  32242. * @param node Node which contains the scene that begins the animations
  32243. * @param targetProperty Specifies which property to animate
  32244. * @param framePerSecond The frames per second of the animation
  32245. * @param totalFrame The total number of frames
  32246. * @param from The frame at the beginning of the animation
  32247. * @param to The frame at the end of the animation
  32248. * @param loopMode Specifies the loop mode of the animation
  32249. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32250. * @param onAnimationEnd Callback to run once the animation is complete
  32251. * @returns Nullable animation
  32252. */
  32253. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32254. /**
  32255. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32256. * @param sourceAnimation defines the Animation containing keyframes to convert
  32257. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32258. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32259. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32260. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32261. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32262. */
  32263. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32264. /**
  32265. * Transition property of an host to the target Value
  32266. * @param property The property to transition
  32267. * @param targetValue The target Value of the property
  32268. * @param host The object where the property to animate belongs
  32269. * @param scene Scene used to run the animation
  32270. * @param frameRate Framerate (in frame/s) to use
  32271. * @param transition The transition type we want to use
  32272. * @param duration The duration of the animation, in milliseconds
  32273. * @param onAnimationEnd Callback trigger at the end of the animation
  32274. * @returns Nullable animation
  32275. */
  32276. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32277. /**
  32278. * Return the array of runtime animations currently using this animation
  32279. */
  32280. get runtimeAnimations(): RuntimeAnimation[];
  32281. /**
  32282. * Specifies if any of the runtime animations are currently running
  32283. */
  32284. get hasRunningRuntimeAnimations(): boolean;
  32285. /**
  32286. * Initializes the animation
  32287. * @param name Name of the animation
  32288. * @param targetProperty Property to animate
  32289. * @param framePerSecond The frames per second of the animation
  32290. * @param dataType The data type of the animation
  32291. * @param loopMode The loop mode of the animation
  32292. * @param enableBlending Specifies if blending should be enabled
  32293. */
  32294. constructor(
  32295. /**Name of the animation */
  32296. name: string,
  32297. /**Property to animate */
  32298. targetProperty: string,
  32299. /**The frames per second of the animation */
  32300. framePerSecond: number,
  32301. /**The data type of the animation */
  32302. dataType: number,
  32303. /**The loop mode of the animation */
  32304. loopMode?: number | undefined,
  32305. /**Specifies if blending should be enabled */
  32306. enableBlending?: boolean | undefined);
  32307. /**
  32308. * Converts the animation to a string
  32309. * @param fullDetails support for multiple levels of logging within scene loading
  32310. * @returns String form of the animation
  32311. */
  32312. toString(fullDetails?: boolean): string;
  32313. /**
  32314. * Add an event to this animation
  32315. * @param event Event to add
  32316. */
  32317. addEvent(event: AnimationEvent): void;
  32318. /**
  32319. * Remove all events found at the given frame
  32320. * @param frame The frame to remove events from
  32321. */
  32322. removeEvents(frame: number): void;
  32323. /**
  32324. * Retrieves all the events from the animation
  32325. * @returns Events from the animation
  32326. */
  32327. getEvents(): AnimationEvent[];
  32328. /**
  32329. * Creates an animation range
  32330. * @param name Name of the animation range
  32331. * @param from Starting frame of the animation range
  32332. * @param to Ending frame of the animation
  32333. */
  32334. createRange(name: string, from: number, to: number): void;
  32335. /**
  32336. * Deletes an animation range by name
  32337. * @param name Name of the animation range to delete
  32338. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32339. */
  32340. deleteRange(name: string, deleteFrames?: boolean): void;
  32341. /**
  32342. * Gets the animation range by name, or null if not defined
  32343. * @param name Name of the animation range
  32344. * @returns Nullable animation range
  32345. */
  32346. getRange(name: string): Nullable<AnimationRange>;
  32347. /**
  32348. * Gets the key frames from the animation
  32349. * @returns The key frames of the animation
  32350. */
  32351. getKeys(): Array<IAnimationKey>;
  32352. /**
  32353. * Gets the highest frame rate of the animation
  32354. * @returns Highest frame rate of the animation
  32355. */
  32356. getHighestFrame(): number;
  32357. /**
  32358. * Gets the easing function of the animation
  32359. * @returns Easing function of the animation
  32360. */
  32361. getEasingFunction(): IEasingFunction;
  32362. /**
  32363. * Sets the easing function of the animation
  32364. * @param easingFunction A custom mathematical formula for animation
  32365. */
  32366. setEasingFunction(easingFunction: EasingFunction): void;
  32367. /**
  32368. * Interpolates a scalar linearly
  32369. * @param startValue Start value of the animation curve
  32370. * @param endValue End value of the animation curve
  32371. * @param gradient Scalar amount to interpolate
  32372. * @returns Interpolated scalar value
  32373. */
  32374. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32375. /**
  32376. * Interpolates a scalar cubically
  32377. * @param startValue Start value of the animation curve
  32378. * @param outTangent End tangent of the animation
  32379. * @param endValue End value of the animation curve
  32380. * @param inTangent Start tangent of the animation curve
  32381. * @param gradient Scalar amount to interpolate
  32382. * @returns Interpolated scalar value
  32383. */
  32384. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32385. /**
  32386. * Interpolates a quaternion using a spherical linear interpolation
  32387. * @param startValue Start value of the animation curve
  32388. * @param endValue End value of the animation curve
  32389. * @param gradient Scalar amount to interpolate
  32390. * @returns Interpolated quaternion value
  32391. */
  32392. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32393. /**
  32394. * Interpolates a quaternion cubically
  32395. * @param startValue Start value of the animation curve
  32396. * @param outTangent End tangent of the animation curve
  32397. * @param endValue End value of the animation curve
  32398. * @param inTangent Start tangent of the animation curve
  32399. * @param gradient Scalar amount to interpolate
  32400. * @returns Interpolated quaternion value
  32401. */
  32402. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32403. /**
  32404. * Interpolates a Vector3 linearl
  32405. * @param startValue Start value of the animation curve
  32406. * @param endValue End value of the animation curve
  32407. * @param gradient Scalar amount to interpolate
  32408. * @returns Interpolated scalar value
  32409. */
  32410. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32411. /**
  32412. * Interpolates a Vector3 cubically
  32413. * @param startValue Start value of the animation curve
  32414. * @param outTangent End tangent of the animation
  32415. * @param endValue End value of the animation curve
  32416. * @param inTangent Start tangent of the animation curve
  32417. * @param gradient Scalar amount to interpolate
  32418. * @returns InterpolatedVector3 value
  32419. */
  32420. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32421. /**
  32422. * Interpolates a Vector2 linearly
  32423. * @param startValue Start value of the animation curve
  32424. * @param endValue End value of the animation curve
  32425. * @param gradient Scalar amount to interpolate
  32426. * @returns Interpolated Vector2 value
  32427. */
  32428. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32429. /**
  32430. * Interpolates a Vector2 cubically
  32431. * @param startValue Start value of the animation curve
  32432. * @param outTangent End tangent of the animation
  32433. * @param endValue End value of the animation curve
  32434. * @param inTangent Start tangent of the animation curve
  32435. * @param gradient Scalar amount to interpolate
  32436. * @returns Interpolated Vector2 value
  32437. */
  32438. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32439. /**
  32440. * Interpolates a size linearly
  32441. * @param startValue Start value of the animation curve
  32442. * @param endValue End value of the animation curve
  32443. * @param gradient Scalar amount to interpolate
  32444. * @returns Interpolated Size value
  32445. */
  32446. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32447. /**
  32448. * Interpolates a Color3 linearly
  32449. * @param startValue Start value of the animation curve
  32450. * @param endValue End value of the animation curve
  32451. * @param gradient Scalar amount to interpolate
  32452. * @returns Interpolated Color3 value
  32453. */
  32454. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32455. /**
  32456. * Interpolates a Color4 linearly
  32457. * @param startValue Start value of the animation curve
  32458. * @param endValue End value of the animation curve
  32459. * @param gradient Scalar amount to interpolate
  32460. * @returns Interpolated Color3 value
  32461. */
  32462. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32463. /**
  32464. * @hidden Internal use only
  32465. */
  32466. _getKeyValue(value: any): any;
  32467. /**
  32468. * @hidden Internal use only
  32469. */
  32470. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32471. /**
  32472. * Defines the function to use to interpolate matrices
  32473. * @param startValue defines the start matrix
  32474. * @param endValue defines the end matrix
  32475. * @param gradient defines the gradient between both matrices
  32476. * @param result defines an optional target matrix where to store the interpolation
  32477. * @returns the interpolated matrix
  32478. */
  32479. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32480. /**
  32481. * Makes a copy of the animation
  32482. * @returns Cloned animation
  32483. */
  32484. clone(): Animation;
  32485. /**
  32486. * Sets the key frames of the animation
  32487. * @param values The animation key frames to set
  32488. */
  32489. setKeys(values: Array<IAnimationKey>): void;
  32490. /**
  32491. * Serializes the animation to an object
  32492. * @returns Serialized object
  32493. */
  32494. serialize(): any;
  32495. /**
  32496. * Float animation type
  32497. */
  32498. static readonly ANIMATIONTYPE_FLOAT: number;
  32499. /**
  32500. * Vector3 animation type
  32501. */
  32502. static readonly ANIMATIONTYPE_VECTOR3: number;
  32503. /**
  32504. * Quaternion animation type
  32505. */
  32506. static readonly ANIMATIONTYPE_QUATERNION: number;
  32507. /**
  32508. * Matrix animation type
  32509. */
  32510. static readonly ANIMATIONTYPE_MATRIX: number;
  32511. /**
  32512. * Color3 animation type
  32513. */
  32514. static readonly ANIMATIONTYPE_COLOR3: number;
  32515. /**
  32516. * Color3 animation type
  32517. */
  32518. static readonly ANIMATIONTYPE_COLOR4: number;
  32519. /**
  32520. * Vector2 animation type
  32521. */
  32522. static readonly ANIMATIONTYPE_VECTOR2: number;
  32523. /**
  32524. * Size animation type
  32525. */
  32526. static readonly ANIMATIONTYPE_SIZE: number;
  32527. /**
  32528. * Relative Loop Mode
  32529. */
  32530. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32531. /**
  32532. * Cycle Loop Mode
  32533. */
  32534. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32535. /**
  32536. * Constant Loop Mode
  32537. */
  32538. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32539. /** @hidden */
  32540. static _UniversalLerp(left: any, right: any, amount: number): any;
  32541. /**
  32542. * Parses an animation object and creates an animation
  32543. * @param parsedAnimation Parsed animation object
  32544. * @returns Animation object
  32545. */
  32546. static Parse(parsedAnimation: any): Animation;
  32547. /**
  32548. * Appends the serialized animations from the source animations
  32549. * @param source Source containing the animations
  32550. * @param destination Target to store the animations
  32551. */
  32552. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32553. }
  32554. }
  32555. declare module BABYLON {
  32556. /**
  32557. * Interface containing an array of animations
  32558. */
  32559. export interface IAnimatable {
  32560. /**
  32561. * Array of animations
  32562. */
  32563. animations: Nullable<Array<Animation>>;
  32564. }
  32565. }
  32566. declare module BABYLON {
  32567. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32568. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32569. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32570. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32571. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32572. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32573. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32574. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32575. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32576. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32577. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32578. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32579. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32580. /**
  32581. * Decorator used to define property that can be serialized as reference to a camera
  32582. * @param sourceName defines the name of the property to decorate
  32583. */
  32584. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32585. /**
  32586. * Class used to help serialization objects
  32587. */
  32588. export class SerializationHelper {
  32589. /** @hidden */
  32590. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32591. /** @hidden */
  32592. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32593. /** @hidden */
  32594. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32595. /** @hidden */
  32596. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32597. /**
  32598. * Appends the serialized animations from the source animations
  32599. * @param source Source containing the animations
  32600. * @param destination Target to store the animations
  32601. */
  32602. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32603. /**
  32604. * Static function used to serialized a specific entity
  32605. * @param entity defines the entity to serialize
  32606. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32607. * @returns a JSON compatible object representing the serialization of the entity
  32608. */
  32609. static Serialize<T>(entity: T, serializationObject?: any): any;
  32610. /**
  32611. * Creates a new entity from a serialization data object
  32612. * @param creationFunction defines a function used to instanciated the new entity
  32613. * @param source defines the source serialization data
  32614. * @param scene defines the hosting scene
  32615. * @param rootUrl defines the root url for resources
  32616. * @returns a new entity
  32617. */
  32618. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32619. /**
  32620. * Clones an object
  32621. * @param creationFunction defines the function used to instanciate the new object
  32622. * @param source defines the source object
  32623. * @returns the cloned object
  32624. */
  32625. static Clone<T>(creationFunction: () => T, source: T): T;
  32626. /**
  32627. * Instanciates a new object based on a source one (some data will be shared between both object)
  32628. * @param creationFunction defines the function used to instanciate the new object
  32629. * @param source defines the source object
  32630. * @returns the new object
  32631. */
  32632. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32633. }
  32634. }
  32635. declare module BABYLON {
  32636. /**
  32637. * Base class of all the textures in babylon.
  32638. * It groups all the common properties the materials, post process, lights... might need
  32639. * in order to make a correct use of the texture.
  32640. */
  32641. export class BaseTexture implements IAnimatable {
  32642. /**
  32643. * Default anisotropic filtering level for the application.
  32644. * It is set to 4 as a good tradeoff between perf and quality.
  32645. */
  32646. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32647. /**
  32648. * Gets or sets the unique id of the texture
  32649. */
  32650. uniqueId: number;
  32651. /**
  32652. * Define the name of the texture.
  32653. */
  32654. name: string;
  32655. /**
  32656. * Gets or sets an object used to store user defined information.
  32657. */
  32658. metadata: any;
  32659. /**
  32660. * For internal use only. Please do not use.
  32661. */
  32662. reservedDataStore: any;
  32663. private _hasAlpha;
  32664. /**
  32665. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32666. */
  32667. set hasAlpha(value: boolean);
  32668. get hasAlpha(): boolean;
  32669. /**
  32670. * Defines if the alpha value should be determined via the rgb values.
  32671. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32672. */
  32673. getAlphaFromRGB: boolean;
  32674. /**
  32675. * Intensity or strength of the texture.
  32676. * It is commonly used by materials to fine tune the intensity of the texture
  32677. */
  32678. level: number;
  32679. /**
  32680. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32681. * This is part of the texture as textures usually maps to one uv set.
  32682. */
  32683. coordinatesIndex: number;
  32684. private _coordinatesMode;
  32685. /**
  32686. * How a texture is mapped.
  32687. *
  32688. * | Value | Type | Description |
  32689. * | ----- | ----------------------------------- | ----------- |
  32690. * | 0 | EXPLICIT_MODE | |
  32691. * | 1 | SPHERICAL_MODE | |
  32692. * | 2 | PLANAR_MODE | |
  32693. * | 3 | CUBIC_MODE | |
  32694. * | 4 | PROJECTION_MODE | |
  32695. * | 5 | SKYBOX_MODE | |
  32696. * | 6 | INVCUBIC_MODE | |
  32697. * | 7 | EQUIRECTANGULAR_MODE | |
  32698. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32699. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32700. */
  32701. set coordinatesMode(value: number);
  32702. get coordinatesMode(): number;
  32703. /**
  32704. * | Value | Type | Description |
  32705. * | ----- | ------------------ | ----------- |
  32706. * | 0 | CLAMP_ADDRESSMODE | |
  32707. * | 1 | WRAP_ADDRESSMODE | |
  32708. * | 2 | MIRROR_ADDRESSMODE | |
  32709. */
  32710. wrapU: number;
  32711. /**
  32712. * | Value | Type | Description |
  32713. * | ----- | ------------------ | ----------- |
  32714. * | 0 | CLAMP_ADDRESSMODE | |
  32715. * | 1 | WRAP_ADDRESSMODE | |
  32716. * | 2 | MIRROR_ADDRESSMODE | |
  32717. */
  32718. wrapV: number;
  32719. /**
  32720. * | Value | Type | Description |
  32721. * | ----- | ------------------ | ----------- |
  32722. * | 0 | CLAMP_ADDRESSMODE | |
  32723. * | 1 | WRAP_ADDRESSMODE | |
  32724. * | 2 | MIRROR_ADDRESSMODE | |
  32725. */
  32726. wrapR: number;
  32727. /**
  32728. * With compliant hardware and browser (supporting anisotropic filtering)
  32729. * this defines the level of anisotropic filtering in the texture.
  32730. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32731. */
  32732. anisotropicFilteringLevel: number;
  32733. /**
  32734. * Define if the texture is a cube texture or if false a 2d texture.
  32735. */
  32736. get isCube(): boolean;
  32737. set isCube(value: boolean);
  32738. /**
  32739. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32740. */
  32741. get is3D(): boolean;
  32742. set is3D(value: boolean);
  32743. /**
  32744. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32745. */
  32746. get is2DArray(): boolean;
  32747. set is2DArray(value: boolean);
  32748. /**
  32749. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32750. * HDR texture are usually stored in linear space.
  32751. * This only impacts the PBR and Background materials
  32752. */
  32753. gammaSpace: boolean;
  32754. /**
  32755. * Gets or sets whether or not the texture contains RGBD data.
  32756. */
  32757. get isRGBD(): boolean;
  32758. set isRGBD(value: boolean);
  32759. /**
  32760. * Is Z inverted in the texture (useful in a cube texture).
  32761. */
  32762. invertZ: boolean;
  32763. /**
  32764. * Are mip maps generated for this texture or not.
  32765. */
  32766. get noMipmap(): boolean;
  32767. /**
  32768. * @hidden
  32769. */
  32770. lodLevelInAlpha: boolean;
  32771. /**
  32772. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32773. */
  32774. get lodGenerationOffset(): number;
  32775. set lodGenerationOffset(value: number);
  32776. /**
  32777. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32778. */
  32779. get lodGenerationScale(): number;
  32780. set lodGenerationScale(value: number);
  32781. /**
  32782. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32783. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32784. * average roughness values.
  32785. */
  32786. get linearSpecularLOD(): boolean;
  32787. set linearSpecularLOD(value: boolean);
  32788. /**
  32789. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32790. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32791. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32792. */
  32793. get irradianceTexture(): Nullable<BaseTexture>;
  32794. set irradianceTexture(value: Nullable<BaseTexture>);
  32795. /**
  32796. * Define if the texture is a render target.
  32797. */
  32798. isRenderTarget: boolean;
  32799. /**
  32800. * Define the unique id of the texture in the scene.
  32801. */
  32802. get uid(): string;
  32803. /** @hidden */
  32804. _prefiltered: boolean;
  32805. /**
  32806. * Return a string representation of the texture.
  32807. * @returns the texture as a string
  32808. */
  32809. toString(): string;
  32810. /**
  32811. * Get the class name of the texture.
  32812. * @returns "BaseTexture"
  32813. */
  32814. getClassName(): string;
  32815. /**
  32816. * Define the list of animation attached to the texture.
  32817. */
  32818. animations: Animation[];
  32819. /**
  32820. * An event triggered when the texture is disposed.
  32821. */
  32822. onDisposeObservable: Observable<BaseTexture>;
  32823. private _onDisposeObserver;
  32824. /**
  32825. * Callback triggered when the texture has been disposed.
  32826. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32827. */
  32828. set onDispose(callback: () => void);
  32829. /**
  32830. * Define the current state of the loading sequence when in delayed load mode.
  32831. */
  32832. delayLoadState: number;
  32833. private _scene;
  32834. private _engine;
  32835. /** @hidden */
  32836. _texture: Nullable<InternalTexture>;
  32837. private _uid;
  32838. /**
  32839. * Define if the texture is preventinga material to render or not.
  32840. * If not and the texture is not ready, the engine will use a default black texture instead.
  32841. */
  32842. get isBlocking(): boolean;
  32843. /**
  32844. * Instantiates a new BaseTexture.
  32845. * Base class of all the textures in babylon.
  32846. * It groups all the common properties the materials, post process, lights... might need
  32847. * in order to make a correct use of the texture.
  32848. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32849. */
  32850. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32851. /**
  32852. * Get the scene the texture belongs to.
  32853. * @returns the scene or null if undefined
  32854. */
  32855. getScene(): Nullable<Scene>;
  32856. /** @hidden */
  32857. protected _getEngine(): Nullable<ThinEngine>;
  32858. /**
  32859. * Get the texture transform matrix used to offset tile the texture for istance.
  32860. * @returns the transformation matrix
  32861. */
  32862. getTextureMatrix(): Matrix;
  32863. /**
  32864. * Get the texture reflection matrix used to rotate/transform the reflection.
  32865. * @returns the reflection matrix
  32866. */
  32867. getReflectionTextureMatrix(): Matrix;
  32868. /**
  32869. * Get the underlying lower level texture from Babylon.
  32870. * @returns the insternal texture
  32871. */
  32872. getInternalTexture(): Nullable<InternalTexture>;
  32873. /**
  32874. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32875. * @returns true if ready or not blocking
  32876. */
  32877. isReadyOrNotBlocking(): boolean;
  32878. /**
  32879. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32880. * @returns true if fully ready
  32881. */
  32882. isReady(): boolean;
  32883. private _cachedSize;
  32884. /**
  32885. * Get the size of the texture.
  32886. * @returns the texture size.
  32887. */
  32888. getSize(): ISize;
  32889. /**
  32890. * Get the base size of the texture.
  32891. * It can be different from the size if the texture has been resized for POT for instance
  32892. * @returns the base size
  32893. */
  32894. getBaseSize(): ISize;
  32895. /**
  32896. * Update the sampling mode of the texture.
  32897. * Default is Trilinear mode.
  32898. *
  32899. * | Value | Type | Description |
  32900. * | ----- | ------------------ | ----------- |
  32901. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32902. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32903. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32904. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32905. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32906. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32907. * | 7 | NEAREST_LINEAR | |
  32908. * | 8 | NEAREST_NEAREST | |
  32909. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32910. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32911. * | 11 | LINEAR_LINEAR | |
  32912. * | 12 | LINEAR_NEAREST | |
  32913. *
  32914. * > _mag_: magnification filter (close to the viewer)
  32915. * > _min_: minification filter (far from the viewer)
  32916. * > _mip_: filter used between mip map levels
  32917. *@param samplingMode Define the new sampling mode of the texture
  32918. */
  32919. updateSamplingMode(samplingMode: number): void;
  32920. /**
  32921. * Scales the texture if is `canRescale()`
  32922. * @param ratio the resize factor we want to use to rescale
  32923. */
  32924. scale(ratio: number): void;
  32925. /**
  32926. * Get if the texture can rescale.
  32927. */
  32928. get canRescale(): boolean;
  32929. /** @hidden */
  32930. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32931. /** @hidden */
  32932. _rebuild(): void;
  32933. /**
  32934. * Triggers the load sequence in delayed load mode.
  32935. */
  32936. delayLoad(): void;
  32937. /**
  32938. * Clones the texture.
  32939. * @returns the cloned texture
  32940. */
  32941. clone(): Nullable<BaseTexture>;
  32942. /**
  32943. * Get the texture underlying type (INT, FLOAT...)
  32944. */
  32945. get textureType(): number;
  32946. /**
  32947. * Get the texture underlying format (RGB, RGBA...)
  32948. */
  32949. get textureFormat(): number;
  32950. /**
  32951. * Indicates that textures need to be re-calculated for all materials
  32952. */
  32953. protected _markAllSubMeshesAsTexturesDirty(): void;
  32954. /**
  32955. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32956. * This will returns an RGBA array buffer containing either in values (0-255) or
  32957. * float values (0-1) depending of the underlying buffer type.
  32958. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32959. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32960. * @param buffer defines a user defined buffer to fill with data (can be null)
  32961. * @returns The Array buffer containing the pixels data.
  32962. */
  32963. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32964. /**
  32965. * Release and destroy the underlying lower level texture aka internalTexture.
  32966. */
  32967. releaseInternalTexture(): void;
  32968. /** @hidden */
  32969. get _lodTextureHigh(): Nullable<BaseTexture>;
  32970. /** @hidden */
  32971. get _lodTextureMid(): Nullable<BaseTexture>;
  32972. /** @hidden */
  32973. get _lodTextureLow(): Nullable<BaseTexture>;
  32974. /**
  32975. * Dispose the texture and release its associated resources.
  32976. */
  32977. dispose(): void;
  32978. /**
  32979. * Serialize the texture into a JSON representation that can be parsed later on.
  32980. * @returns the JSON representation of the texture
  32981. */
  32982. serialize(): any;
  32983. /**
  32984. * Helper function to be called back once a list of texture contains only ready textures.
  32985. * @param textures Define the list of textures to wait for
  32986. * @param callback Define the callback triggered once the entire list will be ready
  32987. */
  32988. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32989. private static _isScene;
  32990. }
  32991. }
  32992. declare module BABYLON {
  32993. /**
  32994. * Options to be used when creating an effect.
  32995. */
  32996. export interface IEffectCreationOptions {
  32997. /**
  32998. * Atrributes that will be used in the shader.
  32999. */
  33000. attributes: string[];
  33001. /**
  33002. * Uniform varible names that will be set in the shader.
  33003. */
  33004. uniformsNames: string[];
  33005. /**
  33006. * Uniform buffer variable names that will be set in the shader.
  33007. */
  33008. uniformBuffersNames: string[];
  33009. /**
  33010. * Sampler texture variable names that will be set in the shader.
  33011. */
  33012. samplers: string[];
  33013. /**
  33014. * Define statements that will be set in the shader.
  33015. */
  33016. defines: any;
  33017. /**
  33018. * Possible fallbacks for this effect to improve performance when needed.
  33019. */
  33020. fallbacks: Nullable<IEffectFallbacks>;
  33021. /**
  33022. * Callback that will be called when the shader is compiled.
  33023. */
  33024. onCompiled: Nullable<(effect: Effect) => void>;
  33025. /**
  33026. * Callback that will be called if an error occurs during shader compilation.
  33027. */
  33028. onError: Nullable<(effect: Effect, errors: string) => void>;
  33029. /**
  33030. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33031. */
  33032. indexParameters?: any;
  33033. /**
  33034. * Max number of lights that can be used in the shader.
  33035. */
  33036. maxSimultaneousLights?: number;
  33037. /**
  33038. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33039. */
  33040. transformFeedbackVaryings?: Nullable<string[]>;
  33041. /**
  33042. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  33043. */
  33044. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33045. }
  33046. /**
  33047. * Effect containing vertex and fragment shader that can be executed on an object.
  33048. */
  33049. export class Effect implements IDisposable {
  33050. /**
  33051. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33052. */
  33053. static ShadersRepository: string;
  33054. /**
  33055. * Enable logging of the shader code when a compilation error occurs
  33056. */
  33057. static LogShaderCodeOnCompilationError: boolean;
  33058. /**
  33059. * Name of the effect.
  33060. */
  33061. name: any;
  33062. /**
  33063. * String container all the define statements that should be set on the shader.
  33064. */
  33065. defines: string;
  33066. /**
  33067. * Callback that will be called when the shader is compiled.
  33068. */
  33069. onCompiled: Nullable<(effect: Effect) => void>;
  33070. /**
  33071. * Callback that will be called if an error occurs during shader compilation.
  33072. */
  33073. onError: Nullable<(effect: Effect, errors: string) => void>;
  33074. /**
  33075. * Callback that will be called when effect is bound.
  33076. */
  33077. onBind: Nullable<(effect: Effect) => void>;
  33078. /**
  33079. * Unique ID of the effect.
  33080. */
  33081. uniqueId: number;
  33082. /**
  33083. * Observable that will be called when the shader is compiled.
  33084. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33085. */
  33086. onCompileObservable: Observable<Effect>;
  33087. /**
  33088. * Observable that will be called if an error occurs during shader compilation.
  33089. */
  33090. onErrorObservable: Observable<Effect>;
  33091. /** @hidden */
  33092. _onBindObservable: Nullable<Observable<Effect>>;
  33093. /**
  33094. * @hidden
  33095. * Specifies if the effect was previously ready
  33096. */
  33097. _wasPreviouslyReady: boolean;
  33098. /**
  33099. * Observable that will be called when effect is bound.
  33100. */
  33101. get onBindObservable(): Observable<Effect>;
  33102. /** @hidden */
  33103. _bonesComputationForcedToCPU: boolean;
  33104. private static _uniqueIdSeed;
  33105. private _engine;
  33106. private _uniformBuffersNames;
  33107. private _uniformBuffersNamesList;
  33108. private _uniformsNames;
  33109. private _samplerList;
  33110. private _samplers;
  33111. private _isReady;
  33112. private _compilationError;
  33113. private _allFallbacksProcessed;
  33114. private _attributesNames;
  33115. private _attributes;
  33116. private _attributeLocationByName;
  33117. private _uniforms;
  33118. /**
  33119. * Key for the effect.
  33120. * @hidden
  33121. */
  33122. _key: string;
  33123. private _indexParameters;
  33124. private _fallbacks;
  33125. private _vertexSourceCode;
  33126. private _fragmentSourceCode;
  33127. private _vertexSourceCodeOverride;
  33128. private _fragmentSourceCodeOverride;
  33129. private _transformFeedbackVaryings;
  33130. /**
  33131. * Compiled shader to webGL program.
  33132. * @hidden
  33133. */
  33134. _pipelineContext: Nullable<IPipelineContext>;
  33135. private _valueCache;
  33136. private static _baseCache;
  33137. /**
  33138. * Instantiates an effect.
  33139. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33140. * @param baseName Name of the effect.
  33141. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33142. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33143. * @param samplers List of sampler variables that will be passed to the shader.
  33144. * @param engine Engine to be used to render the effect
  33145. * @param defines Define statements to be added to the shader.
  33146. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33147. * @param onCompiled Callback that will be called when the shader is compiled.
  33148. * @param onError Callback that will be called if an error occurs during shader compilation.
  33149. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33150. */
  33151. 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);
  33152. private _useFinalCode;
  33153. /**
  33154. * Unique key for this effect
  33155. */
  33156. get key(): string;
  33157. /**
  33158. * If the effect has been compiled and prepared.
  33159. * @returns if the effect is compiled and prepared.
  33160. */
  33161. isReady(): boolean;
  33162. private _isReadyInternal;
  33163. /**
  33164. * The engine the effect was initialized with.
  33165. * @returns the engine.
  33166. */
  33167. getEngine(): Engine;
  33168. /**
  33169. * The pipeline context for this effect
  33170. * @returns the associated pipeline context
  33171. */
  33172. getPipelineContext(): Nullable<IPipelineContext>;
  33173. /**
  33174. * The set of names of attribute variables for the shader.
  33175. * @returns An array of attribute names.
  33176. */
  33177. getAttributesNames(): string[];
  33178. /**
  33179. * Returns the attribute at the given index.
  33180. * @param index The index of the attribute.
  33181. * @returns The location of the attribute.
  33182. */
  33183. getAttributeLocation(index: number): number;
  33184. /**
  33185. * Returns the attribute based on the name of the variable.
  33186. * @param name of the attribute to look up.
  33187. * @returns the attribute location.
  33188. */
  33189. getAttributeLocationByName(name: string): number;
  33190. /**
  33191. * The number of attributes.
  33192. * @returns the numnber of attributes.
  33193. */
  33194. getAttributesCount(): number;
  33195. /**
  33196. * Gets the index of a uniform variable.
  33197. * @param uniformName of the uniform to look up.
  33198. * @returns the index.
  33199. */
  33200. getUniformIndex(uniformName: string): number;
  33201. /**
  33202. * Returns the attribute based on the name of the variable.
  33203. * @param uniformName of the uniform to look up.
  33204. * @returns the location of the uniform.
  33205. */
  33206. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33207. /**
  33208. * Returns an array of sampler variable names
  33209. * @returns The array of sampler variable names.
  33210. */
  33211. getSamplers(): string[];
  33212. /**
  33213. * Returns an array of uniform variable names
  33214. * @returns The array of uniform variable names.
  33215. */
  33216. getUniformNames(): string[];
  33217. /**
  33218. * Returns an array of uniform buffer variable names
  33219. * @returns The array of uniform buffer variable names.
  33220. */
  33221. getUniformBuffersNames(): string[];
  33222. /**
  33223. * Returns the index parameters used to create the effect
  33224. * @returns The index parameters object
  33225. */
  33226. getIndexParameters(): any;
  33227. /**
  33228. * The error from the last compilation.
  33229. * @returns the error string.
  33230. */
  33231. getCompilationError(): string;
  33232. /**
  33233. * Gets a boolean indicating that all fallbacks were used during compilation
  33234. * @returns true if all fallbacks were used
  33235. */
  33236. allFallbacksProcessed(): boolean;
  33237. /**
  33238. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33239. * @param func The callback to be used.
  33240. */
  33241. executeWhenCompiled(func: (effect: Effect) => void): void;
  33242. private _checkIsReady;
  33243. private _loadShader;
  33244. /**
  33245. * Gets the vertex shader source code of this effect
  33246. */
  33247. get vertexSourceCode(): string;
  33248. /**
  33249. * Gets the fragment shader source code of this effect
  33250. */
  33251. get fragmentSourceCode(): string;
  33252. /**
  33253. * Recompiles the webGL program
  33254. * @param vertexSourceCode The source code for the vertex shader.
  33255. * @param fragmentSourceCode The source code for the fragment shader.
  33256. * @param onCompiled Callback called when completed.
  33257. * @param onError Callback called on error.
  33258. * @hidden
  33259. */
  33260. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33261. /**
  33262. * Prepares the effect
  33263. * @hidden
  33264. */
  33265. _prepareEffect(): void;
  33266. private _getShaderCodeAndErrorLine;
  33267. private _processCompilationErrors;
  33268. /**
  33269. * Checks if the effect is supported. (Must be called after compilation)
  33270. */
  33271. get isSupported(): boolean;
  33272. /**
  33273. * Binds a texture to the engine to be used as output of the shader.
  33274. * @param channel Name of the output variable.
  33275. * @param texture Texture to bind.
  33276. * @hidden
  33277. */
  33278. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33279. /**
  33280. * Sets a texture on the engine to be used in the shader.
  33281. * @param channel Name of the sampler variable.
  33282. * @param texture Texture to set.
  33283. */
  33284. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33285. /**
  33286. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33287. * @param channel Name of the sampler variable.
  33288. * @param texture Texture to set.
  33289. */
  33290. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33291. /**
  33292. * Sets an array of textures on the engine to be used in the shader.
  33293. * @param channel Name of the variable.
  33294. * @param textures Textures to set.
  33295. */
  33296. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33297. /**
  33298. * 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)
  33299. * @param channel Name of the sampler variable.
  33300. * @param postProcess Post process to get the input texture from.
  33301. */
  33302. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33303. /**
  33304. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33305. * 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)
  33306. * @param channel Name of the sampler variable.
  33307. * @param postProcess Post process to get the output texture from.
  33308. */
  33309. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33310. /** @hidden */
  33311. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33312. /** @hidden */
  33313. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33314. /** @hidden */
  33315. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33316. /** @hidden */
  33317. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33318. /**
  33319. * Binds a buffer to a uniform.
  33320. * @param buffer Buffer to bind.
  33321. * @param name Name of the uniform variable to bind to.
  33322. */
  33323. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33324. /**
  33325. * Binds block to a uniform.
  33326. * @param blockName Name of the block to bind.
  33327. * @param index Index to bind.
  33328. */
  33329. bindUniformBlock(blockName: string, index: number): void;
  33330. /**
  33331. * Sets an interger value on a uniform variable.
  33332. * @param uniformName Name of the variable.
  33333. * @param value Value to be set.
  33334. * @returns this effect.
  33335. */
  33336. setInt(uniformName: string, value: number): Effect;
  33337. /**
  33338. * Sets an int array on a uniform variable.
  33339. * @param uniformName Name of the variable.
  33340. * @param array array to be set.
  33341. * @returns this effect.
  33342. */
  33343. setIntArray(uniformName: string, array: Int32Array): Effect;
  33344. /**
  33345. * 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)
  33346. * @param uniformName Name of the variable.
  33347. * @param array array to be set.
  33348. * @returns this effect.
  33349. */
  33350. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33351. /**
  33352. * 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)
  33353. * @param uniformName Name of the variable.
  33354. * @param array array to be set.
  33355. * @returns this effect.
  33356. */
  33357. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33358. /**
  33359. * 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)
  33360. * @param uniformName Name of the variable.
  33361. * @param array array to be set.
  33362. * @returns this effect.
  33363. */
  33364. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33365. /**
  33366. * Sets an float array on a uniform variable.
  33367. * @param uniformName Name of the variable.
  33368. * @param array array to be set.
  33369. * @returns this effect.
  33370. */
  33371. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33372. /**
  33373. * 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)
  33374. * @param uniformName Name of the variable.
  33375. * @param array array to be set.
  33376. * @returns this effect.
  33377. */
  33378. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33379. /**
  33380. * 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)
  33381. * @param uniformName Name of the variable.
  33382. * @param array array to be set.
  33383. * @returns this effect.
  33384. */
  33385. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33386. /**
  33387. * 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)
  33388. * @param uniformName Name of the variable.
  33389. * @param array array to be set.
  33390. * @returns this effect.
  33391. */
  33392. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33393. /**
  33394. * Sets an array on a uniform variable.
  33395. * @param uniformName Name of the variable.
  33396. * @param array array to be set.
  33397. * @returns this effect.
  33398. */
  33399. setArray(uniformName: string, array: number[]): Effect;
  33400. /**
  33401. * 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)
  33402. * @param uniformName Name of the variable.
  33403. * @param array array to be set.
  33404. * @returns this effect.
  33405. */
  33406. setArray2(uniformName: string, array: number[]): Effect;
  33407. /**
  33408. * 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)
  33409. * @param uniformName Name of the variable.
  33410. * @param array array to be set.
  33411. * @returns this effect.
  33412. */
  33413. setArray3(uniformName: string, array: number[]): Effect;
  33414. /**
  33415. * 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)
  33416. * @param uniformName Name of the variable.
  33417. * @param array array to be set.
  33418. * @returns this effect.
  33419. */
  33420. setArray4(uniformName: string, array: number[]): Effect;
  33421. /**
  33422. * Sets matrices on a uniform variable.
  33423. * @param uniformName Name of the variable.
  33424. * @param matrices matrices to be set.
  33425. * @returns this effect.
  33426. */
  33427. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33428. /**
  33429. * Sets matrix on a uniform variable.
  33430. * @param uniformName Name of the variable.
  33431. * @param matrix matrix to be set.
  33432. * @returns this effect.
  33433. */
  33434. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33435. /**
  33436. * 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)
  33437. * @param uniformName Name of the variable.
  33438. * @param matrix matrix to be set.
  33439. * @returns this effect.
  33440. */
  33441. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33442. /**
  33443. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33444. * @param uniformName Name of the variable.
  33445. * @param matrix matrix to be set.
  33446. * @returns this effect.
  33447. */
  33448. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33449. /**
  33450. * Sets a float on a uniform variable.
  33451. * @param uniformName Name of the variable.
  33452. * @param value value to be set.
  33453. * @returns this effect.
  33454. */
  33455. setFloat(uniformName: string, value: number): Effect;
  33456. /**
  33457. * Sets a boolean on a uniform variable.
  33458. * @param uniformName Name of the variable.
  33459. * @param bool value to be set.
  33460. * @returns this effect.
  33461. */
  33462. setBool(uniformName: string, bool: boolean): Effect;
  33463. /**
  33464. * Sets a Vector2 on a uniform variable.
  33465. * @param uniformName Name of the variable.
  33466. * @param vector2 vector2 to be set.
  33467. * @returns this effect.
  33468. */
  33469. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33470. /**
  33471. * Sets a float2 on a uniform variable.
  33472. * @param uniformName Name of the variable.
  33473. * @param x First float in float2.
  33474. * @param y Second float in float2.
  33475. * @returns this effect.
  33476. */
  33477. setFloat2(uniformName: string, x: number, y: number): Effect;
  33478. /**
  33479. * Sets a Vector3 on a uniform variable.
  33480. * @param uniformName Name of the variable.
  33481. * @param vector3 Value to be set.
  33482. * @returns this effect.
  33483. */
  33484. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33485. /**
  33486. * Sets a float3 on a uniform variable.
  33487. * @param uniformName Name of the variable.
  33488. * @param x First float in float3.
  33489. * @param y Second float in float3.
  33490. * @param z Third float in float3.
  33491. * @returns this effect.
  33492. */
  33493. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33494. /**
  33495. * Sets a Vector4 on a uniform variable.
  33496. * @param uniformName Name of the variable.
  33497. * @param vector4 Value to be set.
  33498. * @returns this effect.
  33499. */
  33500. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33501. /**
  33502. * Sets a float4 on a uniform variable.
  33503. * @param uniformName Name of the variable.
  33504. * @param x First float in float4.
  33505. * @param y Second float in float4.
  33506. * @param z Third float in float4.
  33507. * @param w Fourth float in float4.
  33508. * @returns this effect.
  33509. */
  33510. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33511. /**
  33512. * Sets a Color3 on a uniform variable.
  33513. * @param uniformName Name of the variable.
  33514. * @param color3 Value to be set.
  33515. * @returns this effect.
  33516. */
  33517. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33518. /**
  33519. * Sets a Color4 on a uniform variable.
  33520. * @param uniformName Name of the variable.
  33521. * @param color3 Value to be set.
  33522. * @param alpha Alpha value to be set.
  33523. * @returns this effect.
  33524. */
  33525. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33526. /**
  33527. * Sets a Color4 on a uniform variable
  33528. * @param uniformName defines the name of the variable
  33529. * @param color4 defines the value to be set
  33530. * @returns this effect.
  33531. */
  33532. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33533. /** Release all associated resources */
  33534. dispose(): void;
  33535. /**
  33536. * This function will add a new shader to the shader store
  33537. * @param name the name of the shader
  33538. * @param pixelShader optional pixel shader content
  33539. * @param vertexShader optional vertex shader content
  33540. */
  33541. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33542. /**
  33543. * Store of each shader (The can be looked up using effect.key)
  33544. */
  33545. static ShadersStore: {
  33546. [key: string]: string;
  33547. };
  33548. /**
  33549. * Store of each included file for a shader (The can be looked up using effect.key)
  33550. */
  33551. static IncludesShadersStore: {
  33552. [key: string]: string;
  33553. };
  33554. /**
  33555. * Resets the cache of effects.
  33556. */
  33557. static ResetCache(): void;
  33558. }
  33559. }
  33560. declare module BABYLON {
  33561. /**
  33562. * Interface used to describe the capabilities of the engine relatively to the current browser
  33563. */
  33564. export interface EngineCapabilities {
  33565. /** Maximum textures units per fragment shader */
  33566. maxTexturesImageUnits: number;
  33567. /** Maximum texture units per vertex shader */
  33568. maxVertexTextureImageUnits: number;
  33569. /** Maximum textures units in the entire pipeline */
  33570. maxCombinedTexturesImageUnits: number;
  33571. /** Maximum texture size */
  33572. maxTextureSize: number;
  33573. /** Maximum texture samples */
  33574. maxSamples?: number;
  33575. /** Maximum cube texture size */
  33576. maxCubemapTextureSize: number;
  33577. /** Maximum render texture size */
  33578. maxRenderTextureSize: number;
  33579. /** Maximum number of vertex attributes */
  33580. maxVertexAttribs: number;
  33581. /** Maximum number of varyings */
  33582. maxVaryingVectors: number;
  33583. /** Maximum number of uniforms per vertex shader */
  33584. maxVertexUniformVectors: number;
  33585. /** Maximum number of uniforms per fragment shader */
  33586. maxFragmentUniformVectors: number;
  33587. /** Defines if standard derivates (dx/dy) are supported */
  33588. standardDerivatives: boolean;
  33589. /** Defines if s3tc texture compression is supported */
  33590. s3tc?: WEBGL_compressed_texture_s3tc;
  33591. /** Defines if pvrtc texture compression is supported */
  33592. pvrtc: any;
  33593. /** Defines if etc1 texture compression is supported */
  33594. etc1: any;
  33595. /** Defines if etc2 texture compression is supported */
  33596. etc2: any;
  33597. /** Defines if astc texture compression is supported */
  33598. astc: any;
  33599. /** Defines if float textures are supported */
  33600. textureFloat: boolean;
  33601. /** Defines if vertex array objects are supported */
  33602. vertexArrayObject: boolean;
  33603. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33604. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33605. /** Gets the maximum level of anisotropy supported */
  33606. maxAnisotropy: number;
  33607. /** Defines if instancing is supported */
  33608. instancedArrays: boolean;
  33609. /** Defines if 32 bits indices are supported */
  33610. uintIndices: boolean;
  33611. /** Defines if high precision shaders are supported */
  33612. highPrecisionShaderSupported: boolean;
  33613. /** Defines if depth reading in the fragment shader is supported */
  33614. fragmentDepthSupported: boolean;
  33615. /** Defines if float texture linear filtering is supported*/
  33616. textureFloatLinearFiltering: boolean;
  33617. /** Defines if rendering to float textures is supported */
  33618. textureFloatRender: boolean;
  33619. /** Defines if half float textures are supported*/
  33620. textureHalfFloat: boolean;
  33621. /** Defines if half float texture linear filtering is supported*/
  33622. textureHalfFloatLinearFiltering: boolean;
  33623. /** Defines if rendering to half float textures is supported */
  33624. textureHalfFloatRender: boolean;
  33625. /** Defines if textureLOD shader command is supported */
  33626. textureLOD: boolean;
  33627. /** Defines if draw buffers extension is supported */
  33628. drawBuffersExtension: boolean;
  33629. /** Defines if depth textures are supported */
  33630. depthTextureExtension: boolean;
  33631. /** Defines if float color buffer are supported */
  33632. colorBufferFloat: boolean;
  33633. /** Gets disjoint timer query extension (null if not supported) */
  33634. timerQuery?: EXT_disjoint_timer_query;
  33635. /** Defines if timestamp can be used with timer query */
  33636. canUseTimestampForTimerQuery: boolean;
  33637. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33638. multiview?: any;
  33639. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33640. oculusMultiview?: any;
  33641. /** Function used to let the system compiles shaders in background */
  33642. parallelShaderCompile?: {
  33643. COMPLETION_STATUS_KHR: number;
  33644. };
  33645. /** Max number of texture samples for MSAA */
  33646. maxMSAASamples: number;
  33647. /** Defines if the blend min max extension is supported */
  33648. blendMinMax: boolean;
  33649. }
  33650. }
  33651. declare module BABYLON {
  33652. /**
  33653. * @hidden
  33654. **/
  33655. export class DepthCullingState {
  33656. private _isDepthTestDirty;
  33657. private _isDepthMaskDirty;
  33658. private _isDepthFuncDirty;
  33659. private _isCullFaceDirty;
  33660. private _isCullDirty;
  33661. private _isZOffsetDirty;
  33662. private _isFrontFaceDirty;
  33663. private _depthTest;
  33664. private _depthMask;
  33665. private _depthFunc;
  33666. private _cull;
  33667. private _cullFace;
  33668. private _zOffset;
  33669. private _frontFace;
  33670. /**
  33671. * Initializes the state.
  33672. */
  33673. constructor();
  33674. get isDirty(): boolean;
  33675. get zOffset(): number;
  33676. set zOffset(value: number);
  33677. get cullFace(): Nullable<number>;
  33678. set cullFace(value: Nullable<number>);
  33679. get cull(): Nullable<boolean>;
  33680. set cull(value: Nullable<boolean>);
  33681. get depthFunc(): Nullable<number>;
  33682. set depthFunc(value: Nullable<number>);
  33683. get depthMask(): boolean;
  33684. set depthMask(value: boolean);
  33685. get depthTest(): boolean;
  33686. set depthTest(value: boolean);
  33687. get frontFace(): Nullable<number>;
  33688. set frontFace(value: Nullable<number>);
  33689. reset(): void;
  33690. apply(gl: WebGLRenderingContext): void;
  33691. }
  33692. }
  33693. declare module BABYLON {
  33694. /**
  33695. * @hidden
  33696. **/
  33697. export class StencilState {
  33698. /** 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 */
  33699. static readonly ALWAYS: number;
  33700. /** Passed to stencilOperation to specify that stencil value must be kept */
  33701. static readonly KEEP: number;
  33702. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33703. static readonly REPLACE: number;
  33704. private _isStencilTestDirty;
  33705. private _isStencilMaskDirty;
  33706. private _isStencilFuncDirty;
  33707. private _isStencilOpDirty;
  33708. private _stencilTest;
  33709. private _stencilMask;
  33710. private _stencilFunc;
  33711. private _stencilFuncRef;
  33712. private _stencilFuncMask;
  33713. private _stencilOpStencilFail;
  33714. private _stencilOpDepthFail;
  33715. private _stencilOpStencilDepthPass;
  33716. get isDirty(): boolean;
  33717. get stencilFunc(): number;
  33718. set stencilFunc(value: number);
  33719. get stencilFuncRef(): number;
  33720. set stencilFuncRef(value: number);
  33721. get stencilFuncMask(): number;
  33722. set stencilFuncMask(value: number);
  33723. get stencilOpStencilFail(): number;
  33724. set stencilOpStencilFail(value: number);
  33725. get stencilOpDepthFail(): number;
  33726. set stencilOpDepthFail(value: number);
  33727. get stencilOpStencilDepthPass(): number;
  33728. set stencilOpStencilDepthPass(value: number);
  33729. get stencilMask(): number;
  33730. set stencilMask(value: number);
  33731. get stencilTest(): boolean;
  33732. set stencilTest(value: boolean);
  33733. constructor();
  33734. reset(): void;
  33735. apply(gl: WebGLRenderingContext): void;
  33736. }
  33737. }
  33738. declare module BABYLON {
  33739. /**
  33740. * @hidden
  33741. **/
  33742. export class AlphaState {
  33743. private _isAlphaBlendDirty;
  33744. private _isBlendFunctionParametersDirty;
  33745. private _isBlendEquationParametersDirty;
  33746. private _isBlendConstantsDirty;
  33747. private _alphaBlend;
  33748. private _blendFunctionParameters;
  33749. private _blendEquationParameters;
  33750. private _blendConstants;
  33751. /**
  33752. * Initializes the state.
  33753. */
  33754. constructor();
  33755. get isDirty(): boolean;
  33756. get alphaBlend(): boolean;
  33757. set alphaBlend(value: boolean);
  33758. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33759. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33760. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33761. reset(): void;
  33762. apply(gl: WebGLRenderingContext): void;
  33763. }
  33764. }
  33765. declare module BABYLON {
  33766. /** @hidden */
  33767. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33768. attributeProcessor(attribute: string): string;
  33769. varyingProcessor(varying: string, isFragment: boolean): string;
  33770. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33771. }
  33772. }
  33773. declare module BABYLON {
  33774. /**
  33775. * Interface for attribute information associated with buffer instanciation
  33776. */
  33777. export interface InstancingAttributeInfo {
  33778. /**
  33779. * Name of the GLSL attribute
  33780. * if attribute index is not specified, this is used to retrieve the index from the effect
  33781. */
  33782. attributeName: string;
  33783. /**
  33784. * Index/offset of the attribute in the vertex shader
  33785. * if not specified, this will be computes from the name.
  33786. */
  33787. index?: number;
  33788. /**
  33789. * size of the attribute, 1, 2, 3 or 4
  33790. */
  33791. attributeSize: number;
  33792. /**
  33793. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33794. */
  33795. offset: number;
  33796. /**
  33797. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33798. * default to 1
  33799. */
  33800. divisor?: number;
  33801. /**
  33802. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33803. * default is FLOAT
  33804. */
  33805. attributeType?: number;
  33806. /**
  33807. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33808. */
  33809. normalized?: boolean;
  33810. }
  33811. }
  33812. declare module BABYLON {
  33813. interface ThinEngine {
  33814. /**
  33815. * Update a video texture
  33816. * @param texture defines the texture to update
  33817. * @param video defines the video element to use
  33818. * @param invertY defines if data must be stored with Y axis inverted
  33819. */
  33820. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33821. }
  33822. }
  33823. declare module BABYLON {
  33824. /**
  33825. * Settings for finer control over video usage
  33826. */
  33827. export interface VideoTextureSettings {
  33828. /**
  33829. * Applies `autoplay` to video, if specified
  33830. */
  33831. autoPlay?: boolean;
  33832. /**
  33833. * Applies `loop` to video, if specified
  33834. */
  33835. loop?: boolean;
  33836. /**
  33837. * Automatically updates internal texture from video at every frame in the render loop
  33838. */
  33839. autoUpdateTexture: boolean;
  33840. /**
  33841. * Image src displayed during the video loading or until the user interacts with the video.
  33842. */
  33843. poster?: string;
  33844. }
  33845. /**
  33846. * If you want to display a video in your scene, this is the special texture for that.
  33847. * This special texture works similar to other textures, with the exception of a few parameters.
  33848. * @see https://doc.babylonjs.com/how_to/video_texture
  33849. */
  33850. export class VideoTexture extends Texture {
  33851. /**
  33852. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33853. */
  33854. readonly autoUpdateTexture: boolean;
  33855. /**
  33856. * The video instance used by the texture internally
  33857. */
  33858. readonly video: HTMLVideoElement;
  33859. private _onUserActionRequestedObservable;
  33860. /**
  33861. * Event triggerd when a dom action is required by the user to play the video.
  33862. * This happens due to recent changes in browser policies preventing video to auto start.
  33863. */
  33864. get onUserActionRequestedObservable(): Observable<Texture>;
  33865. private _generateMipMaps;
  33866. private _stillImageCaptured;
  33867. private _displayingPosterTexture;
  33868. private _settings;
  33869. private _createInternalTextureOnEvent;
  33870. private _frameId;
  33871. private _currentSrc;
  33872. /**
  33873. * Creates a video texture.
  33874. * If you want to display a video in your scene, this is the special texture for that.
  33875. * This special texture works similar to other textures, with the exception of a few parameters.
  33876. * @see https://doc.babylonjs.com/how_to/video_texture
  33877. * @param name optional name, will detect from video source, if not defined
  33878. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33879. * @param scene is obviously the current scene.
  33880. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33881. * @param invertY is false by default but can be used to invert video on Y axis
  33882. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33883. * @param settings allows finer control over video usage
  33884. */
  33885. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33886. private _getName;
  33887. private _getVideo;
  33888. private _createInternalTexture;
  33889. private reset;
  33890. /**
  33891. * @hidden Internal method to initiate `update`.
  33892. */
  33893. _rebuild(): void;
  33894. /**
  33895. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33896. */
  33897. update(): void;
  33898. /**
  33899. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33900. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33901. */
  33902. updateTexture(isVisible: boolean): void;
  33903. protected _updateInternalTexture: () => void;
  33904. /**
  33905. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33906. * @param url New url.
  33907. */
  33908. updateURL(url: string): void;
  33909. /**
  33910. * Clones the texture.
  33911. * @returns the cloned texture
  33912. */
  33913. clone(): VideoTexture;
  33914. /**
  33915. * Dispose the texture and release its associated resources.
  33916. */
  33917. dispose(): void;
  33918. /**
  33919. * Creates a video texture straight from a stream.
  33920. * @param scene Define the scene the texture should be created in
  33921. * @param stream Define the stream the texture should be created from
  33922. * @returns The created video texture as a promise
  33923. */
  33924. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33925. /**
  33926. * Creates a video texture straight from your WebCam video feed.
  33927. * @param scene Define the scene the texture should be created in
  33928. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33929. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33930. * @returns The created video texture as a promise
  33931. */
  33932. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33933. minWidth: number;
  33934. maxWidth: number;
  33935. minHeight: number;
  33936. maxHeight: number;
  33937. deviceId: string;
  33938. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33939. /**
  33940. * Creates a video texture straight from your WebCam video feed.
  33941. * @param scene Define the scene the texture should be created in
  33942. * @param onReady Define a callback to triggered once the texture will be ready
  33943. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33944. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33945. */
  33946. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33947. minWidth: number;
  33948. maxWidth: number;
  33949. minHeight: number;
  33950. maxHeight: number;
  33951. deviceId: string;
  33952. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33953. }
  33954. }
  33955. declare module BABYLON {
  33956. /**
  33957. * Defines the interface used by objects working like Scene
  33958. * @hidden
  33959. */
  33960. export interface ISceneLike {
  33961. _addPendingData(data: any): void;
  33962. _removePendingData(data: any): void;
  33963. offlineProvider: IOfflineProvider;
  33964. }
  33965. /** Interface defining initialization parameters for Engine class */
  33966. export interface EngineOptions extends WebGLContextAttributes {
  33967. /**
  33968. * Defines if the engine should no exceed a specified device ratio
  33969. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33970. */
  33971. limitDeviceRatio?: number;
  33972. /**
  33973. * Defines if webvr should be enabled automatically
  33974. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33975. */
  33976. autoEnableWebVR?: boolean;
  33977. /**
  33978. * Defines if webgl2 should be turned off even if supported
  33979. * @see http://doc.babylonjs.com/features/webgl2
  33980. */
  33981. disableWebGL2Support?: boolean;
  33982. /**
  33983. * Defines if webaudio should be initialized as well
  33984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33985. */
  33986. audioEngine?: boolean;
  33987. /**
  33988. * Defines if animations should run using a deterministic lock step
  33989. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33990. */
  33991. deterministicLockstep?: boolean;
  33992. /** Defines the maximum steps to use with deterministic lock step mode */
  33993. lockstepMaxSteps?: number;
  33994. /** Defines the seconds between each deterministic lock step */
  33995. timeStep?: number;
  33996. /**
  33997. * Defines that engine should ignore context lost events
  33998. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  33999. */
  34000. doNotHandleContextLost?: boolean;
  34001. /**
  34002. * Defines that engine should ignore modifying touch action attribute and style
  34003. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34004. */
  34005. doNotHandleTouchAction?: boolean;
  34006. /**
  34007. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34008. */
  34009. useHighPrecisionFloats?: boolean;
  34010. }
  34011. /**
  34012. * The base engine class (root of all engines)
  34013. */
  34014. export class ThinEngine {
  34015. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34016. static ExceptionList: ({
  34017. key: string;
  34018. capture: string;
  34019. captureConstraint: number;
  34020. targets: string[];
  34021. } | {
  34022. key: string;
  34023. capture: null;
  34024. captureConstraint: null;
  34025. targets: string[];
  34026. })[];
  34027. /** @hidden */
  34028. static _TextureLoaders: IInternalTextureLoader[];
  34029. /**
  34030. * Returns the current npm package of the sdk
  34031. */
  34032. static get NpmPackage(): string;
  34033. /**
  34034. * Returns the current version of the framework
  34035. */
  34036. static get Version(): string;
  34037. /**
  34038. * Returns a string describing the current engine
  34039. */
  34040. get description(): string;
  34041. /**
  34042. * Gets or sets the epsilon value used by collision engine
  34043. */
  34044. static CollisionsEpsilon: number;
  34045. /**
  34046. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34047. */
  34048. static get ShadersRepository(): string;
  34049. static set ShadersRepository(value: string);
  34050. /** @hidden */
  34051. _shaderProcessor: IShaderProcessor;
  34052. /**
  34053. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34054. */
  34055. forcePOTTextures: boolean;
  34056. /**
  34057. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34058. */
  34059. isFullscreen: boolean;
  34060. /**
  34061. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34062. */
  34063. cullBackFaces: boolean;
  34064. /**
  34065. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34066. */
  34067. renderEvenInBackground: boolean;
  34068. /**
  34069. * Gets or sets a boolean indicating that cache can be kept between frames
  34070. */
  34071. preventCacheWipeBetweenFrames: boolean;
  34072. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34073. validateShaderPrograms: boolean;
  34074. /**
  34075. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34076. * This can provide greater z depth for distant objects.
  34077. */
  34078. useReverseDepthBuffer: boolean;
  34079. /**
  34080. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34081. */
  34082. disableUniformBuffers: boolean;
  34083. /** @hidden */
  34084. _uniformBuffers: UniformBuffer[];
  34085. /**
  34086. * Gets a boolean indicating that the engine supports uniform buffers
  34087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34088. */
  34089. get supportsUniformBuffers(): boolean;
  34090. /** @hidden */
  34091. _gl: WebGLRenderingContext;
  34092. /** @hidden */
  34093. _webGLVersion: number;
  34094. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34095. protected _windowIsBackground: boolean;
  34096. protected _creationOptions: EngineOptions;
  34097. protected _highPrecisionShadersAllowed: boolean;
  34098. /** @hidden */
  34099. get _shouldUseHighPrecisionShader(): boolean;
  34100. /**
  34101. * Gets a boolean indicating that only power of 2 textures are supported
  34102. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34103. */
  34104. get needPOTTextures(): boolean;
  34105. /** @hidden */
  34106. _badOS: boolean;
  34107. /** @hidden */
  34108. _badDesktopOS: boolean;
  34109. private _hardwareScalingLevel;
  34110. /** @hidden */
  34111. _caps: EngineCapabilities;
  34112. private _isStencilEnable;
  34113. private _glVersion;
  34114. private _glRenderer;
  34115. private _glVendor;
  34116. /** @hidden */
  34117. _videoTextureSupported: boolean;
  34118. protected _renderingQueueLaunched: boolean;
  34119. protected _activeRenderLoops: (() => void)[];
  34120. /**
  34121. * Observable signaled when a context lost event is raised
  34122. */
  34123. onContextLostObservable: Observable<ThinEngine>;
  34124. /**
  34125. * Observable signaled when a context restored event is raised
  34126. */
  34127. onContextRestoredObservable: Observable<ThinEngine>;
  34128. private _onContextLost;
  34129. private _onContextRestored;
  34130. protected _contextWasLost: boolean;
  34131. /** @hidden */
  34132. _doNotHandleContextLost: boolean;
  34133. /**
  34134. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34136. */
  34137. get doNotHandleContextLost(): boolean;
  34138. set doNotHandleContextLost(value: boolean);
  34139. /**
  34140. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34141. */
  34142. disableVertexArrayObjects: boolean;
  34143. /** @hidden */
  34144. protected _colorWrite: boolean;
  34145. /** @hidden */
  34146. protected _colorWriteChanged: boolean;
  34147. /** @hidden */
  34148. protected _depthCullingState: DepthCullingState;
  34149. /** @hidden */
  34150. protected _stencilState: StencilState;
  34151. /** @hidden */
  34152. _alphaState: AlphaState;
  34153. /** @hidden */
  34154. _alphaMode: number;
  34155. /** @hidden */
  34156. _alphaEquation: number;
  34157. /** @hidden */
  34158. _internalTexturesCache: InternalTexture[];
  34159. /** @hidden */
  34160. protected _activeChannel: number;
  34161. private _currentTextureChannel;
  34162. /** @hidden */
  34163. protected _boundTexturesCache: {
  34164. [key: string]: Nullable<InternalTexture>;
  34165. };
  34166. /** @hidden */
  34167. protected _currentEffect: Nullable<Effect>;
  34168. /** @hidden */
  34169. protected _currentProgram: Nullable<WebGLProgram>;
  34170. private _compiledEffects;
  34171. private _vertexAttribArraysEnabled;
  34172. /** @hidden */
  34173. protected _cachedViewport: Nullable<IViewportLike>;
  34174. private _cachedVertexArrayObject;
  34175. /** @hidden */
  34176. protected _cachedVertexBuffers: any;
  34177. /** @hidden */
  34178. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34179. /** @hidden */
  34180. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34181. /** @hidden */
  34182. _currentRenderTarget: Nullable<InternalTexture>;
  34183. private _uintIndicesCurrentlySet;
  34184. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34185. /** @hidden */
  34186. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34187. /** @hidden */
  34188. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34189. private _currentBufferPointers;
  34190. private _currentInstanceLocations;
  34191. private _currentInstanceBuffers;
  34192. private _textureUnits;
  34193. /** @hidden */
  34194. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34195. /** @hidden */
  34196. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34197. /** @hidden */
  34198. _boundRenderFunction: any;
  34199. private _vaoRecordInProgress;
  34200. private _mustWipeVertexAttributes;
  34201. private _emptyTexture;
  34202. private _emptyCubeTexture;
  34203. private _emptyTexture3D;
  34204. private _emptyTexture2DArray;
  34205. /** @hidden */
  34206. _frameHandler: number;
  34207. private _nextFreeTextureSlots;
  34208. private _maxSimultaneousTextures;
  34209. private _activeRequests;
  34210. /** @hidden */
  34211. _transformTextureUrl: Nullable<(url: string) => string>;
  34212. protected get _supportsHardwareTextureRescaling(): boolean;
  34213. private _framebufferDimensionsObject;
  34214. /**
  34215. * sets the object from which width and height will be taken from when getting render width and height
  34216. * Will fallback to the gl object
  34217. * @param dimensions the framebuffer width and height that will be used.
  34218. */
  34219. set framebufferDimensionsObject(dimensions: Nullable<{
  34220. framebufferWidth: number;
  34221. framebufferHeight: number;
  34222. }>);
  34223. /**
  34224. * Gets the current viewport
  34225. */
  34226. get currentViewport(): Nullable<IViewportLike>;
  34227. /**
  34228. * Gets the default empty texture
  34229. */
  34230. get emptyTexture(): InternalTexture;
  34231. /**
  34232. * Gets the default empty 3D texture
  34233. */
  34234. get emptyTexture3D(): InternalTexture;
  34235. /**
  34236. * Gets the default empty 2D array texture
  34237. */
  34238. get emptyTexture2DArray(): InternalTexture;
  34239. /**
  34240. * Gets the default empty cube texture
  34241. */
  34242. get emptyCubeTexture(): InternalTexture;
  34243. /**
  34244. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34245. */
  34246. readonly premultipliedAlpha: boolean;
  34247. /**
  34248. * Observable event triggered before each texture is initialized
  34249. */
  34250. onBeforeTextureInitObservable: Observable<Texture>;
  34251. /**
  34252. * Creates a new engine
  34253. * @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
  34254. * @param antialias defines enable antialiasing (default: false)
  34255. * @param options defines further options to be sent to the getContext() function
  34256. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34257. */
  34258. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34259. private _rebuildInternalTextures;
  34260. private _rebuildEffects;
  34261. /**
  34262. * Gets a boolean indicating if all created effects are ready
  34263. * @returns true if all effects are ready
  34264. */
  34265. areAllEffectsReady(): boolean;
  34266. protected _rebuildBuffers(): void;
  34267. protected _initGLContext(): void;
  34268. /**
  34269. * Gets version of the current webGL context
  34270. */
  34271. get webGLVersion(): number;
  34272. /**
  34273. * Gets a string idenfifying the name of the class
  34274. * @returns "Engine" string
  34275. */
  34276. getClassName(): string;
  34277. /**
  34278. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34279. */
  34280. get isStencilEnable(): boolean;
  34281. /** @hidden */
  34282. _prepareWorkingCanvas(): void;
  34283. /**
  34284. * Reset the texture cache to empty state
  34285. */
  34286. resetTextureCache(): void;
  34287. /**
  34288. * Gets an object containing information about the current webGL context
  34289. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34290. */
  34291. getGlInfo(): {
  34292. vendor: string;
  34293. renderer: string;
  34294. version: string;
  34295. };
  34296. /**
  34297. * Defines the hardware scaling level.
  34298. * By default the hardware scaling level is computed from the window device ratio.
  34299. * 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.
  34300. * @param level defines the level to use
  34301. */
  34302. setHardwareScalingLevel(level: number): void;
  34303. /**
  34304. * Gets the current hardware scaling level.
  34305. * By default the hardware scaling level is computed from the window device ratio.
  34306. * 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.
  34307. * @returns a number indicating the current hardware scaling level
  34308. */
  34309. getHardwareScalingLevel(): number;
  34310. /**
  34311. * Gets the list of loaded textures
  34312. * @returns an array containing all loaded textures
  34313. */
  34314. getLoadedTexturesCache(): InternalTexture[];
  34315. /**
  34316. * Gets the object containing all engine capabilities
  34317. * @returns the EngineCapabilities object
  34318. */
  34319. getCaps(): EngineCapabilities;
  34320. /**
  34321. * stop executing a render loop function and remove it from the execution array
  34322. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34323. */
  34324. stopRenderLoop(renderFunction?: () => void): void;
  34325. /** @hidden */
  34326. _renderLoop(): void;
  34327. /**
  34328. * Gets the HTML canvas attached with the current webGL context
  34329. * @returns a HTML canvas
  34330. */
  34331. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34332. /**
  34333. * Gets host window
  34334. * @returns the host window object
  34335. */
  34336. getHostWindow(): Nullable<Window>;
  34337. /**
  34338. * Gets the current render width
  34339. * @param useScreen defines if screen size must be used (or the current render target if any)
  34340. * @returns a number defining the current render width
  34341. */
  34342. getRenderWidth(useScreen?: boolean): number;
  34343. /**
  34344. * Gets the current render height
  34345. * @param useScreen defines if screen size must be used (or the current render target if any)
  34346. * @returns a number defining the current render height
  34347. */
  34348. getRenderHeight(useScreen?: boolean): number;
  34349. /**
  34350. * Can be used to override the current requestAnimationFrame requester.
  34351. * @hidden
  34352. */
  34353. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34354. /**
  34355. * Register and execute a render loop. The engine can have more than one render function
  34356. * @param renderFunction defines the function to continuously execute
  34357. */
  34358. runRenderLoop(renderFunction: () => void): void;
  34359. /**
  34360. * Clear the current render buffer or the current render target (if any is set up)
  34361. * @param color defines the color to use
  34362. * @param backBuffer defines if the back buffer must be cleared
  34363. * @param depth defines if the depth buffer must be cleared
  34364. * @param stencil defines if the stencil buffer must be cleared
  34365. */
  34366. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34367. private _viewportCached;
  34368. /** @hidden */
  34369. _viewport(x: number, y: number, width: number, height: number): void;
  34370. /**
  34371. * Set the WebGL's viewport
  34372. * @param viewport defines the viewport element to be used
  34373. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34374. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34375. */
  34376. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34377. /**
  34378. * Begin a new frame
  34379. */
  34380. beginFrame(): void;
  34381. /**
  34382. * Enf the current frame
  34383. */
  34384. endFrame(): void;
  34385. /**
  34386. * Resize the view according to the canvas' size
  34387. */
  34388. resize(): void;
  34389. /**
  34390. * Force a specific size of the canvas
  34391. * @param width defines the new canvas' width
  34392. * @param height defines the new canvas' height
  34393. */
  34394. setSize(width: number, height: number): void;
  34395. /**
  34396. * Binds the frame buffer to the specified texture.
  34397. * @param texture The texture to render to or null for the default canvas
  34398. * @param faceIndex The face of the texture to render to in case of cube texture
  34399. * @param requiredWidth The width of the target to render to
  34400. * @param requiredHeight The height of the target to render to
  34401. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34402. * @param lodLevel defines the lod level to bind to the frame buffer
  34403. * @param layer defines the 2d array index to bind to frame buffer to
  34404. */
  34405. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34406. /** @hidden */
  34407. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34408. /**
  34409. * Unbind the current render target texture from the webGL context
  34410. * @param texture defines the render target texture to unbind
  34411. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34412. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34413. */
  34414. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34415. /**
  34416. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34417. */
  34418. flushFramebuffer(): void;
  34419. /**
  34420. * Unbind the current render target and bind the default framebuffer
  34421. */
  34422. restoreDefaultFramebuffer(): void;
  34423. /** @hidden */
  34424. protected _resetVertexBufferBinding(): void;
  34425. /**
  34426. * Creates a vertex buffer
  34427. * @param data the data for the vertex buffer
  34428. * @returns the new WebGL static buffer
  34429. */
  34430. createVertexBuffer(data: DataArray): DataBuffer;
  34431. private _createVertexBuffer;
  34432. /**
  34433. * Creates a dynamic vertex buffer
  34434. * @param data the data for the dynamic vertex buffer
  34435. * @returns the new WebGL dynamic buffer
  34436. */
  34437. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34438. protected _resetIndexBufferBinding(): void;
  34439. /**
  34440. * Creates a new index buffer
  34441. * @param indices defines the content of the index buffer
  34442. * @param updatable defines if the index buffer must be updatable
  34443. * @returns a new webGL buffer
  34444. */
  34445. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34446. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34447. /**
  34448. * Bind a webGL buffer to the webGL context
  34449. * @param buffer defines the buffer to bind
  34450. */
  34451. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34452. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34453. private bindBuffer;
  34454. /**
  34455. * update the bound buffer with the given data
  34456. * @param data defines the data to update
  34457. */
  34458. updateArrayBuffer(data: Float32Array): void;
  34459. private _vertexAttribPointer;
  34460. /** @hidden */
  34461. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34462. private _bindVertexBuffersAttributes;
  34463. /**
  34464. * Records a vertex array object
  34465. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34466. * @param vertexBuffers defines the list of vertex buffers to store
  34467. * @param indexBuffer defines the index buffer to store
  34468. * @param effect defines the effect to store
  34469. * @returns the new vertex array object
  34470. */
  34471. recordVertexArrayObject(vertexBuffers: {
  34472. [key: string]: VertexBuffer;
  34473. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34474. /**
  34475. * Bind a specific vertex array object
  34476. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34477. * @param vertexArrayObject defines the vertex array object to bind
  34478. * @param indexBuffer defines the index buffer to bind
  34479. */
  34480. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34481. /**
  34482. * Bind webGl buffers directly to the webGL context
  34483. * @param vertexBuffer defines the vertex buffer to bind
  34484. * @param indexBuffer defines the index buffer to bind
  34485. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34486. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34487. * @param effect defines the effect associated with the vertex buffer
  34488. */
  34489. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34490. private _unbindVertexArrayObject;
  34491. /**
  34492. * Bind a list of vertex buffers to the webGL context
  34493. * @param vertexBuffers defines the list of vertex buffers to bind
  34494. * @param indexBuffer defines the index buffer to bind
  34495. * @param effect defines the effect associated with the vertex buffers
  34496. */
  34497. bindBuffers(vertexBuffers: {
  34498. [key: string]: Nullable<VertexBuffer>;
  34499. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34500. /**
  34501. * Unbind all instance attributes
  34502. */
  34503. unbindInstanceAttributes(): void;
  34504. /**
  34505. * Release and free the memory of a vertex array object
  34506. * @param vao defines the vertex array object to delete
  34507. */
  34508. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34509. /** @hidden */
  34510. _releaseBuffer(buffer: DataBuffer): boolean;
  34511. protected _deleteBuffer(buffer: DataBuffer): void;
  34512. /**
  34513. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34514. * @param instancesBuffer defines the webGL buffer to update and bind
  34515. * @param data defines the data to store in the buffer
  34516. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34517. */
  34518. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34519. /**
  34520. * Bind the content of a webGL buffer used with instantiation
  34521. * @param instancesBuffer defines the webGL buffer to bind
  34522. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34523. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34524. */
  34525. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34526. /**
  34527. * Disable the instance attribute corresponding to the name in parameter
  34528. * @param name defines the name of the attribute to disable
  34529. */
  34530. disableInstanceAttributeByName(name: string): void;
  34531. /**
  34532. * Disable the instance attribute corresponding to the location in parameter
  34533. * @param attributeLocation defines the attribute location of the attribute to disable
  34534. */
  34535. disableInstanceAttribute(attributeLocation: number): void;
  34536. /**
  34537. * Disable the attribute corresponding to the location in parameter
  34538. * @param attributeLocation defines the attribute location of the attribute to disable
  34539. */
  34540. disableAttributeByIndex(attributeLocation: number): void;
  34541. /**
  34542. * Send a draw order
  34543. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34544. * @param indexStart defines the starting index
  34545. * @param indexCount defines the number of index to draw
  34546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34547. */
  34548. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34549. /**
  34550. * Draw a list of points
  34551. * @param verticesStart defines the index of first vertex to draw
  34552. * @param verticesCount defines the count of vertices to draw
  34553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34554. */
  34555. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34556. /**
  34557. * Draw a list of unindexed primitives
  34558. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34559. * @param verticesStart defines the index of first vertex to draw
  34560. * @param verticesCount defines the count of vertices to draw
  34561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34562. */
  34563. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34564. /**
  34565. * Draw a list of indexed primitives
  34566. * @param fillMode defines the primitive to use
  34567. * @param indexStart defines the starting index
  34568. * @param indexCount defines the number of index to draw
  34569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34570. */
  34571. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34572. /**
  34573. * Draw a list of unindexed primitives
  34574. * @param fillMode defines the primitive to use
  34575. * @param verticesStart defines the index of first vertex to draw
  34576. * @param verticesCount defines the count of vertices to draw
  34577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34578. */
  34579. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34580. private _drawMode;
  34581. /** @hidden */
  34582. protected _reportDrawCall(): void;
  34583. /** @hidden */
  34584. _releaseEffect(effect: Effect): void;
  34585. /** @hidden */
  34586. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34587. /**
  34588. * Create a new effect (used to store vertex/fragment shaders)
  34589. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34590. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34591. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34592. * @param samplers defines an array of string used to represent textures
  34593. * @param defines defines the string containing the defines to use to compile the shaders
  34594. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34595. * @param onCompiled defines a function to call when the effect creation is successful
  34596. * @param onError defines a function to call when the effect creation has failed
  34597. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34598. * @returns the new Effect
  34599. */
  34600. 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;
  34601. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34602. private _compileShader;
  34603. private _compileRawShader;
  34604. /** @hidden */
  34605. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34606. /**
  34607. * Directly creates a webGL program
  34608. * @param pipelineContext defines the pipeline context to attach to
  34609. * @param vertexCode defines the vertex shader code to use
  34610. * @param fragmentCode defines the fragment shader code to use
  34611. * @param context defines the webGL context to use (if not set, the current one will be used)
  34612. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34613. * @returns the new webGL program
  34614. */
  34615. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34616. /**
  34617. * Creates a webGL program
  34618. * @param pipelineContext defines the pipeline context to attach to
  34619. * @param vertexCode defines the vertex shader code to use
  34620. * @param fragmentCode defines the fragment shader code to use
  34621. * @param defines defines the string containing the defines to use to compile the shaders
  34622. * @param context defines the webGL context to use (if not set, the current one will be used)
  34623. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34624. * @returns the new webGL program
  34625. */
  34626. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34627. /**
  34628. * Creates a new pipeline context
  34629. * @returns the new pipeline
  34630. */
  34631. createPipelineContext(): IPipelineContext;
  34632. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34633. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34634. /** @hidden */
  34635. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34636. /** @hidden */
  34637. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34638. /** @hidden */
  34639. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34640. /**
  34641. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34642. * @param pipelineContext defines the pipeline context to use
  34643. * @param uniformsNames defines the list of uniform names
  34644. * @returns an array of webGL uniform locations
  34645. */
  34646. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34647. /**
  34648. * Gets the lsit of active attributes for a given webGL program
  34649. * @param pipelineContext defines the pipeline context to use
  34650. * @param attributesNames defines the list of attribute names to get
  34651. * @returns an array of indices indicating the offset of each attribute
  34652. */
  34653. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34654. /**
  34655. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34656. * @param effect defines the effect to activate
  34657. */
  34658. enableEffect(effect: Nullable<Effect>): void;
  34659. /**
  34660. * Set the value of an uniform to a number (int)
  34661. * @param uniform defines the webGL uniform location where to store the value
  34662. * @param value defines the int number to store
  34663. */
  34664. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34665. /**
  34666. * Set the value of an uniform to an array of int32
  34667. * @param uniform defines the webGL uniform location where to store the value
  34668. * @param array defines the array of int32 to store
  34669. */
  34670. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34671. /**
  34672. * Set the value of an uniform to an array of int32 (stored as vec2)
  34673. * @param uniform defines the webGL uniform location where to store the value
  34674. * @param array defines the array of int32 to store
  34675. */
  34676. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34677. /**
  34678. * Set the value of an uniform to an array of int32 (stored as vec3)
  34679. * @param uniform defines the webGL uniform location where to store the value
  34680. * @param array defines the array of int32 to store
  34681. */
  34682. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34683. /**
  34684. * Set the value of an uniform to an array of int32 (stored as vec4)
  34685. * @param uniform defines the webGL uniform location where to store the value
  34686. * @param array defines the array of int32 to store
  34687. */
  34688. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34689. /**
  34690. * Set the value of an uniform to an array of number
  34691. * @param uniform defines the webGL uniform location where to store the value
  34692. * @param array defines the array of number to store
  34693. */
  34694. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34695. /**
  34696. * Set the value of an uniform to an array of number (stored as vec2)
  34697. * @param uniform defines the webGL uniform location where to store the value
  34698. * @param array defines the array of number to store
  34699. */
  34700. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34701. /**
  34702. * Set the value of an uniform to an array of number (stored as vec3)
  34703. * @param uniform defines the webGL uniform location where to store the value
  34704. * @param array defines the array of number to store
  34705. */
  34706. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34707. /**
  34708. * Set the value of an uniform to an array of number (stored as vec4)
  34709. * @param uniform defines the webGL uniform location where to store the value
  34710. * @param array defines the array of number to store
  34711. */
  34712. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34713. /**
  34714. * Set the value of an uniform to an array of float32 (stored as matrices)
  34715. * @param uniform defines the webGL uniform location where to store the value
  34716. * @param matrices defines the array of float32 to store
  34717. */
  34718. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34719. /**
  34720. * Set the value of an uniform to a matrix (3x3)
  34721. * @param uniform defines the webGL uniform location where to store the value
  34722. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34723. */
  34724. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34725. /**
  34726. * Set the value of an uniform to a matrix (2x2)
  34727. * @param uniform defines the webGL uniform location where to store the value
  34728. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34729. */
  34730. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34731. /**
  34732. * Set the value of an uniform to a number (float)
  34733. * @param uniform defines the webGL uniform location where to store the value
  34734. * @param value defines the float number to store
  34735. */
  34736. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34737. /**
  34738. * Set the value of an uniform to a vec2
  34739. * @param uniform defines the webGL uniform location where to store the value
  34740. * @param x defines the 1st component of the value
  34741. * @param y defines the 2nd component of the value
  34742. */
  34743. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34744. /**
  34745. * Set the value of an uniform to a vec3
  34746. * @param uniform defines the webGL uniform location where to store the value
  34747. * @param x defines the 1st component of the value
  34748. * @param y defines the 2nd component of the value
  34749. * @param z defines the 3rd component of the value
  34750. */
  34751. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34752. /**
  34753. * Set the value of an uniform to a vec4
  34754. * @param uniform defines the webGL uniform location where to store the value
  34755. * @param x defines the 1st component of the value
  34756. * @param y defines the 2nd component of the value
  34757. * @param z defines the 3rd component of the value
  34758. * @param w defines the 4th component of the value
  34759. */
  34760. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34761. /**
  34762. * Apply all cached states (depth, culling, stencil and alpha)
  34763. */
  34764. applyStates(): void;
  34765. /**
  34766. * Enable or disable color writing
  34767. * @param enable defines the state to set
  34768. */
  34769. setColorWrite(enable: boolean): void;
  34770. /**
  34771. * Gets a boolean indicating if color writing is enabled
  34772. * @returns the current color writing state
  34773. */
  34774. getColorWrite(): boolean;
  34775. /**
  34776. * Gets the depth culling state manager
  34777. */
  34778. get depthCullingState(): DepthCullingState;
  34779. /**
  34780. * Gets the alpha state manager
  34781. */
  34782. get alphaState(): AlphaState;
  34783. /**
  34784. * Gets the stencil state manager
  34785. */
  34786. get stencilState(): StencilState;
  34787. /**
  34788. * Clears the list of texture accessible through engine.
  34789. * This can help preventing texture load conflict due to name collision.
  34790. */
  34791. clearInternalTexturesCache(): void;
  34792. /**
  34793. * Force the entire cache to be cleared
  34794. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34795. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34796. */
  34797. wipeCaches(bruteForce?: boolean): void;
  34798. /** @hidden */
  34799. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34800. min: number;
  34801. mag: number;
  34802. };
  34803. /** @hidden */
  34804. _createTexture(): WebGLTexture;
  34805. /**
  34806. * Usually called from Texture.ts.
  34807. * Passed information to create a WebGLTexture
  34808. * @param url defines a value which contains one of the following:
  34809. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34810. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34811. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34813. * @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)
  34814. * @param scene needed for loading to the correct scene
  34815. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34816. * @param onLoad optional callback to be called upon successful completion
  34817. * @param onError optional callback to be called upon failure
  34818. * @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
  34819. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34820. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34821. * @param forcedExtension defines the extension to use to pick the right loader
  34822. * @param mimeType defines an optional mime type
  34823. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34824. */
  34825. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  34826. /**
  34827. * Loads an image as an HTMLImageElement.
  34828. * @param input url string, ArrayBuffer, or Blob to load
  34829. * @param onLoad callback called when the image successfully loads
  34830. * @param onError callback called when the image fails to load
  34831. * @param offlineProvider offline provider for caching
  34832. * @param mimeType optional mime type
  34833. * @returns the HTMLImageElement of the loaded image
  34834. * @hidden
  34835. */
  34836. 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>;
  34837. /**
  34838. * @hidden
  34839. */
  34840. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34841. private _unpackFlipYCached;
  34842. /**
  34843. * In case you are sharing the context with other applications, it might
  34844. * be interested to not cache the unpack flip y state to ensure a consistent
  34845. * value would be set.
  34846. */
  34847. enableUnpackFlipYCached: boolean;
  34848. /** @hidden */
  34849. _unpackFlipY(value: boolean): void;
  34850. /** @hidden */
  34851. _getUnpackAlignement(): number;
  34852. private _getTextureTarget;
  34853. /**
  34854. * Update the sampling mode of a given texture
  34855. * @param samplingMode defines the required sampling mode
  34856. * @param texture defines the texture to update
  34857. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34858. */
  34859. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34860. /**
  34861. * Update the sampling mode of a given texture
  34862. * @param texture defines the texture to update
  34863. * @param wrapU defines the texture wrap mode of the u coordinates
  34864. * @param wrapV defines the texture wrap mode of the v coordinates
  34865. * @param wrapR defines the texture wrap mode of the r coordinates
  34866. */
  34867. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34868. /** @hidden */
  34869. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34870. width: number;
  34871. height: number;
  34872. layers?: number;
  34873. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34874. /** @hidden */
  34875. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34876. /** @hidden */
  34877. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34878. /**
  34879. * Update a portion of an internal texture
  34880. * @param texture defines the texture to update
  34881. * @param imageData defines the data to store into the texture
  34882. * @param xOffset defines the x coordinates of the update rectangle
  34883. * @param yOffset defines the y coordinates of the update rectangle
  34884. * @param width defines the width of the update rectangle
  34885. * @param height defines the height of the update rectangle
  34886. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34887. * @param lod defines the lod level to update (0 by default)
  34888. */
  34889. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34890. /** @hidden */
  34891. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34892. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34893. private _prepareWebGLTexture;
  34894. /** @hidden */
  34895. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34896. private _getDepthStencilBuffer;
  34897. /** @hidden */
  34898. _releaseFramebufferObjects(texture: InternalTexture): void;
  34899. /** @hidden */
  34900. _releaseTexture(texture: InternalTexture): void;
  34901. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34902. protected _setProgram(program: WebGLProgram): void;
  34903. protected _boundUniforms: {
  34904. [key: number]: WebGLUniformLocation;
  34905. };
  34906. /**
  34907. * Binds an effect to the webGL context
  34908. * @param effect defines the effect to bind
  34909. */
  34910. bindSamplers(effect: Effect): void;
  34911. private _activateCurrentTexture;
  34912. /** @hidden */
  34913. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34914. /** @hidden */
  34915. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34916. /**
  34917. * Unbind all textures from the webGL context
  34918. */
  34919. unbindAllTextures(): void;
  34920. /**
  34921. * Sets a texture to the according uniform.
  34922. * @param channel The texture channel
  34923. * @param uniform The uniform to set
  34924. * @param texture The texture to apply
  34925. */
  34926. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34927. private _bindSamplerUniformToChannel;
  34928. private _getTextureWrapMode;
  34929. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34930. /**
  34931. * Sets an array of texture to the webGL context
  34932. * @param channel defines the channel where the texture array must be set
  34933. * @param uniform defines the associated uniform location
  34934. * @param textures defines the array of textures to bind
  34935. */
  34936. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34937. /** @hidden */
  34938. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34939. private _setTextureParameterFloat;
  34940. private _setTextureParameterInteger;
  34941. /**
  34942. * Unbind all vertex attributes from the webGL context
  34943. */
  34944. unbindAllAttributes(): void;
  34945. /**
  34946. * 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
  34947. */
  34948. releaseEffects(): void;
  34949. /**
  34950. * Dispose and release all associated resources
  34951. */
  34952. dispose(): void;
  34953. /**
  34954. * Attach a new callback raised when context lost event is fired
  34955. * @param callback defines the callback to call
  34956. */
  34957. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34958. /**
  34959. * Attach a new callback raised when context restored event is fired
  34960. * @param callback defines the callback to call
  34961. */
  34962. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34963. /**
  34964. * Get the current error code of the webGL context
  34965. * @returns the error code
  34966. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34967. */
  34968. getError(): number;
  34969. private _canRenderToFloatFramebuffer;
  34970. private _canRenderToHalfFloatFramebuffer;
  34971. private _canRenderToFramebuffer;
  34972. /** @hidden */
  34973. _getWebGLTextureType(type: number): number;
  34974. /** @hidden */
  34975. _getInternalFormat(format: number): number;
  34976. /** @hidden */
  34977. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34978. /** @hidden */
  34979. _getRGBAMultiSampleBufferFormat(type: number): number;
  34980. /** @hidden */
  34981. _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;
  34982. /**
  34983. * Loads a file from a url
  34984. * @param url url to load
  34985. * @param onSuccess callback called when the file successfully loads
  34986. * @param onProgress callback called while file is loading (if the server supports this mode)
  34987. * @param offlineProvider defines the offline provider for caching
  34988. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34989. * @param onError callback called when the file fails to load
  34990. * @returns a file request object
  34991. * @hidden
  34992. */
  34993. 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;
  34994. /**
  34995. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34996. * @param x defines the x coordinate of the rectangle where pixels must be read
  34997. * @param y defines the y coordinate of the rectangle where pixels must be read
  34998. * @param width defines the width of the rectangle where pixels must be read
  34999. * @param height defines the height of the rectangle where pixels must be read
  35000. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35001. * @returns a Uint8Array containing RGBA colors
  35002. */
  35003. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35004. private static _isSupported;
  35005. /**
  35006. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35007. * @returns true if the engine can be created
  35008. * @ignorenaming
  35009. */
  35010. static isSupported(): boolean;
  35011. /**
  35012. * Find the next highest power of two.
  35013. * @param x Number to start search from.
  35014. * @return Next highest power of two.
  35015. */
  35016. static CeilingPOT(x: number): number;
  35017. /**
  35018. * Find the next lowest power of two.
  35019. * @param x Number to start search from.
  35020. * @return Next lowest power of two.
  35021. */
  35022. static FloorPOT(x: number): number;
  35023. /**
  35024. * Find the nearest power of two.
  35025. * @param x Number to start search from.
  35026. * @return Next nearest power of two.
  35027. */
  35028. static NearestPOT(x: number): number;
  35029. /**
  35030. * Get the closest exponent of two
  35031. * @param value defines the value to approximate
  35032. * @param max defines the maximum value to return
  35033. * @param mode defines how to define the closest value
  35034. * @returns closest exponent of two of the given value
  35035. */
  35036. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35037. /**
  35038. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35039. * @param func - the function to be called
  35040. * @param requester - the object that will request the next frame. Falls back to window.
  35041. * @returns frame number
  35042. */
  35043. static QueueNewFrame(func: () => void, requester?: any): number;
  35044. /**
  35045. * Gets host document
  35046. * @returns the host document object
  35047. */
  35048. getHostDocument(): Nullable<Document>;
  35049. }
  35050. }
  35051. declare module BABYLON {
  35052. /**
  35053. * Class representing spherical harmonics coefficients to the 3rd degree
  35054. */
  35055. export class SphericalHarmonics {
  35056. /**
  35057. * Defines whether or not the harmonics have been prescaled for rendering.
  35058. */
  35059. preScaled: boolean;
  35060. /**
  35061. * The l0,0 coefficients of the spherical harmonics
  35062. */
  35063. l00: Vector3;
  35064. /**
  35065. * The l1,-1 coefficients of the spherical harmonics
  35066. */
  35067. l1_1: Vector3;
  35068. /**
  35069. * The l1,0 coefficients of the spherical harmonics
  35070. */
  35071. l10: Vector3;
  35072. /**
  35073. * The l1,1 coefficients of the spherical harmonics
  35074. */
  35075. l11: Vector3;
  35076. /**
  35077. * The l2,-2 coefficients of the spherical harmonics
  35078. */
  35079. l2_2: Vector3;
  35080. /**
  35081. * The l2,-1 coefficients of the spherical harmonics
  35082. */
  35083. l2_1: Vector3;
  35084. /**
  35085. * The l2,0 coefficients of the spherical harmonics
  35086. */
  35087. l20: Vector3;
  35088. /**
  35089. * The l2,1 coefficients of the spherical harmonics
  35090. */
  35091. l21: Vector3;
  35092. /**
  35093. * The l2,2 coefficients of the spherical harmonics
  35094. */
  35095. l22: Vector3;
  35096. /**
  35097. * Adds a light to the spherical harmonics
  35098. * @param direction the direction of the light
  35099. * @param color the color of the light
  35100. * @param deltaSolidAngle the delta solid angle of the light
  35101. */
  35102. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35103. /**
  35104. * Scales the spherical harmonics by the given amount
  35105. * @param scale the amount to scale
  35106. */
  35107. scaleInPlace(scale: number): void;
  35108. /**
  35109. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35110. *
  35111. * ```
  35112. * E_lm = A_l * L_lm
  35113. * ```
  35114. *
  35115. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35116. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35117. * the scaling factors are given in equation 9.
  35118. */
  35119. convertIncidentRadianceToIrradiance(): void;
  35120. /**
  35121. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35122. *
  35123. * ```
  35124. * L = (1/pi) * E * rho
  35125. * ```
  35126. *
  35127. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35128. */
  35129. convertIrradianceToLambertianRadiance(): void;
  35130. /**
  35131. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35132. * required operations at run time.
  35133. *
  35134. * This is simply done by scaling back the SH with Ylm constants parameter.
  35135. * The trigonometric part being applied by the shader at run time.
  35136. */
  35137. preScaleForRendering(): void;
  35138. /**
  35139. * Constructs a spherical harmonics from an array.
  35140. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35141. * @returns the spherical harmonics
  35142. */
  35143. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35144. /**
  35145. * Gets the spherical harmonics from polynomial
  35146. * @param polynomial the spherical polynomial
  35147. * @returns the spherical harmonics
  35148. */
  35149. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35150. }
  35151. /**
  35152. * Class representing spherical polynomial coefficients to the 3rd degree
  35153. */
  35154. export class SphericalPolynomial {
  35155. private _harmonics;
  35156. /**
  35157. * The spherical harmonics used to create the polynomials.
  35158. */
  35159. get preScaledHarmonics(): SphericalHarmonics;
  35160. /**
  35161. * The x coefficients of the spherical polynomial
  35162. */
  35163. x: Vector3;
  35164. /**
  35165. * The y coefficients of the spherical polynomial
  35166. */
  35167. y: Vector3;
  35168. /**
  35169. * The z coefficients of the spherical polynomial
  35170. */
  35171. z: Vector3;
  35172. /**
  35173. * The xx coefficients of the spherical polynomial
  35174. */
  35175. xx: Vector3;
  35176. /**
  35177. * The yy coefficients of the spherical polynomial
  35178. */
  35179. yy: Vector3;
  35180. /**
  35181. * The zz coefficients of the spherical polynomial
  35182. */
  35183. zz: Vector3;
  35184. /**
  35185. * The xy coefficients of the spherical polynomial
  35186. */
  35187. xy: Vector3;
  35188. /**
  35189. * The yz coefficients of the spherical polynomial
  35190. */
  35191. yz: Vector3;
  35192. /**
  35193. * The zx coefficients of the spherical polynomial
  35194. */
  35195. zx: Vector3;
  35196. /**
  35197. * Adds an ambient color to the spherical polynomial
  35198. * @param color the color to add
  35199. */
  35200. addAmbient(color: Color3): void;
  35201. /**
  35202. * Scales the spherical polynomial by the given amount
  35203. * @param scale the amount to scale
  35204. */
  35205. scaleInPlace(scale: number): void;
  35206. /**
  35207. * Gets the spherical polynomial from harmonics
  35208. * @param harmonics the spherical harmonics
  35209. * @returns the spherical polynomial
  35210. */
  35211. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35212. /**
  35213. * Constructs a spherical polynomial from an array.
  35214. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35215. * @returns the spherical polynomial
  35216. */
  35217. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35218. }
  35219. }
  35220. declare module BABYLON {
  35221. /**
  35222. * Defines the source of the internal texture
  35223. */
  35224. export enum InternalTextureSource {
  35225. /**
  35226. * The source of the texture data is unknown
  35227. */
  35228. Unknown = 0,
  35229. /**
  35230. * Texture data comes from an URL
  35231. */
  35232. Url = 1,
  35233. /**
  35234. * Texture data is only used for temporary storage
  35235. */
  35236. Temp = 2,
  35237. /**
  35238. * Texture data comes from raw data (ArrayBuffer)
  35239. */
  35240. Raw = 3,
  35241. /**
  35242. * Texture content is dynamic (video or dynamic texture)
  35243. */
  35244. Dynamic = 4,
  35245. /**
  35246. * Texture content is generated by rendering to it
  35247. */
  35248. RenderTarget = 5,
  35249. /**
  35250. * Texture content is part of a multi render target process
  35251. */
  35252. MultiRenderTarget = 6,
  35253. /**
  35254. * Texture data comes from a cube data file
  35255. */
  35256. Cube = 7,
  35257. /**
  35258. * Texture data comes from a raw cube data
  35259. */
  35260. CubeRaw = 8,
  35261. /**
  35262. * Texture data come from a prefiltered cube data file
  35263. */
  35264. CubePrefiltered = 9,
  35265. /**
  35266. * Texture content is raw 3D data
  35267. */
  35268. Raw3D = 10,
  35269. /**
  35270. * Texture content is raw 2D array data
  35271. */
  35272. Raw2DArray = 11,
  35273. /**
  35274. * Texture content is a depth texture
  35275. */
  35276. Depth = 12,
  35277. /**
  35278. * Texture data comes from a raw cube data encoded with RGBD
  35279. */
  35280. CubeRawRGBD = 13
  35281. }
  35282. /**
  35283. * Class used to store data associated with WebGL texture data for the engine
  35284. * This class should not be used directly
  35285. */
  35286. export class InternalTexture {
  35287. /** @hidden */
  35288. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35289. /**
  35290. * Defines if the texture is ready
  35291. */
  35292. isReady: boolean;
  35293. /**
  35294. * Defines if the texture is a cube texture
  35295. */
  35296. isCube: boolean;
  35297. /**
  35298. * Defines if the texture contains 3D data
  35299. */
  35300. is3D: boolean;
  35301. /**
  35302. * Defines if the texture contains 2D array data
  35303. */
  35304. is2DArray: boolean;
  35305. /**
  35306. * Defines if the texture contains multiview data
  35307. */
  35308. isMultiview: boolean;
  35309. /**
  35310. * Gets the URL used to load this texture
  35311. */
  35312. url: string;
  35313. /**
  35314. * Gets the sampling mode of the texture
  35315. */
  35316. samplingMode: number;
  35317. /**
  35318. * Gets a boolean indicating if the texture needs mipmaps generation
  35319. */
  35320. generateMipMaps: boolean;
  35321. /**
  35322. * Gets the number of samples used by the texture (WebGL2+ only)
  35323. */
  35324. samples: number;
  35325. /**
  35326. * Gets the type of the texture (int, float...)
  35327. */
  35328. type: number;
  35329. /**
  35330. * Gets the format of the texture (RGB, RGBA...)
  35331. */
  35332. format: number;
  35333. /**
  35334. * Observable called when the texture is loaded
  35335. */
  35336. onLoadedObservable: Observable<InternalTexture>;
  35337. /**
  35338. * Gets the width of the texture
  35339. */
  35340. width: number;
  35341. /**
  35342. * Gets the height of the texture
  35343. */
  35344. height: number;
  35345. /**
  35346. * Gets the depth of the texture
  35347. */
  35348. depth: number;
  35349. /**
  35350. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35351. */
  35352. baseWidth: number;
  35353. /**
  35354. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35355. */
  35356. baseHeight: number;
  35357. /**
  35358. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35359. */
  35360. baseDepth: number;
  35361. /**
  35362. * Gets a boolean indicating if the texture is inverted on Y axis
  35363. */
  35364. invertY: boolean;
  35365. /** @hidden */
  35366. _invertVScale: boolean;
  35367. /** @hidden */
  35368. _associatedChannel: number;
  35369. /** @hidden */
  35370. _source: InternalTextureSource;
  35371. /** @hidden */
  35372. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35373. /** @hidden */
  35374. _bufferView: Nullable<ArrayBufferView>;
  35375. /** @hidden */
  35376. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35377. /** @hidden */
  35378. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35379. /** @hidden */
  35380. _size: number;
  35381. /** @hidden */
  35382. _extension: string;
  35383. /** @hidden */
  35384. _files: Nullable<string[]>;
  35385. /** @hidden */
  35386. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35387. /** @hidden */
  35388. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35389. /** @hidden */
  35390. _framebuffer: Nullable<WebGLFramebuffer>;
  35391. /** @hidden */
  35392. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35393. /** @hidden */
  35394. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35395. /** @hidden */
  35396. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35397. /** @hidden */
  35398. _attachments: Nullable<number[]>;
  35399. /** @hidden */
  35400. _cachedCoordinatesMode: Nullable<number>;
  35401. /** @hidden */
  35402. _cachedWrapU: Nullable<number>;
  35403. /** @hidden */
  35404. _cachedWrapV: Nullable<number>;
  35405. /** @hidden */
  35406. _cachedWrapR: Nullable<number>;
  35407. /** @hidden */
  35408. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35409. /** @hidden */
  35410. _isDisabled: boolean;
  35411. /** @hidden */
  35412. _compression: Nullable<string>;
  35413. /** @hidden */
  35414. _generateStencilBuffer: boolean;
  35415. /** @hidden */
  35416. _generateDepthBuffer: boolean;
  35417. /** @hidden */
  35418. _comparisonFunction: number;
  35419. /** @hidden */
  35420. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35421. /** @hidden */
  35422. _lodGenerationScale: number;
  35423. /** @hidden */
  35424. _lodGenerationOffset: number;
  35425. /** @hidden */
  35426. _depthStencilTexture: Nullable<InternalTexture>;
  35427. /** @hidden */
  35428. _colorTextureArray: Nullable<WebGLTexture>;
  35429. /** @hidden */
  35430. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35431. /** @hidden */
  35432. _lodTextureHigh: Nullable<BaseTexture>;
  35433. /** @hidden */
  35434. _lodTextureMid: Nullable<BaseTexture>;
  35435. /** @hidden */
  35436. _lodTextureLow: Nullable<BaseTexture>;
  35437. /** @hidden */
  35438. _isRGBD: boolean;
  35439. /** @hidden */
  35440. _linearSpecularLOD: boolean;
  35441. /** @hidden */
  35442. _irradianceTexture: Nullable<BaseTexture>;
  35443. /** @hidden */
  35444. _webGLTexture: Nullable<WebGLTexture>;
  35445. /** @hidden */
  35446. _references: number;
  35447. private _engine;
  35448. /**
  35449. * Gets the Engine the texture belongs to.
  35450. * @returns The babylon engine
  35451. */
  35452. getEngine(): ThinEngine;
  35453. /**
  35454. * Gets the data source type of the texture
  35455. */
  35456. get source(): InternalTextureSource;
  35457. /**
  35458. * Creates a new InternalTexture
  35459. * @param engine defines the engine to use
  35460. * @param source defines the type of data that will be used
  35461. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35462. */
  35463. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35464. /**
  35465. * Increments the number of references (ie. the number of Texture that point to it)
  35466. */
  35467. incrementReferences(): void;
  35468. /**
  35469. * Change the size of the texture (not the size of the content)
  35470. * @param width defines the new width
  35471. * @param height defines the new height
  35472. * @param depth defines the new depth (1 by default)
  35473. */
  35474. updateSize(width: int, height: int, depth?: int): void;
  35475. /** @hidden */
  35476. _rebuild(): void;
  35477. /** @hidden */
  35478. _swapAndDie(target: InternalTexture): void;
  35479. /**
  35480. * Dispose the current allocated resources
  35481. */
  35482. dispose(): void;
  35483. }
  35484. }
  35485. declare module BABYLON {
  35486. /**
  35487. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35489. */
  35490. export class Analyser {
  35491. /**
  35492. * Gets or sets the smoothing
  35493. * @ignorenaming
  35494. */
  35495. SMOOTHING: number;
  35496. /**
  35497. * Gets or sets the FFT table size
  35498. * @ignorenaming
  35499. */
  35500. FFT_SIZE: number;
  35501. /**
  35502. * Gets or sets the bar graph amplitude
  35503. * @ignorenaming
  35504. */
  35505. BARGRAPHAMPLITUDE: number;
  35506. /**
  35507. * Gets or sets the position of the debug canvas
  35508. * @ignorenaming
  35509. */
  35510. DEBUGCANVASPOS: {
  35511. x: number;
  35512. y: number;
  35513. };
  35514. /**
  35515. * Gets or sets the debug canvas size
  35516. * @ignorenaming
  35517. */
  35518. DEBUGCANVASSIZE: {
  35519. width: number;
  35520. height: number;
  35521. };
  35522. private _byteFreqs;
  35523. private _byteTime;
  35524. private _floatFreqs;
  35525. private _webAudioAnalyser;
  35526. private _debugCanvas;
  35527. private _debugCanvasContext;
  35528. private _scene;
  35529. private _registerFunc;
  35530. private _audioEngine;
  35531. /**
  35532. * Creates a new analyser
  35533. * @param scene defines hosting scene
  35534. */
  35535. constructor(scene: Scene);
  35536. /**
  35537. * Get the number of data values you will have to play with for the visualization
  35538. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35539. * @returns a number
  35540. */
  35541. getFrequencyBinCount(): number;
  35542. /**
  35543. * Gets the current frequency data as a byte array
  35544. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35545. * @returns a Uint8Array
  35546. */
  35547. getByteFrequencyData(): Uint8Array;
  35548. /**
  35549. * Gets the current waveform as a byte array
  35550. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35551. * @returns a Uint8Array
  35552. */
  35553. getByteTimeDomainData(): Uint8Array;
  35554. /**
  35555. * Gets the current frequency data as a float array
  35556. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35557. * @returns a Float32Array
  35558. */
  35559. getFloatFrequencyData(): Float32Array;
  35560. /**
  35561. * Renders the debug canvas
  35562. */
  35563. drawDebugCanvas(): void;
  35564. /**
  35565. * Stops rendering the debug canvas and removes it
  35566. */
  35567. stopDebugCanvas(): void;
  35568. /**
  35569. * Connects two audio nodes
  35570. * @param inputAudioNode defines first node to connect
  35571. * @param outputAudioNode defines second node to connect
  35572. */
  35573. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35574. /**
  35575. * Releases all associated resources
  35576. */
  35577. dispose(): void;
  35578. }
  35579. }
  35580. declare module BABYLON {
  35581. /**
  35582. * This represents an audio engine and it is responsible
  35583. * to play, synchronize and analyse sounds throughout the application.
  35584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35585. */
  35586. export interface IAudioEngine extends IDisposable {
  35587. /**
  35588. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35589. */
  35590. readonly canUseWebAudio: boolean;
  35591. /**
  35592. * Gets the current AudioContext if available.
  35593. */
  35594. readonly audioContext: Nullable<AudioContext>;
  35595. /**
  35596. * The master gain node defines the global audio volume of your audio engine.
  35597. */
  35598. readonly masterGain: GainNode;
  35599. /**
  35600. * Gets whether or not mp3 are supported by your browser.
  35601. */
  35602. readonly isMP3supported: boolean;
  35603. /**
  35604. * Gets whether or not ogg are supported by your browser.
  35605. */
  35606. readonly isOGGsupported: boolean;
  35607. /**
  35608. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35609. * @ignoreNaming
  35610. */
  35611. WarnedWebAudioUnsupported: boolean;
  35612. /**
  35613. * Defines if the audio engine relies on a custom unlocked button.
  35614. * In this case, the embedded button will not be displayed.
  35615. */
  35616. useCustomUnlockedButton: boolean;
  35617. /**
  35618. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35619. */
  35620. readonly unlocked: boolean;
  35621. /**
  35622. * Event raised when audio has been unlocked on the browser.
  35623. */
  35624. onAudioUnlockedObservable: Observable<AudioEngine>;
  35625. /**
  35626. * Event raised when audio has been locked on the browser.
  35627. */
  35628. onAudioLockedObservable: Observable<AudioEngine>;
  35629. /**
  35630. * Flags the audio engine in Locked state.
  35631. * This happens due to new browser policies preventing audio to autoplay.
  35632. */
  35633. lock(): void;
  35634. /**
  35635. * Unlocks the audio engine once a user action has been done on the dom.
  35636. * This is helpful to resume play once browser policies have been satisfied.
  35637. */
  35638. unlock(): void;
  35639. /**
  35640. * Gets the global volume sets on the master gain.
  35641. * @returns the global volume if set or -1 otherwise
  35642. */
  35643. getGlobalVolume(): number;
  35644. /**
  35645. * Sets the global volume of your experience (sets on the master gain).
  35646. * @param newVolume Defines the new global volume of the application
  35647. */
  35648. setGlobalVolume(newVolume: number): void;
  35649. /**
  35650. * Connect the audio engine to an audio analyser allowing some amazing
  35651. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35653. * @param analyser The analyser to connect to the engine
  35654. */
  35655. connectToAnalyser(analyser: Analyser): void;
  35656. }
  35657. /**
  35658. * This represents the default audio engine used in babylon.
  35659. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35661. */
  35662. export class AudioEngine implements IAudioEngine {
  35663. private _audioContext;
  35664. private _audioContextInitialized;
  35665. private _muteButton;
  35666. private _hostElement;
  35667. /**
  35668. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35669. */
  35670. canUseWebAudio: boolean;
  35671. /**
  35672. * The master gain node defines the global audio volume of your audio engine.
  35673. */
  35674. masterGain: GainNode;
  35675. /**
  35676. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35677. * @ignoreNaming
  35678. */
  35679. WarnedWebAudioUnsupported: boolean;
  35680. /**
  35681. * Gets whether or not mp3 are supported by your browser.
  35682. */
  35683. isMP3supported: boolean;
  35684. /**
  35685. * Gets whether or not ogg are supported by your browser.
  35686. */
  35687. isOGGsupported: boolean;
  35688. /**
  35689. * Gets whether audio has been unlocked on the device.
  35690. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35691. * a user interaction has happened.
  35692. */
  35693. unlocked: boolean;
  35694. /**
  35695. * Defines if the audio engine relies on a custom unlocked button.
  35696. * In this case, the embedded button will not be displayed.
  35697. */
  35698. useCustomUnlockedButton: boolean;
  35699. /**
  35700. * Event raised when audio has been unlocked on the browser.
  35701. */
  35702. onAudioUnlockedObservable: Observable<AudioEngine>;
  35703. /**
  35704. * Event raised when audio has been locked on the browser.
  35705. */
  35706. onAudioLockedObservable: Observable<AudioEngine>;
  35707. /**
  35708. * Gets the current AudioContext if available.
  35709. */
  35710. get audioContext(): Nullable<AudioContext>;
  35711. private _connectedAnalyser;
  35712. /**
  35713. * Instantiates a new audio engine.
  35714. *
  35715. * There should be only one per page as some browsers restrict the number
  35716. * of audio contexts you can create.
  35717. * @param hostElement defines the host element where to display the mute icon if necessary
  35718. */
  35719. constructor(hostElement?: Nullable<HTMLElement>);
  35720. /**
  35721. * Flags the audio engine in Locked state.
  35722. * This happens due to new browser policies preventing audio to autoplay.
  35723. */
  35724. lock(): void;
  35725. /**
  35726. * Unlocks the audio engine once a user action has been done on the dom.
  35727. * This is helpful to resume play once browser policies have been satisfied.
  35728. */
  35729. unlock(): void;
  35730. private _resumeAudioContext;
  35731. private _initializeAudioContext;
  35732. private _tryToRun;
  35733. private _triggerRunningState;
  35734. private _triggerSuspendedState;
  35735. private _displayMuteButton;
  35736. private _moveButtonToTopLeft;
  35737. private _onResize;
  35738. private _hideMuteButton;
  35739. /**
  35740. * Destroy and release the resources associated with the audio ccontext.
  35741. */
  35742. dispose(): void;
  35743. /**
  35744. * Gets the global volume sets on the master gain.
  35745. * @returns the global volume if set or -1 otherwise
  35746. */
  35747. getGlobalVolume(): number;
  35748. /**
  35749. * Sets the global volume of your experience (sets on the master gain).
  35750. * @param newVolume Defines the new global volume of the application
  35751. */
  35752. setGlobalVolume(newVolume: number): void;
  35753. /**
  35754. * Connect the audio engine to an audio analyser allowing some amazing
  35755. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35757. * @param analyser The analyser to connect to the engine
  35758. */
  35759. connectToAnalyser(analyser: Analyser): void;
  35760. }
  35761. }
  35762. declare module BABYLON {
  35763. /**
  35764. * Interface used to present a loading screen while loading a scene
  35765. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35766. */
  35767. export interface ILoadingScreen {
  35768. /**
  35769. * Function called to display the loading screen
  35770. */
  35771. displayLoadingUI: () => void;
  35772. /**
  35773. * Function called to hide the loading screen
  35774. */
  35775. hideLoadingUI: () => void;
  35776. /**
  35777. * Gets or sets the color to use for the background
  35778. */
  35779. loadingUIBackgroundColor: string;
  35780. /**
  35781. * Gets or sets the text to display while loading
  35782. */
  35783. loadingUIText: string;
  35784. }
  35785. /**
  35786. * Class used for the default loading screen
  35787. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35788. */
  35789. export class DefaultLoadingScreen implements ILoadingScreen {
  35790. private _renderingCanvas;
  35791. private _loadingText;
  35792. private _loadingDivBackgroundColor;
  35793. private _loadingDiv;
  35794. private _loadingTextDiv;
  35795. /** Gets or sets the logo url to use for the default loading screen */
  35796. static DefaultLogoUrl: string;
  35797. /** Gets or sets the spinner url to use for the default loading screen */
  35798. static DefaultSpinnerUrl: string;
  35799. /**
  35800. * Creates a new default loading screen
  35801. * @param _renderingCanvas defines the canvas used to render the scene
  35802. * @param _loadingText defines the default text to display
  35803. * @param _loadingDivBackgroundColor defines the default background color
  35804. */
  35805. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35806. /**
  35807. * Function called to display the loading screen
  35808. */
  35809. displayLoadingUI(): void;
  35810. /**
  35811. * Function called to hide the loading screen
  35812. */
  35813. hideLoadingUI(): void;
  35814. /**
  35815. * Gets or sets the text to display while loading
  35816. */
  35817. set loadingUIText(text: string);
  35818. get loadingUIText(): string;
  35819. /**
  35820. * Gets or sets the color to use for the background
  35821. */
  35822. get loadingUIBackgroundColor(): string;
  35823. set loadingUIBackgroundColor(color: string);
  35824. private _resizeLoadingUI;
  35825. }
  35826. }
  35827. declare module BABYLON {
  35828. /**
  35829. * Interface for any object that can request an animation frame
  35830. */
  35831. export interface ICustomAnimationFrameRequester {
  35832. /**
  35833. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35834. */
  35835. renderFunction?: Function;
  35836. /**
  35837. * Called to request the next frame to render to
  35838. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35839. */
  35840. requestAnimationFrame: Function;
  35841. /**
  35842. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35843. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35844. */
  35845. requestID?: number;
  35846. }
  35847. }
  35848. declare module BABYLON {
  35849. /**
  35850. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35851. */
  35852. export class PerformanceMonitor {
  35853. private _enabled;
  35854. private _rollingFrameTime;
  35855. private _lastFrameTimeMs;
  35856. /**
  35857. * constructor
  35858. * @param frameSampleSize The number of samples required to saturate the sliding window
  35859. */
  35860. constructor(frameSampleSize?: number);
  35861. /**
  35862. * Samples current frame
  35863. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35864. */
  35865. sampleFrame(timeMs?: number): void;
  35866. /**
  35867. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35868. */
  35869. get averageFrameTime(): number;
  35870. /**
  35871. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35872. */
  35873. get averageFrameTimeVariance(): number;
  35874. /**
  35875. * Returns the frame time of the most recent frame
  35876. */
  35877. get instantaneousFrameTime(): number;
  35878. /**
  35879. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35880. */
  35881. get averageFPS(): number;
  35882. /**
  35883. * Returns the average framerate in frames per second using the most recent frame time
  35884. */
  35885. get instantaneousFPS(): number;
  35886. /**
  35887. * Returns true if enough samples have been taken to completely fill the sliding window
  35888. */
  35889. get isSaturated(): boolean;
  35890. /**
  35891. * Enables contributions to the sliding window sample set
  35892. */
  35893. enable(): void;
  35894. /**
  35895. * Disables contributions to the sliding window sample set
  35896. * Samples will not be interpolated over the disabled period
  35897. */
  35898. disable(): void;
  35899. /**
  35900. * Returns true if sampling is enabled
  35901. */
  35902. get isEnabled(): boolean;
  35903. /**
  35904. * Resets performance monitor
  35905. */
  35906. reset(): void;
  35907. }
  35908. /**
  35909. * RollingAverage
  35910. *
  35911. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35912. */
  35913. export class RollingAverage {
  35914. /**
  35915. * Current average
  35916. */
  35917. average: number;
  35918. /**
  35919. * Current variance
  35920. */
  35921. variance: number;
  35922. protected _samples: Array<number>;
  35923. protected _sampleCount: number;
  35924. protected _pos: number;
  35925. protected _m2: number;
  35926. /**
  35927. * constructor
  35928. * @param length The number of samples required to saturate the sliding window
  35929. */
  35930. constructor(length: number);
  35931. /**
  35932. * Adds a sample to the sample set
  35933. * @param v The sample value
  35934. */
  35935. add(v: number): void;
  35936. /**
  35937. * Returns previously added values or null if outside of history or outside the sliding window domain
  35938. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35939. * @return Value previously recorded with add() or null if outside of range
  35940. */
  35941. history(i: number): number;
  35942. /**
  35943. * Returns true if enough samples have been taken to completely fill the sliding window
  35944. * @return true if sample-set saturated
  35945. */
  35946. isSaturated(): boolean;
  35947. /**
  35948. * Resets the rolling average (equivalent to 0 samples taken so far)
  35949. */
  35950. reset(): void;
  35951. /**
  35952. * Wraps a value around the sample range boundaries
  35953. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35954. * @return Wrapped position in sample range
  35955. */
  35956. protected _wrapPosition(i: number): number;
  35957. }
  35958. }
  35959. declare module BABYLON {
  35960. /**
  35961. * This class is used to track a performance counter which is number based.
  35962. * The user has access to many properties which give statistics of different nature.
  35963. *
  35964. * The implementer can track two kinds of Performance Counter: time and count.
  35965. * 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.
  35966. * 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.
  35967. */
  35968. export class PerfCounter {
  35969. /**
  35970. * Gets or sets a global boolean to turn on and off all the counters
  35971. */
  35972. static Enabled: boolean;
  35973. /**
  35974. * Returns the smallest value ever
  35975. */
  35976. get min(): number;
  35977. /**
  35978. * Returns the biggest value ever
  35979. */
  35980. get max(): number;
  35981. /**
  35982. * Returns the average value since the performance counter is running
  35983. */
  35984. get average(): number;
  35985. /**
  35986. * Returns the average value of the last second the counter was monitored
  35987. */
  35988. get lastSecAverage(): number;
  35989. /**
  35990. * Returns the current value
  35991. */
  35992. get current(): number;
  35993. /**
  35994. * Gets the accumulated total
  35995. */
  35996. get total(): number;
  35997. /**
  35998. * Gets the total value count
  35999. */
  36000. get count(): number;
  36001. /**
  36002. * Creates a new counter
  36003. */
  36004. constructor();
  36005. /**
  36006. * Call this method to start monitoring a new frame.
  36007. * 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.
  36008. */
  36009. fetchNewFrame(): void;
  36010. /**
  36011. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36012. * @param newCount the count value to add to the monitored count
  36013. * @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.
  36014. */
  36015. addCount(newCount: number, fetchResult: boolean): void;
  36016. /**
  36017. * Start monitoring this performance counter
  36018. */
  36019. beginMonitoring(): void;
  36020. /**
  36021. * Compute the time lapsed since the previous beginMonitoring() call.
  36022. * @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
  36023. */
  36024. endMonitoring(newFrame?: boolean): void;
  36025. private _fetchResult;
  36026. private _startMonitoringTime;
  36027. private _min;
  36028. private _max;
  36029. private _average;
  36030. private _current;
  36031. private _totalValueCount;
  36032. private _totalAccumulated;
  36033. private _lastSecAverage;
  36034. private _lastSecAccumulated;
  36035. private _lastSecTime;
  36036. private _lastSecValueCount;
  36037. }
  36038. }
  36039. declare module BABYLON {
  36040. interface ThinEngine {
  36041. /**
  36042. * Sets alpha constants used by some alpha blending modes
  36043. * @param r defines the red component
  36044. * @param g defines the green component
  36045. * @param b defines the blue component
  36046. * @param a defines the alpha component
  36047. */
  36048. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36049. /**
  36050. * Sets the current alpha mode
  36051. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36052. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36053. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36054. */
  36055. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36056. /**
  36057. * Gets the current alpha mode
  36058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36059. * @returns the current alpha mode
  36060. */
  36061. getAlphaMode(): number;
  36062. /**
  36063. * Sets the current alpha equation
  36064. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36065. */
  36066. setAlphaEquation(equation: number): void;
  36067. /**
  36068. * Gets the current alpha equation.
  36069. * @returns the current alpha equation
  36070. */
  36071. getAlphaEquation(): number;
  36072. }
  36073. }
  36074. declare module BABYLON {
  36075. interface ThinEngine {
  36076. /** @hidden */
  36077. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36078. }
  36079. }
  36080. declare module BABYLON {
  36081. /**
  36082. * Defines the interface used by display changed events
  36083. */
  36084. export interface IDisplayChangedEventArgs {
  36085. /** Gets the vrDisplay object (if any) */
  36086. vrDisplay: Nullable<any>;
  36087. /** Gets a boolean indicating if webVR is supported */
  36088. vrSupported: boolean;
  36089. }
  36090. /**
  36091. * Defines the interface used by objects containing a viewport (like a camera)
  36092. */
  36093. interface IViewportOwnerLike {
  36094. /**
  36095. * Gets or sets the viewport
  36096. */
  36097. viewport: IViewportLike;
  36098. }
  36099. /**
  36100. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36101. */
  36102. export class Engine extends ThinEngine {
  36103. /** Defines that alpha blending is disabled */
  36104. static readonly ALPHA_DISABLE: number;
  36105. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36106. static readonly ALPHA_ADD: number;
  36107. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36108. static readonly ALPHA_COMBINE: number;
  36109. /** Defines that alpha blending to DEST - SRC * DEST */
  36110. static readonly ALPHA_SUBTRACT: number;
  36111. /** Defines that alpha blending to SRC * DEST */
  36112. static readonly ALPHA_MULTIPLY: number;
  36113. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36114. static readonly ALPHA_MAXIMIZED: number;
  36115. /** Defines that alpha blending to SRC + DEST */
  36116. static readonly ALPHA_ONEONE: number;
  36117. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36118. static readonly ALPHA_PREMULTIPLIED: number;
  36119. /**
  36120. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36121. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36122. */
  36123. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36124. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36125. static readonly ALPHA_INTERPOLATE: number;
  36126. /**
  36127. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36128. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36129. */
  36130. static readonly ALPHA_SCREENMODE: number;
  36131. /** Defines that the ressource is not delayed*/
  36132. static readonly DELAYLOADSTATE_NONE: number;
  36133. /** Defines that the ressource was successfully delay loaded */
  36134. static readonly DELAYLOADSTATE_LOADED: number;
  36135. /** Defines that the ressource is currently delay loading */
  36136. static readonly DELAYLOADSTATE_LOADING: number;
  36137. /** Defines that the ressource is delayed and has not started loading */
  36138. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36139. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36140. static readonly NEVER: number;
  36141. /** 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 */
  36142. static readonly ALWAYS: number;
  36143. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36144. static readonly LESS: number;
  36145. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36146. static readonly EQUAL: number;
  36147. /** 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 */
  36148. static readonly LEQUAL: number;
  36149. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36150. static readonly GREATER: number;
  36151. /** 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 */
  36152. static readonly GEQUAL: number;
  36153. /** 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 */
  36154. static readonly NOTEQUAL: number;
  36155. /** Passed to stencilOperation to specify that stencil value must be kept */
  36156. static readonly KEEP: number;
  36157. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36158. static readonly REPLACE: number;
  36159. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36160. static readonly INCR: number;
  36161. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36162. static readonly DECR: number;
  36163. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36164. static readonly INVERT: number;
  36165. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36166. static readonly INCR_WRAP: number;
  36167. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36168. static readonly DECR_WRAP: number;
  36169. /** Texture is not repeating outside of 0..1 UVs */
  36170. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36171. /** Texture is repeating outside of 0..1 UVs */
  36172. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36173. /** Texture is repeating and mirrored */
  36174. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36175. /** ALPHA */
  36176. static readonly TEXTUREFORMAT_ALPHA: number;
  36177. /** LUMINANCE */
  36178. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36179. /** LUMINANCE_ALPHA */
  36180. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36181. /** RGB */
  36182. static readonly TEXTUREFORMAT_RGB: number;
  36183. /** RGBA */
  36184. static readonly TEXTUREFORMAT_RGBA: number;
  36185. /** RED */
  36186. static readonly TEXTUREFORMAT_RED: number;
  36187. /** RED (2nd reference) */
  36188. static readonly TEXTUREFORMAT_R: number;
  36189. /** RG */
  36190. static readonly TEXTUREFORMAT_RG: number;
  36191. /** RED_INTEGER */
  36192. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36193. /** RED_INTEGER (2nd reference) */
  36194. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36195. /** RG_INTEGER */
  36196. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36197. /** RGB_INTEGER */
  36198. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36199. /** RGBA_INTEGER */
  36200. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36201. /** UNSIGNED_BYTE */
  36202. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36203. /** UNSIGNED_BYTE (2nd reference) */
  36204. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36205. /** FLOAT */
  36206. static readonly TEXTURETYPE_FLOAT: number;
  36207. /** HALF_FLOAT */
  36208. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36209. /** BYTE */
  36210. static readonly TEXTURETYPE_BYTE: number;
  36211. /** SHORT */
  36212. static readonly TEXTURETYPE_SHORT: number;
  36213. /** UNSIGNED_SHORT */
  36214. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36215. /** INT */
  36216. static readonly TEXTURETYPE_INT: number;
  36217. /** UNSIGNED_INT */
  36218. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36219. /** UNSIGNED_SHORT_4_4_4_4 */
  36220. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36221. /** UNSIGNED_SHORT_5_5_5_1 */
  36222. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36223. /** UNSIGNED_SHORT_5_6_5 */
  36224. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36225. /** UNSIGNED_INT_2_10_10_10_REV */
  36226. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36227. /** UNSIGNED_INT_24_8 */
  36228. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36229. /** UNSIGNED_INT_10F_11F_11F_REV */
  36230. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36231. /** UNSIGNED_INT_5_9_9_9_REV */
  36232. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36233. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36234. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36235. /** nearest is mag = nearest and min = nearest and mip = linear */
  36236. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36237. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36238. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36239. /** Trilinear is mag = linear and min = linear and mip = linear */
  36240. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36241. /** nearest is mag = nearest and min = nearest and mip = linear */
  36242. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36243. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36244. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36245. /** Trilinear is mag = linear and min = linear and mip = linear */
  36246. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36247. /** mag = nearest and min = nearest and mip = nearest */
  36248. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36249. /** mag = nearest and min = linear and mip = nearest */
  36250. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36251. /** mag = nearest and min = linear and mip = linear */
  36252. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36253. /** mag = nearest and min = linear and mip = none */
  36254. static readonly TEXTURE_NEAREST_LINEAR: number;
  36255. /** mag = nearest and min = nearest and mip = none */
  36256. static readonly TEXTURE_NEAREST_NEAREST: number;
  36257. /** mag = linear and min = nearest and mip = nearest */
  36258. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36259. /** mag = linear and min = nearest and mip = linear */
  36260. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36261. /** mag = linear and min = linear and mip = none */
  36262. static readonly TEXTURE_LINEAR_LINEAR: number;
  36263. /** mag = linear and min = nearest and mip = none */
  36264. static readonly TEXTURE_LINEAR_NEAREST: number;
  36265. /** Explicit coordinates mode */
  36266. static readonly TEXTURE_EXPLICIT_MODE: number;
  36267. /** Spherical coordinates mode */
  36268. static readonly TEXTURE_SPHERICAL_MODE: number;
  36269. /** Planar coordinates mode */
  36270. static readonly TEXTURE_PLANAR_MODE: number;
  36271. /** Cubic coordinates mode */
  36272. static readonly TEXTURE_CUBIC_MODE: number;
  36273. /** Projection coordinates mode */
  36274. static readonly TEXTURE_PROJECTION_MODE: number;
  36275. /** Skybox coordinates mode */
  36276. static readonly TEXTURE_SKYBOX_MODE: number;
  36277. /** Inverse Cubic coordinates mode */
  36278. static readonly TEXTURE_INVCUBIC_MODE: number;
  36279. /** Equirectangular coordinates mode */
  36280. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36281. /** Equirectangular Fixed coordinates mode */
  36282. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36283. /** Equirectangular Fixed Mirrored coordinates mode */
  36284. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36285. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36286. static readonly SCALEMODE_FLOOR: number;
  36287. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36288. static readonly SCALEMODE_NEAREST: number;
  36289. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36290. static readonly SCALEMODE_CEILING: number;
  36291. /**
  36292. * Returns the current npm package of the sdk
  36293. */
  36294. static get NpmPackage(): string;
  36295. /**
  36296. * Returns the current version of the framework
  36297. */
  36298. static get Version(): string;
  36299. /** Gets the list of created engines */
  36300. static get Instances(): Engine[];
  36301. /**
  36302. * Gets the latest created engine
  36303. */
  36304. static get LastCreatedEngine(): Nullable<Engine>;
  36305. /**
  36306. * Gets the latest created scene
  36307. */
  36308. static get LastCreatedScene(): Nullable<Scene>;
  36309. /**
  36310. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36311. * @param flag defines which part of the materials must be marked as dirty
  36312. * @param predicate defines a predicate used to filter which materials should be affected
  36313. */
  36314. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36315. /**
  36316. * Method called to create the default loading screen.
  36317. * This can be overriden in your own app.
  36318. * @param canvas The rendering canvas element
  36319. * @returns The loading screen
  36320. */
  36321. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36322. /**
  36323. * Method called to create the default rescale post process on each engine.
  36324. */
  36325. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36326. /**
  36327. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36328. **/
  36329. enableOfflineSupport: boolean;
  36330. /**
  36331. * 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)
  36332. **/
  36333. disableManifestCheck: boolean;
  36334. /**
  36335. * Gets the list of created scenes
  36336. */
  36337. scenes: Scene[];
  36338. /**
  36339. * Event raised when a new scene is created
  36340. */
  36341. onNewSceneAddedObservable: Observable<Scene>;
  36342. /**
  36343. * Gets the list of created postprocesses
  36344. */
  36345. postProcesses: PostProcess[];
  36346. /**
  36347. * Gets a boolean indicating if the pointer is currently locked
  36348. */
  36349. isPointerLock: boolean;
  36350. /**
  36351. * Observable event triggered each time the rendering canvas is resized
  36352. */
  36353. onResizeObservable: Observable<Engine>;
  36354. /**
  36355. * Observable event triggered each time the canvas loses focus
  36356. */
  36357. onCanvasBlurObservable: Observable<Engine>;
  36358. /**
  36359. * Observable event triggered each time the canvas gains focus
  36360. */
  36361. onCanvasFocusObservable: Observable<Engine>;
  36362. /**
  36363. * Observable event triggered each time the canvas receives pointerout event
  36364. */
  36365. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36366. /**
  36367. * Observable raised when the engine begins a new frame
  36368. */
  36369. onBeginFrameObservable: Observable<Engine>;
  36370. /**
  36371. * If set, will be used to request the next animation frame for the render loop
  36372. */
  36373. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36374. /**
  36375. * Observable raised when the engine ends the current frame
  36376. */
  36377. onEndFrameObservable: Observable<Engine>;
  36378. /**
  36379. * Observable raised when the engine is about to compile a shader
  36380. */
  36381. onBeforeShaderCompilationObservable: Observable<Engine>;
  36382. /**
  36383. * Observable raised when the engine has jsut compiled a shader
  36384. */
  36385. onAfterShaderCompilationObservable: Observable<Engine>;
  36386. /**
  36387. * Gets the audio engine
  36388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36389. * @ignorenaming
  36390. */
  36391. static audioEngine: IAudioEngine;
  36392. /**
  36393. * Default AudioEngine factory responsible of creating the Audio Engine.
  36394. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36395. */
  36396. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36397. /**
  36398. * Default offline support factory responsible of creating a tool used to store data locally.
  36399. * By default, this will create a Database object if the workload has been embedded.
  36400. */
  36401. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36402. private _loadingScreen;
  36403. private _pointerLockRequested;
  36404. private _rescalePostProcess;
  36405. private _deterministicLockstep;
  36406. private _lockstepMaxSteps;
  36407. private _timeStep;
  36408. protected get _supportsHardwareTextureRescaling(): boolean;
  36409. private _fps;
  36410. private _deltaTime;
  36411. /** @hidden */
  36412. _drawCalls: PerfCounter;
  36413. /** 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 */
  36414. canvasTabIndex: number;
  36415. /**
  36416. * Turn this value on if you want to pause FPS computation when in background
  36417. */
  36418. disablePerformanceMonitorInBackground: boolean;
  36419. private _performanceMonitor;
  36420. /**
  36421. * Gets the performance monitor attached to this engine
  36422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36423. */
  36424. get performanceMonitor(): PerformanceMonitor;
  36425. private _onFocus;
  36426. private _onBlur;
  36427. private _onCanvasPointerOut;
  36428. private _onCanvasBlur;
  36429. private _onCanvasFocus;
  36430. private _onFullscreenChange;
  36431. private _onPointerLockChange;
  36432. /**
  36433. * Gets the HTML element used to attach event listeners
  36434. * @returns a HTML element
  36435. */
  36436. getInputElement(): Nullable<HTMLElement>;
  36437. /**
  36438. * Creates a new engine
  36439. * @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
  36440. * @param antialias defines enable antialiasing (default: false)
  36441. * @param options defines further options to be sent to the getContext() function
  36442. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36443. */
  36444. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36445. /**
  36446. * Gets current aspect ratio
  36447. * @param viewportOwner defines the camera to use to get the aspect ratio
  36448. * @param useScreen defines if screen size must be used (or the current render target if any)
  36449. * @returns a number defining the aspect ratio
  36450. */
  36451. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36452. /**
  36453. * Gets current screen aspect ratio
  36454. * @returns a number defining the aspect ratio
  36455. */
  36456. getScreenAspectRatio(): number;
  36457. /**
  36458. * Gets the client rect of the HTML canvas attached with the current webGL context
  36459. * @returns a client rectanglee
  36460. */
  36461. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36462. /**
  36463. * Gets the client rect of the HTML element used for events
  36464. * @returns a client rectanglee
  36465. */
  36466. getInputElementClientRect(): Nullable<ClientRect>;
  36467. /**
  36468. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36470. * @returns true if engine is in deterministic lock step mode
  36471. */
  36472. isDeterministicLockStep(): boolean;
  36473. /**
  36474. * Gets the max steps when engine is running in deterministic lock step
  36475. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36476. * @returns the max steps
  36477. */
  36478. getLockstepMaxSteps(): number;
  36479. /**
  36480. * Returns the time in ms between steps when using deterministic lock step.
  36481. * @returns time step in (ms)
  36482. */
  36483. getTimeStep(): number;
  36484. /**
  36485. * Force the mipmap generation for the given render target texture
  36486. * @param texture defines the render target texture to use
  36487. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36488. */
  36489. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36490. /** States */
  36491. /**
  36492. * Set various states to the webGL context
  36493. * @param culling defines backface culling state
  36494. * @param zOffset defines the value to apply to zOffset (0 by default)
  36495. * @param force defines if states must be applied even if cache is up to date
  36496. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36497. */
  36498. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36499. /**
  36500. * Set the z offset to apply to current rendering
  36501. * @param value defines the offset to apply
  36502. */
  36503. setZOffset(value: number): void;
  36504. /**
  36505. * Gets the current value of the zOffset
  36506. * @returns the current zOffset state
  36507. */
  36508. getZOffset(): number;
  36509. /**
  36510. * Enable or disable depth buffering
  36511. * @param enable defines the state to set
  36512. */
  36513. setDepthBuffer(enable: boolean): void;
  36514. /**
  36515. * Gets a boolean indicating if depth writing is enabled
  36516. * @returns the current depth writing state
  36517. */
  36518. getDepthWrite(): boolean;
  36519. /**
  36520. * Enable or disable depth writing
  36521. * @param enable defines the state to set
  36522. */
  36523. setDepthWrite(enable: boolean): void;
  36524. /**
  36525. * Gets a boolean indicating if stencil buffer is enabled
  36526. * @returns the current stencil buffer state
  36527. */
  36528. getStencilBuffer(): boolean;
  36529. /**
  36530. * Enable or disable the stencil buffer
  36531. * @param enable defines if the stencil buffer must be enabled or disabled
  36532. */
  36533. setStencilBuffer(enable: boolean): void;
  36534. /**
  36535. * Gets the current stencil mask
  36536. * @returns a number defining the new stencil mask to use
  36537. */
  36538. getStencilMask(): number;
  36539. /**
  36540. * Sets the current stencil mask
  36541. * @param mask defines the new stencil mask to use
  36542. */
  36543. setStencilMask(mask: number): void;
  36544. /**
  36545. * Gets the current stencil function
  36546. * @returns a number defining the stencil function to use
  36547. */
  36548. getStencilFunction(): number;
  36549. /**
  36550. * Gets the current stencil reference value
  36551. * @returns a number defining the stencil reference value to use
  36552. */
  36553. getStencilFunctionReference(): number;
  36554. /**
  36555. * Gets the current stencil mask
  36556. * @returns a number defining the stencil mask to use
  36557. */
  36558. getStencilFunctionMask(): number;
  36559. /**
  36560. * Sets the current stencil function
  36561. * @param stencilFunc defines the new stencil function to use
  36562. */
  36563. setStencilFunction(stencilFunc: number): void;
  36564. /**
  36565. * Sets the current stencil reference
  36566. * @param reference defines the new stencil reference to use
  36567. */
  36568. setStencilFunctionReference(reference: number): void;
  36569. /**
  36570. * Sets the current stencil mask
  36571. * @param mask defines the new stencil mask to use
  36572. */
  36573. setStencilFunctionMask(mask: number): void;
  36574. /**
  36575. * Gets the current stencil operation when stencil fails
  36576. * @returns a number defining stencil operation to use when stencil fails
  36577. */
  36578. getStencilOperationFail(): number;
  36579. /**
  36580. * Gets the current stencil operation when depth fails
  36581. * @returns a number defining stencil operation to use when depth fails
  36582. */
  36583. getStencilOperationDepthFail(): number;
  36584. /**
  36585. * Gets the current stencil operation when stencil passes
  36586. * @returns a number defining stencil operation to use when stencil passes
  36587. */
  36588. getStencilOperationPass(): number;
  36589. /**
  36590. * Sets the stencil operation to use when stencil fails
  36591. * @param operation defines the stencil operation to use when stencil fails
  36592. */
  36593. setStencilOperationFail(operation: number): void;
  36594. /**
  36595. * Sets the stencil operation to use when depth fails
  36596. * @param operation defines the stencil operation to use when depth fails
  36597. */
  36598. setStencilOperationDepthFail(operation: number): void;
  36599. /**
  36600. * Sets the stencil operation to use when stencil passes
  36601. * @param operation defines the stencil operation to use when stencil passes
  36602. */
  36603. setStencilOperationPass(operation: number): void;
  36604. /**
  36605. * Sets a boolean indicating if the dithering state is enabled or disabled
  36606. * @param value defines the dithering state
  36607. */
  36608. setDitheringState(value: boolean): void;
  36609. /**
  36610. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36611. * @param value defines the rasterizer state
  36612. */
  36613. setRasterizerState(value: boolean): void;
  36614. /**
  36615. * Gets the current depth function
  36616. * @returns a number defining the depth function
  36617. */
  36618. getDepthFunction(): Nullable<number>;
  36619. /**
  36620. * Sets the current depth function
  36621. * @param depthFunc defines the function to use
  36622. */
  36623. setDepthFunction(depthFunc: number): void;
  36624. /**
  36625. * Sets the current depth function to GREATER
  36626. */
  36627. setDepthFunctionToGreater(): void;
  36628. /**
  36629. * Sets the current depth function to GEQUAL
  36630. */
  36631. setDepthFunctionToGreaterOrEqual(): void;
  36632. /**
  36633. * Sets the current depth function to LESS
  36634. */
  36635. setDepthFunctionToLess(): void;
  36636. /**
  36637. * Sets the current depth function to LEQUAL
  36638. */
  36639. setDepthFunctionToLessOrEqual(): void;
  36640. private _cachedStencilBuffer;
  36641. private _cachedStencilFunction;
  36642. private _cachedStencilMask;
  36643. private _cachedStencilOperationPass;
  36644. private _cachedStencilOperationFail;
  36645. private _cachedStencilOperationDepthFail;
  36646. private _cachedStencilReference;
  36647. /**
  36648. * Caches the the state of the stencil buffer
  36649. */
  36650. cacheStencilState(): void;
  36651. /**
  36652. * Restores the state of the stencil buffer
  36653. */
  36654. restoreStencilState(): void;
  36655. /**
  36656. * Directly set the WebGL Viewport
  36657. * @param x defines the x coordinate of the viewport (in screen space)
  36658. * @param y defines the y coordinate of the viewport (in screen space)
  36659. * @param width defines the width of the viewport (in screen space)
  36660. * @param height defines the height of the viewport (in screen space)
  36661. * @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
  36662. */
  36663. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36664. /**
  36665. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36666. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36667. * @param y defines the y-coordinate of the corner of the clear rectangle
  36668. * @param width defines the width of the clear rectangle
  36669. * @param height defines the height of the clear rectangle
  36670. * @param clearColor defines the clear color
  36671. */
  36672. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36673. /**
  36674. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36675. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36676. * @param y defines the y-coordinate of the corner of the clear rectangle
  36677. * @param width defines the width of the clear rectangle
  36678. * @param height defines the height of the clear rectangle
  36679. */
  36680. enableScissor(x: number, y: number, width: number, height: number): void;
  36681. /**
  36682. * Disable previously set scissor test rectangle
  36683. */
  36684. disableScissor(): void;
  36685. protected _reportDrawCall(): void;
  36686. /**
  36687. * Initializes a webVR display and starts listening to display change events
  36688. * The onVRDisplayChangedObservable will be notified upon these changes
  36689. * @returns The onVRDisplayChangedObservable
  36690. */
  36691. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36692. /** @hidden */
  36693. _prepareVRComponent(): void;
  36694. /** @hidden */
  36695. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36696. /** @hidden */
  36697. _submitVRFrame(): void;
  36698. /**
  36699. * Call this function to leave webVR mode
  36700. * Will do nothing if webVR is not supported or if there is no webVR device
  36701. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36702. */
  36703. disableVR(): void;
  36704. /**
  36705. * Gets a boolean indicating that the system is in VR mode and is presenting
  36706. * @returns true if VR mode is engaged
  36707. */
  36708. isVRPresenting(): boolean;
  36709. /** @hidden */
  36710. _requestVRFrame(): void;
  36711. /** @hidden */
  36712. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36713. /**
  36714. * Gets the source code of the vertex shader associated with a specific webGL program
  36715. * @param program defines the program to use
  36716. * @returns a string containing the source code of the vertex shader associated with the program
  36717. */
  36718. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36719. /**
  36720. * Gets the source code of the fragment shader associated with a specific webGL program
  36721. * @param program defines the program to use
  36722. * @returns a string containing the source code of the fragment shader associated with the program
  36723. */
  36724. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36725. /**
  36726. * Sets a depth stencil texture from a render target to the according uniform.
  36727. * @param channel The texture channel
  36728. * @param uniform The uniform to set
  36729. * @param texture The render target texture containing the depth stencil texture to apply
  36730. */
  36731. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36732. /**
  36733. * Sets a texture to the webGL context from a postprocess
  36734. * @param channel defines the channel to use
  36735. * @param postProcess defines the source postprocess
  36736. */
  36737. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36738. /**
  36739. * Binds the output of the passed in post process to the texture channel specified
  36740. * @param channel The channel the texture should be bound to
  36741. * @param postProcess The post process which's output should be bound
  36742. */
  36743. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36744. protected _rebuildBuffers(): void;
  36745. /** @hidden */
  36746. _renderFrame(): void;
  36747. _renderLoop(): void;
  36748. /** @hidden */
  36749. _renderViews(): boolean;
  36750. /**
  36751. * Toggle full screen mode
  36752. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36753. */
  36754. switchFullscreen(requestPointerLock: boolean): void;
  36755. /**
  36756. * Enters full screen mode
  36757. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36758. */
  36759. enterFullscreen(requestPointerLock: boolean): void;
  36760. /**
  36761. * Exits full screen mode
  36762. */
  36763. exitFullscreen(): void;
  36764. /**
  36765. * Enters Pointerlock mode
  36766. */
  36767. enterPointerlock(): void;
  36768. /**
  36769. * Exits Pointerlock mode
  36770. */
  36771. exitPointerlock(): void;
  36772. /**
  36773. * Begin a new frame
  36774. */
  36775. beginFrame(): void;
  36776. /**
  36777. * Enf the current frame
  36778. */
  36779. endFrame(): void;
  36780. resize(): void;
  36781. /**
  36782. * Force a specific size of the canvas
  36783. * @param width defines the new canvas' width
  36784. * @param height defines the new canvas' height
  36785. */
  36786. setSize(width: number, height: number): void;
  36787. /**
  36788. * Updates a dynamic vertex buffer.
  36789. * @param vertexBuffer the vertex buffer to update
  36790. * @param data the data used to update the vertex buffer
  36791. * @param byteOffset the byte offset of the data
  36792. * @param byteLength the byte length of the data
  36793. */
  36794. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36795. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36796. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36797. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36798. _releaseTexture(texture: InternalTexture): void;
  36799. /**
  36800. * @hidden
  36801. * Rescales a texture
  36802. * @param source input texutre
  36803. * @param destination destination texture
  36804. * @param scene scene to use to render the resize
  36805. * @param internalFormat format to use when resizing
  36806. * @param onComplete callback to be called when resize has completed
  36807. */
  36808. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36809. /**
  36810. * Gets the current framerate
  36811. * @returns a number representing the framerate
  36812. */
  36813. getFps(): number;
  36814. /**
  36815. * Gets the time spent between current and previous frame
  36816. * @returns a number representing the delta time in ms
  36817. */
  36818. getDeltaTime(): number;
  36819. private _measureFps;
  36820. /** @hidden */
  36821. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36822. /**
  36823. * Update a dynamic index buffer
  36824. * @param indexBuffer defines the target index buffer
  36825. * @param indices defines the data to update
  36826. * @param offset defines the offset in the target index buffer where update should start
  36827. */
  36828. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36829. /**
  36830. * Updates the sample count of a render target texture
  36831. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36832. * @param texture defines the texture to update
  36833. * @param samples defines the sample count to set
  36834. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36835. */
  36836. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36837. /**
  36838. * Updates a depth texture Comparison Mode and Function.
  36839. * If the comparison Function is equal to 0, the mode will be set to none.
  36840. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36841. * @param texture The texture to set the comparison function for
  36842. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36843. */
  36844. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36845. /**
  36846. * Creates a webGL buffer to use with instanciation
  36847. * @param capacity defines the size of the buffer
  36848. * @returns the webGL buffer
  36849. */
  36850. createInstancesBuffer(capacity: number): DataBuffer;
  36851. /**
  36852. * Delete a webGL buffer used with instanciation
  36853. * @param buffer defines the webGL buffer to delete
  36854. */
  36855. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36856. private _clientWaitAsync;
  36857. /** @hidden */
  36858. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36859. dispose(): void;
  36860. private _disableTouchAction;
  36861. /**
  36862. * Display the loading screen
  36863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36864. */
  36865. displayLoadingUI(): void;
  36866. /**
  36867. * Hide the loading screen
  36868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36869. */
  36870. hideLoadingUI(): void;
  36871. /**
  36872. * Gets the current loading screen object
  36873. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36874. */
  36875. get loadingScreen(): ILoadingScreen;
  36876. /**
  36877. * Sets the current loading screen object
  36878. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36879. */
  36880. set loadingScreen(loadingScreen: ILoadingScreen);
  36881. /**
  36882. * Sets the current loading screen text
  36883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36884. */
  36885. set loadingUIText(text: string);
  36886. /**
  36887. * Sets the current loading screen background color
  36888. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36889. */
  36890. set loadingUIBackgroundColor(color: string);
  36891. /** Pointerlock and fullscreen */
  36892. /**
  36893. * Ask the browser to promote the current element to pointerlock mode
  36894. * @param element defines the DOM element to promote
  36895. */
  36896. static _RequestPointerlock(element: HTMLElement): void;
  36897. /**
  36898. * Asks the browser to exit pointerlock mode
  36899. */
  36900. static _ExitPointerlock(): void;
  36901. /**
  36902. * Ask the browser to promote the current element to fullscreen rendering mode
  36903. * @param element defines the DOM element to promote
  36904. */
  36905. static _RequestFullscreen(element: HTMLElement): void;
  36906. /**
  36907. * Asks the browser to exit fullscreen mode
  36908. */
  36909. static _ExitFullscreen(): void;
  36910. }
  36911. }
  36912. declare module BABYLON {
  36913. /**
  36914. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36915. * during the life time of the application.
  36916. */
  36917. export class EngineStore {
  36918. /** Gets the list of created engines */
  36919. static Instances: Engine[];
  36920. /** @hidden */
  36921. static _LastCreatedScene: Nullable<Scene>;
  36922. /**
  36923. * Gets the latest created engine
  36924. */
  36925. static get LastCreatedEngine(): Nullable<Engine>;
  36926. /**
  36927. * Gets the latest created scene
  36928. */
  36929. static get LastCreatedScene(): Nullable<Scene>;
  36930. /**
  36931. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36932. * @ignorenaming
  36933. */
  36934. static UseFallbackTexture: boolean;
  36935. /**
  36936. * Texture content used if a texture cannot loaded
  36937. * @ignorenaming
  36938. */
  36939. static FallbackTexture: string;
  36940. }
  36941. }
  36942. declare module BABYLON {
  36943. /**
  36944. * Helper class that provides a small promise polyfill
  36945. */
  36946. export class PromisePolyfill {
  36947. /**
  36948. * Static function used to check if the polyfill is required
  36949. * If this is the case then the function will inject the polyfill to window.Promise
  36950. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36951. */
  36952. static Apply(force?: boolean): void;
  36953. }
  36954. }
  36955. declare module BABYLON {
  36956. /**
  36957. * Interface for screenshot methods with describe argument called `size` as object with options
  36958. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36959. */
  36960. export interface IScreenshotSize {
  36961. /**
  36962. * number in pixels for canvas height
  36963. */
  36964. height?: number;
  36965. /**
  36966. * multiplier allowing render at a higher or lower resolution
  36967. * If value is defined then height and width will be ignored and taken from camera
  36968. */
  36969. precision?: number;
  36970. /**
  36971. * number in pixels for canvas width
  36972. */
  36973. width?: number;
  36974. }
  36975. }
  36976. declare module BABYLON {
  36977. interface IColor4Like {
  36978. r: float;
  36979. g: float;
  36980. b: float;
  36981. a: float;
  36982. }
  36983. /**
  36984. * Class containing a set of static utilities functions
  36985. */
  36986. export class Tools {
  36987. /**
  36988. * Gets or sets the base URL to use to load assets
  36989. */
  36990. static get BaseUrl(): string;
  36991. static set BaseUrl(value: string);
  36992. /**
  36993. * Enable/Disable Custom HTTP Request Headers globally.
  36994. * default = false
  36995. * @see CustomRequestHeaders
  36996. */
  36997. static UseCustomRequestHeaders: boolean;
  36998. /**
  36999. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37000. * i.e. when loading files, where the server/service expects an Authorization header
  37001. */
  37002. static CustomRequestHeaders: {
  37003. [key: string]: string;
  37004. };
  37005. /**
  37006. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37007. */
  37008. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37009. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37010. /**
  37011. * Default behaviour for cors in the application.
  37012. * It can be a string if the expected behavior is identical in the entire app.
  37013. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37014. */
  37015. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37016. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37017. /**
  37018. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37019. * @ignorenaming
  37020. */
  37021. static get UseFallbackTexture(): boolean;
  37022. static set UseFallbackTexture(value: boolean);
  37023. /**
  37024. * Use this object to register external classes like custom textures or material
  37025. * to allow the laoders to instantiate them
  37026. */
  37027. static get RegisteredExternalClasses(): {
  37028. [key: string]: Object;
  37029. };
  37030. static set RegisteredExternalClasses(classes: {
  37031. [key: string]: Object;
  37032. });
  37033. /**
  37034. * Texture content used if a texture cannot loaded
  37035. * @ignorenaming
  37036. */
  37037. static get fallbackTexture(): string;
  37038. static set fallbackTexture(value: string);
  37039. /**
  37040. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37041. * @param u defines the coordinate on X axis
  37042. * @param v defines the coordinate on Y axis
  37043. * @param width defines the width of the source data
  37044. * @param height defines the height of the source data
  37045. * @param pixels defines the source byte array
  37046. * @param color defines the output color
  37047. */
  37048. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37049. /**
  37050. * Interpolates between a and b via alpha
  37051. * @param a The lower value (returned when alpha = 0)
  37052. * @param b The upper value (returned when alpha = 1)
  37053. * @param alpha The interpolation-factor
  37054. * @return The mixed value
  37055. */
  37056. static Mix(a: number, b: number, alpha: number): number;
  37057. /**
  37058. * Tries to instantiate a new object from a given class name
  37059. * @param className defines the class name to instantiate
  37060. * @returns the new object or null if the system was not able to do the instantiation
  37061. */
  37062. static Instantiate(className: string): any;
  37063. /**
  37064. * Provides a slice function that will work even on IE
  37065. * @param data defines the array to slice
  37066. * @param start defines the start of the data (optional)
  37067. * @param end defines the end of the data (optional)
  37068. * @returns the new sliced array
  37069. */
  37070. static Slice<T>(data: T, start?: number, end?: number): T;
  37071. /**
  37072. * Polyfill for setImmediate
  37073. * @param action defines the action to execute after the current execution block
  37074. */
  37075. static SetImmediate(action: () => void): void;
  37076. /**
  37077. * Function indicating if a number is an exponent of 2
  37078. * @param value defines the value to test
  37079. * @returns true if the value is an exponent of 2
  37080. */
  37081. static IsExponentOfTwo(value: number): boolean;
  37082. private static _tmpFloatArray;
  37083. /**
  37084. * Returns the nearest 32-bit single precision float representation of a Number
  37085. * @param value A Number. If the parameter is of a different type, it will get converted
  37086. * to a number or to NaN if it cannot be converted
  37087. * @returns number
  37088. */
  37089. static FloatRound(value: number): number;
  37090. /**
  37091. * Extracts the filename from a path
  37092. * @param path defines the path to use
  37093. * @returns the filename
  37094. */
  37095. static GetFilename(path: string): string;
  37096. /**
  37097. * Extracts the "folder" part of a path (everything before the filename).
  37098. * @param uri The URI to extract the info from
  37099. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37100. * @returns The "folder" part of the path
  37101. */
  37102. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37103. /**
  37104. * Extracts text content from a DOM element hierarchy
  37105. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37106. */
  37107. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37108. /**
  37109. * Convert an angle in radians to degrees
  37110. * @param angle defines the angle to convert
  37111. * @returns the angle in degrees
  37112. */
  37113. static ToDegrees(angle: number): number;
  37114. /**
  37115. * Convert an angle in degrees to radians
  37116. * @param angle defines the angle to convert
  37117. * @returns the angle in radians
  37118. */
  37119. static ToRadians(angle: number): number;
  37120. /**
  37121. * Returns an array if obj is not an array
  37122. * @param obj defines the object to evaluate as an array
  37123. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37124. * @returns either obj directly if obj is an array or a new array containing obj
  37125. */
  37126. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37127. /**
  37128. * Gets the pointer prefix to use
  37129. * @param engine defines the engine we are finding the prefix for
  37130. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37131. */
  37132. static GetPointerPrefix(engine: Engine): string;
  37133. /**
  37134. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37135. * @param url define the url we are trying
  37136. * @param element define the dom element where to configure the cors policy
  37137. */
  37138. static SetCorsBehavior(url: string | string[], element: {
  37139. crossOrigin: string | null;
  37140. }): void;
  37141. /**
  37142. * Removes unwanted characters from an url
  37143. * @param url defines the url to clean
  37144. * @returns the cleaned url
  37145. */
  37146. static CleanUrl(url: string): string;
  37147. /**
  37148. * Gets or sets a function used to pre-process url before using them to load assets
  37149. */
  37150. static get PreprocessUrl(): (url: string) => string;
  37151. static set PreprocessUrl(processor: (url: string) => string);
  37152. /**
  37153. * Loads an image as an HTMLImageElement.
  37154. * @param input url string, ArrayBuffer, or Blob to load
  37155. * @param onLoad callback called when the image successfully loads
  37156. * @param onError callback called when the image fails to load
  37157. * @param offlineProvider offline provider for caching
  37158. * @param mimeType optional mime type
  37159. * @returns the HTMLImageElement of the loaded image
  37160. */
  37161. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37162. /**
  37163. * Loads a file from a url
  37164. * @param url url string, ArrayBuffer, or Blob to load
  37165. * @param onSuccess callback called when the file successfully loads
  37166. * @param onProgress callback called while file is loading (if the server supports this mode)
  37167. * @param offlineProvider defines the offline provider for caching
  37168. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37169. * @param onError callback called when the file fails to load
  37170. * @returns a file request object
  37171. */
  37172. 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;
  37173. /**
  37174. * Loads a file from a url
  37175. * @param url the file url to load
  37176. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37177. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37178. */
  37179. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37180. /**
  37181. * Load a script (identified by an url). When the url returns, the
  37182. * content of this file is added into a new script element, attached to the DOM (body element)
  37183. * @param scriptUrl defines the url of the script to laod
  37184. * @param onSuccess defines the callback called when the script is loaded
  37185. * @param onError defines the callback to call if an error occurs
  37186. * @param scriptId defines the id of the script element
  37187. */
  37188. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37189. /**
  37190. * Load an asynchronous script (identified by an url). When the url returns, the
  37191. * content of this file is added into a new script element, attached to the DOM (body element)
  37192. * @param scriptUrl defines the url of the script to laod
  37193. * @param scriptId defines the id of the script element
  37194. * @returns a promise request object
  37195. */
  37196. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37197. /**
  37198. * Loads a file from a blob
  37199. * @param fileToLoad defines the blob to use
  37200. * @param callback defines the callback to call when data is loaded
  37201. * @param progressCallback defines the callback to call during loading process
  37202. * @returns a file request object
  37203. */
  37204. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37205. /**
  37206. * Reads a file from a File object
  37207. * @param file defines the file to load
  37208. * @param onSuccess defines the callback to call when data is loaded
  37209. * @param onProgress defines the callback to call during loading process
  37210. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37211. * @param onError defines the callback to call when an error occurs
  37212. * @returns a file request object
  37213. */
  37214. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37215. /**
  37216. * Creates a data url from a given string content
  37217. * @param content defines the content to convert
  37218. * @returns the new data url link
  37219. */
  37220. static FileAsURL(content: string): string;
  37221. /**
  37222. * Format the given number to a specific decimal format
  37223. * @param value defines the number to format
  37224. * @param decimals defines the number of decimals to use
  37225. * @returns the formatted string
  37226. */
  37227. static Format(value: number, decimals?: number): string;
  37228. /**
  37229. * Tries to copy an object by duplicating every property
  37230. * @param source defines the source object
  37231. * @param destination defines the target object
  37232. * @param doNotCopyList defines a list of properties to avoid
  37233. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37234. */
  37235. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37236. /**
  37237. * Gets a boolean indicating if the given object has no own property
  37238. * @param obj defines the object to test
  37239. * @returns true if object has no own property
  37240. */
  37241. static IsEmpty(obj: any): boolean;
  37242. /**
  37243. * Function used to register events at window level
  37244. * @param windowElement defines the Window object to use
  37245. * @param events defines the events to register
  37246. */
  37247. static RegisterTopRootEvents(windowElement: Window, events: {
  37248. name: string;
  37249. handler: Nullable<(e: FocusEvent) => any>;
  37250. }[]): void;
  37251. /**
  37252. * Function used to unregister events from window level
  37253. * @param windowElement defines the Window object to use
  37254. * @param events defines the events to unregister
  37255. */
  37256. static UnregisterTopRootEvents(windowElement: Window, events: {
  37257. name: string;
  37258. handler: Nullable<(e: FocusEvent) => any>;
  37259. }[]): void;
  37260. /**
  37261. * @ignore
  37262. */
  37263. static _ScreenshotCanvas: HTMLCanvasElement;
  37264. /**
  37265. * Dumps the current bound framebuffer
  37266. * @param width defines the rendering width
  37267. * @param height defines the rendering height
  37268. * @param engine defines the hosting engine
  37269. * @param successCallback defines the callback triggered once the data are available
  37270. * @param mimeType defines the mime type of the result
  37271. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37272. */
  37273. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37274. /**
  37275. * Converts the canvas data to blob.
  37276. * This acts as a polyfill for browsers not supporting the to blob function.
  37277. * @param canvas Defines the canvas to extract the data from
  37278. * @param successCallback Defines the callback triggered once the data are available
  37279. * @param mimeType Defines the mime type of the result
  37280. */
  37281. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37282. /**
  37283. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37284. * @param successCallback defines the callback triggered once the data are available
  37285. * @param mimeType defines the mime type of the result
  37286. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37287. */
  37288. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37289. /**
  37290. * Downloads a blob in the browser
  37291. * @param blob defines the blob to download
  37292. * @param fileName defines the name of the downloaded file
  37293. */
  37294. static Download(blob: Blob, fileName: string): void;
  37295. /**
  37296. * Captures a screenshot of the current rendering
  37297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37298. * @param engine defines the rendering engine
  37299. * @param camera defines the source camera
  37300. * @param size This parameter can be set to a single number or to an object with the
  37301. * following (optional) properties: precision, width, height. If a single number is passed,
  37302. * it will be used for both width and height. If an object is passed, the screenshot size
  37303. * will be derived from the parameters. The precision property is a multiplier allowing
  37304. * rendering at a higher or lower resolution
  37305. * @param successCallback defines the callback receives a single parameter which contains the
  37306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37307. * src parameter of an <img> to display it
  37308. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37309. * Check your browser for supported MIME types
  37310. */
  37311. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37312. /**
  37313. * Captures a screenshot of the current rendering
  37314. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37315. * @param engine defines the rendering engine
  37316. * @param camera defines the source camera
  37317. * @param size This parameter can be set to a single number or to an object with the
  37318. * following (optional) properties: precision, width, height. If a single number is passed,
  37319. * it will be used for both width and height. If an object is passed, the screenshot size
  37320. * will be derived from the parameters. The precision property is a multiplier allowing
  37321. * rendering at a higher or lower resolution
  37322. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37323. * Check your browser for supported MIME types
  37324. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37325. * to the src parameter of an <img> to display it
  37326. */
  37327. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37328. /**
  37329. * Generates an image screenshot from the specified camera.
  37330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37331. * @param engine The engine to use for rendering
  37332. * @param camera The camera to use for rendering
  37333. * @param size This parameter can be set to a single number or to an object with the
  37334. * following (optional) properties: precision, width, height. If a single number is passed,
  37335. * it will be used for both width and height. If an object is passed, the screenshot size
  37336. * will be derived from the parameters. The precision property is a multiplier allowing
  37337. * rendering at a higher or lower resolution
  37338. * @param successCallback The callback receives a single parameter which contains the
  37339. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37340. * src parameter of an <img> to display it
  37341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37342. * Check your browser for supported MIME types
  37343. * @param samples Texture samples (default: 1)
  37344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37345. * @param fileName A name for for the downloaded file.
  37346. */
  37347. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37348. /**
  37349. * Generates an image screenshot from the specified camera.
  37350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37351. * @param engine The engine to use for rendering
  37352. * @param camera The camera to use for rendering
  37353. * @param size This parameter can be set to a single number or to an object with the
  37354. * following (optional) properties: precision, width, height. If a single number is passed,
  37355. * it will be used for both width and height. If an object is passed, the screenshot size
  37356. * will be derived from the parameters. The precision property is a multiplier allowing
  37357. * rendering at a higher or lower resolution
  37358. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37359. * Check your browser for supported MIME types
  37360. * @param samples Texture samples (default: 1)
  37361. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37362. * @param fileName A name for for the downloaded file.
  37363. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37364. * to the src parameter of an <img> to display it
  37365. */
  37366. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37367. /**
  37368. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37369. * Be aware Math.random() could cause collisions, but:
  37370. * "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"
  37371. * @returns a pseudo random id
  37372. */
  37373. static RandomId(): string;
  37374. /**
  37375. * Test if the given uri is a base64 string
  37376. * @param uri The uri to test
  37377. * @return True if the uri is a base64 string or false otherwise
  37378. */
  37379. static IsBase64(uri: string): boolean;
  37380. /**
  37381. * Decode the given base64 uri.
  37382. * @param uri The uri to decode
  37383. * @return The decoded base64 data.
  37384. */
  37385. static DecodeBase64(uri: string): ArrayBuffer;
  37386. /**
  37387. * Gets the absolute url.
  37388. * @param url the input url
  37389. * @return the absolute url
  37390. */
  37391. static GetAbsoluteUrl(url: string): string;
  37392. /**
  37393. * No log
  37394. */
  37395. static readonly NoneLogLevel: number;
  37396. /**
  37397. * Only message logs
  37398. */
  37399. static readonly MessageLogLevel: number;
  37400. /**
  37401. * Only warning logs
  37402. */
  37403. static readonly WarningLogLevel: number;
  37404. /**
  37405. * Only error logs
  37406. */
  37407. static readonly ErrorLogLevel: number;
  37408. /**
  37409. * All logs
  37410. */
  37411. static readonly AllLogLevel: number;
  37412. /**
  37413. * Gets a value indicating the number of loading errors
  37414. * @ignorenaming
  37415. */
  37416. static get errorsCount(): number;
  37417. /**
  37418. * Callback called when a new log is added
  37419. */
  37420. static OnNewCacheEntry: (entry: string) => void;
  37421. /**
  37422. * Log a message to the console
  37423. * @param message defines the message to log
  37424. */
  37425. static Log(message: string): void;
  37426. /**
  37427. * Write a warning message to the console
  37428. * @param message defines the message to log
  37429. */
  37430. static Warn(message: string): void;
  37431. /**
  37432. * Write an error message to the console
  37433. * @param message defines the message to log
  37434. */
  37435. static Error(message: string): void;
  37436. /**
  37437. * Gets current log cache (list of logs)
  37438. */
  37439. static get LogCache(): string;
  37440. /**
  37441. * Clears the log cache
  37442. */
  37443. static ClearLogCache(): void;
  37444. /**
  37445. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37446. */
  37447. static set LogLevels(level: number);
  37448. /**
  37449. * Checks if the window object exists
  37450. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37451. */
  37452. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37453. /**
  37454. * No performance log
  37455. */
  37456. static readonly PerformanceNoneLogLevel: number;
  37457. /**
  37458. * Use user marks to log performance
  37459. */
  37460. static readonly PerformanceUserMarkLogLevel: number;
  37461. /**
  37462. * Log performance to the console
  37463. */
  37464. static readonly PerformanceConsoleLogLevel: number;
  37465. private static _performance;
  37466. /**
  37467. * Sets the current performance log level
  37468. */
  37469. static set PerformanceLogLevel(level: number);
  37470. private static _StartPerformanceCounterDisabled;
  37471. private static _EndPerformanceCounterDisabled;
  37472. private static _StartUserMark;
  37473. private static _EndUserMark;
  37474. private static _StartPerformanceConsole;
  37475. private static _EndPerformanceConsole;
  37476. /**
  37477. * Starts a performance counter
  37478. */
  37479. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37480. /**
  37481. * Ends a specific performance coutner
  37482. */
  37483. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37484. /**
  37485. * Gets either window.performance.now() if supported or Date.now() else
  37486. */
  37487. static get Now(): number;
  37488. /**
  37489. * This method will return the name of the class used to create the instance of the given object.
  37490. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37491. * @param object the object to get the class name from
  37492. * @param isType defines if the object is actually a type
  37493. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37494. */
  37495. static GetClassName(object: any, isType?: boolean): string;
  37496. /**
  37497. * Gets the first element of an array satisfying a given predicate
  37498. * @param array defines the array to browse
  37499. * @param predicate defines the predicate to use
  37500. * @returns null if not found or the element
  37501. */
  37502. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37503. /**
  37504. * This method will return the name of the full name of the class, including its owning module (if any).
  37505. * 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).
  37506. * @param object the object to get the class name from
  37507. * @param isType defines if the object is actually a type
  37508. * @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.
  37509. * @ignorenaming
  37510. */
  37511. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37512. /**
  37513. * Returns a promise that resolves after the given amount of time.
  37514. * @param delay Number of milliseconds to delay
  37515. * @returns Promise that resolves after the given amount of time
  37516. */
  37517. static DelayAsync(delay: number): Promise<void>;
  37518. /**
  37519. * Utility function to detect if the current user agent is Safari
  37520. * @returns whether or not the current user agent is safari
  37521. */
  37522. static IsSafari(): boolean;
  37523. }
  37524. /**
  37525. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37526. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37527. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37528. * @param name The name of the class, case should be preserved
  37529. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37530. */
  37531. export function className(name: string, module?: string): (target: Object) => void;
  37532. /**
  37533. * An implementation of a loop for asynchronous functions.
  37534. */
  37535. export class AsyncLoop {
  37536. /**
  37537. * Defines the number of iterations for the loop
  37538. */
  37539. iterations: number;
  37540. /**
  37541. * Defines the current index of the loop.
  37542. */
  37543. index: number;
  37544. private _done;
  37545. private _fn;
  37546. private _successCallback;
  37547. /**
  37548. * Constructor.
  37549. * @param iterations the number of iterations.
  37550. * @param func the function to run each iteration
  37551. * @param successCallback the callback that will be called upon succesful execution
  37552. * @param offset starting offset.
  37553. */
  37554. constructor(
  37555. /**
  37556. * Defines the number of iterations for the loop
  37557. */
  37558. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37559. /**
  37560. * Execute the next iteration. Must be called after the last iteration was finished.
  37561. */
  37562. executeNext(): void;
  37563. /**
  37564. * Break the loop and run the success callback.
  37565. */
  37566. breakLoop(): void;
  37567. /**
  37568. * Create and run an async loop.
  37569. * @param iterations the number of iterations.
  37570. * @param fn the function to run each iteration
  37571. * @param successCallback the callback that will be called upon succesful execution
  37572. * @param offset starting offset.
  37573. * @returns the created async loop object
  37574. */
  37575. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37576. /**
  37577. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37578. * @param iterations total number of iterations
  37579. * @param syncedIterations number of synchronous iterations in each async iteration.
  37580. * @param fn the function to call each iteration.
  37581. * @param callback a success call back that will be called when iterating stops.
  37582. * @param breakFunction a break condition (optional)
  37583. * @param timeout timeout settings for the setTimeout function. default - 0.
  37584. * @returns the created async loop object
  37585. */
  37586. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37587. }
  37588. }
  37589. declare module BABYLON {
  37590. /**
  37591. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37592. * The underlying implementation relies on an associative array to ensure the best performances.
  37593. * The value can be anything including 'null' but except 'undefined'
  37594. */
  37595. export class StringDictionary<T> {
  37596. /**
  37597. * This will clear this dictionary and copy the content from the 'source' one.
  37598. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37599. * @param source the dictionary to take the content from and copy to this dictionary
  37600. */
  37601. copyFrom(source: StringDictionary<T>): void;
  37602. /**
  37603. * Get a value based from its key
  37604. * @param key the given key to get the matching value from
  37605. * @return the value if found, otherwise undefined is returned
  37606. */
  37607. get(key: string): T | undefined;
  37608. /**
  37609. * Get a value from its key or add it if it doesn't exist.
  37610. * This method will ensure you that a given key/data will be present in the dictionary.
  37611. * @param key the given key to get the matching value from
  37612. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37613. * The factory will only be invoked if there's no data for the given key.
  37614. * @return the value corresponding to the key.
  37615. */
  37616. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37617. /**
  37618. * Get a value from its key if present in the dictionary otherwise add it
  37619. * @param key the key to get the value from
  37620. * @param val if there's no such key/value pair in the dictionary add it with this value
  37621. * @return the value corresponding to the key
  37622. */
  37623. getOrAdd(key: string, val: T): T;
  37624. /**
  37625. * Check if there's a given key in the dictionary
  37626. * @param key the key to check for
  37627. * @return true if the key is present, false otherwise
  37628. */
  37629. contains(key: string): boolean;
  37630. /**
  37631. * Add a new key and its corresponding value
  37632. * @param key the key to add
  37633. * @param value the value corresponding to the key
  37634. * @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
  37635. */
  37636. add(key: string, value: T): boolean;
  37637. /**
  37638. * Update a specific value associated to a key
  37639. * @param key defines the key to use
  37640. * @param value defines the value to store
  37641. * @returns true if the value was updated (or false if the key was not found)
  37642. */
  37643. set(key: string, value: T): boolean;
  37644. /**
  37645. * Get the element of the given key and remove it from the dictionary
  37646. * @param key defines the key to search
  37647. * @returns the value associated with the key or null if not found
  37648. */
  37649. getAndRemove(key: string): Nullable<T>;
  37650. /**
  37651. * Remove a key/value from the dictionary.
  37652. * @param key the key to remove
  37653. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37654. */
  37655. remove(key: string): boolean;
  37656. /**
  37657. * Clear the whole content of the dictionary
  37658. */
  37659. clear(): void;
  37660. /**
  37661. * Gets the current count
  37662. */
  37663. get count(): number;
  37664. /**
  37665. * Execute a callback on each key/val of the dictionary.
  37666. * Note that you can remove any element in this dictionary in the callback implementation
  37667. * @param callback the callback to execute on a given key/value pair
  37668. */
  37669. forEach(callback: (key: string, val: T) => void): void;
  37670. /**
  37671. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37672. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37673. * Note that you can remove any element in this dictionary in the callback implementation
  37674. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37675. * @returns the first item
  37676. */
  37677. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37678. private _count;
  37679. private _data;
  37680. }
  37681. }
  37682. declare module BABYLON {
  37683. /** @hidden */
  37684. export interface ICollisionCoordinator {
  37685. createCollider(): Collider;
  37686. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37687. init(scene: Scene): void;
  37688. }
  37689. /** @hidden */
  37690. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37691. private _scene;
  37692. private _scaledPosition;
  37693. private _scaledVelocity;
  37694. private _finalPosition;
  37695. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37696. createCollider(): Collider;
  37697. init(scene: Scene): void;
  37698. private _collideWithWorld;
  37699. }
  37700. }
  37701. declare module BABYLON {
  37702. /**
  37703. * Class used to manage all inputs for the scene.
  37704. */
  37705. export class InputManager {
  37706. /** The distance in pixel that you have to move to prevent some events */
  37707. static DragMovementThreshold: number;
  37708. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37709. static LongPressDelay: number;
  37710. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37711. static DoubleClickDelay: number;
  37712. /** If you need to check double click without raising a single click at first click, enable this flag */
  37713. static ExclusiveDoubleClickMode: boolean;
  37714. private _wheelEventName;
  37715. private _onPointerMove;
  37716. private _onPointerDown;
  37717. private _onPointerUp;
  37718. private _initClickEvent;
  37719. private _initActionManager;
  37720. private _delayedSimpleClick;
  37721. private _delayedSimpleClickTimeout;
  37722. private _previousDelayedSimpleClickTimeout;
  37723. private _meshPickProceed;
  37724. private _previousButtonPressed;
  37725. private _currentPickResult;
  37726. private _previousPickResult;
  37727. private _totalPointersPressed;
  37728. private _doubleClickOccured;
  37729. private _pointerOverMesh;
  37730. private _pickedDownMesh;
  37731. private _pickedUpMesh;
  37732. private _pointerX;
  37733. private _pointerY;
  37734. private _unTranslatedPointerX;
  37735. private _unTranslatedPointerY;
  37736. private _startingPointerPosition;
  37737. private _previousStartingPointerPosition;
  37738. private _startingPointerTime;
  37739. private _previousStartingPointerTime;
  37740. private _pointerCaptures;
  37741. private _onKeyDown;
  37742. private _onKeyUp;
  37743. private _onCanvasFocusObserver;
  37744. private _onCanvasBlurObserver;
  37745. private _scene;
  37746. /**
  37747. * Creates a new InputManager
  37748. * @param scene defines the hosting scene
  37749. */
  37750. constructor(scene: Scene);
  37751. /**
  37752. * Gets the mesh that is currently under the pointer
  37753. */
  37754. get meshUnderPointer(): Nullable<AbstractMesh>;
  37755. /**
  37756. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37757. */
  37758. get unTranslatedPointer(): Vector2;
  37759. /**
  37760. * Gets or sets the current on-screen X position of the pointer
  37761. */
  37762. get pointerX(): number;
  37763. set pointerX(value: number);
  37764. /**
  37765. * Gets or sets the current on-screen Y position of the pointer
  37766. */
  37767. get pointerY(): number;
  37768. set pointerY(value: number);
  37769. private _updatePointerPosition;
  37770. private _processPointerMove;
  37771. private _setRayOnPointerInfo;
  37772. private _checkPrePointerObservable;
  37773. /**
  37774. * Use this method to simulate a pointer move on a mesh
  37775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37778. */
  37779. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37780. /**
  37781. * Use this method to simulate a pointer down on a mesh
  37782. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37783. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37784. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37785. */
  37786. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37787. private _processPointerDown;
  37788. /** @hidden */
  37789. _isPointerSwiping(): boolean;
  37790. /**
  37791. * Use this method to simulate a pointer up on a mesh
  37792. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37793. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37794. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37795. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37796. */
  37797. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37798. private _processPointerUp;
  37799. /**
  37800. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37801. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37802. * @returns true if the pointer was captured
  37803. */
  37804. isPointerCaptured(pointerId?: number): boolean;
  37805. /**
  37806. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37807. * @param attachUp defines if you want to attach events to pointerup
  37808. * @param attachDown defines if you want to attach events to pointerdown
  37809. * @param attachMove defines if you want to attach events to pointermove
  37810. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37811. */
  37812. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37813. /**
  37814. * Detaches all event handlers
  37815. */
  37816. detachControl(): void;
  37817. /**
  37818. * Force the value of meshUnderPointer
  37819. * @param mesh defines the mesh to use
  37820. */
  37821. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37822. /**
  37823. * Gets the mesh under the pointer
  37824. * @returns a Mesh or null if no mesh is under the pointer
  37825. */
  37826. getPointerOverMesh(): Nullable<AbstractMesh>;
  37827. }
  37828. }
  37829. declare module BABYLON {
  37830. /**
  37831. * This class defines the direct association between an animation and a target
  37832. */
  37833. export class TargetedAnimation {
  37834. /**
  37835. * Animation to perform
  37836. */
  37837. animation: Animation;
  37838. /**
  37839. * Target to animate
  37840. */
  37841. target: any;
  37842. /**
  37843. * Serialize the object
  37844. * @returns the JSON object representing the current entity
  37845. */
  37846. serialize(): any;
  37847. }
  37848. /**
  37849. * Use this class to create coordinated animations on multiple targets
  37850. */
  37851. export class AnimationGroup implements IDisposable {
  37852. /** The name of the animation group */
  37853. name: string;
  37854. private _scene;
  37855. private _targetedAnimations;
  37856. private _animatables;
  37857. private _from;
  37858. private _to;
  37859. private _isStarted;
  37860. private _isPaused;
  37861. private _speedRatio;
  37862. private _loopAnimation;
  37863. private _isAdditive;
  37864. /**
  37865. * Gets or sets the unique id of the node
  37866. */
  37867. uniqueId: number;
  37868. /**
  37869. * This observable will notify when one animation have ended
  37870. */
  37871. onAnimationEndObservable: Observable<TargetedAnimation>;
  37872. /**
  37873. * Observer raised when one animation loops
  37874. */
  37875. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37876. /**
  37877. * Observer raised when all animations have looped
  37878. */
  37879. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37880. /**
  37881. * This observable will notify when all animations have ended.
  37882. */
  37883. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37884. /**
  37885. * This observable will notify when all animations have paused.
  37886. */
  37887. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37888. /**
  37889. * This observable will notify when all animations are playing.
  37890. */
  37891. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37892. /**
  37893. * Gets the first frame
  37894. */
  37895. get from(): number;
  37896. /**
  37897. * Gets the last frame
  37898. */
  37899. get to(): number;
  37900. /**
  37901. * Define if the animations are started
  37902. */
  37903. get isStarted(): boolean;
  37904. /**
  37905. * Gets a value indicating that the current group is playing
  37906. */
  37907. get isPlaying(): boolean;
  37908. /**
  37909. * Gets or sets the speed ratio to use for all animations
  37910. */
  37911. get speedRatio(): number;
  37912. /**
  37913. * Gets or sets the speed ratio to use for all animations
  37914. */
  37915. set speedRatio(value: number);
  37916. /**
  37917. * Gets or sets if all animations should loop or not
  37918. */
  37919. get loopAnimation(): boolean;
  37920. set loopAnimation(value: boolean);
  37921. /**
  37922. * Gets or sets if all animations should be evaluated additively
  37923. */
  37924. get isAdditive(): boolean;
  37925. set isAdditive(value: boolean);
  37926. /**
  37927. * Gets the targeted animations for this animation group
  37928. */
  37929. get targetedAnimations(): Array<TargetedAnimation>;
  37930. /**
  37931. * returning the list of animatables controlled by this animation group.
  37932. */
  37933. get animatables(): Array<Animatable>;
  37934. /**
  37935. * Instantiates a new Animation Group.
  37936. * This helps managing several animations at once.
  37937. * @see http://doc.babylonjs.com/how_to/group
  37938. * @param name Defines the name of the group
  37939. * @param scene Defines the scene the group belongs to
  37940. */
  37941. constructor(
  37942. /** The name of the animation group */
  37943. name: string, scene?: Nullable<Scene>);
  37944. /**
  37945. * Add an animation (with its target) in the group
  37946. * @param animation defines the animation we want to add
  37947. * @param target defines the target of the animation
  37948. * @returns the TargetedAnimation object
  37949. */
  37950. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37951. /**
  37952. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37953. * It can add constant keys at begin or end
  37954. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37955. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37956. * @returns the animation group
  37957. */
  37958. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37959. private _animationLoopCount;
  37960. private _animationLoopFlags;
  37961. private _processLoop;
  37962. /**
  37963. * Start all animations on given targets
  37964. * @param loop defines if animations must loop
  37965. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37966. * @param from defines the from key (optional)
  37967. * @param to defines the to key (optional)
  37968. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37969. * @returns the current animation group
  37970. */
  37971. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37972. /**
  37973. * Pause all animations
  37974. * @returns the animation group
  37975. */
  37976. pause(): AnimationGroup;
  37977. /**
  37978. * Play all animations to initial state
  37979. * This function will start() the animations if they were not started or will restart() them if they were paused
  37980. * @param loop defines if animations must loop
  37981. * @returns the animation group
  37982. */
  37983. play(loop?: boolean): AnimationGroup;
  37984. /**
  37985. * Reset all animations to initial state
  37986. * @returns the animation group
  37987. */
  37988. reset(): AnimationGroup;
  37989. /**
  37990. * Restart animations from key 0
  37991. * @returns the animation group
  37992. */
  37993. restart(): AnimationGroup;
  37994. /**
  37995. * Stop all animations
  37996. * @returns the animation group
  37997. */
  37998. stop(): AnimationGroup;
  37999. /**
  38000. * Set animation weight for all animatables
  38001. * @param weight defines the weight to use
  38002. * @return the animationGroup
  38003. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38004. */
  38005. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38006. /**
  38007. * Synchronize and normalize all animatables with a source animatable
  38008. * @param root defines the root animatable to synchronize with
  38009. * @return the animationGroup
  38010. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38011. */
  38012. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38013. /**
  38014. * Goes to a specific frame in this animation group
  38015. * @param frame the frame number to go to
  38016. * @return the animationGroup
  38017. */
  38018. goToFrame(frame: number): AnimationGroup;
  38019. /**
  38020. * Dispose all associated resources
  38021. */
  38022. dispose(): void;
  38023. private _checkAnimationGroupEnded;
  38024. /**
  38025. * Clone the current animation group and returns a copy
  38026. * @param newName defines the name of the new group
  38027. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38028. * @returns the new aniamtion group
  38029. */
  38030. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38031. /**
  38032. * Serializes the animationGroup to an object
  38033. * @returns Serialized object
  38034. */
  38035. serialize(): any;
  38036. /**
  38037. * Returns a new AnimationGroup object parsed from the source provided.
  38038. * @param parsedAnimationGroup defines the source
  38039. * @param scene defines the scene that will receive the animationGroup
  38040. * @returns a new AnimationGroup
  38041. */
  38042. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38043. /**
  38044. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38045. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38046. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38047. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38048. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38049. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38050. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38051. */
  38052. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38053. /**
  38054. * Returns the string "AnimationGroup"
  38055. * @returns "AnimationGroup"
  38056. */
  38057. getClassName(): string;
  38058. /**
  38059. * Creates a detailled string about the object
  38060. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38061. * @returns a string representing the object
  38062. */
  38063. toString(fullDetails?: boolean): string;
  38064. }
  38065. }
  38066. declare module BABYLON {
  38067. /**
  38068. * Define an interface for all classes that will hold resources
  38069. */
  38070. export interface IDisposable {
  38071. /**
  38072. * Releases all held resources
  38073. */
  38074. dispose(): void;
  38075. }
  38076. /** Interface defining initialization parameters for Scene class */
  38077. export interface SceneOptions {
  38078. /**
  38079. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38080. * It will improve performance when the number of geometries becomes important.
  38081. */
  38082. useGeometryUniqueIdsMap?: boolean;
  38083. /**
  38084. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38085. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38086. */
  38087. useMaterialMeshMap?: boolean;
  38088. /**
  38089. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38090. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38091. */
  38092. useClonedMeshMap?: boolean;
  38093. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38094. virtual?: boolean;
  38095. }
  38096. /**
  38097. * Represents a scene to be rendered by the engine.
  38098. * @see http://doc.babylonjs.com/features/scene
  38099. */
  38100. export class Scene extends AbstractScene implements IAnimatable {
  38101. /** The fog is deactivated */
  38102. static readonly FOGMODE_NONE: number;
  38103. /** The fog density is following an exponential function */
  38104. static readonly FOGMODE_EXP: number;
  38105. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38106. static readonly FOGMODE_EXP2: number;
  38107. /** The fog density is following a linear function. */
  38108. static readonly FOGMODE_LINEAR: number;
  38109. /**
  38110. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38112. */
  38113. static MinDeltaTime: number;
  38114. /**
  38115. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38117. */
  38118. static MaxDeltaTime: number;
  38119. /**
  38120. * Factory used to create the default material.
  38121. * @param name The name of the material to create
  38122. * @param scene The scene to create the material for
  38123. * @returns The default material
  38124. */
  38125. static DefaultMaterialFactory(scene: Scene): Material;
  38126. /**
  38127. * Factory used to create the a collision coordinator.
  38128. * @returns The collision coordinator
  38129. */
  38130. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38131. /** @hidden */
  38132. _inputManager: InputManager;
  38133. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38134. cameraToUseForPointers: Nullable<Camera>;
  38135. /** @hidden */
  38136. readonly _isScene: boolean;
  38137. /** @hidden */
  38138. _blockEntityCollection: boolean;
  38139. /**
  38140. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38141. */
  38142. autoClear: boolean;
  38143. /**
  38144. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38145. */
  38146. autoClearDepthAndStencil: boolean;
  38147. /**
  38148. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38149. */
  38150. clearColor: Color4;
  38151. /**
  38152. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38153. */
  38154. ambientColor: Color3;
  38155. /**
  38156. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38157. * It should only be one of the following (if not the default embedded one):
  38158. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38159. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38160. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38161. * The material properties need to be setup according to the type of texture in use.
  38162. */
  38163. environmentBRDFTexture: BaseTexture;
  38164. /** @hidden */
  38165. protected _environmentTexture: Nullable<BaseTexture>;
  38166. /**
  38167. * Texture used in all pbr material as the reflection texture.
  38168. * As in the majority of the scene they are the same (exception for multi room and so on),
  38169. * this is easier to reference from here than from all the materials.
  38170. */
  38171. get environmentTexture(): Nullable<BaseTexture>;
  38172. /**
  38173. * Texture used in all pbr material as the reflection texture.
  38174. * As in the majority of the scene they are the same (exception for multi room and so on),
  38175. * this is easier to set here than in all the materials.
  38176. */
  38177. set environmentTexture(value: Nullable<BaseTexture>);
  38178. /** @hidden */
  38179. protected _environmentIntensity: number;
  38180. /**
  38181. * Intensity of the environment in all pbr material.
  38182. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38183. * As in the majority of the scene they are the same (exception for multi room and so on),
  38184. * this is easier to reference from here than from all the materials.
  38185. */
  38186. get environmentIntensity(): number;
  38187. /**
  38188. * Intensity of the environment in all pbr material.
  38189. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38190. * As in the majority of the scene they are the same (exception for multi room and so on),
  38191. * this is easier to set here than in all the materials.
  38192. */
  38193. set environmentIntensity(value: number);
  38194. /** @hidden */
  38195. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38196. /**
  38197. * Default image processing configuration used either in the rendering
  38198. * Forward main pass or through the imageProcessingPostProcess if present.
  38199. * As in the majority of the scene they are the same (exception for multi camera),
  38200. * this is easier to reference from here than from all the materials and post process.
  38201. *
  38202. * No setter as we it is a shared configuration, you can set the values instead.
  38203. */
  38204. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38205. private _forceWireframe;
  38206. /**
  38207. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38208. */
  38209. set forceWireframe(value: boolean);
  38210. get forceWireframe(): boolean;
  38211. private _skipFrustumClipping;
  38212. /**
  38213. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38214. */
  38215. set skipFrustumClipping(value: boolean);
  38216. get skipFrustumClipping(): boolean;
  38217. private _forcePointsCloud;
  38218. /**
  38219. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38220. */
  38221. set forcePointsCloud(value: boolean);
  38222. get forcePointsCloud(): boolean;
  38223. /**
  38224. * Gets or sets the active clipplane 1
  38225. */
  38226. clipPlane: Nullable<Plane>;
  38227. /**
  38228. * Gets or sets the active clipplane 2
  38229. */
  38230. clipPlane2: Nullable<Plane>;
  38231. /**
  38232. * Gets or sets the active clipplane 3
  38233. */
  38234. clipPlane3: Nullable<Plane>;
  38235. /**
  38236. * Gets or sets the active clipplane 4
  38237. */
  38238. clipPlane4: Nullable<Plane>;
  38239. /**
  38240. * Gets or sets the active clipplane 5
  38241. */
  38242. clipPlane5: Nullable<Plane>;
  38243. /**
  38244. * Gets or sets the active clipplane 6
  38245. */
  38246. clipPlane6: Nullable<Plane>;
  38247. /**
  38248. * Gets or sets a boolean indicating if animations are enabled
  38249. */
  38250. animationsEnabled: boolean;
  38251. private _animationPropertiesOverride;
  38252. /**
  38253. * Gets or sets the animation properties override
  38254. */
  38255. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38256. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38257. /**
  38258. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38259. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38260. */
  38261. useConstantAnimationDeltaTime: boolean;
  38262. /**
  38263. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38264. * Please note that it requires to run a ray cast through the scene on every frame
  38265. */
  38266. constantlyUpdateMeshUnderPointer: boolean;
  38267. /**
  38268. * Defines the HTML cursor to use when hovering over interactive elements
  38269. */
  38270. hoverCursor: string;
  38271. /**
  38272. * Defines the HTML default cursor to use (empty by default)
  38273. */
  38274. defaultCursor: string;
  38275. /**
  38276. * Defines whether cursors are handled by the scene.
  38277. */
  38278. doNotHandleCursors: boolean;
  38279. /**
  38280. * This is used to call preventDefault() on pointer down
  38281. * in order to block unwanted artifacts like system double clicks
  38282. */
  38283. preventDefaultOnPointerDown: boolean;
  38284. /**
  38285. * This is used to call preventDefault() on pointer up
  38286. * in order to block unwanted artifacts like system double clicks
  38287. */
  38288. preventDefaultOnPointerUp: boolean;
  38289. /**
  38290. * Gets or sets user defined metadata
  38291. */
  38292. metadata: any;
  38293. /**
  38294. * For internal use only. Please do not use.
  38295. */
  38296. reservedDataStore: any;
  38297. /**
  38298. * Gets the name of the plugin used to load this scene (null by default)
  38299. */
  38300. loadingPluginName: string;
  38301. /**
  38302. * Use this array to add regular expressions used to disable offline support for specific urls
  38303. */
  38304. disableOfflineSupportExceptionRules: RegExp[];
  38305. /**
  38306. * An event triggered when the scene is disposed.
  38307. */
  38308. onDisposeObservable: Observable<Scene>;
  38309. private _onDisposeObserver;
  38310. /** Sets a function to be executed when this scene is disposed. */
  38311. set onDispose(callback: () => void);
  38312. /**
  38313. * An event triggered before rendering the scene (right after animations and physics)
  38314. */
  38315. onBeforeRenderObservable: Observable<Scene>;
  38316. private _onBeforeRenderObserver;
  38317. /** Sets a function to be executed before rendering this scene */
  38318. set beforeRender(callback: Nullable<() => void>);
  38319. /**
  38320. * An event triggered after rendering the scene
  38321. */
  38322. onAfterRenderObservable: Observable<Scene>;
  38323. /**
  38324. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38325. */
  38326. onAfterRenderCameraObservable: Observable<Camera>;
  38327. private _onAfterRenderObserver;
  38328. /** Sets a function to be executed after rendering this scene */
  38329. set afterRender(callback: Nullable<() => void>);
  38330. /**
  38331. * An event triggered before animating the scene
  38332. */
  38333. onBeforeAnimationsObservable: Observable<Scene>;
  38334. /**
  38335. * An event triggered after animations processing
  38336. */
  38337. onAfterAnimationsObservable: Observable<Scene>;
  38338. /**
  38339. * An event triggered before draw calls are ready to be sent
  38340. */
  38341. onBeforeDrawPhaseObservable: Observable<Scene>;
  38342. /**
  38343. * An event triggered after draw calls have been sent
  38344. */
  38345. onAfterDrawPhaseObservable: Observable<Scene>;
  38346. /**
  38347. * An event triggered when the scene is ready
  38348. */
  38349. onReadyObservable: Observable<Scene>;
  38350. /**
  38351. * An event triggered before rendering a camera
  38352. */
  38353. onBeforeCameraRenderObservable: Observable<Camera>;
  38354. private _onBeforeCameraRenderObserver;
  38355. /** Sets a function to be executed before rendering a camera*/
  38356. set beforeCameraRender(callback: () => void);
  38357. /**
  38358. * An event triggered after rendering a camera
  38359. */
  38360. onAfterCameraRenderObservable: Observable<Camera>;
  38361. private _onAfterCameraRenderObserver;
  38362. /** Sets a function to be executed after rendering a camera*/
  38363. set afterCameraRender(callback: () => void);
  38364. /**
  38365. * An event triggered when active meshes evaluation is about to start
  38366. */
  38367. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38368. /**
  38369. * An event triggered when active meshes evaluation is done
  38370. */
  38371. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38372. /**
  38373. * An event triggered when particles rendering is about to start
  38374. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38375. */
  38376. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38377. /**
  38378. * An event triggered when particles rendering is done
  38379. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38380. */
  38381. onAfterParticlesRenderingObservable: Observable<Scene>;
  38382. /**
  38383. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38384. */
  38385. onDataLoadedObservable: Observable<Scene>;
  38386. /**
  38387. * An event triggered when a camera is created
  38388. */
  38389. onNewCameraAddedObservable: Observable<Camera>;
  38390. /**
  38391. * An event triggered when a camera is removed
  38392. */
  38393. onCameraRemovedObservable: Observable<Camera>;
  38394. /**
  38395. * An event triggered when a light is created
  38396. */
  38397. onNewLightAddedObservable: Observable<Light>;
  38398. /**
  38399. * An event triggered when a light is removed
  38400. */
  38401. onLightRemovedObservable: Observable<Light>;
  38402. /**
  38403. * An event triggered when a geometry is created
  38404. */
  38405. onNewGeometryAddedObservable: Observable<Geometry>;
  38406. /**
  38407. * An event triggered when a geometry is removed
  38408. */
  38409. onGeometryRemovedObservable: Observable<Geometry>;
  38410. /**
  38411. * An event triggered when a transform node is created
  38412. */
  38413. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38414. /**
  38415. * An event triggered when a transform node is removed
  38416. */
  38417. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38418. /**
  38419. * An event triggered when a mesh is created
  38420. */
  38421. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38422. /**
  38423. * An event triggered when a mesh is removed
  38424. */
  38425. onMeshRemovedObservable: Observable<AbstractMesh>;
  38426. /**
  38427. * An event triggered when a skeleton is created
  38428. */
  38429. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38430. /**
  38431. * An event triggered when a skeleton is removed
  38432. */
  38433. onSkeletonRemovedObservable: Observable<Skeleton>;
  38434. /**
  38435. * An event triggered when a material is created
  38436. */
  38437. onNewMaterialAddedObservable: Observable<Material>;
  38438. /**
  38439. * An event triggered when a material is removed
  38440. */
  38441. onMaterialRemovedObservable: Observable<Material>;
  38442. /**
  38443. * An event triggered when a texture is created
  38444. */
  38445. onNewTextureAddedObservable: Observable<BaseTexture>;
  38446. /**
  38447. * An event triggered when a texture is removed
  38448. */
  38449. onTextureRemovedObservable: Observable<BaseTexture>;
  38450. /**
  38451. * An event triggered when render targets are about to be rendered
  38452. * Can happen multiple times per frame.
  38453. */
  38454. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38455. /**
  38456. * An event triggered when render targets were rendered.
  38457. * Can happen multiple times per frame.
  38458. */
  38459. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38460. /**
  38461. * An event triggered before calculating deterministic simulation step
  38462. */
  38463. onBeforeStepObservable: Observable<Scene>;
  38464. /**
  38465. * An event triggered after calculating deterministic simulation step
  38466. */
  38467. onAfterStepObservable: Observable<Scene>;
  38468. /**
  38469. * An event triggered when the activeCamera property is updated
  38470. */
  38471. onActiveCameraChanged: Observable<Scene>;
  38472. /**
  38473. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38474. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38475. * 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)
  38476. */
  38477. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38478. /**
  38479. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38480. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38481. * 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)
  38482. */
  38483. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38484. /**
  38485. * This Observable will when a mesh has been imported into the scene.
  38486. */
  38487. onMeshImportedObservable: Observable<AbstractMesh>;
  38488. /**
  38489. * This Observable will when an animation file has been imported into the scene.
  38490. */
  38491. onAnimationFileImportedObservable: Observable<Scene>;
  38492. /**
  38493. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38494. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38495. */
  38496. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38497. /** @hidden */
  38498. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38499. /**
  38500. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38501. */
  38502. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38503. /**
  38504. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38505. */
  38506. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38507. /**
  38508. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38509. */
  38510. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38511. /** Callback called when a pointer move is detected */
  38512. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38513. /** Callback called when a pointer down is detected */
  38514. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38515. /** Callback called when a pointer up is detected */
  38516. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38517. /** Callback called when a pointer pick is detected */
  38518. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38519. /**
  38520. * 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).
  38521. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38522. */
  38523. onPrePointerObservable: Observable<PointerInfoPre>;
  38524. /**
  38525. * Observable event triggered each time an input event is received from the rendering canvas
  38526. */
  38527. onPointerObservable: Observable<PointerInfo>;
  38528. /**
  38529. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38530. */
  38531. get unTranslatedPointer(): Vector2;
  38532. /**
  38533. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38534. */
  38535. static get DragMovementThreshold(): number;
  38536. static set DragMovementThreshold(value: number);
  38537. /**
  38538. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38539. */
  38540. static get LongPressDelay(): number;
  38541. static set LongPressDelay(value: number);
  38542. /**
  38543. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38544. */
  38545. static get DoubleClickDelay(): number;
  38546. static set DoubleClickDelay(value: number);
  38547. /** If you need to check double click without raising a single click at first click, enable this flag */
  38548. static get ExclusiveDoubleClickMode(): boolean;
  38549. static set ExclusiveDoubleClickMode(value: boolean);
  38550. /** @hidden */
  38551. _mirroredCameraPosition: Nullable<Vector3>;
  38552. /**
  38553. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38554. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38555. */
  38556. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38557. /**
  38558. * Observable event triggered each time an keyboard event is received from the hosting window
  38559. */
  38560. onKeyboardObservable: Observable<KeyboardInfo>;
  38561. private _useRightHandedSystem;
  38562. /**
  38563. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38564. */
  38565. set useRightHandedSystem(value: boolean);
  38566. get useRightHandedSystem(): boolean;
  38567. private _timeAccumulator;
  38568. private _currentStepId;
  38569. private _currentInternalStep;
  38570. /**
  38571. * Sets the step Id used by deterministic lock step
  38572. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38573. * @param newStepId defines the step Id
  38574. */
  38575. setStepId(newStepId: number): void;
  38576. /**
  38577. * Gets the step Id used by deterministic lock step
  38578. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38579. * @returns the step Id
  38580. */
  38581. getStepId(): number;
  38582. /**
  38583. * Gets the internal step used by deterministic lock step
  38584. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38585. * @returns the internal step
  38586. */
  38587. getInternalStep(): number;
  38588. private _fogEnabled;
  38589. /**
  38590. * Gets or sets a boolean indicating if fog is enabled on this scene
  38591. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38592. * (Default is true)
  38593. */
  38594. set fogEnabled(value: boolean);
  38595. get fogEnabled(): boolean;
  38596. private _fogMode;
  38597. /**
  38598. * Gets or sets the fog mode to use
  38599. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38600. * | mode | value |
  38601. * | --- | --- |
  38602. * | FOGMODE_NONE | 0 |
  38603. * | FOGMODE_EXP | 1 |
  38604. * | FOGMODE_EXP2 | 2 |
  38605. * | FOGMODE_LINEAR | 3 |
  38606. */
  38607. set fogMode(value: number);
  38608. get fogMode(): number;
  38609. /**
  38610. * Gets or sets the fog color to use
  38611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38612. * (Default is Color3(0.2, 0.2, 0.3))
  38613. */
  38614. fogColor: Color3;
  38615. /**
  38616. * Gets or sets the fog density to use
  38617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38618. * (Default is 0.1)
  38619. */
  38620. fogDensity: number;
  38621. /**
  38622. * Gets or sets the fog start distance to use
  38623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38624. * (Default is 0)
  38625. */
  38626. fogStart: number;
  38627. /**
  38628. * Gets or sets the fog end distance to use
  38629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38630. * (Default is 1000)
  38631. */
  38632. fogEnd: number;
  38633. private _shadowsEnabled;
  38634. /**
  38635. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38636. */
  38637. set shadowsEnabled(value: boolean);
  38638. get shadowsEnabled(): boolean;
  38639. private _lightsEnabled;
  38640. /**
  38641. * Gets or sets a boolean indicating if lights are enabled on this scene
  38642. */
  38643. set lightsEnabled(value: boolean);
  38644. get lightsEnabled(): boolean;
  38645. /** All of the active cameras added to this scene. */
  38646. activeCameras: Camera[];
  38647. /** @hidden */
  38648. _activeCamera: Nullable<Camera>;
  38649. /** Gets or sets the current active camera */
  38650. get activeCamera(): Nullable<Camera>;
  38651. set activeCamera(value: Nullable<Camera>);
  38652. private _defaultMaterial;
  38653. /** The default material used on meshes when no material is affected */
  38654. get defaultMaterial(): Material;
  38655. /** The default material used on meshes when no material is affected */
  38656. set defaultMaterial(value: Material);
  38657. private _texturesEnabled;
  38658. /**
  38659. * Gets or sets a boolean indicating if textures are enabled on this scene
  38660. */
  38661. set texturesEnabled(value: boolean);
  38662. get texturesEnabled(): boolean;
  38663. /**
  38664. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38665. */
  38666. physicsEnabled: boolean;
  38667. /**
  38668. * Gets or sets a boolean indicating if particles are enabled on this scene
  38669. */
  38670. particlesEnabled: boolean;
  38671. /**
  38672. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38673. */
  38674. spritesEnabled: boolean;
  38675. private _skeletonsEnabled;
  38676. /**
  38677. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38678. */
  38679. set skeletonsEnabled(value: boolean);
  38680. get skeletonsEnabled(): boolean;
  38681. /**
  38682. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38683. */
  38684. lensFlaresEnabled: boolean;
  38685. /**
  38686. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38687. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38688. */
  38689. collisionsEnabled: boolean;
  38690. private _collisionCoordinator;
  38691. /** @hidden */
  38692. get collisionCoordinator(): ICollisionCoordinator;
  38693. /**
  38694. * Defines the gravity applied to this scene (used only for collisions)
  38695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38696. */
  38697. gravity: Vector3;
  38698. /**
  38699. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38700. */
  38701. postProcessesEnabled: boolean;
  38702. /**
  38703. * The list of postprocesses added to the scene
  38704. */
  38705. postProcesses: PostProcess[];
  38706. /**
  38707. * Gets the current postprocess manager
  38708. */
  38709. postProcessManager: PostProcessManager;
  38710. /**
  38711. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38712. */
  38713. renderTargetsEnabled: boolean;
  38714. /**
  38715. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38716. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38717. */
  38718. dumpNextRenderTargets: boolean;
  38719. /**
  38720. * The list of user defined render targets added to the scene
  38721. */
  38722. customRenderTargets: RenderTargetTexture[];
  38723. /**
  38724. * Defines if texture loading must be delayed
  38725. * If true, textures will only be loaded when they need to be rendered
  38726. */
  38727. useDelayedTextureLoading: boolean;
  38728. /**
  38729. * Gets the list of meshes imported to the scene through SceneLoader
  38730. */
  38731. importedMeshesFiles: String[];
  38732. /**
  38733. * Gets or sets a boolean indicating if probes are enabled on this scene
  38734. */
  38735. probesEnabled: boolean;
  38736. /**
  38737. * Gets or sets the current offline provider to use to store scene data
  38738. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38739. */
  38740. offlineProvider: IOfflineProvider;
  38741. /**
  38742. * Gets or sets the action manager associated with the scene
  38743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38744. */
  38745. actionManager: AbstractActionManager;
  38746. private _meshesForIntersections;
  38747. /**
  38748. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38749. */
  38750. proceduralTexturesEnabled: boolean;
  38751. private _engine;
  38752. private _totalVertices;
  38753. /** @hidden */
  38754. _activeIndices: PerfCounter;
  38755. /** @hidden */
  38756. _activeParticles: PerfCounter;
  38757. /** @hidden */
  38758. _activeBones: PerfCounter;
  38759. private _animationRatio;
  38760. /** @hidden */
  38761. _animationTimeLast: number;
  38762. /** @hidden */
  38763. _animationTime: number;
  38764. /**
  38765. * Gets or sets a general scale for animation speed
  38766. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38767. */
  38768. animationTimeScale: number;
  38769. /** @hidden */
  38770. _cachedMaterial: Nullable<Material>;
  38771. /** @hidden */
  38772. _cachedEffect: Nullable<Effect>;
  38773. /** @hidden */
  38774. _cachedVisibility: Nullable<number>;
  38775. private _renderId;
  38776. private _frameId;
  38777. private _executeWhenReadyTimeoutId;
  38778. private _intermediateRendering;
  38779. private _viewUpdateFlag;
  38780. private _projectionUpdateFlag;
  38781. /** @hidden */
  38782. _toBeDisposed: Nullable<IDisposable>[];
  38783. private _activeRequests;
  38784. /** @hidden */
  38785. _pendingData: any[];
  38786. private _isDisposed;
  38787. /**
  38788. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38789. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38790. */
  38791. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38792. private _activeMeshes;
  38793. private _processedMaterials;
  38794. private _renderTargets;
  38795. /** @hidden */
  38796. _activeParticleSystems: SmartArray<IParticleSystem>;
  38797. private _activeSkeletons;
  38798. private _softwareSkinnedMeshes;
  38799. private _renderingManager;
  38800. /** @hidden */
  38801. _activeAnimatables: Animatable[];
  38802. private _transformMatrix;
  38803. private _sceneUbo;
  38804. /** @hidden */
  38805. _viewMatrix: Matrix;
  38806. private _projectionMatrix;
  38807. /** @hidden */
  38808. _forcedViewPosition: Nullable<Vector3>;
  38809. /** @hidden */
  38810. _frustumPlanes: Plane[];
  38811. /**
  38812. * Gets the list of frustum planes (built from the active camera)
  38813. */
  38814. get frustumPlanes(): Plane[];
  38815. /**
  38816. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38817. * This is useful if there are more lights that the maximum simulteanous authorized
  38818. */
  38819. requireLightSorting: boolean;
  38820. /** @hidden */
  38821. readonly useMaterialMeshMap: boolean;
  38822. /** @hidden */
  38823. readonly useClonedMeshMap: boolean;
  38824. private _externalData;
  38825. private _uid;
  38826. /**
  38827. * @hidden
  38828. * Backing store of defined scene components.
  38829. */
  38830. _components: ISceneComponent[];
  38831. /**
  38832. * @hidden
  38833. * Backing store of defined scene components.
  38834. */
  38835. _serializableComponents: ISceneSerializableComponent[];
  38836. /**
  38837. * List of components to register on the next registration step.
  38838. */
  38839. private _transientComponents;
  38840. /**
  38841. * Registers the transient components if needed.
  38842. */
  38843. private _registerTransientComponents;
  38844. /**
  38845. * @hidden
  38846. * Add a component to the scene.
  38847. * Note that the ccomponent could be registered on th next frame if this is called after
  38848. * the register component stage.
  38849. * @param component Defines the component to add to the scene
  38850. */
  38851. _addComponent(component: ISceneComponent): void;
  38852. /**
  38853. * @hidden
  38854. * Gets a component from the scene.
  38855. * @param name defines the name of the component to retrieve
  38856. * @returns the component or null if not present
  38857. */
  38858. _getComponent(name: string): Nullable<ISceneComponent>;
  38859. /**
  38860. * @hidden
  38861. * Defines the actions happening before camera updates.
  38862. */
  38863. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38864. /**
  38865. * @hidden
  38866. * Defines the actions happening before clear the canvas.
  38867. */
  38868. _beforeClearStage: Stage<SimpleStageAction>;
  38869. /**
  38870. * @hidden
  38871. * Defines the actions when collecting render targets for the frame.
  38872. */
  38873. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38874. /**
  38875. * @hidden
  38876. * Defines the actions happening for one camera in the frame.
  38877. */
  38878. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38879. /**
  38880. * @hidden
  38881. * Defines the actions happening during the per mesh ready checks.
  38882. */
  38883. _isReadyForMeshStage: Stage<MeshStageAction>;
  38884. /**
  38885. * @hidden
  38886. * Defines the actions happening before evaluate active mesh checks.
  38887. */
  38888. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38889. /**
  38890. * @hidden
  38891. * Defines the actions happening during the evaluate sub mesh checks.
  38892. */
  38893. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38894. /**
  38895. * @hidden
  38896. * Defines the actions happening during the active mesh stage.
  38897. */
  38898. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38899. /**
  38900. * @hidden
  38901. * Defines the actions happening during the per camera render target step.
  38902. */
  38903. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38904. /**
  38905. * @hidden
  38906. * Defines the actions happening just before the active camera is drawing.
  38907. */
  38908. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38909. /**
  38910. * @hidden
  38911. * Defines the actions happening just before a render target is drawing.
  38912. */
  38913. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38914. /**
  38915. * @hidden
  38916. * Defines the actions happening just before a rendering group is drawing.
  38917. */
  38918. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38919. /**
  38920. * @hidden
  38921. * Defines the actions happening just before a mesh is drawing.
  38922. */
  38923. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38924. /**
  38925. * @hidden
  38926. * Defines the actions happening just after a mesh has been drawn.
  38927. */
  38928. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38929. /**
  38930. * @hidden
  38931. * Defines the actions happening just after a rendering group has been drawn.
  38932. */
  38933. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38934. /**
  38935. * @hidden
  38936. * Defines the actions happening just after the active camera has been drawn.
  38937. */
  38938. _afterCameraDrawStage: Stage<CameraStageAction>;
  38939. /**
  38940. * @hidden
  38941. * Defines the actions happening just after a render target has been drawn.
  38942. */
  38943. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38944. /**
  38945. * @hidden
  38946. * Defines the actions happening just after rendering all cameras and computing intersections.
  38947. */
  38948. _afterRenderStage: Stage<SimpleStageAction>;
  38949. /**
  38950. * @hidden
  38951. * Defines the actions happening when a pointer move event happens.
  38952. */
  38953. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38954. /**
  38955. * @hidden
  38956. * Defines the actions happening when a pointer down event happens.
  38957. */
  38958. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38959. /**
  38960. * @hidden
  38961. * Defines the actions happening when a pointer up event happens.
  38962. */
  38963. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38964. /**
  38965. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38966. */
  38967. private geometriesByUniqueId;
  38968. /**
  38969. * Creates a new Scene
  38970. * @param engine defines the engine to use to render this scene
  38971. * @param options defines the scene options
  38972. */
  38973. constructor(engine: Engine, options?: SceneOptions);
  38974. /**
  38975. * Gets a string idenfifying the name of the class
  38976. * @returns "Scene" string
  38977. */
  38978. getClassName(): string;
  38979. private _defaultMeshCandidates;
  38980. /**
  38981. * @hidden
  38982. */
  38983. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38984. private _defaultSubMeshCandidates;
  38985. /**
  38986. * @hidden
  38987. */
  38988. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38989. /**
  38990. * Sets the default candidate providers for the scene.
  38991. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  38992. * and getCollidingSubMeshCandidates to their default function
  38993. */
  38994. setDefaultCandidateProviders(): void;
  38995. /**
  38996. * Gets the mesh that is currently under the pointer
  38997. */
  38998. get meshUnderPointer(): Nullable<AbstractMesh>;
  38999. /**
  39000. * Gets or sets the current on-screen X position of the pointer
  39001. */
  39002. get pointerX(): number;
  39003. set pointerX(value: number);
  39004. /**
  39005. * Gets or sets the current on-screen Y position of the pointer
  39006. */
  39007. get pointerY(): number;
  39008. set pointerY(value: number);
  39009. /**
  39010. * Gets the cached material (ie. the latest rendered one)
  39011. * @returns the cached material
  39012. */
  39013. getCachedMaterial(): Nullable<Material>;
  39014. /**
  39015. * Gets the cached effect (ie. the latest rendered one)
  39016. * @returns the cached effect
  39017. */
  39018. getCachedEffect(): Nullable<Effect>;
  39019. /**
  39020. * Gets the cached visibility state (ie. the latest rendered one)
  39021. * @returns the cached visibility state
  39022. */
  39023. getCachedVisibility(): Nullable<number>;
  39024. /**
  39025. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39026. * @param material defines the current material
  39027. * @param effect defines the current effect
  39028. * @param visibility defines the current visibility state
  39029. * @returns true if one parameter is not cached
  39030. */
  39031. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39032. /**
  39033. * Gets the engine associated with the scene
  39034. * @returns an Engine
  39035. */
  39036. getEngine(): Engine;
  39037. /**
  39038. * Gets the total number of vertices rendered per frame
  39039. * @returns the total number of vertices rendered per frame
  39040. */
  39041. getTotalVertices(): number;
  39042. /**
  39043. * Gets the performance counter for total vertices
  39044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39045. */
  39046. get totalVerticesPerfCounter(): PerfCounter;
  39047. /**
  39048. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39049. * @returns the total number of active indices rendered per frame
  39050. */
  39051. getActiveIndices(): number;
  39052. /**
  39053. * Gets the performance counter for active indices
  39054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39055. */
  39056. get totalActiveIndicesPerfCounter(): PerfCounter;
  39057. /**
  39058. * Gets the total number of active particles rendered per frame
  39059. * @returns the total number of active particles rendered per frame
  39060. */
  39061. getActiveParticles(): number;
  39062. /**
  39063. * Gets the performance counter for active particles
  39064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39065. */
  39066. get activeParticlesPerfCounter(): PerfCounter;
  39067. /**
  39068. * Gets the total number of active bones rendered per frame
  39069. * @returns the total number of active bones rendered per frame
  39070. */
  39071. getActiveBones(): number;
  39072. /**
  39073. * Gets the performance counter for active bones
  39074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39075. */
  39076. get activeBonesPerfCounter(): PerfCounter;
  39077. /**
  39078. * Gets the array of active meshes
  39079. * @returns an array of AbstractMesh
  39080. */
  39081. getActiveMeshes(): SmartArray<AbstractMesh>;
  39082. /**
  39083. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39084. * @returns a number
  39085. */
  39086. getAnimationRatio(): number;
  39087. /**
  39088. * Gets an unique Id for the current render phase
  39089. * @returns a number
  39090. */
  39091. getRenderId(): number;
  39092. /**
  39093. * Gets an unique Id for the current frame
  39094. * @returns a number
  39095. */
  39096. getFrameId(): number;
  39097. /** Call this function if you want to manually increment the render Id*/
  39098. incrementRenderId(): void;
  39099. private _createUbo;
  39100. /**
  39101. * Use this method to simulate a pointer move on a mesh
  39102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39105. * @returns the current scene
  39106. */
  39107. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39108. /**
  39109. * Use this method to simulate a pointer down on a mesh
  39110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39113. * @returns the current scene
  39114. */
  39115. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39116. /**
  39117. * Use this method to simulate a pointer up on a mesh
  39118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39121. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39122. * @returns the current scene
  39123. */
  39124. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39125. /**
  39126. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39127. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39128. * @returns true if the pointer was captured
  39129. */
  39130. isPointerCaptured(pointerId?: number): boolean;
  39131. /**
  39132. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39133. * @param attachUp defines if you want to attach events to pointerup
  39134. * @param attachDown defines if you want to attach events to pointerdown
  39135. * @param attachMove defines if you want to attach events to pointermove
  39136. */
  39137. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39138. /** Detaches all event handlers*/
  39139. detachControl(): void;
  39140. /**
  39141. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39142. * Delay loaded resources are not taking in account
  39143. * @return true if all required resources are ready
  39144. */
  39145. isReady(): boolean;
  39146. /** Resets all cached information relative to material (including effect and visibility) */
  39147. resetCachedMaterial(): void;
  39148. /**
  39149. * Registers a function to be called before every frame render
  39150. * @param func defines the function to register
  39151. */
  39152. registerBeforeRender(func: () => void): void;
  39153. /**
  39154. * Unregisters a function called before every frame render
  39155. * @param func defines the function to unregister
  39156. */
  39157. unregisterBeforeRender(func: () => void): void;
  39158. /**
  39159. * Registers a function to be called after every frame render
  39160. * @param func defines the function to register
  39161. */
  39162. registerAfterRender(func: () => void): void;
  39163. /**
  39164. * Unregisters a function called after every frame render
  39165. * @param func defines the function to unregister
  39166. */
  39167. unregisterAfterRender(func: () => void): void;
  39168. private _executeOnceBeforeRender;
  39169. /**
  39170. * The provided function will run before render once and will be disposed afterwards.
  39171. * A timeout delay can be provided so that the function will be executed in N ms.
  39172. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39173. * @param func The function to be executed.
  39174. * @param timeout optional delay in ms
  39175. */
  39176. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39177. /** @hidden */
  39178. _addPendingData(data: any): void;
  39179. /** @hidden */
  39180. _removePendingData(data: any): void;
  39181. /**
  39182. * Returns the number of items waiting to be loaded
  39183. * @returns the number of items waiting to be loaded
  39184. */
  39185. getWaitingItemsCount(): number;
  39186. /**
  39187. * Returns a boolean indicating if the scene is still loading data
  39188. */
  39189. get isLoading(): boolean;
  39190. /**
  39191. * Registers a function to be executed when the scene is ready
  39192. * @param {Function} func - the function to be executed
  39193. */
  39194. executeWhenReady(func: () => void): void;
  39195. /**
  39196. * Returns a promise that resolves when the scene is ready
  39197. * @returns A promise that resolves when the scene is ready
  39198. */
  39199. whenReadyAsync(): Promise<void>;
  39200. /** @hidden */
  39201. _checkIsReady(): void;
  39202. /**
  39203. * Gets all animatable attached to the scene
  39204. */
  39205. get animatables(): Animatable[];
  39206. /**
  39207. * Resets the last animation time frame.
  39208. * Useful to override when animations start running when loading a scene for the first time.
  39209. */
  39210. resetLastAnimationTimeFrame(): void;
  39211. /**
  39212. * Gets the current view matrix
  39213. * @returns a Matrix
  39214. */
  39215. getViewMatrix(): Matrix;
  39216. /**
  39217. * Gets the current projection matrix
  39218. * @returns a Matrix
  39219. */
  39220. getProjectionMatrix(): Matrix;
  39221. /**
  39222. * Gets the current transform matrix
  39223. * @returns a Matrix made of View * Projection
  39224. */
  39225. getTransformMatrix(): Matrix;
  39226. /**
  39227. * Sets the current transform matrix
  39228. * @param viewL defines the View matrix to use
  39229. * @param projectionL defines the Projection matrix to use
  39230. * @param viewR defines the right View matrix to use (if provided)
  39231. * @param projectionR defines the right Projection matrix to use (if provided)
  39232. */
  39233. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39234. /**
  39235. * Gets the uniform buffer used to store scene data
  39236. * @returns a UniformBuffer
  39237. */
  39238. getSceneUniformBuffer(): UniformBuffer;
  39239. /**
  39240. * Gets an unique (relatively to the current scene) Id
  39241. * @returns an unique number for the scene
  39242. */
  39243. getUniqueId(): number;
  39244. /**
  39245. * Add a mesh to the list of scene's meshes
  39246. * @param newMesh defines the mesh to add
  39247. * @param recursive if all child meshes should also be added to the scene
  39248. */
  39249. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39250. /**
  39251. * Remove a mesh for the list of scene's meshes
  39252. * @param toRemove defines the mesh to remove
  39253. * @param recursive if all child meshes should also be removed from the scene
  39254. * @returns the index where the mesh was in the mesh list
  39255. */
  39256. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39257. /**
  39258. * Add a transform node to the list of scene's transform nodes
  39259. * @param newTransformNode defines the transform node to add
  39260. */
  39261. addTransformNode(newTransformNode: TransformNode): void;
  39262. /**
  39263. * Remove a transform node for the list of scene's transform nodes
  39264. * @param toRemove defines the transform node to remove
  39265. * @returns the index where the transform node was in the transform node list
  39266. */
  39267. removeTransformNode(toRemove: TransformNode): number;
  39268. /**
  39269. * Remove a skeleton for the list of scene's skeletons
  39270. * @param toRemove defines the skeleton to remove
  39271. * @returns the index where the skeleton was in the skeleton list
  39272. */
  39273. removeSkeleton(toRemove: Skeleton): number;
  39274. /**
  39275. * Remove a morph target for the list of scene's morph targets
  39276. * @param toRemove defines the morph target to remove
  39277. * @returns the index where the morph target was in the morph target list
  39278. */
  39279. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39280. /**
  39281. * Remove a light for the list of scene's lights
  39282. * @param toRemove defines the light to remove
  39283. * @returns the index where the light was in the light list
  39284. */
  39285. removeLight(toRemove: Light): number;
  39286. /**
  39287. * Remove a camera for the list of scene's cameras
  39288. * @param toRemove defines the camera to remove
  39289. * @returns the index where the camera was in the camera list
  39290. */
  39291. removeCamera(toRemove: Camera): number;
  39292. /**
  39293. * Remove a particle system for the list of scene's particle systems
  39294. * @param toRemove defines the particle system to remove
  39295. * @returns the index where the particle system was in the particle system list
  39296. */
  39297. removeParticleSystem(toRemove: IParticleSystem): number;
  39298. /**
  39299. * Remove a animation for the list of scene's animations
  39300. * @param toRemove defines the animation to remove
  39301. * @returns the index where the animation was in the animation list
  39302. */
  39303. removeAnimation(toRemove: Animation): number;
  39304. /**
  39305. * Will stop the animation of the given target
  39306. * @param target - the target
  39307. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39308. * @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)
  39309. */
  39310. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39311. /**
  39312. * Removes the given animation group from this scene.
  39313. * @param toRemove The animation group to remove
  39314. * @returns The index of the removed animation group
  39315. */
  39316. removeAnimationGroup(toRemove: AnimationGroup): number;
  39317. /**
  39318. * Removes the given multi-material from this scene.
  39319. * @param toRemove The multi-material to remove
  39320. * @returns The index of the removed multi-material
  39321. */
  39322. removeMultiMaterial(toRemove: MultiMaterial): number;
  39323. /**
  39324. * Removes the given material from this scene.
  39325. * @param toRemove The material to remove
  39326. * @returns The index of the removed material
  39327. */
  39328. removeMaterial(toRemove: Material): number;
  39329. /**
  39330. * Removes the given action manager from this scene.
  39331. * @param toRemove The action manager to remove
  39332. * @returns The index of the removed action manager
  39333. */
  39334. removeActionManager(toRemove: AbstractActionManager): number;
  39335. /**
  39336. * Removes the given texture from this scene.
  39337. * @param toRemove The texture to remove
  39338. * @returns The index of the removed texture
  39339. */
  39340. removeTexture(toRemove: BaseTexture): number;
  39341. /**
  39342. * Adds the given light to this scene
  39343. * @param newLight The light to add
  39344. */
  39345. addLight(newLight: Light): void;
  39346. /**
  39347. * Sorts the list list based on light priorities
  39348. */
  39349. sortLightsByPriority(): void;
  39350. /**
  39351. * Adds the given camera to this scene
  39352. * @param newCamera The camera to add
  39353. */
  39354. addCamera(newCamera: Camera): void;
  39355. /**
  39356. * Adds the given skeleton to this scene
  39357. * @param newSkeleton The skeleton to add
  39358. */
  39359. addSkeleton(newSkeleton: Skeleton): void;
  39360. /**
  39361. * Adds the given particle system to this scene
  39362. * @param newParticleSystem The particle system to add
  39363. */
  39364. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39365. /**
  39366. * Adds the given animation to this scene
  39367. * @param newAnimation The animation to add
  39368. */
  39369. addAnimation(newAnimation: Animation): void;
  39370. /**
  39371. * Adds the given animation group to this scene.
  39372. * @param newAnimationGroup The animation group to add
  39373. */
  39374. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39375. /**
  39376. * Adds the given multi-material to this scene
  39377. * @param newMultiMaterial The multi-material to add
  39378. */
  39379. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39380. /**
  39381. * Adds the given material to this scene
  39382. * @param newMaterial The material to add
  39383. */
  39384. addMaterial(newMaterial: Material): void;
  39385. /**
  39386. * Adds the given morph target to this scene
  39387. * @param newMorphTargetManager The morph target to add
  39388. */
  39389. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39390. /**
  39391. * Adds the given geometry to this scene
  39392. * @param newGeometry The geometry to add
  39393. */
  39394. addGeometry(newGeometry: Geometry): void;
  39395. /**
  39396. * Adds the given action manager to this scene
  39397. * @param newActionManager The action manager to add
  39398. */
  39399. addActionManager(newActionManager: AbstractActionManager): void;
  39400. /**
  39401. * Adds the given texture to this scene.
  39402. * @param newTexture The texture to add
  39403. */
  39404. addTexture(newTexture: BaseTexture): void;
  39405. /**
  39406. * Switch active camera
  39407. * @param newCamera defines the new active camera
  39408. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39409. */
  39410. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39411. /**
  39412. * sets the active camera of the scene using its ID
  39413. * @param id defines the camera's ID
  39414. * @return the new active camera or null if none found.
  39415. */
  39416. setActiveCameraByID(id: string): Nullable<Camera>;
  39417. /**
  39418. * sets the active camera of the scene using its name
  39419. * @param name defines the camera's name
  39420. * @returns the new active camera or null if none found.
  39421. */
  39422. setActiveCameraByName(name: string): Nullable<Camera>;
  39423. /**
  39424. * get an animation group using its name
  39425. * @param name defines the material's name
  39426. * @return the animation group or null if none found.
  39427. */
  39428. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39429. /**
  39430. * Get a material using its unique id
  39431. * @param uniqueId defines the material's unique id
  39432. * @return the material or null if none found.
  39433. */
  39434. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39435. /**
  39436. * get a material using its id
  39437. * @param id defines the material's ID
  39438. * @return the material or null if none found.
  39439. */
  39440. getMaterialByID(id: string): Nullable<Material>;
  39441. /**
  39442. * Gets a the last added material using a given id
  39443. * @param id defines the material's ID
  39444. * @return the last material with the given id or null if none found.
  39445. */
  39446. getLastMaterialByID(id: string): Nullable<Material>;
  39447. /**
  39448. * Gets a material using its name
  39449. * @param name defines the material's name
  39450. * @return the material or null if none found.
  39451. */
  39452. getMaterialByName(name: string): Nullable<Material>;
  39453. /**
  39454. * Get a texture using its unique id
  39455. * @param uniqueId defines the texture's unique id
  39456. * @return the texture or null if none found.
  39457. */
  39458. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39459. /**
  39460. * Gets a camera using its id
  39461. * @param id defines the id to look for
  39462. * @returns the camera or null if not found
  39463. */
  39464. getCameraByID(id: string): Nullable<Camera>;
  39465. /**
  39466. * Gets a camera using its unique id
  39467. * @param uniqueId defines the unique id to look for
  39468. * @returns the camera or null if not found
  39469. */
  39470. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39471. /**
  39472. * Gets a camera using its name
  39473. * @param name defines the camera's name
  39474. * @return the camera or null if none found.
  39475. */
  39476. getCameraByName(name: string): Nullable<Camera>;
  39477. /**
  39478. * Gets a bone using its id
  39479. * @param id defines the bone's id
  39480. * @return the bone or null if not found
  39481. */
  39482. getBoneByID(id: string): Nullable<Bone>;
  39483. /**
  39484. * Gets a bone using its id
  39485. * @param name defines the bone's name
  39486. * @return the bone or null if not found
  39487. */
  39488. getBoneByName(name: string): Nullable<Bone>;
  39489. /**
  39490. * Gets a light node using its name
  39491. * @param name defines the the light's name
  39492. * @return the light or null if none found.
  39493. */
  39494. getLightByName(name: string): Nullable<Light>;
  39495. /**
  39496. * Gets a light node using its id
  39497. * @param id defines the light's id
  39498. * @return the light or null if none found.
  39499. */
  39500. getLightByID(id: string): Nullable<Light>;
  39501. /**
  39502. * Gets a light node using its scene-generated unique ID
  39503. * @param uniqueId defines the light's unique id
  39504. * @return the light or null if none found.
  39505. */
  39506. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39507. /**
  39508. * Gets a particle system by id
  39509. * @param id defines the particle system id
  39510. * @return the corresponding system or null if none found
  39511. */
  39512. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39513. /**
  39514. * Gets a geometry using its ID
  39515. * @param id defines the geometry's id
  39516. * @return the geometry or null if none found.
  39517. */
  39518. getGeometryByID(id: string): Nullable<Geometry>;
  39519. private _getGeometryByUniqueID;
  39520. /**
  39521. * Add a new geometry to this scene
  39522. * @param geometry defines the geometry to be added to the scene.
  39523. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39524. * @return a boolean defining if the geometry was added or not
  39525. */
  39526. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39527. /**
  39528. * Removes an existing geometry
  39529. * @param geometry defines the geometry to be removed from the scene
  39530. * @return a boolean defining if the geometry was removed or not
  39531. */
  39532. removeGeometry(geometry: Geometry): boolean;
  39533. /**
  39534. * Gets the list of geometries attached to the scene
  39535. * @returns an array of Geometry
  39536. */
  39537. getGeometries(): Geometry[];
  39538. /**
  39539. * Gets the first added mesh found of a given ID
  39540. * @param id defines the id to search for
  39541. * @return the mesh found or null if not found at all
  39542. */
  39543. getMeshByID(id: string): Nullable<AbstractMesh>;
  39544. /**
  39545. * Gets a list of meshes using their id
  39546. * @param id defines the id to search for
  39547. * @returns a list of meshes
  39548. */
  39549. getMeshesByID(id: string): Array<AbstractMesh>;
  39550. /**
  39551. * Gets the first added transform node found of a given ID
  39552. * @param id defines the id to search for
  39553. * @return the found transform node or null if not found at all.
  39554. */
  39555. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39556. /**
  39557. * Gets a transform node with its auto-generated unique id
  39558. * @param uniqueId efines the unique id to search for
  39559. * @return the found transform node or null if not found at all.
  39560. */
  39561. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39562. /**
  39563. * Gets a list of transform nodes using their id
  39564. * @param id defines the id to search for
  39565. * @returns a list of transform nodes
  39566. */
  39567. getTransformNodesByID(id: string): Array<TransformNode>;
  39568. /**
  39569. * Gets a mesh with its auto-generated unique id
  39570. * @param uniqueId defines the unique id to search for
  39571. * @return the found mesh or null if not found at all.
  39572. */
  39573. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39574. /**
  39575. * Gets a the last added mesh using a given id
  39576. * @param id defines the id to search for
  39577. * @return the found mesh or null if not found at all.
  39578. */
  39579. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39580. /**
  39581. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39582. * @param id defines the id to search for
  39583. * @return the found node or null if not found at all
  39584. */
  39585. getLastEntryByID(id: string): Nullable<Node>;
  39586. /**
  39587. * Gets a node (Mesh, Camera, Light) using a given id
  39588. * @param id defines the id to search for
  39589. * @return the found node or null if not found at all
  39590. */
  39591. getNodeByID(id: string): Nullable<Node>;
  39592. /**
  39593. * Gets a node (Mesh, Camera, Light) using a given name
  39594. * @param name defines the name to search for
  39595. * @return the found node or null if not found at all.
  39596. */
  39597. getNodeByName(name: string): Nullable<Node>;
  39598. /**
  39599. * Gets a mesh using a given name
  39600. * @param name defines the name to search for
  39601. * @return the found mesh or null if not found at all.
  39602. */
  39603. getMeshByName(name: string): Nullable<AbstractMesh>;
  39604. /**
  39605. * Gets a transform node using a given name
  39606. * @param name defines the name to search for
  39607. * @return the found transform node or null if not found at all.
  39608. */
  39609. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39610. /**
  39611. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39612. * @param id defines the id to search for
  39613. * @return the found skeleton or null if not found at all.
  39614. */
  39615. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39616. /**
  39617. * Gets a skeleton using a given auto generated unique id
  39618. * @param uniqueId defines the unique id to search for
  39619. * @return the found skeleton or null if not found at all.
  39620. */
  39621. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39622. /**
  39623. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39624. * @param id defines the id to search for
  39625. * @return the found skeleton or null if not found at all.
  39626. */
  39627. getSkeletonById(id: string): Nullable<Skeleton>;
  39628. /**
  39629. * Gets a skeleton using a given name
  39630. * @param name defines the name to search for
  39631. * @return the found skeleton or null if not found at all.
  39632. */
  39633. getSkeletonByName(name: string): Nullable<Skeleton>;
  39634. /**
  39635. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39636. * @param id defines the id to search for
  39637. * @return the found morph target manager or null if not found at all.
  39638. */
  39639. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39640. /**
  39641. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39642. * @param id defines the id to search for
  39643. * @return the found morph target or null if not found at all.
  39644. */
  39645. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39646. /**
  39647. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39648. * @param name defines the name to search for
  39649. * @return the found morph target or null if not found at all.
  39650. */
  39651. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39652. /**
  39653. * Gets a boolean indicating if the given mesh is active
  39654. * @param mesh defines the mesh to look for
  39655. * @returns true if the mesh is in the active list
  39656. */
  39657. isActiveMesh(mesh: AbstractMesh): boolean;
  39658. /**
  39659. * Return a unique id as a string which can serve as an identifier for the scene
  39660. */
  39661. get uid(): string;
  39662. /**
  39663. * Add an externaly attached data from its key.
  39664. * This method call will fail and return false, if such key already exists.
  39665. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39666. * @param key the unique key that identifies the data
  39667. * @param data the data object to associate to the key for this Engine instance
  39668. * @return true if no such key were already present and the data was added successfully, false otherwise
  39669. */
  39670. addExternalData<T>(key: string, data: T): boolean;
  39671. /**
  39672. * Get an externaly attached data from its key
  39673. * @param key the unique key that identifies the data
  39674. * @return the associated data, if present (can be null), or undefined if not present
  39675. */
  39676. getExternalData<T>(key: string): Nullable<T>;
  39677. /**
  39678. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39679. * @param key the unique key that identifies the data
  39680. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39681. * @return the associated data, can be null if the factory returned null.
  39682. */
  39683. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39684. /**
  39685. * Remove an externaly attached data from the Engine instance
  39686. * @param key the unique key that identifies the data
  39687. * @return true if the data was successfully removed, false if it doesn't exist
  39688. */
  39689. removeExternalData(key: string): boolean;
  39690. private _evaluateSubMesh;
  39691. /**
  39692. * Clear the processed materials smart array preventing retention point in material dispose.
  39693. */
  39694. freeProcessedMaterials(): void;
  39695. private _preventFreeActiveMeshesAndRenderingGroups;
  39696. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39697. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39698. * when disposing several meshes in a row or a hierarchy of meshes.
  39699. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39700. */
  39701. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39702. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39703. /**
  39704. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39705. */
  39706. freeActiveMeshes(): void;
  39707. /**
  39708. * Clear the info related to rendering groups preventing retention points during dispose.
  39709. */
  39710. freeRenderingGroups(): void;
  39711. /** @hidden */
  39712. _isInIntermediateRendering(): boolean;
  39713. /**
  39714. * Lambda returning the list of potentially active meshes.
  39715. */
  39716. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39717. /**
  39718. * Lambda returning the list of potentially active sub meshes.
  39719. */
  39720. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39721. /**
  39722. * Lambda returning the list of potentially intersecting sub meshes.
  39723. */
  39724. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39725. /**
  39726. * Lambda returning the list of potentially colliding sub meshes.
  39727. */
  39728. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39729. private _activeMeshesFrozen;
  39730. private _skipEvaluateActiveMeshesCompletely;
  39731. /**
  39732. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39733. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39734. * @returns the current scene
  39735. */
  39736. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39737. /**
  39738. * Use this function to restart evaluating active meshes on every frame
  39739. * @returns the current scene
  39740. */
  39741. unfreezeActiveMeshes(): Scene;
  39742. private _evaluateActiveMeshes;
  39743. private _activeMesh;
  39744. /**
  39745. * Update the transform matrix to update from the current active camera
  39746. * @param force defines a boolean used to force the update even if cache is up to date
  39747. */
  39748. updateTransformMatrix(force?: boolean): void;
  39749. private _bindFrameBuffer;
  39750. /** @hidden */
  39751. _allowPostProcessClearColor: boolean;
  39752. /** @hidden */
  39753. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39754. private _processSubCameras;
  39755. private _checkIntersections;
  39756. /** @hidden */
  39757. _advancePhysicsEngineStep(step: number): void;
  39758. /**
  39759. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39760. */
  39761. getDeterministicFrameTime: () => number;
  39762. /** @hidden */
  39763. _animate(): void;
  39764. /** Execute all animations (for a frame) */
  39765. animate(): void;
  39766. /**
  39767. * Render the scene
  39768. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39769. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39770. */
  39771. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39772. /**
  39773. * Freeze all materials
  39774. * A frozen material will not be updatable but should be faster to render
  39775. */
  39776. freezeMaterials(): void;
  39777. /**
  39778. * Unfreeze all materials
  39779. * A frozen material will not be updatable but should be faster to render
  39780. */
  39781. unfreezeMaterials(): void;
  39782. /**
  39783. * Releases all held ressources
  39784. */
  39785. dispose(): void;
  39786. /**
  39787. * Gets if the scene is already disposed
  39788. */
  39789. get isDisposed(): boolean;
  39790. /**
  39791. * Call this function to reduce memory footprint of the scene.
  39792. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39793. */
  39794. clearCachedVertexData(): void;
  39795. /**
  39796. * This function will remove the local cached buffer data from texture.
  39797. * It will save memory but will prevent the texture from being rebuilt
  39798. */
  39799. cleanCachedTextureBuffer(): void;
  39800. /**
  39801. * Get the world extend vectors with an optional filter
  39802. *
  39803. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39804. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39805. */
  39806. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39807. min: Vector3;
  39808. max: Vector3;
  39809. };
  39810. /**
  39811. * Creates a ray that can be used to pick in the scene
  39812. * @param x defines the x coordinate of the origin (on-screen)
  39813. * @param y defines the y coordinate of the origin (on-screen)
  39814. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39815. * @param camera defines the camera to use for the picking
  39816. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39817. * @returns a Ray
  39818. */
  39819. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39820. /**
  39821. * Creates a ray that can be used to pick in the scene
  39822. * @param x defines the x coordinate of the origin (on-screen)
  39823. * @param y defines the y coordinate of the origin (on-screen)
  39824. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39825. * @param result defines the ray where to store the picking ray
  39826. * @param camera defines the camera to use for the picking
  39827. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39828. * @returns the current scene
  39829. */
  39830. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39831. /**
  39832. * Creates a ray that can be used to pick in the scene
  39833. * @param x defines the x coordinate of the origin (on-screen)
  39834. * @param y defines the y coordinate of the origin (on-screen)
  39835. * @param camera defines the camera to use for the picking
  39836. * @returns a Ray
  39837. */
  39838. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39839. /**
  39840. * Creates a ray that can be used to pick in the scene
  39841. * @param x defines the x coordinate of the origin (on-screen)
  39842. * @param y defines the y coordinate of the origin (on-screen)
  39843. * @param result defines the ray where to store the picking ray
  39844. * @param camera defines the camera to use for the picking
  39845. * @returns the current scene
  39846. */
  39847. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39848. /** Launch a ray to try to pick a mesh in the scene
  39849. * @param x position on screen
  39850. * @param y position on screen
  39851. * @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
  39852. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39853. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39854. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39855. * @returns a PickingInfo
  39856. */
  39857. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39858. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39859. * @param x position on screen
  39860. * @param y position on screen
  39861. * @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
  39862. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39863. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39864. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  39865. */
  39866. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39867. /** Use the given ray to pick a mesh in the scene
  39868. * @param ray The ray to use to pick meshes
  39869. * @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
  39870. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39872. * @returns a PickingInfo
  39873. */
  39874. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39875. /**
  39876. * Launch a ray to try to pick a mesh in the scene
  39877. * @param x X position on screen
  39878. * @param y Y position on screen
  39879. * @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
  39880. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39881. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39882. * @returns an array of PickingInfo
  39883. */
  39884. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39885. /**
  39886. * Launch a ray to try to pick a mesh in the scene
  39887. * @param ray Ray to use
  39888. * @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
  39889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39890. * @returns an array of PickingInfo
  39891. */
  39892. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39893. /**
  39894. * Force the value of meshUnderPointer
  39895. * @param mesh defines the mesh to use
  39896. */
  39897. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39898. /**
  39899. * Gets the mesh under the pointer
  39900. * @returns a Mesh or null if no mesh is under the pointer
  39901. */
  39902. getPointerOverMesh(): Nullable<AbstractMesh>;
  39903. /** @hidden */
  39904. _rebuildGeometries(): void;
  39905. /** @hidden */
  39906. _rebuildTextures(): void;
  39907. private _getByTags;
  39908. /**
  39909. * Get a list of meshes by tags
  39910. * @param tagsQuery defines the tags query to use
  39911. * @param forEach defines a predicate used to filter results
  39912. * @returns an array of Mesh
  39913. */
  39914. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39915. /**
  39916. * Get a list of cameras by tags
  39917. * @param tagsQuery defines the tags query to use
  39918. * @param forEach defines a predicate used to filter results
  39919. * @returns an array of Camera
  39920. */
  39921. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39922. /**
  39923. * Get a list of lights by tags
  39924. * @param tagsQuery defines the tags query to use
  39925. * @param forEach defines a predicate used to filter results
  39926. * @returns an array of Light
  39927. */
  39928. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39929. /**
  39930. * Get a list of materials by tags
  39931. * @param tagsQuery defines the tags query to use
  39932. * @param forEach defines a predicate used to filter results
  39933. * @returns an array of Material
  39934. */
  39935. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39936. /**
  39937. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39938. * This allowed control for front to back rendering or reversly depending of the special needs.
  39939. *
  39940. * @param renderingGroupId The rendering group id corresponding to its index
  39941. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39942. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39943. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39944. */
  39945. 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;
  39946. /**
  39947. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39948. *
  39949. * @param renderingGroupId The rendering group id corresponding to its index
  39950. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39951. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39952. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39953. */
  39954. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39955. /**
  39956. * Gets the current auto clear configuration for one rendering group of the rendering
  39957. * manager.
  39958. * @param index the rendering group index to get the information for
  39959. * @returns The auto clear setup for the requested rendering group
  39960. */
  39961. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39962. private _blockMaterialDirtyMechanism;
  39963. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39964. get blockMaterialDirtyMechanism(): boolean;
  39965. set blockMaterialDirtyMechanism(value: boolean);
  39966. /**
  39967. * Will flag all materials as dirty to trigger new shader compilation
  39968. * @param flag defines the flag used to specify which material part must be marked as dirty
  39969. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39970. */
  39971. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39972. /** @hidden */
  39973. _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;
  39974. /** @hidden */
  39975. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39976. /** @hidden */
  39977. _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;
  39978. /** @hidden */
  39979. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39980. /** @hidden */
  39981. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39982. /** @hidden */
  39983. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /**
  39988. * Set of assets to keep when moving a scene into an asset container.
  39989. */
  39990. export class KeepAssets extends AbstractScene {
  39991. }
  39992. /**
  39993. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  39994. */
  39995. export class InstantiatedEntries {
  39996. /**
  39997. * List of new root nodes (eg. nodes with no parent)
  39998. */
  39999. rootNodes: TransformNode[];
  40000. /**
  40001. * List of new skeletons
  40002. */
  40003. skeletons: Skeleton[];
  40004. /**
  40005. * List of new animation groups
  40006. */
  40007. animationGroups: AnimationGroup[];
  40008. }
  40009. /**
  40010. * Container with a set of assets that can be added or removed from a scene.
  40011. */
  40012. export class AssetContainer extends AbstractScene {
  40013. private _wasAddedToScene;
  40014. /**
  40015. * The scene the AssetContainer belongs to.
  40016. */
  40017. scene: Scene;
  40018. /**
  40019. * Instantiates an AssetContainer.
  40020. * @param scene The scene the AssetContainer belongs to.
  40021. */
  40022. constructor(scene: Scene);
  40023. /**
  40024. * Instantiate or clone all meshes and add the new ones to the scene.
  40025. * Skeletons and animation groups will all be cloned
  40026. * @param nameFunction defines an optional function used to get new names for clones
  40027. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40028. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40029. */
  40030. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40031. /**
  40032. * Adds all the assets from the container to the scene.
  40033. */
  40034. addAllToScene(): void;
  40035. /**
  40036. * Removes all the assets in the container from the scene
  40037. */
  40038. removeAllFromScene(): void;
  40039. /**
  40040. * Disposes all the assets in the container
  40041. */
  40042. dispose(): void;
  40043. private _moveAssets;
  40044. /**
  40045. * Removes all the assets contained in the scene and adds them to the container.
  40046. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40047. */
  40048. moveAllFromScene(keepAssets?: KeepAssets): void;
  40049. /**
  40050. * 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.
  40051. * @returns the root mesh
  40052. */
  40053. createRootMesh(): Mesh;
  40054. /**
  40055. * Merge animations (direct and animation groups) from this asset container into a scene
  40056. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40057. * @param animatables set of animatables to retarget to a node from the scene
  40058. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40059. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40060. */
  40061. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40062. }
  40063. }
  40064. declare module BABYLON {
  40065. /**
  40066. * Defines how the parser contract is defined.
  40067. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40068. */
  40069. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40070. /**
  40071. * Defines how the individual parser contract is defined.
  40072. * These parser can parse an individual asset
  40073. */
  40074. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40075. /**
  40076. * Base class of the scene acting as a container for the different elements composing a scene.
  40077. * This class is dynamically extended by the different components of the scene increasing
  40078. * flexibility and reducing coupling
  40079. */
  40080. export abstract class AbstractScene {
  40081. /**
  40082. * Stores the list of available parsers in the application.
  40083. */
  40084. private static _BabylonFileParsers;
  40085. /**
  40086. * Stores the list of available individual parsers in the application.
  40087. */
  40088. private static _IndividualBabylonFileParsers;
  40089. /**
  40090. * Adds a parser in the list of available ones
  40091. * @param name Defines the name of the parser
  40092. * @param parser Defines the parser to add
  40093. */
  40094. static AddParser(name: string, parser: BabylonFileParser): void;
  40095. /**
  40096. * Gets a general parser from the list of avaialble ones
  40097. * @param name Defines the name of the parser
  40098. * @returns the requested parser or null
  40099. */
  40100. static GetParser(name: string): Nullable<BabylonFileParser>;
  40101. /**
  40102. * Adds n individual parser in the list of available ones
  40103. * @param name Defines the name of the parser
  40104. * @param parser Defines the parser to add
  40105. */
  40106. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40107. /**
  40108. * Gets an individual parser from the list of avaialble ones
  40109. * @param name Defines the name of the parser
  40110. * @returns the requested parser or null
  40111. */
  40112. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40113. /**
  40114. * Parser json data and populate both a scene and its associated container object
  40115. * @param jsonData Defines the data to parse
  40116. * @param scene Defines the scene to parse the data for
  40117. * @param container Defines the container attached to the parsing sequence
  40118. * @param rootUrl Defines the root url of the data
  40119. */
  40120. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40121. /**
  40122. * Gets the list of root nodes (ie. nodes with no parent)
  40123. */
  40124. rootNodes: Node[];
  40125. /** All of the cameras added to this scene
  40126. * @see http://doc.babylonjs.com/babylon101/cameras
  40127. */
  40128. cameras: Camera[];
  40129. /**
  40130. * All of the lights added to this scene
  40131. * @see http://doc.babylonjs.com/babylon101/lights
  40132. */
  40133. lights: Light[];
  40134. /**
  40135. * All of the (abstract) meshes added to this scene
  40136. */
  40137. meshes: AbstractMesh[];
  40138. /**
  40139. * The list of skeletons added to the scene
  40140. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40141. */
  40142. skeletons: Skeleton[];
  40143. /**
  40144. * All of the particle systems added to this scene
  40145. * @see http://doc.babylonjs.com/babylon101/particles
  40146. */
  40147. particleSystems: IParticleSystem[];
  40148. /**
  40149. * Gets a list of Animations associated with the scene
  40150. */
  40151. animations: Animation[];
  40152. /**
  40153. * All of the animation groups added to this scene
  40154. * @see http://doc.babylonjs.com/how_to/group
  40155. */
  40156. animationGroups: AnimationGroup[];
  40157. /**
  40158. * All of the multi-materials added to this scene
  40159. * @see http://doc.babylonjs.com/how_to/multi_materials
  40160. */
  40161. multiMaterials: MultiMaterial[];
  40162. /**
  40163. * All of the materials added to this scene
  40164. * In the context of a Scene, it is not supposed to be modified manually.
  40165. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40166. * Note also that the order of the Material within the array is not significant and might change.
  40167. * @see http://doc.babylonjs.com/babylon101/materials
  40168. */
  40169. materials: Material[];
  40170. /**
  40171. * The list of morph target managers added to the scene
  40172. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40173. */
  40174. morphTargetManagers: MorphTargetManager[];
  40175. /**
  40176. * The list of geometries used in the scene.
  40177. */
  40178. geometries: Geometry[];
  40179. /**
  40180. * All of the tranform nodes added to this scene
  40181. * In the context of a Scene, it is not supposed to be modified manually.
  40182. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40183. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40184. * @see http://doc.babylonjs.com/how_to/transformnode
  40185. */
  40186. transformNodes: TransformNode[];
  40187. /**
  40188. * ActionManagers available on the scene.
  40189. */
  40190. actionManagers: AbstractActionManager[];
  40191. /**
  40192. * Textures to keep.
  40193. */
  40194. textures: BaseTexture[];
  40195. /**
  40196. * Environment texture for the scene
  40197. */
  40198. environmentTexture: Nullable<BaseTexture>;
  40199. /**
  40200. * @returns all meshes, lights, cameras, transformNodes and bones
  40201. */
  40202. getNodes(): Array<Node>;
  40203. }
  40204. }
  40205. declare module BABYLON {
  40206. /**
  40207. * Interface used to define options for Sound class
  40208. */
  40209. export interface ISoundOptions {
  40210. /**
  40211. * Does the sound autoplay once loaded.
  40212. */
  40213. autoplay?: boolean;
  40214. /**
  40215. * Does the sound loop after it finishes playing once.
  40216. */
  40217. loop?: boolean;
  40218. /**
  40219. * Sound's volume
  40220. */
  40221. volume?: number;
  40222. /**
  40223. * Is it a spatial sound?
  40224. */
  40225. spatialSound?: boolean;
  40226. /**
  40227. * Maximum distance to hear that sound
  40228. */
  40229. maxDistance?: number;
  40230. /**
  40231. * Uses user defined attenuation function
  40232. */
  40233. useCustomAttenuation?: boolean;
  40234. /**
  40235. * Define the roll off factor of spatial sounds.
  40236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40237. */
  40238. rolloffFactor?: number;
  40239. /**
  40240. * Define the reference distance the sound should be heard perfectly.
  40241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40242. */
  40243. refDistance?: number;
  40244. /**
  40245. * Define the distance attenuation model the sound will follow.
  40246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40247. */
  40248. distanceModel?: string;
  40249. /**
  40250. * Defines the playback speed (1 by default)
  40251. */
  40252. playbackRate?: number;
  40253. /**
  40254. * Defines if the sound is from a streaming source
  40255. */
  40256. streaming?: boolean;
  40257. /**
  40258. * Defines an optional length (in seconds) inside the sound file
  40259. */
  40260. length?: number;
  40261. /**
  40262. * Defines an optional offset (in seconds) inside the sound file
  40263. */
  40264. offset?: number;
  40265. /**
  40266. * If true, URLs will not be required to state the audio file codec to use.
  40267. */
  40268. skipCodecCheck?: boolean;
  40269. }
  40270. /**
  40271. * Defines a sound that can be played in the application.
  40272. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40274. */
  40275. export class Sound {
  40276. /**
  40277. * The name of the sound in the scene.
  40278. */
  40279. name: string;
  40280. /**
  40281. * Does the sound autoplay once loaded.
  40282. */
  40283. autoplay: boolean;
  40284. /**
  40285. * Does the sound loop after it finishes playing once.
  40286. */
  40287. loop: boolean;
  40288. /**
  40289. * Does the sound use a custom attenuation curve to simulate the falloff
  40290. * happening when the source gets further away from the camera.
  40291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40292. */
  40293. useCustomAttenuation: boolean;
  40294. /**
  40295. * The sound track id this sound belongs to.
  40296. */
  40297. soundTrackId: number;
  40298. /**
  40299. * Is this sound currently played.
  40300. */
  40301. isPlaying: boolean;
  40302. /**
  40303. * Is this sound currently paused.
  40304. */
  40305. isPaused: boolean;
  40306. /**
  40307. * Does this sound enables spatial sound.
  40308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40309. */
  40310. spatialSound: boolean;
  40311. /**
  40312. * Define the reference distance the sound should be heard perfectly.
  40313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40314. */
  40315. refDistance: number;
  40316. /**
  40317. * Define the roll off factor of spatial sounds.
  40318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40319. */
  40320. rolloffFactor: number;
  40321. /**
  40322. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40324. */
  40325. maxDistance: number;
  40326. /**
  40327. * Define the distance attenuation model the sound will follow.
  40328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40329. */
  40330. distanceModel: string;
  40331. /**
  40332. * @hidden
  40333. * Back Compat
  40334. **/
  40335. onended: () => any;
  40336. /**
  40337. * Gets or sets an object used to store user defined information for the sound.
  40338. */
  40339. metadata: any;
  40340. /**
  40341. * Observable event when the current playing sound finishes.
  40342. */
  40343. onEndedObservable: Observable<Sound>;
  40344. private _panningModel;
  40345. private _playbackRate;
  40346. private _streaming;
  40347. private _startTime;
  40348. private _startOffset;
  40349. private _position;
  40350. /** @hidden */
  40351. _positionInEmitterSpace: boolean;
  40352. private _localDirection;
  40353. private _volume;
  40354. private _isReadyToPlay;
  40355. private _isDirectional;
  40356. private _readyToPlayCallback;
  40357. private _audioBuffer;
  40358. private _soundSource;
  40359. private _streamingSource;
  40360. private _soundPanner;
  40361. private _soundGain;
  40362. private _inputAudioNode;
  40363. private _outputAudioNode;
  40364. private _coneInnerAngle;
  40365. private _coneOuterAngle;
  40366. private _coneOuterGain;
  40367. private _scene;
  40368. private _connectedTransformNode;
  40369. private _customAttenuationFunction;
  40370. private _registerFunc;
  40371. private _isOutputConnected;
  40372. private _htmlAudioElement;
  40373. private _urlType;
  40374. private _length?;
  40375. private _offset?;
  40376. /** @hidden */
  40377. static _SceneComponentInitialization: (scene: Scene) => void;
  40378. /**
  40379. * Create a sound and attach it to a scene
  40380. * @param name Name of your sound
  40381. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40382. * @param scene defines the scene the sound belongs to
  40383. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40384. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40385. */
  40386. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40387. /**
  40388. * Release the sound and its associated resources
  40389. */
  40390. dispose(): void;
  40391. /**
  40392. * Gets if the sounds is ready to be played or not.
  40393. * @returns true if ready, otherwise false
  40394. */
  40395. isReady(): boolean;
  40396. private _soundLoaded;
  40397. /**
  40398. * Sets the data of the sound from an audiobuffer
  40399. * @param audioBuffer The audioBuffer containing the data
  40400. */
  40401. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40402. /**
  40403. * Updates the current sounds options such as maxdistance, loop...
  40404. * @param options A JSON object containing values named as the object properties
  40405. */
  40406. updateOptions(options: ISoundOptions): void;
  40407. private _createSpatialParameters;
  40408. private _updateSpatialParameters;
  40409. /**
  40410. * Switch the panning model to HRTF:
  40411. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40413. */
  40414. switchPanningModelToHRTF(): void;
  40415. /**
  40416. * Switch the panning model to Equal Power:
  40417. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40419. */
  40420. switchPanningModelToEqualPower(): void;
  40421. private _switchPanningModel;
  40422. /**
  40423. * Connect this sound to a sound track audio node like gain...
  40424. * @param soundTrackAudioNode the sound track audio node to connect to
  40425. */
  40426. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40427. /**
  40428. * Transform this sound into a directional source
  40429. * @param coneInnerAngle Size of the inner cone in degree
  40430. * @param coneOuterAngle Size of the outer cone in degree
  40431. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40432. */
  40433. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40434. /**
  40435. * Gets or sets the inner angle for the directional cone.
  40436. */
  40437. get directionalConeInnerAngle(): number;
  40438. /**
  40439. * Gets or sets the inner angle for the directional cone.
  40440. */
  40441. set directionalConeInnerAngle(value: number);
  40442. /**
  40443. * Gets or sets the outer angle for the directional cone.
  40444. */
  40445. get directionalConeOuterAngle(): number;
  40446. /**
  40447. * Gets or sets the outer angle for the directional cone.
  40448. */
  40449. set directionalConeOuterAngle(value: number);
  40450. /**
  40451. * Sets the position of the emitter if spatial sound is enabled
  40452. * @param newPosition Defines the new posisiton
  40453. */
  40454. setPosition(newPosition: Vector3): void;
  40455. /**
  40456. * Sets the local direction of the emitter if spatial sound is enabled
  40457. * @param newLocalDirection Defines the new local direction
  40458. */
  40459. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40460. private _updateDirection;
  40461. /** @hidden */
  40462. updateDistanceFromListener(): void;
  40463. /**
  40464. * Sets a new custom attenuation function for the sound.
  40465. * @param callback Defines the function used for the attenuation
  40466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40467. */
  40468. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40469. /**
  40470. * Play the sound
  40471. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40472. * @param offset (optional) Start the sound at a specific time in seconds
  40473. * @param length (optional) Sound duration (in seconds)
  40474. */
  40475. play(time?: number, offset?: number, length?: number): void;
  40476. private _onended;
  40477. /**
  40478. * Stop the sound
  40479. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40480. */
  40481. stop(time?: number): void;
  40482. /**
  40483. * Put the sound in pause
  40484. */
  40485. pause(): void;
  40486. /**
  40487. * Sets a dedicated volume for this sounds
  40488. * @param newVolume Define the new volume of the sound
  40489. * @param time Define time for gradual change to new volume
  40490. */
  40491. setVolume(newVolume: number, time?: number): void;
  40492. /**
  40493. * Set the sound play back rate
  40494. * @param newPlaybackRate Define the playback rate the sound should be played at
  40495. */
  40496. setPlaybackRate(newPlaybackRate: number): void;
  40497. /**
  40498. * Gets the volume of the sound.
  40499. * @returns the volume of the sound
  40500. */
  40501. getVolume(): number;
  40502. /**
  40503. * Attach the sound to a dedicated mesh
  40504. * @param transformNode The transform node to connect the sound with
  40505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40506. */
  40507. attachToMesh(transformNode: TransformNode): void;
  40508. /**
  40509. * Detach the sound from the previously attached mesh
  40510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40511. */
  40512. detachFromMesh(): void;
  40513. private _onRegisterAfterWorldMatrixUpdate;
  40514. /**
  40515. * Clone the current sound in the scene.
  40516. * @returns the new sound clone
  40517. */
  40518. clone(): Nullable<Sound>;
  40519. /**
  40520. * Gets the current underlying audio buffer containing the data
  40521. * @returns the audio buffer
  40522. */
  40523. getAudioBuffer(): Nullable<AudioBuffer>;
  40524. /**
  40525. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40526. * @returns the source node
  40527. */
  40528. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40529. /**
  40530. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40531. * @returns the gain node
  40532. */
  40533. getSoundGain(): Nullable<GainNode>;
  40534. /**
  40535. * Serializes the Sound in a JSON representation
  40536. * @returns the JSON representation of the sound
  40537. */
  40538. serialize(): any;
  40539. /**
  40540. * Parse a JSON representation of a sound to innstantiate in a given scene
  40541. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40542. * @param scene Define the scene the new parsed sound should be created in
  40543. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40544. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40545. * @returns the newly parsed sound
  40546. */
  40547. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40548. }
  40549. }
  40550. declare module BABYLON {
  40551. /**
  40552. * This defines an action helpful to play a defined sound on a triggered action.
  40553. */
  40554. export class PlaySoundAction extends Action {
  40555. private _sound;
  40556. /**
  40557. * Instantiate the action
  40558. * @param triggerOptions defines the trigger options
  40559. * @param sound defines the sound to play
  40560. * @param condition defines the trigger related conditions
  40561. */
  40562. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40563. /** @hidden */
  40564. _prepare(): void;
  40565. /**
  40566. * Execute the action and play the sound.
  40567. */
  40568. execute(): void;
  40569. /**
  40570. * Serializes the actions and its related information.
  40571. * @param parent defines the object to serialize in
  40572. * @returns the serialized object
  40573. */
  40574. serialize(parent: any): any;
  40575. }
  40576. /**
  40577. * This defines an action helpful to stop a defined sound on a triggered action.
  40578. */
  40579. export class StopSoundAction extends Action {
  40580. private _sound;
  40581. /**
  40582. * Instantiate the action
  40583. * @param triggerOptions defines the trigger options
  40584. * @param sound defines the sound to stop
  40585. * @param condition defines the trigger related conditions
  40586. */
  40587. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40588. /** @hidden */
  40589. _prepare(): void;
  40590. /**
  40591. * Execute the action and stop the sound.
  40592. */
  40593. execute(): void;
  40594. /**
  40595. * Serializes the actions and its related information.
  40596. * @param parent defines the object to serialize in
  40597. * @returns the serialized object
  40598. */
  40599. serialize(parent: any): any;
  40600. }
  40601. }
  40602. declare module BABYLON {
  40603. /**
  40604. * This defines an action responsible to change the value of a property
  40605. * by interpolating between its current value and the newly set one once triggered.
  40606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40607. */
  40608. export class InterpolateValueAction extends Action {
  40609. /**
  40610. * Defines the path of the property where the value should be interpolated
  40611. */
  40612. propertyPath: string;
  40613. /**
  40614. * Defines the target value at the end of the interpolation.
  40615. */
  40616. value: any;
  40617. /**
  40618. * Defines the time it will take for the property to interpolate to the value.
  40619. */
  40620. duration: number;
  40621. /**
  40622. * Defines if the other scene animations should be stopped when the action has been triggered
  40623. */
  40624. stopOtherAnimations?: boolean;
  40625. /**
  40626. * Defines a callback raised once the interpolation animation has been done.
  40627. */
  40628. onInterpolationDone?: () => void;
  40629. /**
  40630. * Observable triggered once the interpolation animation has been done.
  40631. */
  40632. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40633. private _target;
  40634. private _effectiveTarget;
  40635. private _property;
  40636. /**
  40637. * Instantiate the action
  40638. * @param triggerOptions defines the trigger options
  40639. * @param target defines the object containing the value to interpolate
  40640. * @param propertyPath defines the path to the property in the target object
  40641. * @param value defines the target value at the end of the interpolation
  40642. * @param duration deines the time it will take for the property to interpolate to the value.
  40643. * @param condition defines the trigger related conditions
  40644. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40645. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40646. */
  40647. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40648. /** @hidden */
  40649. _prepare(): void;
  40650. /**
  40651. * Execute the action starts the value interpolation.
  40652. */
  40653. execute(): void;
  40654. /**
  40655. * Serializes the actions and its related information.
  40656. * @param parent defines the object to serialize in
  40657. * @returns the serialized object
  40658. */
  40659. serialize(parent: any): any;
  40660. }
  40661. }
  40662. declare module BABYLON {
  40663. /**
  40664. * Options allowed during the creation of a sound track.
  40665. */
  40666. export interface ISoundTrackOptions {
  40667. /**
  40668. * The volume the sound track should take during creation
  40669. */
  40670. volume?: number;
  40671. /**
  40672. * Define if the sound track is the main sound track of the scene
  40673. */
  40674. mainTrack?: boolean;
  40675. }
  40676. /**
  40677. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40678. * It will be also used in a future release to apply effects on a specific track.
  40679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40680. */
  40681. export class SoundTrack {
  40682. /**
  40683. * The unique identifier of the sound track in the scene.
  40684. */
  40685. id: number;
  40686. /**
  40687. * The list of sounds included in the sound track.
  40688. */
  40689. soundCollection: Array<Sound>;
  40690. private _outputAudioNode;
  40691. private _scene;
  40692. private _connectedAnalyser;
  40693. private _options;
  40694. private _isInitialized;
  40695. /**
  40696. * Creates a new sound track.
  40697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40698. * @param scene Define the scene the sound track belongs to
  40699. * @param options
  40700. */
  40701. constructor(scene: Scene, options?: ISoundTrackOptions);
  40702. private _initializeSoundTrackAudioGraph;
  40703. /**
  40704. * Release the sound track and its associated resources
  40705. */
  40706. dispose(): void;
  40707. /**
  40708. * Adds a sound to this sound track
  40709. * @param sound define the cound to add
  40710. * @ignoreNaming
  40711. */
  40712. AddSound(sound: Sound): void;
  40713. /**
  40714. * Removes a sound to this sound track
  40715. * @param sound define the cound to remove
  40716. * @ignoreNaming
  40717. */
  40718. RemoveSound(sound: Sound): void;
  40719. /**
  40720. * Set a global volume for the full sound track.
  40721. * @param newVolume Define the new volume of the sound track
  40722. */
  40723. setVolume(newVolume: number): void;
  40724. /**
  40725. * Switch the panning model to HRTF:
  40726. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40728. */
  40729. switchPanningModelToHRTF(): void;
  40730. /**
  40731. * Switch the panning model to Equal Power:
  40732. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40734. */
  40735. switchPanningModelToEqualPower(): void;
  40736. /**
  40737. * Connect the sound track to an audio analyser allowing some amazing
  40738. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40740. * @param analyser The analyser to connect to the engine
  40741. */
  40742. connectToAnalyser(analyser: Analyser): void;
  40743. }
  40744. }
  40745. declare module BABYLON {
  40746. interface AbstractScene {
  40747. /**
  40748. * The list of sounds used in the scene.
  40749. */
  40750. sounds: Nullable<Array<Sound>>;
  40751. }
  40752. interface Scene {
  40753. /**
  40754. * @hidden
  40755. * Backing field
  40756. */
  40757. _mainSoundTrack: SoundTrack;
  40758. /**
  40759. * The main sound track played by the scene.
  40760. * It cotains your primary collection of sounds.
  40761. */
  40762. mainSoundTrack: SoundTrack;
  40763. /**
  40764. * The list of sound tracks added to the scene
  40765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40766. */
  40767. soundTracks: Nullable<Array<SoundTrack>>;
  40768. /**
  40769. * Gets a sound using a given name
  40770. * @param name defines the name to search for
  40771. * @return the found sound or null if not found at all.
  40772. */
  40773. getSoundByName(name: string): Nullable<Sound>;
  40774. /**
  40775. * Gets or sets if audio support is enabled
  40776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40777. */
  40778. audioEnabled: boolean;
  40779. /**
  40780. * Gets or sets if audio will be output to headphones
  40781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40782. */
  40783. headphone: boolean;
  40784. /**
  40785. * Gets or sets custom audio listener position provider
  40786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40787. */
  40788. audioListenerPositionProvider: Nullable<() => Vector3>;
  40789. /**
  40790. * Gets or sets a refresh rate when using 3D audio positioning
  40791. */
  40792. audioPositioningRefreshRate: number;
  40793. }
  40794. /**
  40795. * Defines the sound scene component responsible to manage any sounds
  40796. * in a given scene.
  40797. */
  40798. export class AudioSceneComponent implements ISceneSerializableComponent {
  40799. /**
  40800. * The component name helpfull to identify the component in the list of scene components.
  40801. */
  40802. readonly name: string;
  40803. /**
  40804. * The scene the component belongs to.
  40805. */
  40806. scene: Scene;
  40807. private _audioEnabled;
  40808. /**
  40809. * Gets whether audio is enabled or not.
  40810. * Please use related enable/disable method to switch state.
  40811. */
  40812. get audioEnabled(): boolean;
  40813. private _headphone;
  40814. /**
  40815. * Gets whether audio is outputing to headphone or not.
  40816. * Please use the according Switch methods to change output.
  40817. */
  40818. get headphone(): boolean;
  40819. /**
  40820. * Gets or sets a refresh rate when using 3D audio positioning
  40821. */
  40822. audioPositioningRefreshRate: number;
  40823. private _audioListenerPositionProvider;
  40824. /**
  40825. * Gets the current audio listener position provider
  40826. */
  40827. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40828. /**
  40829. * Sets a custom listener position for all sounds in the scene
  40830. * By default, this is the position of the first active camera
  40831. */
  40832. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40833. /**
  40834. * Creates a new instance of the component for the given scene
  40835. * @param scene Defines the scene to register the component in
  40836. */
  40837. constructor(scene: Scene);
  40838. /**
  40839. * Registers the component in a given scene
  40840. */
  40841. register(): void;
  40842. /**
  40843. * Rebuilds the elements related to this component in case of
  40844. * context lost for instance.
  40845. */
  40846. rebuild(): void;
  40847. /**
  40848. * Serializes the component data to the specified json object
  40849. * @param serializationObject The object to serialize to
  40850. */
  40851. serialize(serializationObject: any): void;
  40852. /**
  40853. * Adds all the elements from the container to the scene
  40854. * @param container the container holding the elements
  40855. */
  40856. addFromContainer(container: AbstractScene): void;
  40857. /**
  40858. * Removes all the elements in the container from the scene
  40859. * @param container contains the elements to remove
  40860. * @param dispose if the removed element should be disposed (default: false)
  40861. */
  40862. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40863. /**
  40864. * Disposes the component and the associated ressources.
  40865. */
  40866. dispose(): void;
  40867. /**
  40868. * Disables audio in the associated scene.
  40869. */
  40870. disableAudio(): void;
  40871. /**
  40872. * Enables audio in the associated scene.
  40873. */
  40874. enableAudio(): void;
  40875. /**
  40876. * Switch audio to headphone output.
  40877. */
  40878. switchAudioModeForHeadphones(): void;
  40879. /**
  40880. * Switch audio to normal speakers.
  40881. */
  40882. switchAudioModeForNormalSpeakers(): void;
  40883. private _cachedCameraDirection;
  40884. private _cachedCameraPosition;
  40885. private _lastCheck;
  40886. private _afterRender;
  40887. }
  40888. }
  40889. declare module BABYLON {
  40890. /**
  40891. * Wraps one or more Sound objects and selects one with random weight for playback.
  40892. */
  40893. export class WeightedSound {
  40894. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40895. loop: boolean;
  40896. private _coneInnerAngle;
  40897. private _coneOuterAngle;
  40898. private _volume;
  40899. /** A Sound is currently playing. */
  40900. isPlaying: boolean;
  40901. /** A Sound is currently paused. */
  40902. isPaused: boolean;
  40903. private _sounds;
  40904. private _weights;
  40905. private _currentIndex?;
  40906. /**
  40907. * Creates a new WeightedSound from the list of sounds given.
  40908. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40909. * @param sounds Array of Sounds that will be selected from.
  40910. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40911. */
  40912. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40913. /**
  40914. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40915. */
  40916. get directionalConeInnerAngle(): number;
  40917. /**
  40918. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40919. */
  40920. set directionalConeInnerAngle(value: number);
  40921. /**
  40922. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40923. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40924. */
  40925. get directionalConeOuterAngle(): number;
  40926. /**
  40927. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40928. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40929. */
  40930. set directionalConeOuterAngle(value: number);
  40931. /**
  40932. * Playback volume.
  40933. */
  40934. get volume(): number;
  40935. /**
  40936. * Playback volume.
  40937. */
  40938. set volume(value: number);
  40939. private _onended;
  40940. /**
  40941. * Suspend playback
  40942. */
  40943. pause(): void;
  40944. /**
  40945. * Stop playback
  40946. */
  40947. stop(): void;
  40948. /**
  40949. * Start playback.
  40950. * @param startOffset Position the clip head at a specific time in seconds.
  40951. */
  40952. play(startOffset?: number): void;
  40953. }
  40954. }
  40955. declare module BABYLON {
  40956. /**
  40957. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40958. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40959. */
  40960. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40961. /**
  40962. * Gets the name of the behavior.
  40963. */
  40964. get name(): string;
  40965. /**
  40966. * The easing function used by animations
  40967. */
  40968. static EasingFunction: BackEase;
  40969. /**
  40970. * The easing mode used by animations
  40971. */
  40972. static EasingMode: number;
  40973. /**
  40974. * The duration of the animation, in milliseconds
  40975. */
  40976. transitionDuration: number;
  40977. /**
  40978. * Length of the distance animated by the transition when lower radius is reached
  40979. */
  40980. lowerRadiusTransitionRange: number;
  40981. /**
  40982. * Length of the distance animated by the transition when upper radius is reached
  40983. */
  40984. upperRadiusTransitionRange: number;
  40985. private _autoTransitionRange;
  40986. /**
  40987. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40988. */
  40989. get autoTransitionRange(): boolean;
  40990. /**
  40991. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40992. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40993. */
  40994. set autoTransitionRange(value: boolean);
  40995. private _attachedCamera;
  40996. private _onAfterCheckInputsObserver;
  40997. private _onMeshTargetChangedObserver;
  40998. /**
  40999. * Initializes the behavior.
  41000. */
  41001. init(): void;
  41002. /**
  41003. * Attaches the behavior to its arc rotate camera.
  41004. * @param camera Defines the camera to attach the behavior to
  41005. */
  41006. attach(camera: ArcRotateCamera): void;
  41007. /**
  41008. * Detaches the behavior from its current arc rotate camera.
  41009. */
  41010. detach(): void;
  41011. private _radiusIsAnimating;
  41012. private _radiusBounceTransition;
  41013. private _animatables;
  41014. private _cachedWheelPrecision;
  41015. /**
  41016. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41017. * @param radiusLimit The limit to check against.
  41018. * @return Bool to indicate if at limit.
  41019. */
  41020. private _isRadiusAtLimit;
  41021. /**
  41022. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41023. * @param radiusDelta The delta by which to animate to. Can be negative.
  41024. */
  41025. private _applyBoundRadiusAnimation;
  41026. /**
  41027. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41028. */
  41029. protected _clearAnimationLocks(): void;
  41030. /**
  41031. * Stops and removes all animations that have been applied to the camera
  41032. */
  41033. stopAllAnimations(): void;
  41034. }
  41035. }
  41036. declare module BABYLON {
  41037. /**
  41038. * 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.
  41039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41040. */
  41041. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41042. /**
  41043. * Gets the name of the behavior.
  41044. */
  41045. get name(): string;
  41046. private _mode;
  41047. private _radiusScale;
  41048. private _positionScale;
  41049. private _defaultElevation;
  41050. private _elevationReturnTime;
  41051. private _elevationReturnWaitTime;
  41052. private _zoomStopsAnimation;
  41053. private _framingTime;
  41054. /**
  41055. * The easing function used by animations
  41056. */
  41057. static EasingFunction: ExponentialEase;
  41058. /**
  41059. * The easing mode used by animations
  41060. */
  41061. static EasingMode: number;
  41062. /**
  41063. * Sets the current mode used by the behavior
  41064. */
  41065. set mode(mode: number);
  41066. /**
  41067. * Gets current mode used by the behavior.
  41068. */
  41069. get mode(): number;
  41070. /**
  41071. * Sets the scale applied to the radius (1 by default)
  41072. */
  41073. set radiusScale(radius: number);
  41074. /**
  41075. * Gets the scale applied to the radius
  41076. */
  41077. get radiusScale(): number;
  41078. /**
  41079. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41080. */
  41081. set positionScale(scale: number);
  41082. /**
  41083. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41084. */
  41085. get positionScale(): number;
  41086. /**
  41087. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41088. * behaviour is triggered, in radians.
  41089. */
  41090. set defaultElevation(elevation: number);
  41091. /**
  41092. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41093. * behaviour is triggered, in radians.
  41094. */
  41095. get defaultElevation(): number;
  41096. /**
  41097. * Sets the time (in milliseconds) taken to return to the default beta position.
  41098. * Negative value indicates camera should not return to default.
  41099. */
  41100. set elevationReturnTime(speed: number);
  41101. /**
  41102. * Gets the time (in milliseconds) taken to return to the default beta position.
  41103. * Negative value indicates camera should not return to default.
  41104. */
  41105. get elevationReturnTime(): number;
  41106. /**
  41107. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41108. */
  41109. set elevationReturnWaitTime(time: number);
  41110. /**
  41111. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41112. */
  41113. get elevationReturnWaitTime(): number;
  41114. /**
  41115. * Sets the flag that indicates if user zooming should stop animation.
  41116. */
  41117. set zoomStopsAnimation(flag: boolean);
  41118. /**
  41119. * Gets the flag that indicates if user zooming should stop animation.
  41120. */
  41121. get zoomStopsAnimation(): boolean;
  41122. /**
  41123. * Sets the transition time when framing the mesh, in milliseconds
  41124. */
  41125. set framingTime(time: number);
  41126. /**
  41127. * Gets the transition time when framing the mesh, in milliseconds
  41128. */
  41129. get framingTime(): number;
  41130. /**
  41131. * Define if the behavior should automatically change the configured
  41132. * camera limits and sensibilities.
  41133. */
  41134. autoCorrectCameraLimitsAndSensibility: boolean;
  41135. private _onPrePointerObservableObserver;
  41136. private _onAfterCheckInputsObserver;
  41137. private _onMeshTargetChangedObserver;
  41138. private _attachedCamera;
  41139. private _isPointerDown;
  41140. private _lastInteractionTime;
  41141. /**
  41142. * Initializes the behavior.
  41143. */
  41144. init(): void;
  41145. /**
  41146. * Attaches the behavior to its arc rotate camera.
  41147. * @param camera Defines the camera to attach the behavior to
  41148. */
  41149. attach(camera: ArcRotateCamera): void;
  41150. /**
  41151. * Detaches the behavior from its current arc rotate camera.
  41152. */
  41153. detach(): void;
  41154. private _animatables;
  41155. private _betaIsAnimating;
  41156. private _betaTransition;
  41157. private _radiusTransition;
  41158. private _vectorTransition;
  41159. /**
  41160. * Targets the given mesh and updates zoom level accordingly.
  41161. * @param mesh The mesh to target.
  41162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41164. */
  41165. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41166. /**
  41167. * Targets the given mesh with its children and updates zoom level accordingly.
  41168. * @param mesh The mesh to target.
  41169. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41170. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41171. */
  41172. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41173. /**
  41174. * Targets the given meshes with their children and updates zoom level accordingly.
  41175. * @param meshes The mesh to target.
  41176. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41177. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41178. */
  41179. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41180. /**
  41181. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41182. * @param minimumWorld Determines the smaller position of the bounding box extend
  41183. * @param maximumWorld Determines the bigger position of the bounding box extend
  41184. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41185. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41186. */
  41187. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41188. /**
  41189. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41190. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41191. * frustum width.
  41192. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41193. * to fully enclose the mesh in the viewing frustum.
  41194. */
  41195. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41196. /**
  41197. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41198. * is automatically returned to its default position (expected to be above ground plane).
  41199. */
  41200. private _maintainCameraAboveGround;
  41201. /**
  41202. * Returns the frustum slope based on the canvas ratio and camera FOV
  41203. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41204. */
  41205. private _getFrustumSlope;
  41206. /**
  41207. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41208. */
  41209. private _clearAnimationLocks;
  41210. /**
  41211. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41212. */
  41213. private _applyUserInteraction;
  41214. /**
  41215. * Stops and removes all animations that have been applied to the camera
  41216. */
  41217. stopAllAnimations(): void;
  41218. /**
  41219. * Gets a value indicating if the user is moving the camera
  41220. */
  41221. get isUserIsMoving(): boolean;
  41222. /**
  41223. * The camera can move all the way towards the mesh.
  41224. */
  41225. static IgnoreBoundsSizeMode: number;
  41226. /**
  41227. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41228. */
  41229. static FitFrustumSidesMode: number;
  41230. }
  41231. }
  41232. declare module BABYLON {
  41233. /**
  41234. * Base class for Camera Pointer Inputs.
  41235. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41236. * for example usage.
  41237. */
  41238. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41239. /**
  41240. * Defines the camera the input is attached to.
  41241. */
  41242. abstract camera: Camera;
  41243. /**
  41244. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41245. */
  41246. protected _altKey: boolean;
  41247. protected _ctrlKey: boolean;
  41248. protected _metaKey: boolean;
  41249. protected _shiftKey: boolean;
  41250. /**
  41251. * Which mouse buttons were pressed at time of last mouse event.
  41252. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41253. */
  41254. protected _buttonsPressed: number;
  41255. /**
  41256. * Defines the buttons associated with the input to handle camera move.
  41257. */
  41258. buttons: number[];
  41259. /**
  41260. * Attach the input controls to a specific dom element to get the input from.
  41261. * @param element Defines the element the controls should be listened from
  41262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41263. */
  41264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41265. /**
  41266. * Detach the current controls from the specified dom element.
  41267. * @param element Defines the element to stop listening the inputs from
  41268. */
  41269. detachControl(element: Nullable<HTMLElement>): void;
  41270. /**
  41271. * Gets the class name of the current input.
  41272. * @returns the class name
  41273. */
  41274. getClassName(): string;
  41275. /**
  41276. * Get the friendly name associated with the input class.
  41277. * @returns the input friendly name
  41278. */
  41279. getSimpleName(): string;
  41280. /**
  41281. * Called on pointer POINTERDOUBLETAP event.
  41282. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41283. */
  41284. protected onDoubleTap(type: string): void;
  41285. /**
  41286. * Called on pointer POINTERMOVE event if only a single touch is active.
  41287. * Override this method to provide functionality.
  41288. */
  41289. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41290. /**
  41291. * Called on pointer POINTERMOVE event if multiple touches are active.
  41292. * Override this method to provide functionality.
  41293. */
  41294. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41295. /**
  41296. * Called on JS contextmenu event.
  41297. * Override this method to provide functionality.
  41298. */
  41299. protected onContextMenu(evt: PointerEvent): void;
  41300. /**
  41301. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41302. * press.
  41303. * Override this method to provide functionality.
  41304. */
  41305. protected onButtonDown(evt: PointerEvent): void;
  41306. /**
  41307. * Called each time a new POINTERUP event occurs. Ie, for each button
  41308. * release.
  41309. * Override this method to provide functionality.
  41310. */
  41311. protected onButtonUp(evt: PointerEvent): void;
  41312. /**
  41313. * Called when window becomes inactive.
  41314. * Override this method to provide functionality.
  41315. */
  41316. protected onLostFocus(): void;
  41317. private _pointerInput;
  41318. private _observer;
  41319. private _onLostFocus;
  41320. private pointA;
  41321. private pointB;
  41322. }
  41323. }
  41324. declare module BABYLON {
  41325. /**
  41326. * Manage the pointers inputs to control an arc rotate camera.
  41327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41328. */
  41329. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41330. /**
  41331. * Defines the camera the input is attached to.
  41332. */
  41333. camera: ArcRotateCamera;
  41334. /**
  41335. * Gets the class name of the current input.
  41336. * @returns the class name
  41337. */
  41338. getClassName(): string;
  41339. /**
  41340. * Defines the buttons associated with the input to handle camera move.
  41341. */
  41342. buttons: number[];
  41343. /**
  41344. * Defines the pointer angular sensibility along the X axis or how fast is
  41345. * the camera rotating.
  41346. */
  41347. angularSensibilityX: number;
  41348. /**
  41349. * Defines the pointer angular sensibility along the Y axis or how fast is
  41350. * the camera rotating.
  41351. */
  41352. angularSensibilityY: number;
  41353. /**
  41354. * Defines the pointer pinch precision or how fast is the camera zooming.
  41355. */
  41356. pinchPrecision: number;
  41357. /**
  41358. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41359. * from 0.
  41360. * It defines the percentage of current camera.radius to use as delta when
  41361. * pinch zoom is used.
  41362. */
  41363. pinchDeltaPercentage: number;
  41364. /**
  41365. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41366. * that any object in the plane at the camera's target point will scale
  41367. * perfectly with finger motion.
  41368. * Overrides pinchDeltaPercentage and pinchPrecision.
  41369. */
  41370. useNaturalPinchZoom: boolean;
  41371. /**
  41372. * Defines the pointer panning sensibility or how fast is the camera moving.
  41373. */
  41374. panningSensibility: number;
  41375. /**
  41376. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41377. */
  41378. multiTouchPanning: boolean;
  41379. /**
  41380. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41381. * zoom (pinch) through multitouch.
  41382. */
  41383. multiTouchPanAndZoom: boolean;
  41384. /**
  41385. * Revers pinch action direction.
  41386. */
  41387. pinchInwards: boolean;
  41388. private _isPanClick;
  41389. private _twoFingerActivityCount;
  41390. private _isPinching;
  41391. /**
  41392. * Called on pointer POINTERMOVE event if only a single touch is active.
  41393. */
  41394. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41395. /**
  41396. * Called on pointer POINTERDOUBLETAP event.
  41397. */
  41398. protected onDoubleTap(type: string): void;
  41399. /**
  41400. * Called on pointer POINTERMOVE event if multiple touches are active.
  41401. */
  41402. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41403. /**
  41404. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41405. * press.
  41406. */
  41407. protected onButtonDown(evt: PointerEvent): void;
  41408. /**
  41409. * Called each time a new POINTERUP event occurs. Ie, for each button
  41410. * release.
  41411. */
  41412. protected onButtonUp(evt: PointerEvent): void;
  41413. /**
  41414. * Called when window becomes inactive.
  41415. */
  41416. protected onLostFocus(): void;
  41417. }
  41418. }
  41419. declare module BABYLON {
  41420. /**
  41421. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41423. */
  41424. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41425. /**
  41426. * Defines the camera the input is attached to.
  41427. */
  41428. camera: ArcRotateCamera;
  41429. /**
  41430. * Defines the list of key codes associated with the up action (increase alpha)
  41431. */
  41432. keysUp: number[];
  41433. /**
  41434. * Defines the list of key codes associated with the down action (decrease alpha)
  41435. */
  41436. keysDown: number[];
  41437. /**
  41438. * Defines the list of key codes associated with the left action (increase beta)
  41439. */
  41440. keysLeft: number[];
  41441. /**
  41442. * Defines the list of key codes associated with the right action (decrease beta)
  41443. */
  41444. keysRight: number[];
  41445. /**
  41446. * Defines the list of key codes associated with the reset action.
  41447. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41448. */
  41449. keysReset: number[];
  41450. /**
  41451. * Defines the panning sensibility of the inputs.
  41452. * (How fast is the camera panning)
  41453. */
  41454. panningSensibility: number;
  41455. /**
  41456. * Defines the zooming sensibility of the inputs.
  41457. * (How fast is the camera zooming)
  41458. */
  41459. zoomingSensibility: number;
  41460. /**
  41461. * Defines whether maintaining the alt key down switch the movement mode from
  41462. * orientation to zoom.
  41463. */
  41464. useAltToZoom: boolean;
  41465. /**
  41466. * Rotation speed of the camera
  41467. */
  41468. angularSpeed: number;
  41469. private _keys;
  41470. private _ctrlPressed;
  41471. private _altPressed;
  41472. private _onCanvasBlurObserver;
  41473. private _onKeyboardObserver;
  41474. private _engine;
  41475. private _scene;
  41476. /**
  41477. * Attach the input controls to a specific dom element to get the input from.
  41478. * @param element Defines the element the controls should be listened from
  41479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41480. */
  41481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41482. /**
  41483. * Detach the current controls from the specified dom element.
  41484. * @param element Defines the element to stop listening the inputs from
  41485. */
  41486. detachControl(element: Nullable<HTMLElement>): void;
  41487. /**
  41488. * Update the current camera state depending on the inputs that have been used this frame.
  41489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41490. */
  41491. checkInputs(): void;
  41492. /**
  41493. * Gets the class name of the current intput.
  41494. * @returns the class name
  41495. */
  41496. getClassName(): string;
  41497. /**
  41498. * Get the friendly name associated with the input class.
  41499. * @returns the input friendly name
  41500. */
  41501. getSimpleName(): string;
  41502. }
  41503. }
  41504. declare module BABYLON {
  41505. /**
  41506. * Manage the mouse wheel inputs to control an arc rotate camera.
  41507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41508. */
  41509. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41510. /**
  41511. * Defines the camera the input is attached to.
  41512. */
  41513. camera: ArcRotateCamera;
  41514. /**
  41515. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41516. */
  41517. wheelPrecision: number;
  41518. /**
  41519. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41520. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41521. */
  41522. wheelDeltaPercentage: number;
  41523. private _wheel;
  41524. private _observer;
  41525. private computeDeltaFromMouseWheelLegacyEvent;
  41526. /**
  41527. * Attach the input controls to a specific dom element to get the input from.
  41528. * @param element Defines the element the controls should be listened from
  41529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41530. */
  41531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41532. /**
  41533. * Detach the current controls from the specified dom element.
  41534. * @param element Defines the element to stop listening the inputs from
  41535. */
  41536. detachControl(element: Nullable<HTMLElement>): void;
  41537. /**
  41538. * Gets the class name of the current intput.
  41539. * @returns the class name
  41540. */
  41541. getClassName(): string;
  41542. /**
  41543. * Get the friendly name associated with the input class.
  41544. * @returns the input friendly name
  41545. */
  41546. getSimpleName(): string;
  41547. }
  41548. }
  41549. declare module BABYLON {
  41550. /**
  41551. * Default Inputs manager for the ArcRotateCamera.
  41552. * It groups all the default supported inputs for ease of use.
  41553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41554. */
  41555. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41556. /**
  41557. * Instantiates a new ArcRotateCameraInputsManager.
  41558. * @param camera Defines the camera the inputs belong to
  41559. */
  41560. constructor(camera: ArcRotateCamera);
  41561. /**
  41562. * Add mouse wheel input support to the input manager.
  41563. * @returns the current input manager
  41564. */
  41565. addMouseWheel(): ArcRotateCameraInputsManager;
  41566. /**
  41567. * Add pointers input support to the input manager.
  41568. * @returns the current input manager
  41569. */
  41570. addPointers(): ArcRotateCameraInputsManager;
  41571. /**
  41572. * Add keyboard input support to the input manager.
  41573. * @returns the current input manager
  41574. */
  41575. addKeyboard(): ArcRotateCameraInputsManager;
  41576. }
  41577. }
  41578. declare module BABYLON {
  41579. /**
  41580. * This represents an orbital type of camera.
  41581. *
  41582. * 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.
  41583. * 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.
  41584. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41585. */
  41586. export class ArcRotateCamera extends TargetCamera {
  41587. /**
  41588. * Defines the rotation angle of the camera along the longitudinal axis.
  41589. */
  41590. alpha: number;
  41591. /**
  41592. * Defines the rotation angle of the camera along the latitudinal axis.
  41593. */
  41594. beta: number;
  41595. /**
  41596. * Defines the radius of the camera from it s target point.
  41597. */
  41598. radius: number;
  41599. protected _target: Vector3;
  41600. protected _targetHost: Nullable<AbstractMesh>;
  41601. /**
  41602. * Defines the target point of the camera.
  41603. * The camera looks towards it form the radius distance.
  41604. */
  41605. get target(): Vector3;
  41606. set target(value: Vector3);
  41607. /**
  41608. * Define the current local position of the camera in the scene
  41609. */
  41610. get position(): Vector3;
  41611. set position(newPosition: Vector3);
  41612. protected _upVector: Vector3;
  41613. protected _upToYMatrix: Matrix;
  41614. protected _YToUpMatrix: Matrix;
  41615. /**
  41616. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41617. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41618. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41619. */
  41620. set upVector(vec: Vector3);
  41621. get upVector(): Vector3;
  41622. /**
  41623. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41624. */
  41625. setMatUp(): void;
  41626. /**
  41627. * Current inertia value on the longitudinal axis.
  41628. * The bigger this number the longer it will take for the camera to stop.
  41629. */
  41630. inertialAlphaOffset: number;
  41631. /**
  41632. * Current inertia value on the latitudinal axis.
  41633. * The bigger this number the longer it will take for the camera to stop.
  41634. */
  41635. inertialBetaOffset: number;
  41636. /**
  41637. * Current inertia value on the radius axis.
  41638. * The bigger this number the longer it will take for the camera to stop.
  41639. */
  41640. inertialRadiusOffset: number;
  41641. /**
  41642. * Minimum allowed angle on the longitudinal axis.
  41643. * This can help limiting how the Camera is able to move in the scene.
  41644. */
  41645. lowerAlphaLimit: Nullable<number>;
  41646. /**
  41647. * Maximum allowed angle on the longitudinal axis.
  41648. * This can help limiting how the Camera is able to move in the scene.
  41649. */
  41650. upperAlphaLimit: Nullable<number>;
  41651. /**
  41652. * Minimum allowed angle on the latitudinal axis.
  41653. * This can help limiting how the Camera is able to move in the scene.
  41654. */
  41655. lowerBetaLimit: number;
  41656. /**
  41657. * Maximum allowed angle on the latitudinal axis.
  41658. * This can help limiting how the Camera is able to move in the scene.
  41659. */
  41660. upperBetaLimit: number;
  41661. /**
  41662. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41663. * This can help limiting how the Camera is able to move in the scene.
  41664. */
  41665. lowerRadiusLimit: Nullable<number>;
  41666. /**
  41667. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41668. * This can help limiting how the Camera is able to move in the scene.
  41669. */
  41670. upperRadiusLimit: Nullable<number>;
  41671. /**
  41672. * Defines the current inertia value used during panning of the camera along the X axis.
  41673. */
  41674. inertialPanningX: number;
  41675. /**
  41676. * Defines the current inertia value used during panning of the camera along the Y axis.
  41677. */
  41678. inertialPanningY: number;
  41679. /**
  41680. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41681. * Basically if your fingers moves away from more than this distance you will be considered
  41682. * in pinch mode.
  41683. */
  41684. pinchToPanMaxDistance: number;
  41685. /**
  41686. * Defines the maximum distance the camera can pan.
  41687. * This could help keeping the cammera always in your scene.
  41688. */
  41689. panningDistanceLimit: Nullable<number>;
  41690. /**
  41691. * Defines the target of the camera before paning.
  41692. */
  41693. panningOriginTarget: Vector3;
  41694. /**
  41695. * Defines the value of the inertia used during panning.
  41696. * 0 would mean stop inertia and one would mean no decelleration at all.
  41697. */
  41698. panningInertia: number;
  41699. /**
  41700. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41701. */
  41702. get angularSensibilityX(): number;
  41703. set angularSensibilityX(value: number);
  41704. /**
  41705. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41706. */
  41707. get angularSensibilityY(): number;
  41708. set angularSensibilityY(value: number);
  41709. /**
  41710. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41711. */
  41712. get pinchPrecision(): number;
  41713. set pinchPrecision(value: number);
  41714. /**
  41715. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41716. * It will be used instead of pinchDeltaPrecision if different from 0.
  41717. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41718. */
  41719. get pinchDeltaPercentage(): number;
  41720. set pinchDeltaPercentage(value: number);
  41721. /**
  41722. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41723. * and pinch delta percentage.
  41724. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41725. * that any object in the plane at the camera's target point will scale
  41726. * perfectly with finger motion.
  41727. */
  41728. get useNaturalPinchZoom(): boolean;
  41729. set useNaturalPinchZoom(value: boolean);
  41730. /**
  41731. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41732. */
  41733. get panningSensibility(): number;
  41734. set panningSensibility(value: number);
  41735. /**
  41736. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41737. */
  41738. get keysUp(): number[];
  41739. set keysUp(value: number[]);
  41740. /**
  41741. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41742. */
  41743. get keysDown(): number[];
  41744. set keysDown(value: number[]);
  41745. /**
  41746. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41747. */
  41748. get keysLeft(): number[];
  41749. set keysLeft(value: number[]);
  41750. /**
  41751. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41752. */
  41753. get keysRight(): number[];
  41754. set keysRight(value: number[]);
  41755. /**
  41756. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41757. */
  41758. get wheelPrecision(): number;
  41759. set wheelPrecision(value: number);
  41760. /**
  41761. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41762. * It will be used instead of pinchDeltaPrecision if different from 0.
  41763. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41764. */
  41765. get wheelDeltaPercentage(): number;
  41766. set wheelDeltaPercentage(value: number);
  41767. /**
  41768. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41769. */
  41770. zoomOnFactor: number;
  41771. /**
  41772. * Defines a screen offset for the camera position.
  41773. */
  41774. targetScreenOffset: Vector2;
  41775. /**
  41776. * Allows the camera to be completely reversed.
  41777. * If false the camera can not arrive upside down.
  41778. */
  41779. allowUpsideDown: boolean;
  41780. /**
  41781. * Define if double tap/click is used to restore the previously saved state of the camera.
  41782. */
  41783. useInputToRestoreState: boolean;
  41784. /** @hidden */
  41785. _viewMatrix: Matrix;
  41786. /** @hidden */
  41787. _useCtrlForPanning: boolean;
  41788. /** @hidden */
  41789. _panningMouseButton: number;
  41790. /**
  41791. * Defines the input associated to the camera.
  41792. */
  41793. inputs: ArcRotateCameraInputsManager;
  41794. /** @hidden */
  41795. _reset: () => void;
  41796. /**
  41797. * Defines the allowed panning axis.
  41798. */
  41799. panningAxis: Vector3;
  41800. protected _localDirection: Vector3;
  41801. protected _transformedDirection: Vector3;
  41802. private _bouncingBehavior;
  41803. /**
  41804. * Gets the bouncing behavior of the camera if it has been enabled.
  41805. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41806. */
  41807. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41808. /**
  41809. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41810. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41811. */
  41812. get useBouncingBehavior(): boolean;
  41813. set useBouncingBehavior(value: boolean);
  41814. private _framingBehavior;
  41815. /**
  41816. * Gets the framing behavior of the camera if it has been enabled.
  41817. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41818. */
  41819. get framingBehavior(): Nullable<FramingBehavior>;
  41820. /**
  41821. * Defines if the framing behavior of the camera is enabled on the camera.
  41822. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41823. */
  41824. get useFramingBehavior(): boolean;
  41825. set useFramingBehavior(value: boolean);
  41826. private _autoRotationBehavior;
  41827. /**
  41828. * Gets the auto rotation behavior of the camera if it has been enabled.
  41829. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41830. */
  41831. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41832. /**
  41833. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41834. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41835. */
  41836. get useAutoRotationBehavior(): boolean;
  41837. set useAutoRotationBehavior(value: boolean);
  41838. /**
  41839. * Observable triggered when the mesh target has been changed on the camera.
  41840. */
  41841. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41842. /**
  41843. * Event raised when the camera is colliding with a mesh.
  41844. */
  41845. onCollide: (collidedMesh: AbstractMesh) => void;
  41846. /**
  41847. * Defines whether the camera should check collision with the objects oh the scene.
  41848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41849. */
  41850. checkCollisions: boolean;
  41851. /**
  41852. * Defines the collision radius of the camera.
  41853. * This simulates a sphere around the camera.
  41854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41855. */
  41856. collisionRadius: Vector3;
  41857. protected _collider: Collider;
  41858. protected _previousPosition: Vector3;
  41859. protected _collisionVelocity: Vector3;
  41860. protected _newPosition: Vector3;
  41861. protected _previousAlpha: number;
  41862. protected _previousBeta: number;
  41863. protected _previousRadius: number;
  41864. protected _collisionTriggered: boolean;
  41865. protected _targetBoundingCenter: Nullable<Vector3>;
  41866. private _computationVector;
  41867. /**
  41868. * Instantiates a new ArcRotateCamera in a given scene
  41869. * @param name Defines the name of the camera
  41870. * @param alpha Defines the camera rotation along the logitudinal axis
  41871. * @param beta Defines the camera rotation along the latitudinal axis
  41872. * @param radius Defines the camera distance from its target
  41873. * @param target Defines the camera target
  41874. * @param scene Defines the scene the camera belongs to
  41875. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41876. */
  41877. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41878. /** @hidden */
  41879. _initCache(): void;
  41880. /** @hidden */
  41881. _updateCache(ignoreParentClass?: boolean): void;
  41882. protected _getTargetPosition(): Vector3;
  41883. private _storedAlpha;
  41884. private _storedBeta;
  41885. private _storedRadius;
  41886. private _storedTarget;
  41887. private _storedTargetScreenOffset;
  41888. /**
  41889. * Stores the current state of the camera (alpha, beta, radius and target)
  41890. * @returns the camera itself
  41891. */
  41892. storeState(): Camera;
  41893. /**
  41894. * @hidden
  41895. * Restored camera state. You must call storeState() first
  41896. */
  41897. _restoreStateValues(): boolean;
  41898. /** @hidden */
  41899. _isSynchronizedViewMatrix(): boolean;
  41900. /**
  41901. * Attached controls to the current camera.
  41902. * @param element Defines the element the controls should be listened from
  41903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41904. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41905. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41906. */
  41907. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41908. /**
  41909. * Detach the current controls from the camera.
  41910. * The camera will stop reacting to inputs.
  41911. * @param element Defines the element to stop listening the inputs from
  41912. */
  41913. detachControl(element: HTMLElement): void;
  41914. /** @hidden */
  41915. _checkInputs(): void;
  41916. protected _checkLimits(): void;
  41917. /**
  41918. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41919. */
  41920. rebuildAnglesAndRadius(): void;
  41921. /**
  41922. * Use a position to define the current camera related information like alpha, beta and radius
  41923. * @param position Defines the position to set the camera at
  41924. */
  41925. setPosition(position: Vector3): void;
  41926. /**
  41927. * Defines the target the camera should look at.
  41928. * This will automatically adapt alpha beta and radius to fit within the new target.
  41929. * @param target Defines the new target as a Vector or a mesh
  41930. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41931. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41932. */
  41933. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41934. /** @hidden */
  41935. _getViewMatrix(): Matrix;
  41936. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41937. /**
  41938. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41939. * @param meshes Defines the mesh to zoom on
  41940. * @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)
  41941. */
  41942. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41943. /**
  41944. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41945. * The target will be changed but the radius
  41946. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41947. * @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)
  41948. */
  41949. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41950. min: Vector3;
  41951. max: Vector3;
  41952. distance: number;
  41953. }, doNotUpdateMaxZ?: boolean): void;
  41954. /**
  41955. * @override
  41956. * Override Camera.createRigCamera
  41957. */
  41958. createRigCamera(name: string, cameraIndex: number): Camera;
  41959. /**
  41960. * @hidden
  41961. * @override
  41962. * Override Camera._updateRigCameras
  41963. */
  41964. _updateRigCameras(): void;
  41965. /**
  41966. * Destroy the camera and release the current resources hold by it.
  41967. */
  41968. dispose(): void;
  41969. /**
  41970. * Gets the current object class name.
  41971. * @return the class name
  41972. */
  41973. getClassName(): string;
  41974. }
  41975. }
  41976. declare module BABYLON {
  41977. /**
  41978. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41979. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41980. */
  41981. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41982. /**
  41983. * Gets the name of the behavior.
  41984. */
  41985. get name(): string;
  41986. private _zoomStopsAnimation;
  41987. private _idleRotationSpeed;
  41988. private _idleRotationWaitTime;
  41989. private _idleRotationSpinupTime;
  41990. /**
  41991. * Sets the flag that indicates if user zooming should stop animation.
  41992. */
  41993. set zoomStopsAnimation(flag: boolean);
  41994. /**
  41995. * Gets the flag that indicates if user zooming should stop animation.
  41996. */
  41997. get zoomStopsAnimation(): boolean;
  41998. /**
  41999. * Sets the default speed at which the camera rotates around the model.
  42000. */
  42001. set idleRotationSpeed(speed: number);
  42002. /**
  42003. * Gets the default speed at which the camera rotates around the model.
  42004. */
  42005. get idleRotationSpeed(): number;
  42006. /**
  42007. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42008. */
  42009. set idleRotationWaitTime(time: number);
  42010. /**
  42011. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42012. */
  42013. get idleRotationWaitTime(): number;
  42014. /**
  42015. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42016. */
  42017. set idleRotationSpinupTime(time: number);
  42018. /**
  42019. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42020. */
  42021. get idleRotationSpinupTime(): number;
  42022. /**
  42023. * Gets a value indicating if the camera is currently rotating because of this behavior
  42024. */
  42025. get rotationInProgress(): boolean;
  42026. private _onPrePointerObservableObserver;
  42027. private _onAfterCheckInputsObserver;
  42028. private _attachedCamera;
  42029. private _isPointerDown;
  42030. private _lastFrameTime;
  42031. private _lastInteractionTime;
  42032. private _cameraRotationSpeed;
  42033. /**
  42034. * Initializes the behavior.
  42035. */
  42036. init(): void;
  42037. /**
  42038. * Attaches the behavior to its arc rotate camera.
  42039. * @param camera Defines the camera to attach the behavior to
  42040. */
  42041. attach(camera: ArcRotateCamera): void;
  42042. /**
  42043. * Detaches the behavior from its current arc rotate camera.
  42044. */
  42045. detach(): void;
  42046. /**
  42047. * Returns true if user is scrolling.
  42048. * @return true if user is scrolling.
  42049. */
  42050. private _userIsZooming;
  42051. private _lastFrameRadius;
  42052. private _shouldAnimationStopForInteraction;
  42053. /**
  42054. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42055. */
  42056. private _applyUserInteraction;
  42057. private _userIsMoving;
  42058. }
  42059. }
  42060. declare module BABYLON {
  42061. /**
  42062. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42063. */
  42064. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42065. private ui;
  42066. /**
  42067. * The name of the behavior
  42068. */
  42069. name: string;
  42070. /**
  42071. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42072. */
  42073. distanceAwayFromFace: number;
  42074. /**
  42075. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42076. */
  42077. distanceAwayFromBottomOfFace: number;
  42078. private _faceVectors;
  42079. private _target;
  42080. private _scene;
  42081. private _onRenderObserver;
  42082. private _tmpMatrix;
  42083. private _tmpVector;
  42084. /**
  42085. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42086. * @param ui The transform node that should be attched to the mesh
  42087. */
  42088. constructor(ui: TransformNode);
  42089. /**
  42090. * Initializes the behavior
  42091. */
  42092. init(): void;
  42093. private _closestFace;
  42094. private _zeroVector;
  42095. private _lookAtTmpMatrix;
  42096. private _lookAtToRef;
  42097. /**
  42098. * Attaches the AttachToBoxBehavior to the passed in mesh
  42099. * @param target The mesh that the specified node will be attached to
  42100. */
  42101. attach(target: Mesh): void;
  42102. /**
  42103. * Detaches the behavior from the mesh
  42104. */
  42105. detach(): void;
  42106. }
  42107. }
  42108. declare module BABYLON {
  42109. /**
  42110. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42111. */
  42112. export class FadeInOutBehavior implements Behavior<Mesh> {
  42113. /**
  42114. * Time in milliseconds to delay before fading in (Default: 0)
  42115. */
  42116. delay: number;
  42117. /**
  42118. * Time in milliseconds for the mesh to fade in (Default: 300)
  42119. */
  42120. fadeInTime: number;
  42121. private _millisecondsPerFrame;
  42122. private _hovered;
  42123. private _hoverValue;
  42124. private _ownerNode;
  42125. /**
  42126. * Instatiates the FadeInOutBehavior
  42127. */
  42128. constructor();
  42129. /**
  42130. * The name of the behavior
  42131. */
  42132. get name(): string;
  42133. /**
  42134. * Initializes the behavior
  42135. */
  42136. init(): void;
  42137. /**
  42138. * Attaches the fade behavior on the passed in mesh
  42139. * @param ownerNode The mesh that will be faded in/out once attached
  42140. */
  42141. attach(ownerNode: Mesh): void;
  42142. /**
  42143. * Detaches the behavior from the mesh
  42144. */
  42145. detach(): void;
  42146. /**
  42147. * Triggers the mesh to begin fading in or out
  42148. * @param value if the object should fade in or out (true to fade in)
  42149. */
  42150. fadeIn(value: boolean): void;
  42151. private _update;
  42152. private _setAllVisibility;
  42153. }
  42154. }
  42155. declare module BABYLON {
  42156. /**
  42157. * Class containing a set of static utilities functions for managing Pivots
  42158. * @hidden
  42159. */
  42160. export class PivotTools {
  42161. private static _PivotCached;
  42162. private static _OldPivotPoint;
  42163. private static _PivotTranslation;
  42164. private static _PivotTmpVector;
  42165. /** @hidden */
  42166. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42167. /** @hidden */
  42168. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42169. }
  42170. }
  42171. declare module BABYLON {
  42172. /**
  42173. * Class containing static functions to help procedurally build meshes
  42174. */
  42175. export class PlaneBuilder {
  42176. /**
  42177. * Creates a plane mesh
  42178. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42179. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42180. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42182. * * 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
  42183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42184. * @param name defines the name of the mesh
  42185. * @param options defines the options used to create the mesh
  42186. * @param scene defines the hosting scene
  42187. * @returns the plane mesh
  42188. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42189. */
  42190. static CreatePlane(name: string, options: {
  42191. size?: number;
  42192. width?: number;
  42193. height?: number;
  42194. sideOrientation?: number;
  42195. frontUVs?: Vector4;
  42196. backUVs?: Vector4;
  42197. updatable?: boolean;
  42198. sourcePlane?: Plane;
  42199. }, scene?: Nullable<Scene>): Mesh;
  42200. }
  42201. }
  42202. declare module BABYLON {
  42203. /**
  42204. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42205. */
  42206. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42207. private static _AnyMouseID;
  42208. /**
  42209. * Abstract mesh the behavior is set on
  42210. */
  42211. attachedNode: AbstractMesh;
  42212. private _dragPlane;
  42213. private _scene;
  42214. private _pointerObserver;
  42215. private _beforeRenderObserver;
  42216. private static _planeScene;
  42217. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42218. /**
  42219. * 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)
  42220. */
  42221. maxDragAngle: number;
  42222. /**
  42223. * @hidden
  42224. */
  42225. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42226. /**
  42227. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42228. */
  42229. currentDraggingPointerID: number;
  42230. /**
  42231. * The last position where the pointer hit the drag plane in world space
  42232. */
  42233. lastDragPosition: Vector3;
  42234. /**
  42235. * If the behavior is currently in a dragging state
  42236. */
  42237. dragging: boolean;
  42238. /**
  42239. * 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)
  42240. */
  42241. dragDeltaRatio: number;
  42242. /**
  42243. * If the drag plane orientation should be updated during the dragging (Default: true)
  42244. */
  42245. updateDragPlane: boolean;
  42246. private _debugMode;
  42247. private _moving;
  42248. /**
  42249. * Fires each time the attached mesh is dragged with the pointer
  42250. * * delta between last drag position and current drag position in world space
  42251. * * dragDistance along the drag axis
  42252. * * dragPlaneNormal normal of the current drag plane used during the drag
  42253. * * dragPlanePoint in world space where the drag intersects the drag plane
  42254. */
  42255. onDragObservable: Observable<{
  42256. delta: Vector3;
  42257. dragPlanePoint: Vector3;
  42258. dragPlaneNormal: Vector3;
  42259. dragDistance: number;
  42260. pointerId: number;
  42261. }>;
  42262. /**
  42263. * Fires each time a drag begins (eg. mouse down on mesh)
  42264. */
  42265. onDragStartObservable: Observable<{
  42266. dragPlanePoint: Vector3;
  42267. pointerId: number;
  42268. }>;
  42269. /**
  42270. * Fires each time a drag ends (eg. mouse release after drag)
  42271. */
  42272. onDragEndObservable: Observable<{
  42273. dragPlanePoint: Vector3;
  42274. pointerId: number;
  42275. }>;
  42276. /**
  42277. * If the attached mesh should be moved when dragged
  42278. */
  42279. moveAttached: boolean;
  42280. /**
  42281. * If the drag behavior will react to drag events (Default: true)
  42282. */
  42283. enabled: boolean;
  42284. /**
  42285. * If pointer events should start and release the drag (Default: true)
  42286. */
  42287. startAndReleaseDragOnPointerEvents: boolean;
  42288. /**
  42289. * If camera controls should be detached during the drag
  42290. */
  42291. detachCameraControls: boolean;
  42292. /**
  42293. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42294. */
  42295. useObjectOrientationForDragging: boolean;
  42296. private _options;
  42297. /**
  42298. * Gets the options used by the behavior
  42299. */
  42300. get options(): {
  42301. dragAxis?: Vector3;
  42302. dragPlaneNormal?: Vector3;
  42303. };
  42304. /**
  42305. * Sets the options used by the behavior
  42306. */
  42307. set options(options: {
  42308. dragAxis?: Vector3;
  42309. dragPlaneNormal?: Vector3;
  42310. });
  42311. /**
  42312. * Creates a pointer drag behavior that can be attached to a mesh
  42313. * @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)
  42314. */
  42315. constructor(options?: {
  42316. dragAxis?: Vector3;
  42317. dragPlaneNormal?: Vector3;
  42318. });
  42319. /**
  42320. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42321. */
  42322. validateDrag: (targetPosition: Vector3) => boolean;
  42323. /**
  42324. * The name of the behavior
  42325. */
  42326. get name(): string;
  42327. /**
  42328. * Initializes the behavior
  42329. */
  42330. init(): void;
  42331. private _tmpVector;
  42332. private _alternatePickedPoint;
  42333. private _worldDragAxis;
  42334. private _targetPosition;
  42335. private _attachedElement;
  42336. /**
  42337. * Attaches the drag behavior the passed in mesh
  42338. * @param ownerNode The mesh that will be dragged around once attached
  42339. * @param predicate Predicate to use for pick filtering
  42340. */
  42341. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42342. /**
  42343. * Force relase the drag action by code.
  42344. */
  42345. releaseDrag(): void;
  42346. private _startDragRay;
  42347. private _lastPointerRay;
  42348. /**
  42349. * Simulates the start of a pointer drag event on the behavior
  42350. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42351. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42352. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42353. */
  42354. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42355. private _startDrag;
  42356. private _dragDelta;
  42357. private _moveDrag;
  42358. private _pickWithRayOnDragPlane;
  42359. private _pointA;
  42360. private _pointB;
  42361. private _pointC;
  42362. private _lineA;
  42363. private _lineB;
  42364. private _localAxis;
  42365. private _lookAt;
  42366. private _updateDragPlanePosition;
  42367. /**
  42368. * Detaches the behavior from the mesh
  42369. */
  42370. detach(): void;
  42371. }
  42372. }
  42373. declare module BABYLON {
  42374. /**
  42375. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42376. */
  42377. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42378. private _dragBehaviorA;
  42379. private _dragBehaviorB;
  42380. private _startDistance;
  42381. private _initialScale;
  42382. private _targetScale;
  42383. private _ownerNode;
  42384. private _sceneRenderObserver;
  42385. /**
  42386. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42387. */
  42388. constructor();
  42389. /**
  42390. * The name of the behavior
  42391. */
  42392. get name(): string;
  42393. /**
  42394. * Initializes the behavior
  42395. */
  42396. init(): void;
  42397. private _getCurrentDistance;
  42398. /**
  42399. * Attaches the scale behavior the passed in mesh
  42400. * @param ownerNode The mesh that will be scaled around once attached
  42401. */
  42402. attach(ownerNode: Mesh): void;
  42403. /**
  42404. * Detaches the behavior from the mesh
  42405. */
  42406. detach(): void;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * 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
  42412. */
  42413. export class SixDofDragBehavior implements Behavior<Mesh> {
  42414. private static _virtualScene;
  42415. private _ownerNode;
  42416. private _sceneRenderObserver;
  42417. private _scene;
  42418. private _targetPosition;
  42419. private _virtualOriginMesh;
  42420. private _virtualDragMesh;
  42421. private _pointerObserver;
  42422. private _moving;
  42423. private _startingOrientation;
  42424. private _attachedElement;
  42425. /**
  42426. * 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)
  42427. */
  42428. private zDragFactor;
  42429. /**
  42430. * If the object should rotate to face the drag origin
  42431. */
  42432. rotateDraggedObject: boolean;
  42433. /**
  42434. * If the behavior is currently in a dragging state
  42435. */
  42436. dragging: boolean;
  42437. /**
  42438. * 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)
  42439. */
  42440. dragDeltaRatio: number;
  42441. /**
  42442. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42443. */
  42444. currentDraggingPointerID: number;
  42445. /**
  42446. * If camera controls should be detached during the drag
  42447. */
  42448. detachCameraControls: boolean;
  42449. /**
  42450. * Fires each time a drag starts
  42451. */
  42452. onDragStartObservable: Observable<{}>;
  42453. /**
  42454. * Fires each time a drag ends (eg. mouse release after drag)
  42455. */
  42456. onDragEndObservable: Observable<{}>;
  42457. /**
  42458. * 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
  42459. */
  42460. constructor();
  42461. /**
  42462. * The name of the behavior
  42463. */
  42464. get name(): string;
  42465. /**
  42466. * Initializes the behavior
  42467. */
  42468. init(): void;
  42469. /**
  42470. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42471. */
  42472. private get _pointerCamera();
  42473. /**
  42474. * Attaches the scale behavior the passed in mesh
  42475. * @param ownerNode The mesh that will be scaled around once attached
  42476. */
  42477. attach(ownerNode: Mesh): void;
  42478. /**
  42479. * Detaches the behavior from the mesh
  42480. */
  42481. detach(): void;
  42482. }
  42483. }
  42484. declare module BABYLON {
  42485. /**
  42486. * Class used to apply inverse kinematics to bones
  42487. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42488. */
  42489. export class BoneIKController {
  42490. private static _tmpVecs;
  42491. private static _tmpQuat;
  42492. private static _tmpMats;
  42493. /**
  42494. * Gets or sets the target mesh
  42495. */
  42496. targetMesh: AbstractMesh;
  42497. /** Gets or sets the mesh used as pole */
  42498. poleTargetMesh: AbstractMesh;
  42499. /**
  42500. * Gets or sets the bone used as pole
  42501. */
  42502. poleTargetBone: Nullable<Bone>;
  42503. /**
  42504. * Gets or sets the target position
  42505. */
  42506. targetPosition: Vector3;
  42507. /**
  42508. * Gets or sets the pole target position
  42509. */
  42510. poleTargetPosition: Vector3;
  42511. /**
  42512. * Gets or sets the pole target local offset
  42513. */
  42514. poleTargetLocalOffset: Vector3;
  42515. /**
  42516. * Gets or sets the pole angle
  42517. */
  42518. poleAngle: number;
  42519. /**
  42520. * Gets or sets the mesh associated with the controller
  42521. */
  42522. mesh: AbstractMesh;
  42523. /**
  42524. * 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)
  42525. */
  42526. slerpAmount: number;
  42527. private _bone1Quat;
  42528. private _bone1Mat;
  42529. private _bone2Ang;
  42530. private _bone1;
  42531. private _bone2;
  42532. private _bone1Length;
  42533. private _bone2Length;
  42534. private _maxAngle;
  42535. private _maxReach;
  42536. private _rightHandedSystem;
  42537. private _bendAxis;
  42538. private _slerping;
  42539. private _adjustRoll;
  42540. /**
  42541. * Gets or sets maximum allowed angle
  42542. */
  42543. get maxAngle(): number;
  42544. set maxAngle(value: number);
  42545. /**
  42546. * Creates a new BoneIKController
  42547. * @param mesh defines the mesh to control
  42548. * @param bone defines the bone to control
  42549. * @param options defines options to set up the controller
  42550. */
  42551. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42552. targetMesh?: AbstractMesh;
  42553. poleTargetMesh?: AbstractMesh;
  42554. poleTargetBone?: Bone;
  42555. poleTargetLocalOffset?: Vector3;
  42556. poleAngle?: number;
  42557. bendAxis?: Vector3;
  42558. maxAngle?: number;
  42559. slerpAmount?: number;
  42560. });
  42561. private _setMaxAngle;
  42562. /**
  42563. * Force the controller to update the bones
  42564. */
  42565. update(): void;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Class used to make a bone look toward a point in space
  42571. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42572. */
  42573. export class BoneLookController {
  42574. private static _tmpVecs;
  42575. private static _tmpQuat;
  42576. private static _tmpMats;
  42577. /**
  42578. * The target Vector3 that the bone will look at
  42579. */
  42580. target: Vector3;
  42581. /**
  42582. * The mesh that the bone is attached to
  42583. */
  42584. mesh: AbstractMesh;
  42585. /**
  42586. * The bone that will be looking to the target
  42587. */
  42588. bone: Bone;
  42589. /**
  42590. * The up axis of the coordinate system that is used when the bone is rotated
  42591. */
  42592. upAxis: Vector3;
  42593. /**
  42594. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42595. */
  42596. upAxisSpace: Space;
  42597. /**
  42598. * Used to make an adjustment to the yaw of the bone
  42599. */
  42600. adjustYaw: number;
  42601. /**
  42602. * Used to make an adjustment to the pitch of the bone
  42603. */
  42604. adjustPitch: number;
  42605. /**
  42606. * Used to make an adjustment to the roll of the bone
  42607. */
  42608. adjustRoll: number;
  42609. /**
  42610. * 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)
  42611. */
  42612. slerpAmount: number;
  42613. private _minYaw;
  42614. private _maxYaw;
  42615. private _minPitch;
  42616. private _maxPitch;
  42617. private _minYawSin;
  42618. private _minYawCos;
  42619. private _maxYawSin;
  42620. private _maxYawCos;
  42621. private _midYawConstraint;
  42622. private _minPitchTan;
  42623. private _maxPitchTan;
  42624. private _boneQuat;
  42625. private _slerping;
  42626. private _transformYawPitch;
  42627. private _transformYawPitchInv;
  42628. private _firstFrameSkipped;
  42629. private _yawRange;
  42630. private _fowardAxis;
  42631. /**
  42632. * Gets or sets the minimum yaw angle that the bone can look to
  42633. */
  42634. get minYaw(): number;
  42635. set minYaw(value: number);
  42636. /**
  42637. * Gets or sets the maximum yaw angle that the bone can look to
  42638. */
  42639. get maxYaw(): number;
  42640. set maxYaw(value: number);
  42641. /**
  42642. * Gets or sets the minimum pitch angle that the bone can look to
  42643. */
  42644. get minPitch(): number;
  42645. set minPitch(value: number);
  42646. /**
  42647. * Gets or sets the maximum pitch angle that the bone can look to
  42648. */
  42649. get maxPitch(): number;
  42650. set maxPitch(value: number);
  42651. /**
  42652. * Create a BoneLookController
  42653. * @param mesh the mesh that the bone belongs to
  42654. * @param bone the bone that will be looking to the target
  42655. * @param target the target Vector3 to look at
  42656. * @param options optional settings:
  42657. * * maxYaw: the maximum angle the bone will yaw to
  42658. * * minYaw: the minimum angle the bone will yaw to
  42659. * * maxPitch: the maximum angle the bone will pitch to
  42660. * * minPitch: the minimum angle the bone will yaw to
  42661. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42662. * * upAxis: the up axis of the coordinate system
  42663. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42664. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42665. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42666. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42667. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42668. * * adjustRoll: used to make an adjustment to the roll of the bone
  42669. **/
  42670. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42671. maxYaw?: number;
  42672. minYaw?: number;
  42673. maxPitch?: number;
  42674. minPitch?: number;
  42675. slerpAmount?: number;
  42676. upAxis?: Vector3;
  42677. upAxisSpace?: Space;
  42678. yawAxis?: Vector3;
  42679. pitchAxis?: Vector3;
  42680. adjustYaw?: number;
  42681. adjustPitch?: number;
  42682. adjustRoll?: number;
  42683. });
  42684. /**
  42685. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42686. */
  42687. update(): void;
  42688. private _getAngleDiff;
  42689. private _getAngleBetween;
  42690. private _isAngleBetween;
  42691. }
  42692. }
  42693. declare module BABYLON {
  42694. /**
  42695. * Manage the gamepad inputs to control an arc rotate camera.
  42696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42697. */
  42698. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42699. /**
  42700. * Defines the camera the input is attached to.
  42701. */
  42702. camera: ArcRotateCamera;
  42703. /**
  42704. * Defines the gamepad the input is gathering event from.
  42705. */
  42706. gamepad: Nullable<Gamepad>;
  42707. /**
  42708. * Defines the gamepad rotation sensiblity.
  42709. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42710. */
  42711. gamepadRotationSensibility: number;
  42712. /**
  42713. * Defines the gamepad move sensiblity.
  42714. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42715. */
  42716. gamepadMoveSensibility: number;
  42717. private _yAxisScale;
  42718. /**
  42719. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42720. */
  42721. get invertYAxis(): boolean;
  42722. set invertYAxis(value: boolean);
  42723. private _onGamepadConnectedObserver;
  42724. private _onGamepadDisconnectedObserver;
  42725. /**
  42726. * Attach the input controls to a specific dom element to get the input from.
  42727. * @param element Defines the element the controls should be listened from
  42728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42729. */
  42730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42731. /**
  42732. * Detach the current controls from the specified dom element.
  42733. * @param element Defines the element to stop listening the inputs from
  42734. */
  42735. detachControl(element: Nullable<HTMLElement>): void;
  42736. /**
  42737. * Update the current camera state depending on the inputs that have been used this frame.
  42738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42739. */
  42740. checkInputs(): void;
  42741. /**
  42742. * Gets the class name of the current intput.
  42743. * @returns the class name
  42744. */
  42745. getClassName(): string;
  42746. /**
  42747. * Get the friendly name associated with the input class.
  42748. * @returns the input friendly name
  42749. */
  42750. getSimpleName(): string;
  42751. }
  42752. }
  42753. declare module BABYLON {
  42754. interface ArcRotateCameraInputsManager {
  42755. /**
  42756. * Add orientation input support to the input manager.
  42757. * @returns the current input manager
  42758. */
  42759. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42760. }
  42761. /**
  42762. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42764. */
  42765. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42766. /**
  42767. * Defines the camera the input is attached to.
  42768. */
  42769. camera: ArcRotateCamera;
  42770. /**
  42771. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42772. */
  42773. alphaCorrection: number;
  42774. /**
  42775. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42776. */
  42777. gammaCorrection: number;
  42778. private _alpha;
  42779. private _gamma;
  42780. private _dirty;
  42781. private _deviceOrientationHandler;
  42782. /**
  42783. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42784. */
  42785. constructor();
  42786. /**
  42787. * Attach the input controls to a specific dom element to get the input from.
  42788. * @param element Defines the element the controls should be listened from
  42789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42790. */
  42791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42792. /** @hidden */
  42793. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42794. /**
  42795. * Update the current camera state depending on the inputs that have been used this frame.
  42796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42797. */
  42798. checkInputs(): void;
  42799. /**
  42800. * Detach the current controls from the specified dom element.
  42801. * @param element Defines the element to stop listening the inputs from
  42802. */
  42803. detachControl(element: Nullable<HTMLElement>): void;
  42804. /**
  42805. * Gets the class name of the current intput.
  42806. * @returns the class name
  42807. */
  42808. getClassName(): string;
  42809. /**
  42810. * Get the friendly name associated with the input class.
  42811. * @returns the input friendly name
  42812. */
  42813. getSimpleName(): string;
  42814. }
  42815. }
  42816. declare module BABYLON {
  42817. /**
  42818. * Listen to mouse events to control the camera.
  42819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42820. */
  42821. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42822. /**
  42823. * Defines the camera the input is attached to.
  42824. */
  42825. camera: FlyCamera;
  42826. /**
  42827. * Defines if touch is enabled. (Default is true.)
  42828. */
  42829. touchEnabled: boolean;
  42830. /**
  42831. * Defines the buttons associated with the input to handle camera rotation.
  42832. */
  42833. buttons: number[];
  42834. /**
  42835. * Assign buttons for Yaw control.
  42836. */
  42837. buttonsYaw: number[];
  42838. /**
  42839. * Assign buttons for Pitch control.
  42840. */
  42841. buttonsPitch: number[];
  42842. /**
  42843. * Assign buttons for Roll control.
  42844. */
  42845. buttonsRoll: number[];
  42846. /**
  42847. * Detect if any button is being pressed while mouse is moved.
  42848. * -1 = Mouse locked.
  42849. * 0 = Left button.
  42850. * 1 = Middle Button.
  42851. * 2 = Right Button.
  42852. */
  42853. activeButton: number;
  42854. /**
  42855. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42856. * Higher values reduce its sensitivity.
  42857. */
  42858. angularSensibility: number;
  42859. private _mousemoveCallback;
  42860. private _observer;
  42861. private _rollObserver;
  42862. private previousPosition;
  42863. private noPreventDefault;
  42864. private element;
  42865. /**
  42866. * Listen to mouse events to control the camera.
  42867. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42869. */
  42870. constructor(touchEnabled?: boolean);
  42871. /**
  42872. * Attach the mouse control to the HTML DOM element.
  42873. * @param element Defines the element that listens to the input events.
  42874. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42875. */
  42876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42877. /**
  42878. * Detach the current controls from the specified dom element.
  42879. * @param element Defines the element to stop listening the inputs from
  42880. */
  42881. detachControl(element: Nullable<HTMLElement>): void;
  42882. /**
  42883. * Gets the class name of the current input.
  42884. * @returns the class name.
  42885. */
  42886. getClassName(): string;
  42887. /**
  42888. * Get the friendly name associated with the input class.
  42889. * @returns the input's friendly name.
  42890. */
  42891. getSimpleName(): string;
  42892. private _pointerInput;
  42893. private _onMouseMove;
  42894. /**
  42895. * Rotate camera by mouse offset.
  42896. */
  42897. private rotateCamera;
  42898. }
  42899. }
  42900. declare module BABYLON {
  42901. /**
  42902. * Default Inputs manager for the FlyCamera.
  42903. * It groups all the default supported inputs for ease of use.
  42904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42905. */
  42906. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42907. /**
  42908. * Instantiates a new FlyCameraInputsManager.
  42909. * @param camera Defines the camera the inputs belong to.
  42910. */
  42911. constructor(camera: FlyCamera);
  42912. /**
  42913. * Add keyboard input support to the input manager.
  42914. * @returns the new FlyCameraKeyboardMoveInput().
  42915. */
  42916. addKeyboard(): FlyCameraInputsManager;
  42917. /**
  42918. * Add mouse input support to the input manager.
  42919. * @param touchEnabled Enable touch screen support.
  42920. * @returns the new FlyCameraMouseInput().
  42921. */
  42922. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42923. }
  42924. }
  42925. declare module BABYLON {
  42926. /**
  42927. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42928. * such as in a 3D Space Shooter or a Flight Simulator.
  42929. */
  42930. export class FlyCamera extends TargetCamera {
  42931. /**
  42932. * Define the collision ellipsoid of the camera.
  42933. * This is helpful for simulating a camera body, like a player's body.
  42934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42935. */
  42936. ellipsoid: Vector3;
  42937. /**
  42938. * Define an offset for the position of the ellipsoid around the camera.
  42939. * This can be helpful if the camera is attached away from the player's body center,
  42940. * such as at its head.
  42941. */
  42942. ellipsoidOffset: Vector3;
  42943. /**
  42944. * Enable or disable collisions of the camera with the rest of the scene objects.
  42945. */
  42946. checkCollisions: boolean;
  42947. /**
  42948. * Enable or disable gravity on the camera.
  42949. */
  42950. applyGravity: boolean;
  42951. /**
  42952. * Define the current direction the camera is moving to.
  42953. */
  42954. cameraDirection: Vector3;
  42955. /**
  42956. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42957. * This overrides and empties cameraRotation.
  42958. */
  42959. rotationQuaternion: Quaternion;
  42960. /**
  42961. * Track Roll to maintain the wanted Rolling when looking around.
  42962. */
  42963. _trackRoll: number;
  42964. /**
  42965. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42966. */
  42967. rollCorrect: number;
  42968. /**
  42969. * Mimic a banked turn, Rolling the camera when Yawing.
  42970. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42971. */
  42972. bankedTurn: boolean;
  42973. /**
  42974. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42975. */
  42976. bankedTurnLimit: number;
  42977. /**
  42978. * Value of 0 disables the banked Roll.
  42979. * Value of 1 is equal to the Yaw angle in radians.
  42980. */
  42981. bankedTurnMultiplier: number;
  42982. /**
  42983. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42984. */
  42985. inputs: FlyCameraInputsManager;
  42986. /**
  42987. * Gets the input sensibility for mouse input.
  42988. * Higher values reduce sensitivity.
  42989. */
  42990. get angularSensibility(): number;
  42991. /**
  42992. * Sets the input sensibility for a mouse input.
  42993. * Higher values reduce sensitivity.
  42994. */
  42995. set angularSensibility(value: number);
  42996. /**
  42997. * Get the keys for camera movement forward.
  42998. */
  42999. get keysForward(): number[];
  43000. /**
  43001. * Set the keys for camera movement forward.
  43002. */
  43003. set keysForward(value: number[]);
  43004. /**
  43005. * Get the keys for camera movement backward.
  43006. */
  43007. get keysBackward(): number[];
  43008. set keysBackward(value: number[]);
  43009. /**
  43010. * Get the keys for camera movement up.
  43011. */
  43012. get keysUp(): number[];
  43013. /**
  43014. * Set the keys for camera movement up.
  43015. */
  43016. set keysUp(value: number[]);
  43017. /**
  43018. * Get the keys for camera movement down.
  43019. */
  43020. get keysDown(): number[];
  43021. /**
  43022. * Set the keys for camera movement down.
  43023. */
  43024. set keysDown(value: number[]);
  43025. /**
  43026. * Get the keys for camera movement left.
  43027. */
  43028. get keysLeft(): number[];
  43029. /**
  43030. * Set the keys for camera movement left.
  43031. */
  43032. set keysLeft(value: number[]);
  43033. /**
  43034. * Set the keys for camera movement right.
  43035. */
  43036. get keysRight(): number[];
  43037. /**
  43038. * Set the keys for camera movement right.
  43039. */
  43040. set keysRight(value: number[]);
  43041. /**
  43042. * Event raised when the camera collides with a mesh in the scene.
  43043. */
  43044. onCollide: (collidedMesh: AbstractMesh) => void;
  43045. private _collider;
  43046. private _needMoveForGravity;
  43047. private _oldPosition;
  43048. private _diffPosition;
  43049. private _newPosition;
  43050. /** @hidden */
  43051. _localDirection: Vector3;
  43052. /** @hidden */
  43053. _transformedDirection: Vector3;
  43054. /**
  43055. * Instantiates a FlyCamera.
  43056. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43057. * such as in a 3D Space Shooter or a Flight Simulator.
  43058. * @param name Define the name of the camera in the scene.
  43059. * @param position Define the starting position of the camera in the scene.
  43060. * @param scene Define the scene the camera belongs to.
  43061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43062. */
  43063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43064. /**
  43065. * Attach a control to the HTML DOM element.
  43066. * @param element Defines the element that listens to the input events.
  43067. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43068. */
  43069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43070. /**
  43071. * Detach a control from the HTML DOM element.
  43072. * The camera will stop reacting to that input.
  43073. * @param element Defines the element that listens to the input events.
  43074. */
  43075. detachControl(element: HTMLElement): void;
  43076. private _collisionMask;
  43077. /**
  43078. * Get the mask that the camera ignores in collision events.
  43079. */
  43080. get collisionMask(): number;
  43081. /**
  43082. * Set the mask that the camera ignores in collision events.
  43083. */
  43084. set collisionMask(mask: number);
  43085. /** @hidden */
  43086. _collideWithWorld(displacement: Vector3): void;
  43087. /** @hidden */
  43088. private _onCollisionPositionChange;
  43089. /** @hidden */
  43090. _checkInputs(): void;
  43091. /** @hidden */
  43092. _decideIfNeedsToMove(): boolean;
  43093. /** @hidden */
  43094. _updatePosition(): void;
  43095. /**
  43096. * Restore the Roll to its target value at the rate specified.
  43097. * @param rate - Higher means slower restoring.
  43098. * @hidden
  43099. */
  43100. restoreRoll(rate: number): void;
  43101. /**
  43102. * Destroy the camera and release the current resources held by it.
  43103. */
  43104. dispose(): void;
  43105. /**
  43106. * Get the current object class name.
  43107. * @returns the class name.
  43108. */
  43109. getClassName(): string;
  43110. }
  43111. }
  43112. declare module BABYLON {
  43113. /**
  43114. * Listen to keyboard events to control the camera.
  43115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43116. */
  43117. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43118. /**
  43119. * Defines the camera the input is attached to.
  43120. */
  43121. camera: FlyCamera;
  43122. /**
  43123. * The list of keyboard keys used to control the forward move of the camera.
  43124. */
  43125. keysForward: number[];
  43126. /**
  43127. * The list of keyboard keys used to control the backward move of the camera.
  43128. */
  43129. keysBackward: number[];
  43130. /**
  43131. * The list of keyboard keys used to control the forward move of the camera.
  43132. */
  43133. keysUp: number[];
  43134. /**
  43135. * The list of keyboard keys used to control the backward move of the camera.
  43136. */
  43137. keysDown: number[];
  43138. /**
  43139. * The list of keyboard keys used to control the right strafe move of the camera.
  43140. */
  43141. keysRight: number[];
  43142. /**
  43143. * The list of keyboard keys used to control the left strafe move of the camera.
  43144. */
  43145. keysLeft: number[];
  43146. private _keys;
  43147. private _onCanvasBlurObserver;
  43148. private _onKeyboardObserver;
  43149. private _engine;
  43150. private _scene;
  43151. /**
  43152. * Attach the input controls to a specific dom element to get the input from.
  43153. * @param element Defines the element the controls should be listened from
  43154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43155. */
  43156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43157. /**
  43158. * Detach the current controls from the specified dom element.
  43159. * @param element Defines the element to stop listening the inputs from
  43160. */
  43161. detachControl(element: Nullable<HTMLElement>): void;
  43162. /**
  43163. * Gets the class name of the current intput.
  43164. * @returns the class name
  43165. */
  43166. getClassName(): string;
  43167. /** @hidden */
  43168. _onLostFocus(e: FocusEvent): void;
  43169. /**
  43170. * Get the friendly name associated with the input class.
  43171. * @returns the input friendly name
  43172. */
  43173. getSimpleName(): string;
  43174. /**
  43175. * Update the current camera state depending on the inputs that have been used this frame.
  43176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43177. */
  43178. checkInputs(): void;
  43179. }
  43180. }
  43181. declare module BABYLON {
  43182. /**
  43183. * Manage the mouse wheel inputs to control a follow camera.
  43184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43185. */
  43186. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43187. /**
  43188. * Defines the camera the input is attached to.
  43189. */
  43190. camera: FollowCamera;
  43191. /**
  43192. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43193. */
  43194. axisControlRadius: boolean;
  43195. /**
  43196. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43197. */
  43198. axisControlHeight: boolean;
  43199. /**
  43200. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43201. */
  43202. axisControlRotation: boolean;
  43203. /**
  43204. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43205. * relation to mouseWheel events.
  43206. */
  43207. wheelPrecision: number;
  43208. /**
  43209. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43210. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43211. */
  43212. wheelDeltaPercentage: number;
  43213. private _wheel;
  43214. private _observer;
  43215. /**
  43216. * Attach the input controls to a specific dom element to get the input from.
  43217. * @param element Defines the element the controls should be listened from
  43218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43219. */
  43220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43221. /**
  43222. * Detach the current controls from the specified dom element.
  43223. * @param element Defines the element to stop listening the inputs from
  43224. */
  43225. detachControl(element: Nullable<HTMLElement>): void;
  43226. /**
  43227. * Gets the class name of the current intput.
  43228. * @returns the class name
  43229. */
  43230. getClassName(): string;
  43231. /**
  43232. * Get the friendly name associated with the input class.
  43233. * @returns the input friendly name
  43234. */
  43235. getSimpleName(): string;
  43236. }
  43237. }
  43238. declare module BABYLON {
  43239. /**
  43240. * Manage the pointers inputs to control an follow camera.
  43241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43242. */
  43243. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43244. /**
  43245. * Defines the camera the input is attached to.
  43246. */
  43247. camera: FollowCamera;
  43248. /**
  43249. * Gets the class name of the current input.
  43250. * @returns the class name
  43251. */
  43252. getClassName(): string;
  43253. /**
  43254. * Defines the pointer angular sensibility along the X axis or how fast is
  43255. * the camera rotating.
  43256. * A negative number will reverse the axis direction.
  43257. */
  43258. angularSensibilityX: number;
  43259. /**
  43260. * Defines the pointer angular sensibility along the Y axis or how fast is
  43261. * the camera rotating.
  43262. * A negative number will reverse the axis direction.
  43263. */
  43264. angularSensibilityY: number;
  43265. /**
  43266. * Defines the pointer pinch precision or how fast is the camera zooming.
  43267. * A negative number will reverse the axis direction.
  43268. */
  43269. pinchPrecision: number;
  43270. /**
  43271. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43272. * from 0.
  43273. * It defines the percentage of current camera.radius to use as delta when
  43274. * pinch zoom is used.
  43275. */
  43276. pinchDeltaPercentage: number;
  43277. /**
  43278. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43279. */
  43280. axisXControlRadius: boolean;
  43281. /**
  43282. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43283. */
  43284. axisXControlHeight: boolean;
  43285. /**
  43286. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43287. */
  43288. axisXControlRotation: boolean;
  43289. /**
  43290. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43291. */
  43292. axisYControlRadius: boolean;
  43293. /**
  43294. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43295. */
  43296. axisYControlHeight: boolean;
  43297. /**
  43298. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43299. */
  43300. axisYControlRotation: boolean;
  43301. /**
  43302. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43303. */
  43304. axisPinchControlRadius: boolean;
  43305. /**
  43306. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43307. */
  43308. axisPinchControlHeight: boolean;
  43309. /**
  43310. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43311. */
  43312. axisPinchControlRotation: boolean;
  43313. /**
  43314. * Log error messages if basic misconfiguration has occurred.
  43315. */
  43316. warningEnable: boolean;
  43317. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43318. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43319. private _warningCounter;
  43320. private _warning;
  43321. }
  43322. }
  43323. declare module BABYLON {
  43324. /**
  43325. * Default Inputs manager for the FollowCamera.
  43326. * It groups all the default supported inputs for ease of use.
  43327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43328. */
  43329. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43330. /**
  43331. * Instantiates a new FollowCameraInputsManager.
  43332. * @param camera Defines the camera the inputs belong to
  43333. */
  43334. constructor(camera: FollowCamera);
  43335. /**
  43336. * Add keyboard input support to the input manager.
  43337. * @returns the current input manager
  43338. */
  43339. addKeyboard(): FollowCameraInputsManager;
  43340. /**
  43341. * Add mouse wheel input support to the input manager.
  43342. * @returns the current input manager
  43343. */
  43344. addMouseWheel(): FollowCameraInputsManager;
  43345. /**
  43346. * Add pointers input support to the input manager.
  43347. * @returns the current input manager
  43348. */
  43349. addPointers(): FollowCameraInputsManager;
  43350. /**
  43351. * Add orientation input support to the input manager.
  43352. * @returns the current input manager
  43353. */
  43354. addVRDeviceOrientation(): FollowCameraInputsManager;
  43355. }
  43356. }
  43357. declare module BABYLON {
  43358. /**
  43359. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43360. * an arc rotate version arcFollowCamera are available.
  43361. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43362. */
  43363. export class FollowCamera extends TargetCamera {
  43364. /**
  43365. * Distance the follow camera should follow an object at
  43366. */
  43367. radius: number;
  43368. /**
  43369. * Minimum allowed distance of the camera to the axis of rotation
  43370. * (The camera can not get closer).
  43371. * This can help limiting how the Camera is able to move in the scene.
  43372. */
  43373. lowerRadiusLimit: Nullable<number>;
  43374. /**
  43375. * Maximum allowed distance of the camera to the axis of rotation
  43376. * (The camera can not get further).
  43377. * This can help limiting how the Camera is able to move in the scene.
  43378. */
  43379. upperRadiusLimit: Nullable<number>;
  43380. /**
  43381. * Define a rotation offset between the camera and the object it follows
  43382. */
  43383. rotationOffset: number;
  43384. /**
  43385. * Minimum allowed angle to camera position relative to target object.
  43386. * This can help limiting how the Camera is able to move in the scene.
  43387. */
  43388. lowerRotationOffsetLimit: Nullable<number>;
  43389. /**
  43390. * Maximum allowed angle to camera position relative to target object.
  43391. * This can help limiting how the Camera is able to move in the scene.
  43392. */
  43393. upperRotationOffsetLimit: Nullable<number>;
  43394. /**
  43395. * Define a height offset between the camera and the object it follows.
  43396. * It can help following an object from the top (like a car chaing a plane)
  43397. */
  43398. heightOffset: number;
  43399. /**
  43400. * Minimum allowed height of camera position relative to target object.
  43401. * This can help limiting how the Camera is able to move in the scene.
  43402. */
  43403. lowerHeightOffsetLimit: Nullable<number>;
  43404. /**
  43405. * Maximum allowed height of camera position relative to target object.
  43406. * This can help limiting how the Camera is able to move in the scene.
  43407. */
  43408. upperHeightOffsetLimit: Nullable<number>;
  43409. /**
  43410. * Define how fast the camera can accelerate to follow it s target.
  43411. */
  43412. cameraAcceleration: number;
  43413. /**
  43414. * Define the speed limit of the camera following an object.
  43415. */
  43416. maxCameraSpeed: number;
  43417. /**
  43418. * Define the target of the camera.
  43419. */
  43420. lockedTarget: Nullable<AbstractMesh>;
  43421. /**
  43422. * Defines the input associated with the camera.
  43423. */
  43424. inputs: FollowCameraInputsManager;
  43425. /**
  43426. * Instantiates the follow camera.
  43427. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43428. * @param name Define the name of the camera in the scene
  43429. * @param position Define the position of the camera
  43430. * @param scene Define the scene the camera belong to
  43431. * @param lockedTarget Define the target of the camera
  43432. */
  43433. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43434. private _follow;
  43435. /**
  43436. * Attached controls to the current camera.
  43437. * @param element Defines the element the controls should be listened from
  43438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43439. */
  43440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43441. /**
  43442. * Detach the current controls from the camera.
  43443. * The camera will stop reacting to inputs.
  43444. * @param element Defines the element to stop listening the inputs from
  43445. */
  43446. detachControl(element: HTMLElement): void;
  43447. /** @hidden */
  43448. _checkInputs(): void;
  43449. private _checkLimits;
  43450. /**
  43451. * Gets the camera class name.
  43452. * @returns the class name
  43453. */
  43454. getClassName(): string;
  43455. }
  43456. /**
  43457. * Arc Rotate version of the follow camera.
  43458. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43459. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43460. */
  43461. export class ArcFollowCamera extends TargetCamera {
  43462. /** The longitudinal angle of the camera */
  43463. alpha: number;
  43464. /** The latitudinal angle of the camera */
  43465. beta: number;
  43466. /** The radius of the camera from its target */
  43467. radius: number;
  43468. /** Define the camera target (the messh it should follow) */
  43469. target: Nullable<AbstractMesh>;
  43470. private _cartesianCoordinates;
  43471. /**
  43472. * Instantiates a new ArcFollowCamera
  43473. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43474. * @param name Define the name of the camera
  43475. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43476. * @param beta Define the rotation angle of the camera around the elevation axis
  43477. * @param radius Define the radius of the camera from its target point
  43478. * @param target Define the target of the camera
  43479. * @param scene Define the scene the camera belongs to
  43480. */
  43481. constructor(name: string,
  43482. /** The longitudinal angle of the camera */
  43483. alpha: number,
  43484. /** The latitudinal angle of the camera */
  43485. beta: number,
  43486. /** The radius of the camera from its target */
  43487. radius: number,
  43488. /** Define the camera target (the messh it should follow) */
  43489. target: Nullable<AbstractMesh>, scene: Scene);
  43490. private _follow;
  43491. /** @hidden */
  43492. _checkInputs(): void;
  43493. /**
  43494. * Returns the class name of the object.
  43495. * It is mostly used internally for serialization purposes.
  43496. */
  43497. getClassName(): string;
  43498. }
  43499. }
  43500. declare module BABYLON {
  43501. /**
  43502. * Manage the keyboard inputs to control the movement of a follow camera.
  43503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43504. */
  43505. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43506. /**
  43507. * Defines the camera the input is attached to.
  43508. */
  43509. camera: FollowCamera;
  43510. /**
  43511. * Defines the list of key codes associated with the up action (increase heightOffset)
  43512. */
  43513. keysHeightOffsetIncr: number[];
  43514. /**
  43515. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43516. */
  43517. keysHeightOffsetDecr: number[];
  43518. /**
  43519. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43520. */
  43521. keysHeightOffsetModifierAlt: boolean;
  43522. /**
  43523. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43524. */
  43525. keysHeightOffsetModifierCtrl: boolean;
  43526. /**
  43527. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43528. */
  43529. keysHeightOffsetModifierShift: boolean;
  43530. /**
  43531. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43532. */
  43533. keysRotationOffsetIncr: number[];
  43534. /**
  43535. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43536. */
  43537. keysRotationOffsetDecr: number[];
  43538. /**
  43539. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43540. */
  43541. keysRotationOffsetModifierAlt: boolean;
  43542. /**
  43543. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43544. */
  43545. keysRotationOffsetModifierCtrl: boolean;
  43546. /**
  43547. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43548. */
  43549. keysRotationOffsetModifierShift: boolean;
  43550. /**
  43551. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43552. */
  43553. keysRadiusIncr: number[];
  43554. /**
  43555. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43556. */
  43557. keysRadiusDecr: number[];
  43558. /**
  43559. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43560. */
  43561. keysRadiusModifierAlt: boolean;
  43562. /**
  43563. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43564. */
  43565. keysRadiusModifierCtrl: boolean;
  43566. /**
  43567. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43568. */
  43569. keysRadiusModifierShift: boolean;
  43570. /**
  43571. * Defines the rate of change of heightOffset.
  43572. */
  43573. heightSensibility: number;
  43574. /**
  43575. * Defines the rate of change of rotationOffset.
  43576. */
  43577. rotationSensibility: number;
  43578. /**
  43579. * Defines the rate of change of radius.
  43580. */
  43581. radiusSensibility: number;
  43582. private _keys;
  43583. private _ctrlPressed;
  43584. private _altPressed;
  43585. private _shiftPressed;
  43586. private _onCanvasBlurObserver;
  43587. private _onKeyboardObserver;
  43588. private _engine;
  43589. private _scene;
  43590. /**
  43591. * Attach the input controls to a specific dom element to get the input from.
  43592. * @param element Defines the element the controls should be listened from
  43593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43594. */
  43595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43596. /**
  43597. * Detach the current controls from the specified dom element.
  43598. * @param element Defines the element to stop listening the inputs from
  43599. */
  43600. detachControl(element: Nullable<HTMLElement>): void;
  43601. /**
  43602. * Update the current camera state depending on the inputs that have been used this frame.
  43603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43604. */
  43605. checkInputs(): void;
  43606. /**
  43607. * Gets the class name of the current input.
  43608. * @returns the class name
  43609. */
  43610. getClassName(): string;
  43611. /**
  43612. * Get the friendly name associated with the input class.
  43613. * @returns the input friendly name
  43614. */
  43615. getSimpleName(): string;
  43616. /**
  43617. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43618. * allow modification of the heightOffset value.
  43619. */
  43620. private _modifierHeightOffset;
  43621. /**
  43622. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43623. * allow modification of the rotationOffset value.
  43624. */
  43625. private _modifierRotationOffset;
  43626. /**
  43627. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43628. * allow modification of the radius value.
  43629. */
  43630. private _modifierRadius;
  43631. }
  43632. }
  43633. declare module BABYLON {
  43634. interface FreeCameraInputsManager {
  43635. /**
  43636. * @hidden
  43637. */
  43638. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43639. /**
  43640. * Add orientation input support to the input manager.
  43641. * @returns the current input manager
  43642. */
  43643. addDeviceOrientation(): FreeCameraInputsManager;
  43644. }
  43645. /**
  43646. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43647. * Screen rotation is taken into account.
  43648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43649. */
  43650. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43651. private _camera;
  43652. private _screenOrientationAngle;
  43653. private _constantTranform;
  43654. private _screenQuaternion;
  43655. private _alpha;
  43656. private _beta;
  43657. private _gamma;
  43658. /**
  43659. * Can be used to detect if a device orientation sensor is available on a device
  43660. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43661. * @returns a promise that will resolve on orientation change
  43662. */
  43663. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43664. /**
  43665. * @hidden
  43666. */
  43667. _onDeviceOrientationChangedObservable: Observable<void>;
  43668. /**
  43669. * Instantiates a new input
  43670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43671. */
  43672. constructor();
  43673. /**
  43674. * Define the camera controlled by the input.
  43675. */
  43676. get camera(): FreeCamera;
  43677. set camera(camera: FreeCamera);
  43678. /**
  43679. * Attach the input controls to a specific dom element to get the input from.
  43680. * @param element Defines the element the controls should be listened from
  43681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43682. */
  43683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43684. private _orientationChanged;
  43685. private _deviceOrientation;
  43686. /**
  43687. * Detach the current controls from the specified dom element.
  43688. * @param element Defines the element to stop listening the inputs from
  43689. */
  43690. detachControl(element: Nullable<HTMLElement>): void;
  43691. /**
  43692. * Update the current camera state depending on the inputs that have been used this frame.
  43693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43694. */
  43695. checkInputs(): void;
  43696. /**
  43697. * Gets the class name of the current intput.
  43698. * @returns the class name
  43699. */
  43700. getClassName(): string;
  43701. /**
  43702. * Get the friendly name associated with the input class.
  43703. * @returns the input friendly name
  43704. */
  43705. getSimpleName(): string;
  43706. }
  43707. }
  43708. declare module BABYLON {
  43709. /**
  43710. * Manage the gamepad inputs to control a free camera.
  43711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43712. */
  43713. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43714. /**
  43715. * Define the camera the input is attached to.
  43716. */
  43717. camera: FreeCamera;
  43718. /**
  43719. * Define the Gamepad controlling the input
  43720. */
  43721. gamepad: Nullable<Gamepad>;
  43722. /**
  43723. * Defines the gamepad rotation sensiblity.
  43724. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43725. */
  43726. gamepadAngularSensibility: number;
  43727. /**
  43728. * Defines the gamepad move sensiblity.
  43729. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43730. */
  43731. gamepadMoveSensibility: number;
  43732. private _yAxisScale;
  43733. /**
  43734. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43735. */
  43736. get invertYAxis(): boolean;
  43737. set invertYAxis(value: boolean);
  43738. private _onGamepadConnectedObserver;
  43739. private _onGamepadDisconnectedObserver;
  43740. private _cameraTransform;
  43741. private _deltaTransform;
  43742. private _vector3;
  43743. private _vector2;
  43744. /**
  43745. * Attach the input controls to a specific dom element to get the input from.
  43746. * @param element Defines the element the controls should be listened from
  43747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43748. */
  43749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43750. /**
  43751. * Detach the current controls from the specified dom element.
  43752. * @param element Defines the element to stop listening the inputs from
  43753. */
  43754. detachControl(element: Nullable<HTMLElement>): void;
  43755. /**
  43756. * Update the current camera state depending on the inputs that have been used this frame.
  43757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43758. */
  43759. checkInputs(): void;
  43760. /**
  43761. * Gets the class name of the current intput.
  43762. * @returns the class name
  43763. */
  43764. getClassName(): string;
  43765. /**
  43766. * Get the friendly name associated with the input class.
  43767. * @returns the input friendly name
  43768. */
  43769. getSimpleName(): string;
  43770. }
  43771. }
  43772. declare module BABYLON {
  43773. /**
  43774. * Defines the potential axis of a Joystick
  43775. */
  43776. export enum JoystickAxis {
  43777. /** X axis */
  43778. X = 0,
  43779. /** Y axis */
  43780. Y = 1,
  43781. /** Z axis */
  43782. Z = 2
  43783. }
  43784. /**
  43785. * Class used to define virtual joystick (used in touch mode)
  43786. */
  43787. export class VirtualJoystick {
  43788. /**
  43789. * Gets or sets a boolean indicating that left and right values must be inverted
  43790. */
  43791. reverseLeftRight: boolean;
  43792. /**
  43793. * Gets or sets a boolean indicating that up and down values must be inverted
  43794. */
  43795. reverseUpDown: boolean;
  43796. /**
  43797. * Gets the offset value for the position (ie. the change of the position value)
  43798. */
  43799. deltaPosition: Vector3;
  43800. /**
  43801. * Gets a boolean indicating if the virtual joystick was pressed
  43802. */
  43803. pressed: boolean;
  43804. /**
  43805. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43806. */
  43807. static Canvas: Nullable<HTMLCanvasElement>;
  43808. private static _globalJoystickIndex;
  43809. private static vjCanvasContext;
  43810. private static vjCanvasWidth;
  43811. private static vjCanvasHeight;
  43812. private static halfWidth;
  43813. private _action;
  43814. private _axisTargetedByLeftAndRight;
  43815. private _axisTargetedByUpAndDown;
  43816. private _joystickSensibility;
  43817. private _inversedSensibility;
  43818. private _joystickPointerID;
  43819. private _joystickColor;
  43820. private _joystickPointerPos;
  43821. private _joystickPreviousPointerPos;
  43822. private _joystickPointerStartPos;
  43823. private _deltaJoystickVector;
  43824. private _leftJoystick;
  43825. private _touches;
  43826. private _onPointerDownHandlerRef;
  43827. private _onPointerMoveHandlerRef;
  43828. private _onPointerUpHandlerRef;
  43829. private _onResize;
  43830. /**
  43831. * Creates a new virtual joystick
  43832. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43833. */
  43834. constructor(leftJoystick?: boolean);
  43835. /**
  43836. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43837. * @param newJoystickSensibility defines the new sensibility
  43838. */
  43839. setJoystickSensibility(newJoystickSensibility: number): void;
  43840. private _onPointerDown;
  43841. private _onPointerMove;
  43842. private _onPointerUp;
  43843. /**
  43844. * Change the color of the virtual joystick
  43845. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43846. */
  43847. setJoystickColor(newColor: string): void;
  43848. /**
  43849. * Defines a callback to call when the joystick is touched
  43850. * @param action defines the callback
  43851. */
  43852. setActionOnTouch(action: () => any): void;
  43853. /**
  43854. * Defines which axis you'd like to control for left & right
  43855. * @param axis defines the axis to use
  43856. */
  43857. setAxisForLeftRight(axis: JoystickAxis): void;
  43858. /**
  43859. * Defines which axis you'd like to control for up & down
  43860. * @param axis defines the axis to use
  43861. */
  43862. setAxisForUpDown(axis: JoystickAxis): void;
  43863. private _drawVirtualJoystick;
  43864. /**
  43865. * Release internal HTML canvas
  43866. */
  43867. releaseCanvas(): void;
  43868. }
  43869. }
  43870. declare module BABYLON {
  43871. interface FreeCameraInputsManager {
  43872. /**
  43873. * Add virtual joystick input support to the input manager.
  43874. * @returns the current input manager
  43875. */
  43876. addVirtualJoystick(): FreeCameraInputsManager;
  43877. }
  43878. /**
  43879. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43881. */
  43882. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43883. /**
  43884. * Defines the camera the input is attached to.
  43885. */
  43886. camera: FreeCamera;
  43887. private _leftjoystick;
  43888. private _rightjoystick;
  43889. /**
  43890. * Gets the left stick of the virtual joystick.
  43891. * @returns The virtual Joystick
  43892. */
  43893. getLeftJoystick(): VirtualJoystick;
  43894. /**
  43895. * Gets the right stick of the virtual joystick.
  43896. * @returns The virtual Joystick
  43897. */
  43898. getRightJoystick(): VirtualJoystick;
  43899. /**
  43900. * Update the current camera state depending on the inputs that have been used this frame.
  43901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43902. */
  43903. checkInputs(): void;
  43904. /**
  43905. * Attach the input controls to a specific dom element to get the input from.
  43906. * @param element Defines the element the controls should be listened from
  43907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43908. */
  43909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43910. /**
  43911. * Detach the current controls from the specified dom element.
  43912. * @param element Defines the element to stop listening the inputs from
  43913. */
  43914. detachControl(element: Nullable<HTMLElement>): void;
  43915. /**
  43916. * Gets the class name of the current intput.
  43917. * @returns the class name
  43918. */
  43919. getClassName(): string;
  43920. /**
  43921. * Get the friendly name associated with the input class.
  43922. * @returns the input friendly name
  43923. */
  43924. getSimpleName(): string;
  43925. }
  43926. }
  43927. declare module BABYLON {
  43928. /**
  43929. * This represents a FPS type of camera controlled by touch.
  43930. * This is like a universal camera minus the Gamepad controls.
  43931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43932. */
  43933. export class TouchCamera extends FreeCamera {
  43934. /**
  43935. * Defines the touch sensibility for rotation.
  43936. * The higher the faster.
  43937. */
  43938. get touchAngularSensibility(): number;
  43939. set touchAngularSensibility(value: number);
  43940. /**
  43941. * Defines the touch sensibility for move.
  43942. * The higher the faster.
  43943. */
  43944. get touchMoveSensibility(): number;
  43945. set touchMoveSensibility(value: number);
  43946. /**
  43947. * Instantiates a new touch camera.
  43948. * This represents a FPS type of camera controlled by touch.
  43949. * This is like a universal camera minus the Gamepad controls.
  43950. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43951. * @param name Define the name of the camera in the scene
  43952. * @param position Define the start position of the camera in the scene
  43953. * @param scene Define the scene the camera belongs to
  43954. */
  43955. constructor(name: string, position: Vector3, scene: Scene);
  43956. /**
  43957. * Gets the current object class name.
  43958. * @return the class name
  43959. */
  43960. getClassName(): string;
  43961. /** @hidden */
  43962. _setupInputs(): void;
  43963. }
  43964. }
  43965. declare module BABYLON {
  43966. /**
  43967. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43968. * being tilted forward or back and left or right.
  43969. */
  43970. export class DeviceOrientationCamera extends FreeCamera {
  43971. private _initialQuaternion;
  43972. private _quaternionCache;
  43973. private _tmpDragQuaternion;
  43974. private _disablePointerInputWhenUsingDeviceOrientation;
  43975. /**
  43976. * Creates a new device orientation camera
  43977. * @param name The name of the camera
  43978. * @param position The start position camera
  43979. * @param scene The scene the camera belongs to
  43980. */
  43981. constructor(name: string, position: Vector3, scene: Scene);
  43982. /**
  43983. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43984. */
  43985. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43986. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43987. private _dragFactor;
  43988. /**
  43989. * Enabled turning on the y axis when the orientation sensor is active
  43990. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  43991. */
  43992. enableHorizontalDragging(dragFactor?: number): void;
  43993. /**
  43994. * Gets the current instance class name ("DeviceOrientationCamera").
  43995. * This helps avoiding instanceof at run time.
  43996. * @returns the class name
  43997. */
  43998. getClassName(): string;
  43999. /**
  44000. * @hidden
  44001. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44002. */
  44003. _checkInputs(): void;
  44004. /**
  44005. * Reset the camera to its default orientation on the specified axis only.
  44006. * @param axis The axis to reset
  44007. */
  44008. resetToCurrentRotation(axis?: Axis): void;
  44009. }
  44010. }
  44011. declare module BABYLON {
  44012. /**
  44013. * Defines supported buttons for XBox360 compatible gamepads
  44014. */
  44015. export enum Xbox360Button {
  44016. /** A */
  44017. A = 0,
  44018. /** B */
  44019. B = 1,
  44020. /** X */
  44021. X = 2,
  44022. /** Y */
  44023. Y = 3,
  44024. /** Left button */
  44025. LB = 4,
  44026. /** Right button */
  44027. RB = 5,
  44028. /** Back */
  44029. Back = 8,
  44030. /** Start */
  44031. Start = 9,
  44032. /** Left stick */
  44033. LeftStick = 10,
  44034. /** Right stick */
  44035. RightStick = 11
  44036. }
  44037. /** Defines values for XBox360 DPad */
  44038. export enum Xbox360Dpad {
  44039. /** Up */
  44040. Up = 12,
  44041. /** Down */
  44042. Down = 13,
  44043. /** Left */
  44044. Left = 14,
  44045. /** Right */
  44046. Right = 15
  44047. }
  44048. /**
  44049. * Defines a XBox360 gamepad
  44050. */
  44051. export class Xbox360Pad extends Gamepad {
  44052. private _leftTrigger;
  44053. private _rightTrigger;
  44054. private _onlefttriggerchanged;
  44055. private _onrighttriggerchanged;
  44056. private _onbuttondown;
  44057. private _onbuttonup;
  44058. private _ondpaddown;
  44059. private _ondpadup;
  44060. /** Observable raised when a button is pressed */
  44061. onButtonDownObservable: Observable<Xbox360Button>;
  44062. /** Observable raised when a button is released */
  44063. onButtonUpObservable: Observable<Xbox360Button>;
  44064. /** Observable raised when a pad is pressed */
  44065. onPadDownObservable: Observable<Xbox360Dpad>;
  44066. /** Observable raised when a pad is released */
  44067. onPadUpObservable: Observable<Xbox360Dpad>;
  44068. private _buttonA;
  44069. private _buttonB;
  44070. private _buttonX;
  44071. private _buttonY;
  44072. private _buttonBack;
  44073. private _buttonStart;
  44074. private _buttonLB;
  44075. private _buttonRB;
  44076. private _buttonLeftStick;
  44077. private _buttonRightStick;
  44078. private _dPadUp;
  44079. private _dPadDown;
  44080. private _dPadLeft;
  44081. private _dPadRight;
  44082. private _isXboxOnePad;
  44083. /**
  44084. * Creates a new XBox360 gamepad object
  44085. * @param id defines the id of this gamepad
  44086. * @param index defines its index
  44087. * @param gamepad defines the internal HTML gamepad object
  44088. * @param xboxOne defines if it is a XBox One gamepad
  44089. */
  44090. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44091. /**
  44092. * Defines the callback to call when left trigger is pressed
  44093. * @param callback defines the callback to use
  44094. */
  44095. onlefttriggerchanged(callback: (value: number) => void): void;
  44096. /**
  44097. * Defines the callback to call when right trigger is pressed
  44098. * @param callback defines the callback to use
  44099. */
  44100. onrighttriggerchanged(callback: (value: number) => void): void;
  44101. /**
  44102. * Gets the left trigger value
  44103. */
  44104. get leftTrigger(): number;
  44105. /**
  44106. * Sets the left trigger value
  44107. */
  44108. set leftTrigger(newValue: number);
  44109. /**
  44110. * Gets the right trigger value
  44111. */
  44112. get rightTrigger(): number;
  44113. /**
  44114. * Sets the right trigger value
  44115. */
  44116. set rightTrigger(newValue: number);
  44117. /**
  44118. * Defines the callback to call when a button is pressed
  44119. * @param callback defines the callback to use
  44120. */
  44121. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44122. /**
  44123. * Defines the callback to call when a button is released
  44124. * @param callback defines the callback to use
  44125. */
  44126. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44127. /**
  44128. * Defines the callback to call when a pad is pressed
  44129. * @param callback defines the callback to use
  44130. */
  44131. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44132. /**
  44133. * Defines the callback to call when a pad is released
  44134. * @param callback defines the callback to use
  44135. */
  44136. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44137. private _setButtonValue;
  44138. private _setDPadValue;
  44139. /**
  44140. * Gets the value of the `A` button
  44141. */
  44142. get buttonA(): number;
  44143. /**
  44144. * Sets the value of the `A` button
  44145. */
  44146. set buttonA(value: number);
  44147. /**
  44148. * Gets the value of the `B` button
  44149. */
  44150. get buttonB(): number;
  44151. /**
  44152. * Sets the value of the `B` button
  44153. */
  44154. set buttonB(value: number);
  44155. /**
  44156. * Gets the value of the `X` button
  44157. */
  44158. get buttonX(): number;
  44159. /**
  44160. * Sets the value of the `X` button
  44161. */
  44162. set buttonX(value: number);
  44163. /**
  44164. * Gets the value of the `Y` button
  44165. */
  44166. get buttonY(): number;
  44167. /**
  44168. * Sets the value of the `Y` button
  44169. */
  44170. set buttonY(value: number);
  44171. /**
  44172. * Gets the value of the `Start` button
  44173. */
  44174. get buttonStart(): number;
  44175. /**
  44176. * Sets the value of the `Start` button
  44177. */
  44178. set buttonStart(value: number);
  44179. /**
  44180. * Gets the value of the `Back` button
  44181. */
  44182. get buttonBack(): number;
  44183. /**
  44184. * Sets the value of the `Back` button
  44185. */
  44186. set buttonBack(value: number);
  44187. /**
  44188. * Gets the value of the `Left` button
  44189. */
  44190. get buttonLB(): number;
  44191. /**
  44192. * Sets the value of the `Left` button
  44193. */
  44194. set buttonLB(value: number);
  44195. /**
  44196. * Gets the value of the `Right` button
  44197. */
  44198. get buttonRB(): number;
  44199. /**
  44200. * Sets the value of the `Right` button
  44201. */
  44202. set buttonRB(value: number);
  44203. /**
  44204. * Gets the value of the Left joystick
  44205. */
  44206. get buttonLeftStick(): number;
  44207. /**
  44208. * Sets the value of the Left joystick
  44209. */
  44210. set buttonLeftStick(value: number);
  44211. /**
  44212. * Gets the value of the Right joystick
  44213. */
  44214. get buttonRightStick(): number;
  44215. /**
  44216. * Sets the value of the Right joystick
  44217. */
  44218. set buttonRightStick(value: number);
  44219. /**
  44220. * Gets the value of D-pad up
  44221. */
  44222. get dPadUp(): number;
  44223. /**
  44224. * Sets the value of D-pad up
  44225. */
  44226. set dPadUp(value: number);
  44227. /**
  44228. * Gets the value of D-pad down
  44229. */
  44230. get dPadDown(): number;
  44231. /**
  44232. * Sets the value of D-pad down
  44233. */
  44234. set dPadDown(value: number);
  44235. /**
  44236. * Gets the value of D-pad left
  44237. */
  44238. get dPadLeft(): number;
  44239. /**
  44240. * Sets the value of D-pad left
  44241. */
  44242. set dPadLeft(value: number);
  44243. /**
  44244. * Gets the value of D-pad right
  44245. */
  44246. get dPadRight(): number;
  44247. /**
  44248. * Sets the value of D-pad right
  44249. */
  44250. set dPadRight(value: number);
  44251. /**
  44252. * Force the gamepad to synchronize with device values
  44253. */
  44254. update(): void;
  44255. /**
  44256. * Disposes the gamepad
  44257. */
  44258. dispose(): void;
  44259. }
  44260. }
  44261. declare module BABYLON {
  44262. /**
  44263. * Defines supported buttons for DualShock compatible gamepads
  44264. */
  44265. export enum DualShockButton {
  44266. /** Cross */
  44267. Cross = 0,
  44268. /** Circle */
  44269. Circle = 1,
  44270. /** Square */
  44271. Square = 2,
  44272. /** Triangle */
  44273. Triangle = 3,
  44274. /** L1 */
  44275. L1 = 4,
  44276. /** R1 */
  44277. R1 = 5,
  44278. /** Share */
  44279. Share = 8,
  44280. /** Options */
  44281. Options = 9,
  44282. /** Left stick */
  44283. LeftStick = 10,
  44284. /** Right stick */
  44285. RightStick = 11
  44286. }
  44287. /** Defines values for DualShock DPad */
  44288. export enum DualShockDpad {
  44289. /** Up */
  44290. Up = 12,
  44291. /** Down */
  44292. Down = 13,
  44293. /** Left */
  44294. Left = 14,
  44295. /** Right */
  44296. Right = 15
  44297. }
  44298. /**
  44299. * Defines a DualShock gamepad
  44300. */
  44301. export class DualShockPad extends Gamepad {
  44302. private _leftTrigger;
  44303. private _rightTrigger;
  44304. private _onlefttriggerchanged;
  44305. private _onrighttriggerchanged;
  44306. private _onbuttondown;
  44307. private _onbuttonup;
  44308. private _ondpaddown;
  44309. private _ondpadup;
  44310. /** Observable raised when a button is pressed */
  44311. onButtonDownObservable: Observable<DualShockButton>;
  44312. /** Observable raised when a button is released */
  44313. onButtonUpObservable: Observable<DualShockButton>;
  44314. /** Observable raised when a pad is pressed */
  44315. onPadDownObservable: Observable<DualShockDpad>;
  44316. /** Observable raised when a pad is released */
  44317. onPadUpObservable: Observable<DualShockDpad>;
  44318. private _buttonCross;
  44319. private _buttonCircle;
  44320. private _buttonSquare;
  44321. private _buttonTriangle;
  44322. private _buttonShare;
  44323. private _buttonOptions;
  44324. private _buttonL1;
  44325. private _buttonR1;
  44326. private _buttonLeftStick;
  44327. private _buttonRightStick;
  44328. private _dPadUp;
  44329. private _dPadDown;
  44330. private _dPadLeft;
  44331. private _dPadRight;
  44332. /**
  44333. * Creates a new DualShock gamepad object
  44334. * @param id defines the id of this gamepad
  44335. * @param index defines its index
  44336. * @param gamepad defines the internal HTML gamepad object
  44337. */
  44338. constructor(id: string, index: number, gamepad: any);
  44339. /**
  44340. * Defines the callback to call when left trigger is pressed
  44341. * @param callback defines the callback to use
  44342. */
  44343. onlefttriggerchanged(callback: (value: number) => void): void;
  44344. /**
  44345. * Defines the callback to call when right trigger is pressed
  44346. * @param callback defines the callback to use
  44347. */
  44348. onrighttriggerchanged(callback: (value: number) => void): void;
  44349. /**
  44350. * Gets the left trigger value
  44351. */
  44352. get leftTrigger(): number;
  44353. /**
  44354. * Sets the left trigger value
  44355. */
  44356. set leftTrigger(newValue: number);
  44357. /**
  44358. * Gets the right trigger value
  44359. */
  44360. get rightTrigger(): number;
  44361. /**
  44362. * Sets the right trigger value
  44363. */
  44364. set rightTrigger(newValue: number);
  44365. /**
  44366. * Defines the callback to call when a button is pressed
  44367. * @param callback defines the callback to use
  44368. */
  44369. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44370. /**
  44371. * Defines the callback to call when a button is released
  44372. * @param callback defines the callback to use
  44373. */
  44374. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44375. /**
  44376. * Defines the callback to call when a pad is pressed
  44377. * @param callback defines the callback to use
  44378. */
  44379. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44380. /**
  44381. * Defines the callback to call when a pad is released
  44382. * @param callback defines the callback to use
  44383. */
  44384. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44385. private _setButtonValue;
  44386. private _setDPadValue;
  44387. /**
  44388. * Gets the value of the `Cross` button
  44389. */
  44390. get buttonCross(): number;
  44391. /**
  44392. * Sets the value of the `Cross` button
  44393. */
  44394. set buttonCross(value: number);
  44395. /**
  44396. * Gets the value of the `Circle` button
  44397. */
  44398. get buttonCircle(): number;
  44399. /**
  44400. * Sets the value of the `Circle` button
  44401. */
  44402. set buttonCircle(value: number);
  44403. /**
  44404. * Gets the value of the `Square` button
  44405. */
  44406. get buttonSquare(): number;
  44407. /**
  44408. * Sets the value of the `Square` button
  44409. */
  44410. set buttonSquare(value: number);
  44411. /**
  44412. * Gets the value of the `Triangle` button
  44413. */
  44414. get buttonTriangle(): number;
  44415. /**
  44416. * Sets the value of the `Triangle` button
  44417. */
  44418. set buttonTriangle(value: number);
  44419. /**
  44420. * Gets the value of the `Options` button
  44421. */
  44422. get buttonOptions(): number;
  44423. /**
  44424. * Sets the value of the `Options` button
  44425. */
  44426. set buttonOptions(value: number);
  44427. /**
  44428. * Gets the value of the `Share` button
  44429. */
  44430. get buttonShare(): number;
  44431. /**
  44432. * Sets the value of the `Share` button
  44433. */
  44434. set buttonShare(value: number);
  44435. /**
  44436. * Gets the value of the `L1` button
  44437. */
  44438. get buttonL1(): number;
  44439. /**
  44440. * Sets the value of the `L1` button
  44441. */
  44442. set buttonL1(value: number);
  44443. /**
  44444. * Gets the value of the `R1` button
  44445. */
  44446. get buttonR1(): number;
  44447. /**
  44448. * Sets the value of the `R1` button
  44449. */
  44450. set buttonR1(value: number);
  44451. /**
  44452. * Gets the value of the Left joystick
  44453. */
  44454. get buttonLeftStick(): number;
  44455. /**
  44456. * Sets the value of the Left joystick
  44457. */
  44458. set buttonLeftStick(value: number);
  44459. /**
  44460. * Gets the value of the Right joystick
  44461. */
  44462. get buttonRightStick(): number;
  44463. /**
  44464. * Sets the value of the Right joystick
  44465. */
  44466. set buttonRightStick(value: number);
  44467. /**
  44468. * Gets the value of D-pad up
  44469. */
  44470. get dPadUp(): number;
  44471. /**
  44472. * Sets the value of D-pad up
  44473. */
  44474. set dPadUp(value: number);
  44475. /**
  44476. * Gets the value of D-pad down
  44477. */
  44478. get dPadDown(): number;
  44479. /**
  44480. * Sets the value of D-pad down
  44481. */
  44482. set dPadDown(value: number);
  44483. /**
  44484. * Gets the value of D-pad left
  44485. */
  44486. get dPadLeft(): number;
  44487. /**
  44488. * Sets the value of D-pad left
  44489. */
  44490. set dPadLeft(value: number);
  44491. /**
  44492. * Gets the value of D-pad right
  44493. */
  44494. get dPadRight(): number;
  44495. /**
  44496. * Sets the value of D-pad right
  44497. */
  44498. set dPadRight(value: number);
  44499. /**
  44500. * Force the gamepad to synchronize with device values
  44501. */
  44502. update(): void;
  44503. /**
  44504. * Disposes the gamepad
  44505. */
  44506. dispose(): void;
  44507. }
  44508. }
  44509. declare module BABYLON {
  44510. /**
  44511. * Manager for handling gamepads
  44512. */
  44513. export class GamepadManager {
  44514. private _scene?;
  44515. private _babylonGamepads;
  44516. private _oneGamepadConnected;
  44517. /** @hidden */
  44518. _isMonitoring: boolean;
  44519. private _gamepadEventSupported;
  44520. private _gamepadSupport?;
  44521. /**
  44522. * observable to be triggered when the gamepad controller has been connected
  44523. */
  44524. onGamepadConnectedObservable: Observable<Gamepad>;
  44525. /**
  44526. * observable to be triggered when the gamepad controller has been disconnected
  44527. */
  44528. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44529. private _onGamepadConnectedEvent;
  44530. private _onGamepadDisconnectedEvent;
  44531. /**
  44532. * Initializes the gamepad manager
  44533. * @param _scene BabylonJS scene
  44534. */
  44535. constructor(_scene?: Scene | undefined);
  44536. /**
  44537. * The gamepads in the game pad manager
  44538. */
  44539. get gamepads(): Gamepad[];
  44540. /**
  44541. * Get the gamepad controllers based on type
  44542. * @param type The type of gamepad controller
  44543. * @returns Nullable gamepad
  44544. */
  44545. getGamepadByType(type?: number): Nullable<Gamepad>;
  44546. /**
  44547. * Disposes the gamepad manager
  44548. */
  44549. dispose(): void;
  44550. private _addNewGamepad;
  44551. private _startMonitoringGamepads;
  44552. private _stopMonitoringGamepads;
  44553. /** @hidden */
  44554. _checkGamepadsStatus(): void;
  44555. private _updateGamepadObjects;
  44556. }
  44557. }
  44558. declare module BABYLON {
  44559. interface Scene {
  44560. /** @hidden */
  44561. _gamepadManager: Nullable<GamepadManager>;
  44562. /**
  44563. * Gets the gamepad manager associated with the scene
  44564. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44565. */
  44566. gamepadManager: GamepadManager;
  44567. }
  44568. /**
  44569. * Interface representing a free camera inputs manager
  44570. */
  44571. interface FreeCameraInputsManager {
  44572. /**
  44573. * Adds gamepad input support to the FreeCameraInputsManager.
  44574. * @returns the FreeCameraInputsManager
  44575. */
  44576. addGamepad(): FreeCameraInputsManager;
  44577. }
  44578. /**
  44579. * Interface representing an arc rotate camera inputs manager
  44580. */
  44581. interface ArcRotateCameraInputsManager {
  44582. /**
  44583. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44584. * @returns the camera inputs manager
  44585. */
  44586. addGamepad(): ArcRotateCameraInputsManager;
  44587. }
  44588. /**
  44589. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44590. */
  44591. export class GamepadSystemSceneComponent implements ISceneComponent {
  44592. /**
  44593. * The component name helpfull to identify the component in the list of scene components.
  44594. */
  44595. readonly name: string;
  44596. /**
  44597. * The scene the component belongs to.
  44598. */
  44599. scene: Scene;
  44600. /**
  44601. * Creates a new instance of the component for the given scene
  44602. * @param scene Defines the scene to register the component in
  44603. */
  44604. constructor(scene: Scene);
  44605. /**
  44606. * Registers the component in a given scene
  44607. */
  44608. register(): void;
  44609. /**
  44610. * Rebuilds the elements related to this component in case of
  44611. * context lost for instance.
  44612. */
  44613. rebuild(): void;
  44614. /**
  44615. * Disposes the component and the associated ressources
  44616. */
  44617. dispose(): void;
  44618. private _beforeCameraUpdate;
  44619. }
  44620. }
  44621. declare module BABYLON {
  44622. /**
  44623. * 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,
  44624. * which still works and will still be found in many Playgrounds.
  44625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44626. */
  44627. export class UniversalCamera extends TouchCamera {
  44628. /**
  44629. * Defines the gamepad rotation sensiblity.
  44630. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44631. */
  44632. get gamepadAngularSensibility(): number;
  44633. set gamepadAngularSensibility(value: number);
  44634. /**
  44635. * Defines the gamepad move sensiblity.
  44636. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44637. */
  44638. get gamepadMoveSensibility(): number;
  44639. set gamepadMoveSensibility(value: number);
  44640. /**
  44641. * 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,
  44642. * which still works and will still be found in many Playgrounds.
  44643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44644. * @param name Define the name of the camera in the scene
  44645. * @param position Define the start position of the camera in the scene
  44646. * @param scene Define the scene the camera belongs to
  44647. */
  44648. constructor(name: string, position: Vector3, scene: Scene);
  44649. /**
  44650. * Gets the current object class name.
  44651. * @return the class name
  44652. */
  44653. getClassName(): string;
  44654. }
  44655. }
  44656. declare module BABYLON {
  44657. /**
  44658. * This represents a FPS type of camera. This is only here for back compat purpose.
  44659. * Please use the UniversalCamera instead as both are identical.
  44660. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44661. */
  44662. export class GamepadCamera extends UniversalCamera {
  44663. /**
  44664. * Instantiates a new Gamepad Camera
  44665. * This represents a FPS type of camera. This is only here for back compat purpose.
  44666. * Please use the UniversalCamera instead as both are identical.
  44667. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44668. * @param name Define the name of the camera in the scene
  44669. * @param position Define the start position of the camera in the scene
  44670. * @param scene Define the scene the camera belongs to
  44671. */
  44672. constructor(name: string, position: Vector3, scene: Scene);
  44673. /**
  44674. * Gets the current object class name.
  44675. * @return the class name
  44676. */
  44677. getClassName(): string;
  44678. }
  44679. }
  44680. declare module BABYLON {
  44681. /** @hidden */
  44682. export var passPixelShader: {
  44683. name: string;
  44684. shader: string;
  44685. };
  44686. }
  44687. declare module BABYLON {
  44688. /** @hidden */
  44689. export var passCubePixelShader: {
  44690. name: string;
  44691. shader: string;
  44692. };
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * PassPostProcess which produces an output the same as it's input
  44697. */
  44698. export class PassPostProcess extends PostProcess {
  44699. /**
  44700. * Creates the PassPostProcess
  44701. * @param name The name of the effect.
  44702. * @param options The required width/height ratio to downsize to before computing the render pass.
  44703. * @param camera The camera to apply the render pass to.
  44704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44705. * @param engine The engine which the post process will be applied. (default: current engine)
  44706. * @param reusable If the post process can be reused on the same frame. (default: false)
  44707. * @param textureType The type of texture to be used when performing the post processing.
  44708. * @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)
  44709. */
  44710. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44711. }
  44712. /**
  44713. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44714. */
  44715. export class PassCubePostProcess extends PostProcess {
  44716. private _face;
  44717. /**
  44718. * Gets or sets the cube face to display.
  44719. * * 0 is +X
  44720. * * 1 is -X
  44721. * * 2 is +Y
  44722. * * 3 is -Y
  44723. * * 4 is +Z
  44724. * * 5 is -Z
  44725. */
  44726. get face(): number;
  44727. set face(value: number);
  44728. /**
  44729. * Creates the PassCubePostProcess
  44730. * @param name The name of the effect.
  44731. * @param options The required width/height ratio to downsize to before computing the render pass.
  44732. * @param camera The camera to apply the render pass to.
  44733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44734. * @param engine The engine which the post process will be applied. (default: current engine)
  44735. * @param reusable If the post process can be reused on the same frame. (default: false)
  44736. * @param textureType The type of texture to be used when performing the post processing.
  44737. * @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)
  44738. */
  44739. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44740. }
  44741. }
  44742. declare module BABYLON {
  44743. /** @hidden */
  44744. export var anaglyphPixelShader: {
  44745. name: string;
  44746. shader: string;
  44747. };
  44748. }
  44749. declare module BABYLON {
  44750. /**
  44751. * Postprocess used to generate anaglyphic rendering
  44752. */
  44753. export class AnaglyphPostProcess extends PostProcess {
  44754. private _passedProcess;
  44755. /**
  44756. * Creates a new AnaglyphPostProcess
  44757. * @param name defines postprocess name
  44758. * @param options defines creation options or target ratio scale
  44759. * @param rigCameras defines cameras using this postprocess
  44760. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44761. * @param engine defines hosting engine
  44762. * @param reusable defines if the postprocess will be reused multiple times per frame
  44763. */
  44764. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44765. }
  44766. }
  44767. declare module BABYLON {
  44768. /**
  44769. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44770. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44771. */
  44772. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44773. /**
  44774. * Creates a new AnaglyphArcRotateCamera
  44775. * @param name defines camera name
  44776. * @param alpha defines alpha angle (in radians)
  44777. * @param beta defines beta angle (in radians)
  44778. * @param radius defines radius
  44779. * @param target defines camera target
  44780. * @param interaxialDistance defines distance between each color axis
  44781. * @param scene defines the hosting scene
  44782. */
  44783. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44784. /**
  44785. * Gets camera class name
  44786. * @returns AnaglyphArcRotateCamera
  44787. */
  44788. getClassName(): string;
  44789. }
  44790. }
  44791. declare module BABYLON {
  44792. /**
  44793. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44794. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44795. */
  44796. export class AnaglyphFreeCamera extends FreeCamera {
  44797. /**
  44798. * Creates a new AnaglyphFreeCamera
  44799. * @param name defines camera name
  44800. * @param position defines initial position
  44801. * @param interaxialDistance defines distance between each color axis
  44802. * @param scene defines the hosting scene
  44803. */
  44804. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44805. /**
  44806. * Gets camera class name
  44807. * @returns AnaglyphFreeCamera
  44808. */
  44809. getClassName(): string;
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /**
  44814. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44815. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44816. */
  44817. export class AnaglyphGamepadCamera extends GamepadCamera {
  44818. /**
  44819. * Creates a new AnaglyphGamepadCamera
  44820. * @param name defines camera name
  44821. * @param position defines initial position
  44822. * @param interaxialDistance defines distance between each color axis
  44823. * @param scene defines the hosting scene
  44824. */
  44825. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44826. /**
  44827. * Gets camera class name
  44828. * @returns AnaglyphGamepadCamera
  44829. */
  44830. getClassName(): string;
  44831. }
  44832. }
  44833. declare module BABYLON {
  44834. /**
  44835. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44836. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44837. */
  44838. export class AnaglyphUniversalCamera extends UniversalCamera {
  44839. /**
  44840. * Creates a new AnaglyphUniversalCamera
  44841. * @param name defines camera name
  44842. * @param position defines initial position
  44843. * @param interaxialDistance defines distance between each color axis
  44844. * @param scene defines the hosting scene
  44845. */
  44846. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44847. /**
  44848. * Gets camera class name
  44849. * @returns AnaglyphUniversalCamera
  44850. */
  44851. getClassName(): string;
  44852. }
  44853. }
  44854. declare module BABYLON {
  44855. /**
  44856. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44857. * @see http://doc.babylonjs.com/features/cameras
  44858. */
  44859. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44860. /**
  44861. * Creates a new StereoscopicArcRotateCamera
  44862. * @param name defines camera name
  44863. * @param alpha defines alpha angle (in radians)
  44864. * @param beta defines beta angle (in radians)
  44865. * @param radius defines radius
  44866. * @param target defines camera target
  44867. * @param interaxialDistance defines distance between each color axis
  44868. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44869. * @param scene defines the hosting scene
  44870. */
  44871. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44872. /**
  44873. * Gets camera class name
  44874. * @returns StereoscopicArcRotateCamera
  44875. */
  44876. getClassName(): string;
  44877. }
  44878. }
  44879. declare module BABYLON {
  44880. /**
  44881. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44882. * @see http://doc.babylonjs.com/features/cameras
  44883. */
  44884. export class StereoscopicFreeCamera extends FreeCamera {
  44885. /**
  44886. * Creates a new StereoscopicFreeCamera
  44887. * @param name defines camera name
  44888. * @param position defines initial position
  44889. * @param interaxialDistance defines distance between each color axis
  44890. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44891. * @param scene defines the hosting scene
  44892. */
  44893. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44894. /**
  44895. * Gets camera class name
  44896. * @returns StereoscopicFreeCamera
  44897. */
  44898. getClassName(): string;
  44899. }
  44900. }
  44901. declare module BABYLON {
  44902. /**
  44903. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44904. * @see http://doc.babylonjs.com/features/cameras
  44905. */
  44906. export class StereoscopicGamepadCamera extends GamepadCamera {
  44907. /**
  44908. * Creates a new StereoscopicGamepadCamera
  44909. * @param name defines camera name
  44910. * @param position defines initial position
  44911. * @param interaxialDistance defines distance between each color axis
  44912. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44913. * @param scene defines the hosting scene
  44914. */
  44915. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44916. /**
  44917. * Gets camera class name
  44918. * @returns StereoscopicGamepadCamera
  44919. */
  44920. getClassName(): string;
  44921. }
  44922. }
  44923. declare module BABYLON {
  44924. /**
  44925. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44926. * @see http://doc.babylonjs.com/features/cameras
  44927. */
  44928. export class StereoscopicUniversalCamera extends UniversalCamera {
  44929. /**
  44930. * Creates a new StereoscopicUniversalCamera
  44931. * @param name defines camera name
  44932. * @param position defines initial position
  44933. * @param interaxialDistance defines distance between each color axis
  44934. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44935. * @param scene defines the hosting scene
  44936. */
  44937. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44938. /**
  44939. * Gets camera class name
  44940. * @returns StereoscopicUniversalCamera
  44941. */
  44942. getClassName(): string;
  44943. }
  44944. }
  44945. declare module BABYLON {
  44946. /**
  44947. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44948. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44949. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44950. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44951. */
  44952. export class VirtualJoysticksCamera extends FreeCamera {
  44953. /**
  44954. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44955. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44956. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44957. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44958. * @param name Define the name of the camera in the scene
  44959. * @param position Define the start position of the camera in the scene
  44960. * @param scene Define the scene the camera belongs to
  44961. */
  44962. constructor(name: string, position: Vector3, scene: Scene);
  44963. /**
  44964. * Gets the current object class name.
  44965. * @return the class name
  44966. */
  44967. getClassName(): string;
  44968. }
  44969. }
  44970. declare module BABYLON {
  44971. /**
  44972. * This represents all the required metrics to create a VR camera.
  44973. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44974. */
  44975. export class VRCameraMetrics {
  44976. /**
  44977. * Define the horizontal resolution off the screen.
  44978. */
  44979. hResolution: number;
  44980. /**
  44981. * Define the vertical resolution off the screen.
  44982. */
  44983. vResolution: number;
  44984. /**
  44985. * Define the horizontal screen size.
  44986. */
  44987. hScreenSize: number;
  44988. /**
  44989. * Define the vertical screen size.
  44990. */
  44991. vScreenSize: number;
  44992. /**
  44993. * Define the vertical screen center position.
  44994. */
  44995. vScreenCenter: number;
  44996. /**
  44997. * Define the distance of the eyes to the screen.
  44998. */
  44999. eyeToScreenDistance: number;
  45000. /**
  45001. * Define the distance between both lenses
  45002. */
  45003. lensSeparationDistance: number;
  45004. /**
  45005. * Define the distance between both viewer's eyes.
  45006. */
  45007. interpupillaryDistance: number;
  45008. /**
  45009. * Define the distortion factor of the VR postprocess.
  45010. * Please, touch with care.
  45011. */
  45012. distortionK: number[];
  45013. /**
  45014. * Define the chromatic aberration correction factors for the VR post process.
  45015. */
  45016. chromaAbCorrection: number[];
  45017. /**
  45018. * Define the scale factor of the post process.
  45019. * The smaller the better but the slower.
  45020. */
  45021. postProcessScaleFactor: number;
  45022. /**
  45023. * Define an offset for the lens center.
  45024. */
  45025. lensCenterOffset: number;
  45026. /**
  45027. * Define if the current vr camera should compensate the distortion of the lense or not.
  45028. */
  45029. compensateDistortion: boolean;
  45030. /**
  45031. * Defines if multiview should be enabled when rendering (Default: false)
  45032. */
  45033. multiviewEnabled: boolean;
  45034. /**
  45035. * Gets the rendering aspect ratio based on the provided resolutions.
  45036. */
  45037. get aspectRatio(): number;
  45038. /**
  45039. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45040. */
  45041. get aspectRatioFov(): number;
  45042. /**
  45043. * @hidden
  45044. */
  45045. get leftHMatrix(): Matrix;
  45046. /**
  45047. * @hidden
  45048. */
  45049. get rightHMatrix(): Matrix;
  45050. /**
  45051. * @hidden
  45052. */
  45053. get leftPreViewMatrix(): Matrix;
  45054. /**
  45055. * @hidden
  45056. */
  45057. get rightPreViewMatrix(): Matrix;
  45058. /**
  45059. * Get the default VRMetrics based on the most generic setup.
  45060. * @returns the default vr metrics
  45061. */
  45062. static GetDefault(): VRCameraMetrics;
  45063. }
  45064. }
  45065. declare module BABYLON {
  45066. /** @hidden */
  45067. export var vrDistortionCorrectionPixelShader: {
  45068. name: string;
  45069. shader: string;
  45070. };
  45071. }
  45072. declare module BABYLON {
  45073. /**
  45074. * VRDistortionCorrectionPostProcess used for mobile VR
  45075. */
  45076. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45077. private _isRightEye;
  45078. private _distortionFactors;
  45079. private _postProcessScaleFactor;
  45080. private _lensCenterOffset;
  45081. private _scaleIn;
  45082. private _scaleFactor;
  45083. private _lensCenter;
  45084. /**
  45085. * Initializes the VRDistortionCorrectionPostProcess
  45086. * @param name The name of the effect.
  45087. * @param camera The camera to apply the render pass to.
  45088. * @param isRightEye If this is for the right eye distortion
  45089. * @param vrMetrics All the required metrics for the VR camera
  45090. */
  45091. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45092. }
  45093. }
  45094. declare module BABYLON {
  45095. /**
  45096. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45097. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45098. */
  45099. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45100. /**
  45101. * Creates a new VRDeviceOrientationArcRotateCamera
  45102. * @param name defines camera name
  45103. * @param alpha defines the camera rotation along the logitudinal axis
  45104. * @param beta defines the camera rotation along the latitudinal axis
  45105. * @param radius defines the camera distance from its target
  45106. * @param target defines the camera target
  45107. * @param scene defines the scene the camera belongs to
  45108. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45109. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45110. */
  45111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45112. /**
  45113. * Gets camera class name
  45114. * @returns VRDeviceOrientationArcRotateCamera
  45115. */
  45116. getClassName(): string;
  45117. }
  45118. }
  45119. declare module BABYLON {
  45120. /**
  45121. * Camera used to simulate VR rendering (based on FreeCamera)
  45122. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45123. */
  45124. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45125. /**
  45126. * Creates a new VRDeviceOrientationFreeCamera
  45127. * @param name defines camera name
  45128. * @param position defines the start position of the camera
  45129. * @param scene defines the scene the camera belongs to
  45130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45132. */
  45133. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45134. /**
  45135. * Gets camera class name
  45136. * @returns VRDeviceOrientationFreeCamera
  45137. */
  45138. getClassName(): string;
  45139. }
  45140. }
  45141. declare module BABYLON {
  45142. /**
  45143. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45144. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45145. */
  45146. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45147. /**
  45148. * Creates a new VRDeviceOrientationGamepadCamera
  45149. * @param name defines camera name
  45150. * @param position defines the start position of the camera
  45151. * @param scene defines the scene the camera belongs to
  45152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45154. */
  45155. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45156. /**
  45157. * Gets camera class name
  45158. * @returns VRDeviceOrientationGamepadCamera
  45159. */
  45160. getClassName(): string;
  45161. }
  45162. }
  45163. declare module BABYLON {
  45164. /** @hidden */
  45165. export var imageProcessingPixelShader: {
  45166. name: string;
  45167. shader: string;
  45168. };
  45169. }
  45170. declare module BABYLON {
  45171. /**
  45172. * ImageProcessingPostProcess
  45173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45174. */
  45175. export class ImageProcessingPostProcess extends PostProcess {
  45176. /**
  45177. * Default configuration related to image processing available in the PBR Material.
  45178. */
  45179. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45180. /**
  45181. * Gets the image processing configuration used either in this material.
  45182. */
  45183. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45184. /**
  45185. * Sets the Default image processing configuration used either in the this material.
  45186. *
  45187. * If sets to null, the scene one is in use.
  45188. */
  45189. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45190. /**
  45191. * Keep track of the image processing observer to allow dispose and replace.
  45192. */
  45193. private _imageProcessingObserver;
  45194. /**
  45195. * Attaches a new image processing configuration to the PBR Material.
  45196. * @param configuration
  45197. */
  45198. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45199. /**
  45200. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45201. */
  45202. get colorCurves(): Nullable<ColorCurves>;
  45203. /**
  45204. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45205. */
  45206. set colorCurves(value: Nullable<ColorCurves>);
  45207. /**
  45208. * Gets wether the color curves effect is enabled.
  45209. */
  45210. get colorCurvesEnabled(): boolean;
  45211. /**
  45212. * Sets wether the color curves effect is enabled.
  45213. */
  45214. set colorCurvesEnabled(value: boolean);
  45215. /**
  45216. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45217. */
  45218. get colorGradingTexture(): Nullable<BaseTexture>;
  45219. /**
  45220. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45221. */
  45222. set colorGradingTexture(value: Nullable<BaseTexture>);
  45223. /**
  45224. * Gets wether the color grading effect is enabled.
  45225. */
  45226. get colorGradingEnabled(): boolean;
  45227. /**
  45228. * Gets wether the color grading effect is enabled.
  45229. */
  45230. set colorGradingEnabled(value: boolean);
  45231. /**
  45232. * Gets exposure used in the effect.
  45233. */
  45234. get exposure(): number;
  45235. /**
  45236. * Sets exposure used in the effect.
  45237. */
  45238. set exposure(value: number);
  45239. /**
  45240. * Gets wether tonemapping is enabled or not.
  45241. */
  45242. get toneMappingEnabled(): boolean;
  45243. /**
  45244. * Sets wether tonemapping is enabled or not
  45245. */
  45246. set toneMappingEnabled(value: boolean);
  45247. /**
  45248. * Gets the type of tone mapping effect.
  45249. */
  45250. get toneMappingType(): number;
  45251. /**
  45252. * Sets the type of tone mapping effect.
  45253. */
  45254. set toneMappingType(value: number);
  45255. /**
  45256. * Gets contrast used in the effect.
  45257. */
  45258. get contrast(): number;
  45259. /**
  45260. * Sets contrast used in the effect.
  45261. */
  45262. set contrast(value: number);
  45263. /**
  45264. * Gets Vignette stretch size.
  45265. */
  45266. get vignetteStretch(): number;
  45267. /**
  45268. * Sets Vignette stretch size.
  45269. */
  45270. set vignetteStretch(value: number);
  45271. /**
  45272. * Gets Vignette centre X Offset.
  45273. */
  45274. get vignetteCentreX(): number;
  45275. /**
  45276. * Sets Vignette centre X Offset.
  45277. */
  45278. set vignetteCentreX(value: number);
  45279. /**
  45280. * Gets Vignette centre Y Offset.
  45281. */
  45282. get vignetteCentreY(): number;
  45283. /**
  45284. * Sets Vignette centre Y Offset.
  45285. */
  45286. set vignetteCentreY(value: number);
  45287. /**
  45288. * Gets Vignette weight or intensity of the vignette effect.
  45289. */
  45290. get vignetteWeight(): number;
  45291. /**
  45292. * Sets Vignette weight or intensity of the vignette effect.
  45293. */
  45294. set vignetteWeight(value: number);
  45295. /**
  45296. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45297. * if vignetteEnabled is set to true.
  45298. */
  45299. get vignetteColor(): Color4;
  45300. /**
  45301. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45302. * if vignetteEnabled is set to true.
  45303. */
  45304. set vignetteColor(value: Color4);
  45305. /**
  45306. * Gets Camera field of view used by the Vignette effect.
  45307. */
  45308. get vignetteCameraFov(): number;
  45309. /**
  45310. * Sets Camera field of view used by the Vignette effect.
  45311. */
  45312. set vignetteCameraFov(value: number);
  45313. /**
  45314. * Gets the vignette blend mode allowing different kind of effect.
  45315. */
  45316. get vignetteBlendMode(): number;
  45317. /**
  45318. * Sets the vignette blend mode allowing different kind of effect.
  45319. */
  45320. set vignetteBlendMode(value: number);
  45321. /**
  45322. * Gets wether the vignette effect is enabled.
  45323. */
  45324. get vignetteEnabled(): boolean;
  45325. /**
  45326. * Sets wether the vignette effect is enabled.
  45327. */
  45328. set vignetteEnabled(value: boolean);
  45329. private _fromLinearSpace;
  45330. /**
  45331. * Gets wether the input of the processing is in Gamma or Linear Space.
  45332. */
  45333. get fromLinearSpace(): boolean;
  45334. /**
  45335. * Sets wether the input of the processing is in Gamma or Linear Space.
  45336. */
  45337. set fromLinearSpace(value: boolean);
  45338. /**
  45339. * Defines cache preventing GC.
  45340. */
  45341. private _defines;
  45342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45343. /**
  45344. * "ImageProcessingPostProcess"
  45345. * @returns "ImageProcessingPostProcess"
  45346. */
  45347. getClassName(): string;
  45348. protected _updateParameters(): void;
  45349. dispose(camera?: Camera): void;
  45350. }
  45351. }
  45352. declare module BABYLON {
  45353. /**
  45354. * Class containing static functions to help procedurally build meshes
  45355. */
  45356. export class GroundBuilder {
  45357. /**
  45358. * Creates a ground mesh
  45359. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45360. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45362. * @param name defines the name of the mesh
  45363. * @param options defines the options used to create the mesh
  45364. * @param scene defines the hosting scene
  45365. * @returns the ground mesh
  45366. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45367. */
  45368. static CreateGround(name: string, options: {
  45369. width?: number;
  45370. height?: number;
  45371. subdivisions?: number;
  45372. subdivisionsX?: number;
  45373. subdivisionsY?: number;
  45374. updatable?: boolean;
  45375. }, scene: any): Mesh;
  45376. /**
  45377. * Creates a tiled ground mesh
  45378. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45379. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45380. * * 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
  45381. * * 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
  45382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45383. * @param name defines the name of the mesh
  45384. * @param options defines the options used to create the mesh
  45385. * @param scene defines the hosting scene
  45386. * @returns the tiled ground mesh
  45387. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45388. */
  45389. static CreateTiledGround(name: string, options: {
  45390. xmin: number;
  45391. zmin: number;
  45392. xmax: number;
  45393. zmax: number;
  45394. subdivisions?: {
  45395. w: number;
  45396. h: number;
  45397. };
  45398. precision?: {
  45399. w: number;
  45400. h: number;
  45401. };
  45402. updatable?: boolean;
  45403. }, scene?: Nullable<Scene>): Mesh;
  45404. /**
  45405. * Creates a ground mesh from a height map
  45406. * * The parameter `url` sets the URL of the height map image resource.
  45407. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45408. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45409. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45410. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45411. * * 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.
  45412. * * 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).
  45413. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45415. * @param name defines the name of the mesh
  45416. * @param url defines the url to the height map
  45417. * @param options defines the options used to create the mesh
  45418. * @param scene defines the hosting scene
  45419. * @returns the ground mesh
  45420. * @see https://doc.babylonjs.com/babylon101/height_map
  45421. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45422. */
  45423. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45424. width?: number;
  45425. height?: number;
  45426. subdivisions?: number;
  45427. minHeight?: number;
  45428. maxHeight?: number;
  45429. colorFilter?: Color3;
  45430. alphaFilter?: number;
  45431. updatable?: boolean;
  45432. onReady?: (mesh: GroundMesh) => void;
  45433. }, scene?: Nullable<Scene>): GroundMesh;
  45434. }
  45435. }
  45436. declare module BABYLON {
  45437. /**
  45438. * Class containing static functions to help procedurally build meshes
  45439. */
  45440. export class TorusBuilder {
  45441. /**
  45442. * Creates a torus mesh
  45443. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45444. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45445. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45447. * * 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
  45448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45449. * @param name defines the name of the mesh
  45450. * @param options defines the options used to create the mesh
  45451. * @param scene defines the hosting scene
  45452. * @returns the torus mesh
  45453. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45454. */
  45455. static CreateTorus(name: string, options: {
  45456. diameter?: number;
  45457. thickness?: number;
  45458. tessellation?: number;
  45459. updatable?: boolean;
  45460. sideOrientation?: number;
  45461. frontUVs?: Vector4;
  45462. backUVs?: Vector4;
  45463. }, scene: any): Mesh;
  45464. }
  45465. }
  45466. declare module BABYLON {
  45467. /**
  45468. * Class containing static functions to help procedurally build meshes
  45469. */
  45470. export class CylinderBuilder {
  45471. /**
  45472. * Creates a cylinder or a cone mesh
  45473. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45474. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45475. * * 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.
  45476. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45477. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45478. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45479. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45480. * * 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).
  45481. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45482. * * 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).
  45483. * * 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
  45484. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45485. * * 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
  45486. * * 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.
  45487. * * If `enclose` is false, a ring surface is one element.
  45488. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45489. * * 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
  45490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45491. * * 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
  45492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45493. * @param name defines the name of the mesh
  45494. * @param options defines the options used to create the mesh
  45495. * @param scene defines the hosting scene
  45496. * @returns the cylinder mesh
  45497. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45498. */
  45499. static CreateCylinder(name: string, options: {
  45500. height?: number;
  45501. diameterTop?: number;
  45502. diameterBottom?: number;
  45503. diameter?: number;
  45504. tessellation?: number;
  45505. subdivisions?: number;
  45506. arc?: number;
  45507. faceColors?: Color4[];
  45508. faceUV?: Vector4[];
  45509. updatable?: boolean;
  45510. hasRings?: boolean;
  45511. enclose?: boolean;
  45512. cap?: number;
  45513. sideOrientation?: number;
  45514. frontUVs?: Vector4;
  45515. backUVs?: Vector4;
  45516. }, scene: any): Mesh;
  45517. }
  45518. }
  45519. declare module BABYLON {
  45520. /**
  45521. * States of the webXR experience
  45522. */
  45523. export enum WebXRState {
  45524. /**
  45525. * Transitioning to being in XR mode
  45526. */
  45527. ENTERING_XR = 0,
  45528. /**
  45529. * Transitioning to non XR mode
  45530. */
  45531. EXITING_XR = 1,
  45532. /**
  45533. * In XR mode and presenting
  45534. */
  45535. IN_XR = 2,
  45536. /**
  45537. * Not entered XR mode
  45538. */
  45539. NOT_IN_XR = 3
  45540. }
  45541. /**
  45542. * Abstraction of the XR render target
  45543. */
  45544. export interface WebXRRenderTarget extends IDisposable {
  45545. /**
  45546. * xrpresent context of the canvas which can be used to display/mirror xr content
  45547. */
  45548. canvasContext: WebGLRenderingContext;
  45549. /**
  45550. * xr layer for the canvas
  45551. */
  45552. xrLayer: Nullable<XRWebGLLayer>;
  45553. /**
  45554. * Initializes the xr layer for the session
  45555. * @param xrSession xr session
  45556. * @returns a promise that will resolve once the XR Layer has been created
  45557. */
  45558. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * COnfiguration object for WebXR output canvas
  45564. */
  45565. export class WebXRManagedOutputCanvasOptions {
  45566. /**
  45567. * An optional canvas in case you wish to create it yourself and provide it here.
  45568. * If not provided, a new canvas will be created
  45569. */
  45570. canvasElement?: HTMLCanvasElement;
  45571. /**
  45572. * Options for this XR Layer output
  45573. */
  45574. canvasOptions?: XRWebGLLayerOptions;
  45575. /**
  45576. * CSS styling for a newly created canvas (if not provided)
  45577. */
  45578. newCanvasCssStyle?: string;
  45579. /**
  45580. * Get the default values of the configuration object
  45581. * @returns default values of this configuration object
  45582. */
  45583. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45584. }
  45585. /**
  45586. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45587. */
  45588. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45589. private _options;
  45590. private _canvas;
  45591. private _engine;
  45592. /**
  45593. * Rendering context of the canvas which can be used to display/mirror xr content
  45594. */
  45595. canvasContext: WebGLRenderingContext;
  45596. /**
  45597. * xr layer for the canvas
  45598. */
  45599. xrLayer: Nullable<XRWebGLLayer>;
  45600. /**
  45601. * Initializes the canvas to be added/removed upon entering/exiting xr
  45602. * @param _xrSessionManager The XR Session manager
  45603. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45604. */
  45605. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45606. /**
  45607. * Disposes of the object
  45608. */
  45609. dispose(): void;
  45610. /**
  45611. * Initializes the xr layer for the session
  45612. * @param xrSession xr session
  45613. * @returns a promise that will resolve once the XR Layer has been created
  45614. */
  45615. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45616. private _addCanvas;
  45617. private _removeCanvas;
  45618. private _setManagedOutputCanvas;
  45619. }
  45620. }
  45621. declare module BABYLON {
  45622. /**
  45623. * Manages an XRSession to work with Babylon's engine
  45624. * @see https://doc.babylonjs.com/how_to/webxr
  45625. */
  45626. export class WebXRSessionManager implements IDisposable {
  45627. /** The scene which the session should be created for */
  45628. scene: Scene;
  45629. private _referenceSpace;
  45630. private _rttProvider;
  45631. private _sessionEnded;
  45632. private _xrNavigator;
  45633. private baseLayer;
  45634. /**
  45635. * The base reference space from which the session started. good if you want to reset your
  45636. * reference space
  45637. */
  45638. baseReferenceSpace: XRReferenceSpace;
  45639. /**
  45640. * Current XR frame
  45641. */
  45642. currentFrame: Nullable<XRFrame>;
  45643. /** WebXR timestamp updated every frame */
  45644. currentTimestamp: number;
  45645. /**
  45646. * Used just in case of a failure to initialize an immersive session.
  45647. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45648. */
  45649. defaultHeightCompensation: number;
  45650. /**
  45651. * Fires every time a new xrFrame arrives which can be used to update the camera
  45652. */
  45653. onXRFrameObservable: Observable<XRFrame>;
  45654. /**
  45655. * Fires when the reference space changed
  45656. */
  45657. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45658. /**
  45659. * Fires when the xr session is ended either by the device or manually done
  45660. */
  45661. onXRSessionEnded: Observable<any>;
  45662. /**
  45663. * Fires when the xr session is ended either by the device or manually done
  45664. */
  45665. onXRSessionInit: Observable<XRSession>;
  45666. /**
  45667. * Underlying xr session
  45668. */
  45669. session: XRSession;
  45670. /**
  45671. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45672. * or get the offset the player is currently at.
  45673. */
  45674. viewerReferenceSpace: XRReferenceSpace;
  45675. /**
  45676. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45677. * @param scene The scene which the session should be created for
  45678. */
  45679. constructor(
  45680. /** The scene which the session should be created for */
  45681. scene: Scene);
  45682. /**
  45683. * The current reference space used in this session. This reference space can constantly change!
  45684. * It is mainly used to offset the camera's position.
  45685. */
  45686. get referenceSpace(): XRReferenceSpace;
  45687. /**
  45688. * Set a new reference space and triggers the observable
  45689. */
  45690. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45691. /**
  45692. * Disposes of the session manager
  45693. */
  45694. dispose(): void;
  45695. /**
  45696. * Stops the xrSession and restores the render loop
  45697. * @returns Promise which resolves after it exits XR
  45698. */
  45699. exitXRAsync(): Promise<void>;
  45700. /**
  45701. * Gets the correct render target texture to be rendered this frame for this eye
  45702. * @param eye the eye for which to get the render target
  45703. * @returns the render target for the specified eye
  45704. */
  45705. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45706. /**
  45707. * Creates a WebXRRenderTarget object for the XR session
  45708. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45709. * @param options optional options to provide when creating a new render target
  45710. * @returns a WebXR render target to which the session can render
  45711. */
  45712. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45713. /**
  45714. * Initializes the manager
  45715. * After initialization enterXR can be called to start an XR session
  45716. * @returns Promise which resolves after it is initialized
  45717. */
  45718. initializeAsync(): Promise<void>;
  45719. /**
  45720. * Initializes an xr session
  45721. * @param xrSessionMode mode to initialize
  45722. * @param xrSessionInit defines optional and required values to pass to the session builder
  45723. * @returns a promise which will resolve once the session has been initialized
  45724. */
  45725. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45726. /**
  45727. * Checks if a session would be supported for the creation options specified
  45728. * @param sessionMode session mode to check if supported eg. immersive-vr
  45729. * @returns A Promise that resolves to true if supported and false if not
  45730. */
  45731. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45732. /**
  45733. * Resets the reference space to the one started the session
  45734. */
  45735. resetReferenceSpace(): void;
  45736. /**
  45737. * Starts rendering to the xr layer
  45738. */
  45739. runXRRenderLoop(): void;
  45740. /**
  45741. * Sets the reference space on the xr session
  45742. * @param referenceSpaceType space to set
  45743. * @returns a promise that will resolve once the reference space has been set
  45744. */
  45745. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45746. /**
  45747. * Updates the render state of the session
  45748. * @param state state to set
  45749. * @returns a promise that resolves once the render state has been updated
  45750. */
  45751. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45752. /**
  45753. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45754. * @param sessionMode defines the session to test
  45755. * @returns a promise with boolean as final value
  45756. */
  45757. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45758. private _createRenderTargetTexture;
  45759. }
  45760. }
  45761. declare module BABYLON {
  45762. /**
  45763. * WebXR Camera which holds the views for the xrSession
  45764. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45765. */
  45766. export class WebXRCamera extends FreeCamera {
  45767. private _xrSessionManager;
  45768. private _firstFrame;
  45769. private _referenceQuaternion;
  45770. private _referencedPosition;
  45771. private _xrInvPositionCache;
  45772. private _xrInvQuaternionCache;
  45773. /**
  45774. * Should position compensation execute on first frame.
  45775. * This is used when copying the position from a native (non XR) camera
  45776. */
  45777. compensateOnFirstFrame: boolean;
  45778. /**
  45779. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45780. * @param name the name of the camera
  45781. * @param scene the scene to add the camera to
  45782. * @param _xrSessionManager a constructed xr session manager
  45783. */
  45784. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45785. /**
  45786. * Return the user's height, unrelated to the current ground.
  45787. * This will be the y position of this camera, when ground level is 0.
  45788. */
  45789. get realWorldHeight(): number;
  45790. /** @hidden */
  45791. _updateForDualEyeDebugging(): void;
  45792. /**
  45793. * Sets this camera's transformation based on a non-vr camera
  45794. * @param otherCamera the non-vr camera to copy the transformation from
  45795. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45796. */
  45797. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45798. /**
  45799. * Gets the current instance class name ("WebXRCamera").
  45800. * @returns the class name
  45801. */
  45802. getClassName(): string;
  45803. /**
  45804. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45805. */
  45806. _getViewMatrix(): Matrix;
  45807. private _updateFromXRSession;
  45808. private _updateNumberOfRigCameras;
  45809. private _updateReferenceSpace;
  45810. private _updateReferenceSpaceOffset;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * Defining the interface required for a (webxr) feature
  45816. */
  45817. export interface IWebXRFeature extends IDisposable {
  45818. /**
  45819. * Is this feature attached
  45820. */
  45821. attached: boolean;
  45822. /**
  45823. * Should auto-attach be disabled?
  45824. */
  45825. disableAutoAttach: boolean;
  45826. /**
  45827. * Attach the feature to the session
  45828. * Will usually be called by the features manager
  45829. *
  45830. * @param force should attachment be forced (even when already attached)
  45831. * @returns true if successful.
  45832. */
  45833. attach(force?: boolean): boolean;
  45834. /**
  45835. * Detach the feature from the session
  45836. * Will usually be called by the features manager
  45837. *
  45838. * @returns true if successful.
  45839. */
  45840. detach(): boolean;
  45841. }
  45842. /**
  45843. * A list of the currently available features without referencing them
  45844. */
  45845. export class WebXRFeatureName {
  45846. /**
  45847. * The name of the anchor system feature
  45848. */
  45849. static ANCHOR_SYSTEM: string;
  45850. /**
  45851. * The name of the background remover feature
  45852. */
  45853. static BACKGROUND_REMOVER: string;
  45854. /**
  45855. * The name of the hit test feature
  45856. */
  45857. static HIT_TEST: string;
  45858. /**
  45859. * physics impostors for xr controllers feature
  45860. */
  45861. static PHYSICS_CONTROLLERS: string;
  45862. /**
  45863. * The name of the plane detection feature
  45864. */
  45865. static PLANE_DETECTION: string;
  45866. /**
  45867. * The name of the pointer selection feature
  45868. */
  45869. static POINTER_SELECTION: string;
  45870. /**
  45871. * The name of the teleportation feature
  45872. */
  45873. static TELEPORTATION: string;
  45874. }
  45875. /**
  45876. * Defining the constructor of a feature. Used to register the modules.
  45877. */
  45878. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45879. /**
  45880. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45881. * It is mainly used in AR sessions.
  45882. *
  45883. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45884. */
  45885. export class WebXRFeaturesManager implements IDisposable {
  45886. private _xrSessionManager;
  45887. private static readonly _AvailableFeatures;
  45888. private _features;
  45889. /**
  45890. * constructs a new features manages.
  45891. *
  45892. * @param _xrSessionManager an instance of WebXRSessionManager
  45893. */
  45894. constructor(_xrSessionManager: WebXRSessionManager);
  45895. /**
  45896. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45897. * Mainly used internally.
  45898. *
  45899. * @param featureName the name of the feature to register
  45900. * @param constructorFunction the function used to construct the module
  45901. * @param version the (babylon) version of the module
  45902. * @param stable is that a stable version of this module
  45903. */
  45904. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45905. /**
  45906. * Returns a constructor of a specific feature.
  45907. *
  45908. * @param featureName the name of the feature to construct
  45909. * @param version the version of the feature to load
  45910. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45911. * @param options optional options provided to the module.
  45912. * @returns a function that, when called, will return a new instance of this feature
  45913. */
  45914. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45915. /**
  45916. * Can be used to return the list of features currently registered
  45917. *
  45918. * @returns an Array of available features
  45919. */
  45920. static GetAvailableFeatures(): string[];
  45921. /**
  45922. * Gets the versions available for a specific feature
  45923. * @param featureName the name of the feature
  45924. * @returns an array with the available versions
  45925. */
  45926. static GetAvailableVersions(featureName: string): string[];
  45927. /**
  45928. * Return the latest unstable version of this feature
  45929. * @param featureName the name of the feature to search
  45930. * @returns the version number. if not found will return -1
  45931. */
  45932. static GetLatestVersionOfFeature(featureName: string): number;
  45933. /**
  45934. * Return the latest stable version of this feature
  45935. * @param featureName the name of the feature to search
  45936. * @returns the version number. if not found will return -1
  45937. */
  45938. static GetStableVersionOfFeature(featureName: string): number;
  45939. /**
  45940. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45941. * Can be used during a session to start a feature
  45942. * @param featureName the name of feature to attach
  45943. */
  45944. attachFeature(featureName: string): void;
  45945. /**
  45946. * Can be used inside a session or when the session ends to detach a specific feature
  45947. * @param featureName the name of the feature to detach
  45948. */
  45949. detachFeature(featureName: string): void;
  45950. /**
  45951. * Used to disable an already-enabled feature
  45952. * The feature will be disposed and will be recreated once enabled.
  45953. * @param featureName the feature to disable
  45954. * @returns true if disable was successful
  45955. */
  45956. disableFeature(featureName: string | {
  45957. Name: string;
  45958. }): boolean;
  45959. /**
  45960. * dispose this features manager
  45961. */
  45962. dispose(): void;
  45963. /**
  45964. * 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.
  45965. * 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.
  45966. *
  45967. * @param featureName the name of the feature to load or the class of the feature
  45968. * @param version optional version to load. if not provided the latest version will be enabled
  45969. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45970. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45971. * @returns a new constructed feature or throws an error if feature not found.
  45972. */
  45973. enableFeature(featureName: string | {
  45974. Name: string;
  45975. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45976. /**
  45977. * get the implementation of an enabled feature.
  45978. * @param featureName the name of the feature to load
  45979. * @returns the feature class, if found
  45980. */
  45981. getEnabledFeature(featureName: string): IWebXRFeature;
  45982. /**
  45983. * Get the list of enabled features
  45984. * @returns an array of enabled features
  45985. */
  45986. getEnabledFeatures(): string[];
  45987. }
  45988. }
  45989. declare module BABYLON {
  45990. /**
  45991. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45992. * @see https://doc.babylonjs.com/how_to/webxr
  45993. */
  45994. export class WebXRExperienceHelper implements IDisposable {
  45995. private scene;
  45996. private _nonVRCamera;
  45997. private _originalSceneAutoClear;
  45998. private _supported;
  45999. /**
  46000. * Camera used to render xr content
  46001. */
  46002. camera: WebXRCamera;
  46003. /** A features manager for this xr session */
  46004. featuresManager: WebXRFeaturesManager;
  46005. /**
  46006. * Observers registered here will be triggered after the camera's initial transformation is set
  46007. * This can be used to set a different ground level or an extra rotation.
  46008. *
  46009. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46010. * to the position set after this observable is done executing.
  46011. */
  46012. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46013. /**
  46014. * Fires when the state of the experience helper has changed
  46015. */
  46016. onStateChangedObservable: Observable<WebXRState>;
  46017. /** Session manager used to keep track of xr session */
  46018. sessionManager: WebXRSessionManager;
  46019. /**
  46020. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46021. */
  46022. state: WebXRState;
  46023. /**
  46024. * Creates a WebXRExperienceHelper
  46025. * @param scene The scene the helper should be created in
  46026. */
  46027. private constructor();
  46028. /**
  46029. * Creates the experience helper
  46030. * @param scene the scene to attach the experience helper to
  46031. * @returns a promise for the experience helper
  46032. */
  46033. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46034. /**
  46035. * Disposes of the experience helper
  46036. */
  46037. dispose(): void;
  46038. /**
  46039. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46040. * @param sessionMode options for the XR session
  46041. * @param referenceSpaceType frame of reference of the XR session
  46042. * @param renderTarget the output canvas that will be used to enter XR mode
  46043. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46044. * @returns promise that resolves after xr mode has entered
  46045. */
  46046. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46047. /**
  46048. * Exits XR mode and returns the scene to its original state
  46049. * @returns promise that resolves after xr mode has exited
  46050. */
  46051. exitXRAsync(): Promise<void>;
  46052. private _nonXRToXRCamera;
  46053. private _setState;
  46054. }
  46055. }
  46056. declare module BABYLON {
  46057. /**
  46058. * X-Y values for axes in WebXR
  46059. */
  46060. export interface IWebXRMotionControllerAxesValue {
  46061. /**
  46062. * The value of the x axis
  46063. */
  46064. x: number;
  46065. /**
  46066. * The value of the y-axis
  46067. */
  46068. y: number;
  46069. }
  46070. /**
  46071. * changed / previous values for the values of this component
  46072. */
  46073. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46074. /**
  46075. * current (this frame) value
  46076. */
  46077. current: T;
  46078. /**
  46079. * previous (last change) value
  46080. */
  46081. previous: T;
  46082. }
  46083. /**
  46084. * Represents changes in the component between current frame and last values recorded
  46085. */
  46086. export interface IWebXRMotionControllerComponentChanges {
  46087. /**
  46088. * will be populated with previous and current values if axes changed
  46089. */
  46090. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46091. /**
  46092. * will be populated with previous and current values if pressed changed
  46093. */
  46094. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46095. /**
  46096. * will be populated with previous and current values if touched changed
  46097. */
  46098. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46099. /**
  46100. * will be populated with previous and current values if value changed
  46101. */
  46102. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46103. }
  46104. /**
  46105. * This class represents a single component (for example button or thumbstick) of a motion controller
  46106. */
  46107. export class WebXRControllerComponent implements IDisposable {
  46108. /**
  46109. * the id of this component
  46110. */
  46111. id: string;
  46112. /**
  46113. * the type of the component
  46114. */
  46115. type: MotionControllerComponentType;
  46116. private _buttonIndex;
  46117. private _axesIndices;
  46118. private _axes;
  46119. private _changes;
  46120. private _currentValue;
  46121. private _hasChanges;
  46122. private _pressed;
  46123. private _touched;
  46124. /**
  46125. * button component type
  46126. */
  46127. static BUTTON_TYPE: MotionControllerComponentType;
  46128. /**
  46129. * squeeze component type
  46130. */
  46131. static SQUEEZE_TYPE: MotionControllerComponentType;
  46132. /**
  46133. * Thumbstick component type
  46134. */
  46135. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46136. /**
  46137. * Touchpad component type
  46138. */
  46139. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46140. /**
  46141. * trigger component type
  46142. */
  46143. static TRIGGER_TYPE: MotionControllerComponentType;
  46144. /**
  46145. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46146. * the axes data changes
  46147. */
  46148. onAxisValueChangedObservable: Observable<{
  46149. x: number;
  46150. y: number;
  46151. }>;
  46152. /**
  46153. * Observers registered here will be triggered when the state of a button changes
  46154. * State change is either pressed / touched / value
  46155. */
  46156. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46157. /**
  46158. * Creates a new component for a motion controller.
  46159. * It is created by the motion controller itself
  46160. *
  46161. * @param id the id of this component
  46162. * @param type the type of the component
  46163. * @param _buttonIndex index in the buttons array of the gamepad
  46164. * @param _axesIndices indices of the values in the axes array of the gamepad
  46165. */
  46166. constructor(
  46167. /**
  46168. * the id of this component
  46169. */
  46170. id: string,
  46171. /**
  46172. * the type of the component
  46173. */
  46174. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46175. /**
  46176. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46177. */
  46178. get axes(): IWebXRMotionControllerAxesValue;
  46179. /**
  46180. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46181. */
  46182. get changes(): IWebXRMotionControllerComponentChanges;
  46183. /**
  46184. * Return whether or not the component changed the last frame
  46185. */
  46186. get hasChanges(): boolean;
  46187. /**
  46188. * is the button currently pressed
  46189. */
  46190. get pressed(): boolean;
  46191. /**
  46192. * is the button currently touched
  46193. */
  46194. get touched(): boolean;
  46195. /**
  46196. * Get the current value of this component
  46197. */
  46198. get value(): number;
  46199. /**
  46200. * Dispose this component
  46201. */
  46202. dispose(): void;
  46203. /**
  46204. * Are there axes correlating to this component
  46205. * @return true is axes data is available
  46206. */
  46207. isAxes(): boolean;
  46208. /**
  46209. * Is this component a button (hence - pressable)
  46210. * @returns true if can be pressed
  46211. */
  46212. isButton(): boolean;
  46213. /**
  46214. * update this component using the gamepad object it is in. Called on every frame
  46215. * @param nativeController the native gamepad controller object
  46216. */
  46217. update(nativeController: IMinimalMotionControllerObject): void;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /**
  46222. * Class used to represent data loading progression
  46223. */
  46224. export class SceneLoaderProgressEvent {
  46225. /** defines if data length to load can be evaluated */
  46226. readonly lengthComputable: boolean;
  46227. /** defines the loaded data length */
  46228. readonly loaded: number;
  46229. /** defines the data length to load */
  46230. readonly total: number;
  46231. /**
  46232. * Create a new progress event
  46233. * @param lengthComputable defines if data length to load can be evaluated
  46234. * @param loaded defines the loaded data length
  46235. * @param total defines the data length to load
  46236. */
  46237. constructor(
  46238. /** defines if data length to load can be evaluated */
  46239. lengthComputable: boolean,
  46240. /** defines the loaded data length */
  46241. loaded: number,
  46242. /** defines the data length to load */
  46243. total: number);
  46244. /**
  46245. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46246. * @param event defines the source event
  46247. * @returns a new SceneLoaderProgressEvent
  46248. */
  46249. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46250. }
  46251. /**
  46252. * Interface used by SceneLoader plugins to define supported file extensions
  46253. */
  46254. export interface ISceneLoaderPluginExtensions {
  46255. /**
  46256. * Defines the list of supported extensions
  46257. */
  46258. [extension: string]: {
  46259. isBinary: boolean;
  46260. };
  46261. }
  46262. /**
  46263. * Interface used by SceneLoader plugin factory
  46264. */
  46265. export interface ISceneLoaderPluginFactory {
  46266. /**
  46267. * Defines the name of the factory
  46268. */
  46269. name: string;
  46270. /**
  46271. * Function called to create a new plugin
  46272. * @return the new plugin
  46273. */
  46274. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46275. /**
  46276. * The callback that returns true if the data can be directly loaded.
  46277. * @param data string containing the file data
  46278. * @returns if the data can be loaded directly
  46279. */
  46280. canDirectLoad?(data: string): boolean;
  46281. }
  46282. /**
  46283. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46284. */
  46285. export interface ISceneLoaderPluginBase {
  46286. /**
  46287. * The friendly name of this plugin.
  46288. */
  46289. name: string;
  46290. /**
  46291. * The file extensions supported by this plugin.
  46292. */
  46293. extensions: string | ISceneLoaderPluginExtensions;
  46294. /**
  46295. * The callback called when loading from a url.
  46296. * @param scene scene loading this url
  46297. * @param url url to load
  46298. * @param onSuccess callback called when the file successfully loads
  46299. * @param onProgress callback called while file is loading (if the server supports this mode)
  46300. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46301. * @param onError callback called when the file fails to load
  46302. * @returns a file request object
  46303. */
  46304. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46305. /**
  46306. * The callback called when loading from a file object.
  46307. * @param scene scene loading this file
  46308. * @param file defines the file to load
  46309. * @param onSuccess defines the callback to call when data is loaded
  46310. * @param onProgress defines the callback to call during loading process
  46311. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46312. * @param onError defines the callback to call when an error occurs
  46313. * @returns a file request object
  46314. */
  46315. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46316. /**
  46317. * The callback that returns true if the data can be directly loaded.
  46318. * @param data string containing the file data
  46319. * @returns if the data can be loaded directly
  46320. */
  46321. canDirectLoad?(data: string): boolean;
  46322. /**
  46323. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46324. * @param scene scene loading this data
  46325. * @param data string containing the data
  46326. * @returns data to pass to the plugin
  46327. */
  46328. directLoad?(scene: Scene, data: string): any;
  46329. /**
  46330. * The callback that allows custom handling of the root url based on the response url.
  46331. * @param rootUrl the original root url
  46332. * @param responseURL the response url if available
  46333. * @returns the new root url
  46334. */
  46335. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46336. }
  46337. /**
  46338. * Interface used to define a SceneLoader plugin
  46339. */
  46340. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46341. /**
  46342. * Import meshes into a scene.
  46343. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46344. * @param scene The scene to import into
  46345. * @param data The data to import
  46346. * @param rootUrl The root url for scene and resources
  46347. * @param meshes The meshes array to import into
  46348. * @param particleSystems The particle systems array to import into
  46349. * @param skeletons The skeletons array to import into
  46350. * @param onError The callback when import fails
  46351. * @returns True if successful or false otherwise
  46352. */
  46353. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46354. /**
  46355. * Load into a scene.
  46356. * @param scene The scene to load into
  46357. * @param data The data to import
  46358. * @param rootUrl The root url for scene and resources
  46359. * @param onError The callback when import fails
  46360. * @returns True if successful or false otherwise
  46361. */
  46362. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46363. /**
  46364. * Load into an asset container.
  46365. * @param scene The scene to load into
  46366. * @param data The data to import
  46367. * @param rootUrl The root url for scene and resources
  46368. * @param onError The callback when import fails
  46369. * @returns The loaded asset container
  46370. */
  46371. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46372. }
  46373. /**
  46374. * Interface used to define an async SceneLoader plugin
  46375. */
  46376. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46377. /**
  46378. * Import meshes into a scene.
  46379. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46380. * @param scene The scene to import into
  46381. * @param data The data to import
  46382. * @param rootUrl The root url for scene and resources
  46383. * @param onProgress The callback when the load progresses
  46384. * @param fileName Defines the name of the file to load
  46385. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46386. */
  46387. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46388. meshes: AbstractMesh[];
  46389. particleSystems: IParticleSystem[];
  46390. skeletons: Skeleton[];
  46391. animationGroups: AnimationGroup[];
  46392. }>;
  46393. /**
  46394. * Load into a scene.
  46395. * @param scene The scene to load into
  46396. * @param data The data to import
  46397. * @param rootUrl The root url for scene and resources
  46398. * @param onProgress The callback when the load progresses
  46399. * @param fileName Defines the name of the file to load
  46400. * @returns Nothing
  46401. */
  46402. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46403. /**
  46404. * Load into an asset container.
  46405. * @param scene The scene to load into
  46406. * @param data The data to import
  46407. * @param rootUrl The root url for scene and resources
  46408. * @param onProgress The callback when the load progresses
  46409. * @param fileName Defines the name of the file to load
  46410. * @returns The loaded asset container
  46411. */
  46412. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46413. }
  46414. /**
  46415. * Mode that determines how to handle old animation groups before loading new ones.
  46416. */
  46417. export enum SceneLoaderAnimationGroupLoadingMode {
  46418. /**
  46419. * Reset all old animations to initial state then dispose them.
  46420. */
  46421. Clean = 0,
  46422. /**
  46423. * Stop all old animations.
  46424. */
  46425. Stop = 1,
  46426. /**
  46427. * Restart old animations from first frame.
  46428. */
  46429. Sync = 2,
  46430. /**
  46431. * Old animations remains untouched.
  46432. */
  46433. NoSync = 3
  46434. }
  46435. /**
  46436. * Class used to load scene from various file formats using registered plugins
  46437. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46438. */
  46439. export class SceneLoader {
  46440. /**
  46441. * No logging while loading
  46442. */
  46443. static readonly NO_LOGGING: number;
  46444. /**
  46445. * Minimal logging while loading
  46446. */
  46447. static readonly MINIMAL_LOGGING: number;
  46448. /**
  46449. * Summary logging while loading
  46450. */
  46451. static readonly SUMMARY_LOGGING: number;
  46452. /**
  46453. * Detailled logging while loading
  46454. */
  46455. static readonly DETAILED_LOGGING: number;
  46456. /**
  46457. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46458. */
  46459. static get ForceFullSceneLoadingForIncremental(): boolean;
  46460. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46461. /**
  46462. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46463. */
  46464. static get ShowLoadingScreen(): boolean;
  46465. static set ShowLoadingScreen(value: boolean);
  46466. /**
  46467. * Defines the current logging level (while loading the scene)
  46468. * @ignorenaming
  46469. */
  46470. static get loggingLevel(): number;
  46471. static set loggingLevel(value: number);
  46472. /**
  46473. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46474. */
  46475. static get CleanBoneMatrixWeights(): boolean;
  46476. static set CleanBoneMatrixWeights(value: boolean);
  46477. /**
  46478. * Event raised when a plugin is used to load a scene
  46479. */
  46480. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46481. private static _registeredPlugins;
  46482. private static _getDefaultPlugin;
  46483. private static _getPluginForExtension;
  46484. private static _getPluginForDirectLoad;
  46485. private static _getPluginForFilename;
  46486. private static _getDirectLoad;
  46487. private static _loadData;
  46488. private static _getFileInfo;
  46489. /**
  46490. * Gets a plugin that can load the given extension
  46491. * @param extension defines the extension to load
  46492. * @returns a plugin or null if none works
  46493. */
  46494. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46495. /**
  46496. * Gets a boolean indicating that the given extension can be loaded
  46497. * @param extension defines the extension to load
  46498. * @returns true if the extension is supported
  46499. */
  46500. static IsPluginForExtensionAvailable(extension: string): boolean;
  46501. /**
  46502. * Adds a new plugin to the list of registered plugins
  46503. * @param plugin defines the plugin to add
  46504. */
  46505. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46506. /**
  46507. * Import meshes into a scene
  46508. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46509. * @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)
  46510. * @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)
  46511. * @param scene the instance of BABYLON.Scene to append to
  46512. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46513. * @param onProgress a callback with a progress event for each file being loaded
  46514. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46515. * @param pluginExtension the extension used to determine the plugin
  46516. * @returns The loaded plugin
  46517. */
  46518. 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>;
  46519. /**
  46520. * Import meshes into a scene
  46521. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46522. * @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)
  46523. * @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)
  46524. * @param scene the instance of BABYLON.Scene to append to
  46525. * @param onProgress a callback with a progress event for each file being loaded
  46526. * @param pluginExtension the extension used to determine the plugin
  46527. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46528. */
  46529. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46530. meshes: AbstractMesh[];
  46531. particleSystems: IParticleSystem[];
  46532. skeletons: Skeleton[];
  46533. animationGroups: AnimationGroup[];
  46534. }>;
  46535. /**
  46536. * Load a scene
  46537. * @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)
  46538. * @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)
  46539. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46540. * @param onSuccess a callback with the scene when import succeeds
  46541. * @param onProgress a callback with a progress event for each file being loaded
  46542. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46543. * @param pluginExtension the extension used to determine the plugin
  46544. * @returns The loaded plugin
  46545. */
  46546. 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>;
  46547. /**
  46548. * Load a scene
  46549. * @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)
  46550. * @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)
  46551. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46552. * @param onProgress a callback with a progress event for each file being loaded
  46553. * @param pluginExtension the extension used to determine the plugin
  46554. * @returns The loaded scene
  46555. */
  46556. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46557. /**
  46558. * Append a scene
  46559. * @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)
  46560. * @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)
  46561. * @param scene is the instance of BABYLON.Scene to append to
  46562. * @param onSuccess a callback with the scene when import succeeds
  46563. * @param onProgress a callback with a progress event for each file being loaded
  46564. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46565. * @param pluginExtension the extension used to determine the plugin
  46566. * @returns The loaded plugin
  46567. */
  46568. 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>;
  46569. /**
  46570. * Append a scene
  46571. * @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)
  46572. * @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)
  46573. * @param scene is the instance of BABYLON.Scene to append to
  46574. * @param onProgress a callback with a progress event for each file being loaded
  46575. * @param pluginExtension the extension used to determine the plugin
  46576. * @returns The given scene
  46577. */
  46578. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46579. /**
  46580. * Load a scene into an asset container
  46581. * @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)
  46582. * @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)
  46583. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46584. * @param onSuccess a callback with the scene when import succeeds
  46585. * @param onProgress a callback with a progress event for each file being loaded
  46586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46587. * @param pluginExtension the extension used to determine the plugin
  46588. * @returns The loaded plugin
  46589. */
  46590. 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>;
  46591. /**
  46592. * Load a scene into an asset container
  46593. * @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)
  46594. * @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)
  46595. * @param scene is the instance of Scene to append to
  46596. * @param onProgress a callback with a progress event for each file being loaded
  46597. * @param pluginExtension the extension used to determine the plugin
  46598. * @returns The loaded asset container
  46599. */
  46600. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46601. /**
  46602. * Import animations from a file into a scene
  46603. * @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)
  46604. * @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)
  46605. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46606. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46607. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46608. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46609. * @param onSuccess a callback with the scene when import succeeds
  46610. * @param onProgress a callback with a progress event for each file being loaded
  46611. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46612. */
  46613. 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;
  46614. /**
  46615. * Import animations from a file into a scene
  46616. * @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)
  46617. * @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)
  46618. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46619. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46620. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46621. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46622. * @param onSuccess a callback with the scene when import succeeds
  46623. * @param onProgress a callback with a progress event for each file being loaded
  46624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46625. * @returns the updated scene with imported animations
  46626. */
  46627. 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>;
  46628. }
  46629. }
  46630. declare module BABYLON {
  46631. /**
  46632. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46633. */
  46634. export type MotionControllerHandedness = "none" | "left" | "right";
  46635. /**
  46636. * The type of components available in motion controllers.
  46637. * This is not the name of the component.
  46638. */
  46639. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46640. /**
  46641. * The state of a controller component
  46642. */
  46643. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46644. /**
  46645. * The schema of motion controller layout.
  46646. * No object will be initialized using this interface
  46647. * This is used just to define the profile.
  46648. */
  46649. export interface IMotionControllerLayout {
  46650. /**
  46651. * Path to load the assets. Usually relative to the base path
  46652. */
  46653. assetPath: string;
  46654. /**
  46655. * Available components (unsorted)
  46656. */
  46657. components: {
  46658. /**
  46659. * A map of component Ids
  46660. */
  46661. [componentId: string]: {
  46662. /**
  46663. * The type of input the component outputs
  46664. */
  46665. type: MotionControllerComponentType;
  46666. /**
  46667. * The indices of this component in the gamepad object
  46668. */
  46669. gamepadIndices: {
  46670. /**
  46671. * Index of button
  46672. */
  46673. button?: number;
  46674. /**
  46675. * If available, index of x-axis
  46676. */
  46677. xAxis?: number;
  46678. /**
  46679. * If available, index of y-axis
  46680. */
  46681. yAxis?: number;
  46682. };
  46683. /**
  46684. * The mesh's root node name
  46685. */
  46686. rootNodeName: string;
  46687. /**
  46688. * Animation definitions for this model
  46689. */
  46690. visualResponses: {
  46691. [stateKey: string]: {
  46692. /**
  46693. * What property will be animated
  46694. */
  46695. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46696. /**
  46697. * What states influence this visual response
  46698. */
  46699. states: MotionControllerComponentStateType[];
  46700. /**
  46701. * Type of animation - movement or visibility
  46702. */
  46703. valueNodeProperty: "transform" | "visibility";
  46704. /**
  46705. * Base node name to move. Its position will be calculated according to the min and max nodes
  46706. */
  46707. valueNodeName?: string;
  46708. /**
  46709. * Minimum movement node
  46710. */
  46711. minNodeName?: string;
  46712. /**
  46713. * Max movement node
  46714. */
  46715. maxNodeName?: string;
  46716. };
  46717. };
  46718. /**
  46719. * If touch enabled, what is the name of node to display user feedback
  46720. */
  46721. touchPointNodeName?: string;
  46722. };
  46723. };
  46724. /**
  46725. * Is it xr standard mapping or not
  46726. */
  46727. gamepadMapping: "" | "xr-standard";
  46728. /**
  46729. * Base root node of this entire model
  46730. */
  46731. rootNodeName: string;
  46732. /**
  46733. * Defines the main button component id
  46734. */
  46735. selectComponentId: string;
  46736. }
  46737. /**
  46738. * A definition for the layout map in the input profile
  46739. */
  46740. export interface IMotionControllerLayoutMap {
  46741. /**
  46742. * Layouts with handedness type as a key
  46743. */
  46744. [handedness: string]: IMotionControllerLayout;
  46745. }
  46746. /**
  46747. * The XR Input profile schema
  46748. * Profiles can be found here:
  46749. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46750. */
  46751. export interface IMotionControllerProfile {
  46752. /**
  46753. * fallback profiles for this profileId
  46754. */
  46755. fallbackProfileIds: string[];
  46756. /**
  46757. * The layout map, with handedness as key
  46758. */
  46759. layouts: IMotionControllerLayoutMap;
  46760. /**
  46761. * The id of this profile
  46762. * correlates to the profile(s) in the xrInput.profiles array
  46763. */
  46764. profileId: string;
  46765. }
  46766. /**
  46767. * A helper-interface for the 3 meshes needed for controller button animation
  46768. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46769. */
  46770. export interface IMotionControllerButtonMeshMap {
  46771. /**
  46772. * the mesh that defines the pressed value mesh position.
  46773. * This is used to find the max-position of this button
  46774. */
  46775. pressedMesh: AbstractMesh;
  46776. /**
  46777. * the mesh that defines the unpressed value mesh position.
  46778. * This is used to find the min (or initial) position of this button
  46779. */
  46780. unpressedMesh: AbstractMesh;
  46781. /**
  46782. * The mesh that will be changed when value changes
  46783. */
  46784. valueMesh: AbstractMesh;
  46785. }
  46786. /**
  46787. * A helper-interface for the 3 meshes needed for controller axis animation.
  46788. * This will be expanded when touchpad animations are fully supported
  46789. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46790. */
  46791. export interface IMotionControllerMeshMap {
  46792. /**
  46793. * the mesh that defines the maximum value mesh position.
  46794. */
  46795. maxMesh?: AbstractMesh;
  46796. /**
  46797. * the mesh that defines the minimum value mesh position.
  46798. */
  46799. minMesh?: AbstractMesh;
  46800. /**
  46801. * The mesh that will be changed when axis value changes
  46802. */
  46803. valueMesh: AbstractMesh;
  46804. }
  46805. /**
  46806. * The elements needed for change-detection of the gamepad objects in motion controllers
  46807. */
  46808. export interface IMinimalMotionControllerObject {
  46809. /**
  46810. * Available axes of this controller
  46811. */
  46812. axes: number[];
  46813. /**
  46814. * An array of available buttons
  46815. */
  46816. buttons: Array<{
  46817. /**
  46818. * Value of the button/trigger
  46819. */
  46820. value: number;
  46821. /**
  46822. * If the button/trigger is currently touched
  46823. */
  46824. touched: boolean;
  46825. /**
  46826. * If the button/trigger is currently pressed
  46827. */
  46828. pressed: boolean;
  46829. }>;
  46830. /**
  46831. * EXPERIMENTAL haptic support.
  46832. */
  46833. hapticActuators?: Array<{
  46834. pulse: (value: number, duration: number) => Promise<boolean>;
  46835. }>;
  46836. }
  46837. /**
  46838. * An Abstract Motion controller
  46839. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46840. * Each component has an observable to check for changes in value and state
  46841. */
  46842. export abstract class WebXRAbstractMotionController implements IDisposable {
  46843. protected scene: Scene;
  46844. protected layout: IMotionControllerLayout;
  46845. /**
  46846. * The gamepad object correlating to this controller
  46847. */
  46848. gamepadObject: IMinimalMotionControllerObject;
  46849. /**
  46850. * handedness (left/right/none) of this controller
  46851. */
  46852. handedness: MotionControllerHandedness;
  46853. private _initComponent;
  46854. private _modelReady;
  46855. /**
  46856. * A map of components (WebXRControllerComponent) in this motion controller
  46857. * Components have a ComponentType and can also have both button and axis definitions
  46858. */
  46859. readonly components: {
  46860. [id: string]: WebXRControllerComponent;
  46861. };
  46862. /**
  46863. * Disable the model's animation. Can be set at any time.
  46864. */
  46865. disableAnimation: boolean;
  46866. /**
  46867. * Observers registered here will be triggered when the model of this controller is done loading
  46868. */
  46869. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46870. /**
  46871. * The profile id of this motion controller
  46872. */
  46873. abstract profileId: string;
  46874. /**
  46875. * The root mesh of the model. It is null if the model was not yet initialized
  46876. */
  46877. rootMesh: Nullable<AbstractMesh>;
  46878. /**
  46879. * constructs a new abstract motion controller
  46880. * @param scene the scene to which the model of the controller will be added
  46881. * @param layout The profile layout to load
  46882. * @param gamepadObject The gamepad object correlating to this controller
  46883. * @param handedness handedness (left/right/none) of this controller
  46884. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46885. */
  46886. constructor(scene: Scene, layout: IMotionControllerLayout,
  46887. /**
  46888. * The gamepad object correlating to this controller
  46889. */
  46890. gamepadObject: IMinimalMotionControllerObject,
  46891. /**
  46892. * handedness (left/right/none) of this controller
  46893. */
  46894. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46895. /**
  46896. * Dispose this controller, the model mesh and all its components
  46897. */
  46898. dispose(): void;
  46899. /**
  46900. * Returns all components of specific type
  46901. * @param type the type to search for
  46902. * @return an array of components with this type
  46903. */
  46904. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46905. /**
  46906. * get a component based an its component id as defined in layout.components
  46907. * @param id the id of the component
  46908. * @returns the component correlates to the id or undefined if not found
  46909. */
  46910. getComponent(id: string): WebXRControllerComponent;
  46911. /**
  46912. * Get the list of components available in this motion controller
  46913. * @returns an array of strings correlating to available components
  46914. */
  46915. getComponentIds(): string[];
  46916. /**
  46917. * Get the first component of specific type
  46918. * @param type type of component to find
  46919. * @return a controller component or null if not found
  46920. */
  46921. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46922. /**
  46923. * Get the main (Select) component of this controller as defined in the layout
  46924. * @returns the main component of this controller
  46925. */
  46926. getMainComponent(): WebXRControllerComponent;
  46927. /**
  46928. * Loads the model correlating to this controller
  46929. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46930. * @returns A promise fulfilled with the result of the model loading
  46931. */
  46932. loadModel(): Promise<boolean>;
  46933. /**
  46934. * Update this model using the current XRFrame
  46935. * @param xrFrame the current xr frame to use and update the model
  46936. */
  46937. updateFromXRFrame(xrFrame: XRFrame): void;
  46938. /**
  46939. * Backwards compatibility due to a deeply-integrated typo
  46940. */
  46941. get handness(): XREye;
  46942. /**
  46943. * Pulse (vibrate) this controller
  46944. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46945. * Consecutive calls to this function will cancel the last pulse call
  46946. *
  46947. * @param value the strength of the pulse in 0.0...1.0 range
  46948. * @param duration Duration of the pulse in milliseconds
  46949. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46950. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  46951. */
  46952. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46953. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46954. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46955. /**
  46956. * Moves the axis on the controller mesh based on its current state
  46957. * @param axis the index of the axis
  46958. * @param axisValue the value of the axis which determines the meshes new position
  46959. * @hidden
  46960. */
  46961. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46962. /**
  46963. * Update the model itself with the current frame data
  46964. * @param xrFrame the frame to use for updating the model mesh
  46965. */
  46966. protected updateModel(xrFrame: XRFrame): void;
  46967. /**
  46968. * Get the filename and path for this controller's model
  46969. * @returns a map of filename and path
  46970. */
  46971. protected abstract _getFilenameAndPath(): {
  46972. filename: string;
  46973. path: string;
  46974. };
  46975. /**
  46976. * This function is called before the mesh is loaded. It checks for loading constraints.
  46977. * For example, this function can check if the GLB loader is available
  46978. * If this function returns false, the generic controller will be loaded instead
  46979. * @returns Is the client ready to load the mesh
  46980. */
  46981. protected abstract _getModelLoadingConstraints(): boolean;
  46982. /**
  46983. * This function will be called after the model was successfully loaded and can be used
  46984. * for mesh transformations before it is available for the user
  46985. * @param meshes the loaded meshes
  46986. */
  46987. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46988. /**
  46989. * Set the root mesh for this controller. Important for the WebXR controller class
  46990. * @param meshes the loaded meshes
  46991. */
  46992. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46993. /**
  46994. * A function executed each frame that updates the mesh (if needed)
  46995. * @param xrFrame the current xrFrame
  46996. */
  46997. protected abstract _updateModel(xrFrame: XRFrame): void;
  46998. private _getGenericFilenameAndPath;
  46999. private _getGenericParentMesh;
  47000. }
  47001. }
  47002. declare module BABYLON {
  47003. /**
  47004. * A generic trigger-only motion controller for WebXR
  47005. */
  47006. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47007. /**
  47008. * Static version of the profile id of this controller
  47009. */
  47010. static ProfileId: string;
  47011. profileId: string;
  47012. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47013. protected _getFilenameAndPath(): {
  47014. filename: string;
  47015. path: string;
  47016. };
  47017. protected _getModelLoadingConstraints(): boolean;
  47018. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47019. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47020. protected _updateModel(): void;
  47021. }
  47022. }
  47023. declare module BABYLON {
  47024. /**
  47025. * Class containing static functions to help procedurally build meshes
  47026. */
  47027. export class SphereBuilder {
  47028. /**
  47029. * Creates a sphere mesh
  47030. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47031. * * 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`)
  47032. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47033. * * 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
  47034. * * 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)
  47035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47036. * * 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
  47037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47038. * @param name defines the name of the mesh
  47039. * @param options defines the options used to create the mesh
  47040. * @param scene defines the hosting scene
  47041. * @returns the sphere mesh
  47042. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47043. */
  47044. static CreateSphere(name: string, options: {
  47045. segments?: number;
  47046. diameter?: number;
  47047. diameterX?: number;
  47048. diameterY?: number;
  47049. diameterZ?: number;
  47050. arc?: number;
  47051. slice?: number;
  47052. sideOrientation?: number;
  47053. frontUVs?: Vector4;
  47054. backUVs?: Vector4;
  47055. updatable?: boolean;
  47056. }, scene?: Nullable<Scene>): Mesh;
  47057. }
  47058. }
  47059. declare module BABYLON {
  47060. /**
  47061. * A profiled motion controller has its profile loaded from an online repository.
  47062. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47063. */
  47064. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47065. private _repositoryUrl;
  47066. private _buttonMeshMapping;
  47067. private _touchDots;
  47068. /**
  47069. * The profile ID of this controller. Will be populated when the controller initializes.
  47070. */
  47071. profileId: string;
  47072. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47073. dispose(): void;
  47074. protected _getFilenameAndPath(): {
  47075. filename: string;
  47076. path: string;
  47077. };
  47078. protected _getModelLoadingConstraints(): boolean;
  47079. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47080. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47081. protected _updateModel(_xrFrame: XRFrame): void;
  47082. }
  47083. }
  47084. declare module BABYLON {
  47085. /**
  47086. * A construction function type to create a new controller based on an xrInput object
  47087. */
  47088. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47089. /**
  47090. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47091. *
  47092. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47093. * it should be replaced with auto-loaded controllers.
  47094. *
  47095. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47096. */
  47097. export class WebXRMotionControllerManager {
  47098. private static _AvailableControllers;
  47099. private static _Fallbacks;
  47100. private static _ProfileLoadingPromises;
  47101. private static _ProfilesList;
  47102. /**
  47103. * The base URL of the online controller repository. Can be changed at any time.
  47104. */
  47105. static BaseRepositoryUrl: string;
  47106. /**
  47107. * Which repository gets priority - local or online
  47108. */
  47109. static PrioritizeOnlineRepository: boolean;
  47110. /**
  47111. * Use the online repository, or use only locally-defined controllers
  47112. */
  47113. static UseOnlineRepository: boolean;
  47114. /**
  47115. * Clear the cache used for profile loading and reload when requested again
  47116. */
  47117. static ClearProfilesCache(): void;
  47118. /**
  47119. * Register the default fallbacks.
  47120. * This function is called automatically when this file is imported.
  47121. */
  47122. static DefaultFallbacks(): void;
  47123. /**
  47124. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47125. * @param profileId the profile to which a fallback needs to be found
  47126. * @return an array with corresponding fallback profiles
  47127. */
  47128. static FindFallbackWithProfileId(profileId: string): string[];
  47129. /**
  47130. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47131. * The order of search:
  47132. *
  47133. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47134. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47135. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47136. * 4) return the generic trigger controller if none were found
  47137. *
  47138. * @param xrInput the xrInput to which a new controller is initialized
  47139. * @param scene the scene to which the model will be added
  47140. * @param forceProfile force a certain profile for this controller
  47141. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47142. */
  47143. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47144. /**
  47145. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47146. *
  47147. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47148. *
  47149. * @param type the profile type to register
  47150. * @param constructFunction the function to be called when loading this profile
  47151. */
  47152. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47153. /**
  47154. * Register a fallback to a specific profile.
  47155. * @param profileId the profileId that will receive the fallbacks
  47156. * @param fallbacks A list of fallback profiles
  47157. */
  47158. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47159. /**
  47160. * Will update the list of profiles available in the repository
  47161. * @return a promise that resolves to a map of profiles available online
  47162. */
  47163. static UpdateProfilesList(): Promise<{
  47164. [profile: string]: string;
  47165. }>;
  47166. private static _LoadProfileFromRepository;
  47167. private static _LoadProfilesFromAvailableControllers;
  47168. }
  47169. }
  47170. declare module BABYLON {
  47171. /**
  47172. * Configuration options for the WebXR controller creation
  47173. */
  47174. export interface IWebXRControllerOptions {
  47175. /**
  47176. * Should the controller mesh be animated when a user interacts with it
  47177. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47178. */
  47179. disableMotionControllerAnimation?: boolean;
  47180. /**
  47181. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47182. */
  47183. doNotLoadControllerMesh?: boolean;
  47184. /**
  47185. * Force a specific controller type for this controller.
  47186. * This can be used when creating your own profile or when testing different controllers
  47187. */
  47188. forceControllerProfile?: string;
  47189. /**
  47190. * Defines a rendering group ID for meshes that will be loaded.
  47191. * This is for the default controllers only.
  47192. */
  47193. renderingGroupId?: number;
  47194. }
  47195. /**
  47196. * Represents an XR controller
  47197. */
  47198. export class WebXRInputSource {
  47199. private _scene;
  47200. /** The underlying input source for the controller */
  47201. inputSource: XRInputSource;
  47202. private _options;
  47203. private _tmpVector;
  47204. private _uniqueId;
  47205. /**
  47206. * 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
  47207. */
  47208. grip?: AbstractMesh;
  47209. /**
  47210. * If available, this is the gamepad object related to this controller.
  47211. * Using this object it is possible to get click events and trackpad changes of the
  47212. * webxr controller that is currently being used.
  47213. */
  47214. motionController?: WebXRAbstractMotionController;
  47215. /**
  47216. * Event that fires when the controller is removed/disposed.
  47217. * The object provided as event data is this controller, after associated assets were disposed.
  47218. * uniqueId is still available.
  47219. */
  47220. onDisposeObservable: Observable<WebXRInputSource>;
  47221. /**
  47222. * Will be triggered when the mesh associated with the motion controller is done loading.
  47223. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47224. * A shortened version of controller -> motion controller -> on mesh loaded.
  47225. */
  47226. onMeshLoadedObservable: Observable<AbstractMesh>;
  47227. /**
  47228. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47229. */
  47230. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47231. /**
  47232. * Pointer which can be used to select objects or attach a visible laser to
  47233. */
  47234. pointer: AbstractMesh;
  47235. /**
  47236. * Creates the controller
  47237. * @see https://doc.babylonjs.com/how_to/webxr
  47238. * @param _scene the scene which the controller should be associated to
  47239. * @param inputSource the underlying input source for the controller
  47240. * @param _options options for this controller creation
  47241. */
  47242. constructor(_scene: Scene,
  47243. /** The underlying input source for the controller */
  47244. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47245. /**
  47246. * Get this controllers unique id
  47247. */
  47248. get uniqueId(): string;
  47249. /**
  47250. * Disposes of the object
  47251. */
  47252. dispose(): void;
  47253. /**
  47254. * Gets a world space ray coming from the pointer or grip
  47255. * @param result the resulting ray
  47256. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47257. */
  47258. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47259. /**
  47260. * Updates the controller pose based on the given XRFrame
  47261. * @param xrFrame xr frame to update the pose with
  47262. * @param referenceSpace reference space to use
  47263. */
  47264. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47265. }
  47266. }
  47267. declare module BABYLON {
  47268. /**
  47269. * The schema for initialization options of the XR Input class
  47270. */
  47271. export interface IWebXRInputOptions {
  47272. /**
  47273. * If set to true no model will be automatically loaded
  47274. */
  47275. doNotLoadControllerMeshes?: boolean;
  47276. /**
  47277. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47278. * If not found, the xr input profile data will be used.
  47279. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47280. */
  47281. forceInputProfile?: string;
  47282. /**
  47283. * Do not send a request to the controller repository to load the profile.
  47284. *
  47285. * Instead, use the controllers available in babylon itself.
  47286. */
  47287. disableOnlineControllerRepository?: boolean;
  47288. /**
  47289. * A custom URL for the controllers repository
  47290. */
  47291. customControllersRepositoryURL?: string;
  47292. /**
  47293. * Should the controller model's components not move according to the user input
  47294. */
  47295. disableControllerAnimation?: boolean;
  47296. /**
  47297. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47298. */
  47299. controllerOptions?: IWebXRControllerOptions;
  47300. }
  47301. /**
  47302. * XR input used to track XR inputs such as controllers/rays
  47303. */
  47304. export class WebXRInput implements IDisposable {
  47305. /**
  47306. * the xr session manager for this session
  47307. */
  47308. xrSessionManager: WebXRSessionManager;
  47309. /**
  47310. * the WebXR camera for this session. Mainly used for teleportation
  47311. */
  47312. xrCamera: WebXRCamera;
  47313. private readonly options;
  47314. /**
  47315. * XR controllers being tracked
  47316. */
  47317. controllers: Array<WebXRInputSource>;
  47318. private _frameObserver;
  47319. private _sessionEndedObserver;
  47320. private _sessionInitObserver;
  47321. /**
  47322. * Event when a controller has been connected/added
  47323. */
  47324. onControllerAddedObservable: Observable<WebXRInputSource>;
  47325. /**
  47326. * Event when a controller has been removed/disconnected
  47327. */
  47328. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47329. /**
  47330. * Initializes the WebXRInput
  47331. * @param xrSessionManager the xr session manager for this session
  47332. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47333. * @param options = initialization options for this xr input
  47334. */
  47335. constructor(
  47336. /**
  47337. * the xr session manager for this session
  47338. */
  47339. xrSessionManager: WebXRSessionManager,
  47340. /**
  47341. * the WebXR camera for this session. Mainly used for teleportation
  47342. */
  47343. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47344. private _onInputSourcesChange;
  47345. private _addAndRemoveControllers;
  47346. /**
  47347. * Disposes of the object
  47348. */
  47349. dispose(): void;
  47350. }
  47351. }
  47352. declare module BABYLON {
  47353. /**
  47354. * This is the base class for all WebXR features.
  47355. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47356. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47357. */
  47358. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47359. protected _xrSessionManager: WebXRSessionManager;
  47360. private _attached;
  47361. private _removeOnDetach;
  47362. /**
  47363. * Should auto-attach be disabled?
  47364. */
  47365. disableAutoAttach: boolean;
  47366. /**
  47367. * Construct a new (abstract) WebXR feature
  47368. * @param _xrSessionManager the xr session manager for this feature
  47369. */
  47370. constructor(_xrSessionManager: WebXRSessionManager);
  47371. /**
  47372. * Is this feature attached
  47373. */
  47374. get attached(): boolean;
  47375. /**
  47376. * attach this feature
  47377. *
  47378. * @param force should attachment be forced (even when already attached)
  47379. * @returns true if successful, false is failed or already attached
  47380. */
  47381. attach(force?: boolean): boolean;
  47382. /**
  47383. * detach this feature.
  47384. *
  47385. * @returns true if successful, false if failed or already detached
  47386. */
  47387. detach(): boolean;
  47388. /**
  47389. * Dispose this feature and all of the resources attached
  47390. */
  47391. dispose(): void;
  47392. /**
  47393. * This is used to register callbacks that will automatically be removed when detach is called.
  47394. * @param observable the observable to which the observer will be attached
  47395. * @param callback the callback to register
  47396. */
  47397. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47398. /**
  47399. * Code in this function will be executed on each xrFrame received from the browser.
  47400. * This function will not execute after the feature is detached.
  47401. * @param _xrFrame the current frame
  47402. */
  47403. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47404. }
  47405. }
  47406. declare module BABYLON {
  47407. /**
  47408. * Renders a layer on top of an existing scene
  47409. */
  47410. export class UtilityLayerRenderer implements IDisposable {
  47411. /** the original scene that will be rendered on top of */
  47412. originalScene: Scene;
  47413. private _pointerCaptures;
  47414. private _lastPointerEvents;
  47415. private static _DefaultUtilityLayer;
  47416. private static _DefaultKeepDepthUtilityLayer;
  47417. private _sharedGizmoLight;
  47418. private _renderCamera;
  47419. /**
  47420. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47421. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47422. * @returns the camera that is used when rendering the utility layer
  47423. */
  47424. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47425. /**
  47426. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47427. * @param cam the camera that should be used when rendering the utility layer
  47428. */
  47429. setRenderCamera(cam: Nullable<Camera>): void;
  47430. /**
  47431. * @hidden
  47432. * Light which used by gizmos to get light shading
  47433. */
  47434. _getSharedGizmoLight(): HemisphericLight;
  47435. /**
  47436. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47437. */
  47438. pickUtilitySceneFirst: boolean;
  47439. /**
  47440. * 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)
  47441. */
  47442. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47443. /**
  47444. * 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)
  47445. */
  47446. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47447. /**
  47448. * The scene that is rendered on top of the original scene
  47449. */
  47450. utilityLayerScene: Scene;
  47451. /**
  47452. * If the utility layer should automatically be rendered on top of existing scene
  47453. */
  47454. shouldRender: boolean;
  47455. /**
  47456. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47457. */
  47458. onlyCheckPointerDownEvents: boolean;
  47459. /**
  47460. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47461. */
  47462. processAllEvents: boolean;
  47463. /**
  47464. * Observable raised when the pointer move from the utility layer scene to the main scene
  47465. */
  47466. onPointerOutObservable: Observable<number>;
  47467. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47468. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47469. private _afterRenderObserver;
  47470. private _sceneDisposeObserver;
  47471. private _originalPointerObserver;
  47472. /**
  47473. * Instantiates a UtilityLayerRenderer
  47474. * @param originalScene the original scene that will be rendered on top of
  47475. * @param handleEvents boolean indicating if the utility layer should handle events
  47476. */
  47477. constructor(
  47478. /** the original scene that will be rendered on top of */
  47479. originalScene: Scene, handleEvents?: boolean);
  47480. private _notifyObservers;
  47481. /**
  47482. * Renders the utility layers scene on top of the original scene
  47483. */
  47484. render(): void;
  47485. /**
  47486. * Disposes of the renderer
  47487. */
  47488. dispose(): void;
  47489. private _updateCamera;
  47490. }
  47491. }
  47492. declare module BABYLON {
  47493. /**
  47494. * Options interface for the pointer selection module
  47495. */
  47496. export interface IWebXRControllerPointerSelectionOptions {
  47497. /**
  47498. * if provided, this scene will be used to render meshes.
  47499. */
  47500. customUtilityLayerScene?: Scene;
  47501. /**
  47502. * 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)
  47503. * If not disabled, the last picked point will be used to execute a pointer up event
  47504. * If disabled, pointer up event will be triggered right after the pointer down event.
  47505. * Used in screen and gaze target ray mode only
  47506. */
  47507. disablePointerUpOnTouchOut: boolean;
  47508. /**
  47509. * For gaze mode (time to select instead of press)
  47510. */
  47511. forceGazeMode: boolean;
  47512. /**
  47513. * 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
  47514. * to start a new countdown to the pointer down event.
  47515. * Defaults to 1.
  47516. */
  47517. gazeModePointerMovedFactor?: number;
  47518. /**
  47519. * Different button type to use instead of the main component
  47520. */
  47521. overrideButtonId?: string;
  47522. /**
  47523. * use this rendering group id for the meshes (optional)
  47524. */
  47525. renderingGroupId?: number;
  47526. /**
  47527. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47528. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47529. * 3000 means 3 seconds between pointing at something and selecting it
  47530. */
  47531. timeToSelect?: number;
  47532. /**
  47533. * Should meshes created here be added to a utility layer or the main scene
  47534. */
  47535. useUtilityLayer?: boolean;
  47536. /**
  47537. * the xr input to use with this pointer selection
  47538. */
  47539. xrInput: WebXRInput;
  47540. }
  47541. /**
  47542. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47543. */
  47544. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47545. private readonly _options;
  47546. private static _idCounter;
  47547. private _attachController;
  47548. private _controllers;
  47549. private _scene;
  47550. private _tmpVectorForPickCompare;
  47551. /**
  47552. * The module's name
  47553. */
  47554. static readonly Name: string;
  47555. /**
  47556. * The (Babylon) version of this module.
  47557. * This is an integer representing the implementation version.
  47558. * This number does not correspond to the WebXR specs version
  47559. */
  47560. static readonly Version: number;
  47561. /**
  47562. * Disable lighting on the laser pointer (so it will always be visible)
  47563. */
  47564. disablePointerLighting: boolean;
  47565. /**
  47566. * Disable lighting on the selection mesh (so it will always be visible)
  47567. */
  47568. disableSelectionMeshLighting: boolean;
  47569. /**
  47570. * Should the laser pointer be displayed
  47571. */
  47572. displayLaserPointer: boolean;
  47573. /**
  47574. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47575. */
  47576. displaySelectionMesh: boolean;
  47577. /**
  47578. * This color will be set to the laser pointer when selection is triggered
  47579. */
  47580. laserPointerPickedColor: Color3;
  47581. /**
  47582. * Default color of the laser pointer
  47583. */
  47584. lasterPointerDefaultColor: Color3;
  47585. /**
  47586. * default color of the selection ring
  47587. */
  47588. selectionMeshDefaultColor: Color3;
  47589. /**
  47590. * This color will be applied to the selection ring when selection is triggered
  47591. */
  47592. selectionMeshPickedColor: Color3;
  47593. /**
  47594. * Optional filter to be used for ray selection. This predicate shares behavior with
  47595. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47596. */
  47597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47598. /**
  47599. * constructs a new background remover module
  47600. * @param _xrSessionManager the session manager for this module
  47601. * @param _options read-only options to be used in this module
  47602. */
  47603. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47604. /**
  47605. * attach this feature
  47606. * Will usually be called by the features manager
  47607. *
  47608. * @returns true if successful.
  47609. */
  47610. attach(): boolean;
  47611. /**
  47612. * detach this feature.
  47613. * Will usually be called by the features manager
  47614. *
  47615. * @returns true if successful.
  47616. */
  47617. detach(): boolean;
  47618. /**
  47619. * Will get the mesh under a specific pointer.
  47620. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47621. * @param controllerId the controllerId to check
  47622. * @returns The mesh under pointer or null if no mesh is under the pointer
  47623. */
  47624. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47625. /**
  47626. * Get the xr controller that correlates to the pointer id in the pointer event
  47627. *
  47628. * @param id the pointer id to search for
  47629. * @returns the controller that correlates to this id or null if not found
  47630. */
  47631. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47632. protected _onXRFrame(_xrFrame: XRFrame): void;
  47633. private _attachGazeMode;
  47634. private _attachScreenRayMode;
  47635. private _attachTrackedPointerRayMode;
  47636. private _convertNormalToDirectionOfRay;
  47637. private _detachController;
  47638. private _generateNewMeshPair;
  47639. private _pickingMoved;
  47640. private _updatePointerDistance;
  47641. }
  47642. }
  47643. declare module BABYLON {
  47644. /**
  47645. * Button which can be used to enter a different mode of XR
  47646. */
  47647. export class WebXREnterExitUIButton {
  47648. /** button element */
  47649. element: HTMLElement;
  47650. /** XR initialization options for the button */
  47651. sessionMode: XRSessionMode;
  47652. /** Reference space type */
  47653. referenceSpaceType: XRReferenceSpaceType;
  47654. /**
  47655. * Creates a WebXREnterExitUIButton
  47656. * @param element button element
  47657. * @param sessionMode XR initialization session mode
  47658. * @param referenceSpaceType the type of reference space to be used
  47659. */
  47660. constructor(
  47661. /** button element */
  47662. element: HTMLElement,
  47663. /** XR initialization options for the button */
  47664. sessionMode: XRSessionMode,
  47665. /** Reference space type */
  47666. referenceSpaceType: XRReferenceSpaceType);
  47667. /**
  47668. * Extendable function which can be used to update the button's visuals when the state changes
  47669. * @param activeButton the current active button in the UI
  47670. */
  47671. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47672. }
  47673. /**
  47674. * Options to create the webXR UI
  47675. */
  47676. export class WebXREnterExitUIOptions {
  47677. /**
  47678. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47679. */
  47680. customButtons?: Array<WebXREnterExitUIButton>;
  47681. /**
  47682. * A reference space type to use when creating the default button.
  47683. * Default is local-floor
  47684. */
  47685. referenceSpaceType?: XRReferenceSpaceType;
  47686. /**
  47687. * Context to enter xr with
  47688. */
  47689. renderTarget?: Nullable<WebXRRenderTarget>;
  47690. /**
  47691. * A session mode to use when creating the default button.
  47692. * Default is immersive-vr
  47693. */
  47694. sessionMode?: XRSessionMode;
  47695. /**
  47696. * A list of optional features to init the session with
  47697. */
  47698. optionalFeatures?: string[];
  47699. }
  47700. /**
  47701. * UI to allow the user to enter/exit XR mode
  47702. */
  47703. export class WebXREnterExitUI implements IDisposable {
  47704. private scene;
  47705. /** version of the options passed to this UI */
  47706. options: WebXREnterExitUIOptions;
  47707. private _activeButton;
  47708. private _buttons;
  47709. private _overlay;
  47710. /**
  47711. * Fired every time the active button is changed.
  47712. *
  47713. * When xr is entered via a button that launches xr that button will be the callback parameter
  47714. *
  47715. * When exiting xr the callback parameter will be null)
  47716. */
  47717. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47718. /**
  47719. *
  47720. * @param scene babylon scene object to use
  47721. * @param options (read-only) version of the options passed to this UI
  47722. */
  47723. private constructor();
  47724. /**
  47725. * Creates UI to allow the user to enter/exit XR mode
  47726. * @param scene the scene to add the ui to
  47727. * @param helper the xr experience helper to enter/exit xr with
  47728. * @param options options to configure the UI
  47729. * @returns the created ui
  47730. */
  47731. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47732. /**
  47733. * Disposes of the XR UI component
  47734. */
  47735. dispose(): void;
  47736. private _updateButtons;
  47737. }
  47738. }
  47739. declare module BABYLON {
  47740. /**
  47741. * Class containing static functions to help procedurally build meshes
  47742. */
  47743. export class LinesBuilder {
  47744. /**
  47745. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47746. * * 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
  47747. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47748. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47749. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47750. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47751. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47752. * * 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
  47753. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47756. * @param name defines the name of the new line system
  47757. * @param options defines the options used to create the line system
  47758. * @param scene defines the hosting scene
  47759. * @returns a new line system mesh
  47760. */
  47761. static CreateLineSystem(name: string, options: {
  47762. lines: Vector3[][];
  47763. updatable?: boolean;
  47764. instance?: Nullable<LinesMesh>;
  47765. colors?: Nullable<Color4[][]>;
  47766. useVertexAlpha?: boolean;
  47767. }, scene: Nullable<Scene>): LinesMesh;
  47768. /**
  47769. * Creates a line mesh
  47770. * 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
  47771. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47772. * * The parameter `points` is an array successive Vector3
  47773. * * 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
  47774. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47775. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47776. * * When updating an instance, remember that only point positions can change, not the number of points
  47777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47779. * @param name defines the name of the new line system
  47780. * @param options defines the options used to create the line system
  47781. * @param scene defines the hosting scene
  47782. * @returns a new line mesh
  47783. */
  47784. static CreateLines(name: string, options: {
  47785. points: Vector3[];
  47786. updatable?: boolean;
  47787. instance?: Nullable<LinesMesh>;
  47788. colors?: Color4[];
  47789. useVertexAlpha?: boolean;
  47790. }, scene?: Nullable<Scene>): LinesMesh;
  47791. /**
  47792. * Creates a dashed line mesh
  47793. * * 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
  47794. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47795. * * The parameter `points` is an array successive Vector3
  47796. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47797. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47798. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47799. * * 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
  47800. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47801. * * When updating an instance, remember that only point positions can change, not the number of points
  47802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47803. * @param name defines the name of the mesh
  47804. * @param options defines the options used to create the mesh
  47805. * @param scene defines the hosting scene
  47806. * @returns the dashed line mesh
  47807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47808. */
  47809. static CreateDashedLines(name: string, options: {
  47810. points: Vector3[];
  47811. dashSize?: number;
  47812. gapSize?: number;
  47813. dashNb?: number;
  47814. updatable?: boolean;
  47815. instance?: LinesMesh;
  47816. useVertexAlpha?: boolean;
  47817. }, scene?: Nullable<Scene>): LinesMesh;
  47818. }
  47819. }
  47820. declare module BABYLON {
  47821. /**
  47822. * The options container for the teleportation module
  47823. */
  47824. export interface IWebXRTeleportationOptions {
  47825. /**
  47826. * if provided, this scene will be used to render meshes.
  47827. */
  47828. customUtilityLayerScene?: Scene;
  47829. /**
  47830. * Values to configure the default target mesh
  47831. */
  47832. defaultTargetMeshOptions?: {
  47833. /**
  47834. * Fill color of the teleportation area
  47835. */
  47836. teleportationFillColor?: string;
  47837. /**
  47838. * Border color for the teleportation area
  47839. */
  47840. teleportationBorderColor?: string;
  47841. /**
  47842. * Disable the mesh's animation sequence
  47843. */
  47844. disableAnimation?: boolean;
  47845. /**
  47846. * Disable lighting on the material or the ring and arrow
  47847. */
  47848. disableLighting?: boolean;
  47849. /**
  47850. * Override the default material of the torus and arrow
  47851. */
  47852. torusArrowMaterial?: Material;
  47853. };
  47854. /**
  47855. * A list of meshes to use as floor meshes.
  47856. * Meshes can be added and removed after initializing the feature using the
  47857. * addFloorMesh and removeFloorMesh functions
  47858. * If empty, rotation will still work
  47859. */
  47860. floorMeshes?: AbstractMesh[];
  47861. /**
  47862. * use this rendering group id for the meshes (optional)
  47863. */
  47864. renderingGroupId?: number;
  47865. /**
  47866. * Should teleportation move only to snap points
  47867. */
  47868. snapPointsOnly?: boolean;
  47869. /**
  47870. * An array of points to which the teleportation will snap to.
  47871. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47872. */
  47873. snapPositions?: Vector3[];
  47874. /**
  47875. * How close should the teleportation ray be in order to snap to position.
  47876. * Default to 0.8 units (meters)
  47877. */
  47878. snapToPositionRadius?: number;
  47879. /**
  47880. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47881. * If you want to support rotation, make sure your mesh has a direction indicator.
  47882. *
  47883. * When left untouched, the default mesh will be initialized.
  47884. */
  47885. teleportationTargetMesh?: AbstractMesh;
  47886. /**
  47887. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47888. */
  47889. timeToTeleport?: number;
  47890. /**
  47891. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47892. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47893. */
  47894. useMainComponentOnly?: boolean;
  47895. /**
  47896. * Should meshes created here be added to a utility layer or the main scene
  47897. */
  47898. useUtilityLayer?: boolean;
  47899. /**
  47900. * Babylon XR Input class for controller
  47901. */
  47902. xrInput: WebXRInput;
  47903. }
  47904. /**
  47905. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47906. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47907. * the input of the attached controllers.
  47908. */
  47909. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47910. private _options;
  47911. private _controllers;
  47912. private _currentTeleportationControllerId;
  47913. private _floorMeshes;
  47914. private _quadraticBezierCurve;
  47915. private _selectionFeature;
  47916. private _snapToPositions;
  47917. private _snappedToPoint;
  47918. private _teleportationRingMaterial?;
  47919. private _tmpRay;
  47920. private _tmpVector;
  47921. /**
  47922. * The module's name
  47923. */
  47924. static readonly Name: string;
  47925. /**
  47926. * The (Babylon) version of this module.
  47927. * This is an integer representing the implementation version.
  47928. * This number does not correspond to the webxr specs version
  47929. */
  47930. static readonly Version: number;
  47931. /**
  47932. * Is movement backwards enabled
  47933. */
  47934. backwardsMovementEnabled: boolean;
  47935. /**
  47936. * Distance to travel when moving backwards
  47937. */
  47938. backwardsTeleportationDistance: number;
  47939. /**
  47940. * The distance from the user to the inspection point in the direction of the controller
  47941. * A higher number will allow the user to move further
  47942. * defaults to 5 (meters, in xr units)
  47943. */
  47944. parabolicCheckRadius: number;
  47945. /**
  47946. * Should the module support parabolic ray on top of direct ray
  47947. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47948. * Very helpful when moving between floors / different heights
  47949. */
  47950. parabolicRayEnabled: boolean;
  47951. /**
  47952. * How much rotation should be applied when rotating right and left
  47953. */
  47954. rotationAngle: number;
  47955. /**
  47956. * Is rotation enabled when moving forward?
  47957. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47958. */
  47959. rotationEnabled: boolean;
  47960. /**
  47961. * constructs a new anchor system
  47962. * @param _xrSessionManager an instance of WebXRSessionManager
  47963. * @param _options configuration object for this feature
  47964. */
  47965. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47966. /**
  47967. * Get the snapPointsOnly flag
  47968. */
  47969. get snapPointsOnly(): boolean;
  47970. /**
  47971. * Sets the snapPointsOnly flag
  47972. * @param snapToPoints should teleportation be exclusively to snap points
  47973. */
  47974. set snapPointsOnly(snapToPoints: boolean);
  47975. /**
  47976. * Add a new mesh to the floor meshes array
  47977. * @param mesh the mesh to use as floor mesh
  47978. */
  47979. addFloorMesh(mesh: AbstractMesh): void;
  47980. /**
  47981. * Add a new snap-to point to fix teleportation to this position
  47982. * @param newSnapPoint The new Snap-To point
  47983. */
  47984. addSnapPoint(newSnapPoint: Vector3): void;
  47985. attach(): boolean;
  47986. detach(): boolean;
  47987. dispose(): void;
  47988. /**
  47989. * Remove a mesh from the floor meshes array
  47990. * @param mesh the mesh to remove
  47991. */
  47992. removeFloorMesh(mesh: AbstractMesh): void;
  47993. /**
  47994. * Remove a mesh from the floor meshes array using its name
  47995. * @param name the mesh name to remove
  47996. */
  47997. removeFloorMeshByName(name: string): void;
  47998. /**
  47999. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  48000. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48001. * @returns was the point found and removed or not
  48002. */
  48003. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48004. /**
  48005. * This function sets a selection feature that will be disabled when
  48006. * the forward ray is shown and will be reattached when hidden.
  48007. * This is used to remove the selection rays when moving.
  48008. * @param selectionFeature the feature to disable when forward movement is enabled
  48009. */
  48010. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48011. protected _onXRFrame(_xrFrame: XRFrame): void;
  48012. private _attachController;
  48013. private _createDefaultTargetMesh;
  48014. private _detachController;
  48015. private _findClosestSnapPointWithRadius;
  48016. private _setTargetMeshPosition;
  48017. private _setTargetMeshVisibility;
  48018. private _showParabolicPath;
  48019. private _teleportForward;
  48020. }
  48021. }
  48022. declare module BABYLON {
  48023. /**
  48024. * Options for the default xr helper
  48025. */
  48026. export class WebXRDefaultExperienceOptions {
  48027. /**
  48028. * Enable or disable default UI to enter XR
  48029. */
  48030. disableDefaultUI?: boolean;
  48031. /**
  48032. * Should teleportation not initialize. defaults to false.
  48033. */
  48034. disableTeleportation?: boolean;
  48035. /**
  48036. * Floor meshes that will be used for teleport
  48037. */
  48038. floorMeshes?: Array<AbstractMesh>;
  48039. /**
  48040. * If set to true, the first frame will not be used to reset position
  48041. * The first frame is mainly used when copying transformation from the old camera
  48042. * Mainly used in AR
  48043. */
  48044. ignoreNativeCameraTransformation?: boolean;
  48045. /**
  48046. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48047. */
  48048. inputOptions?: IWebXRInputOptions;
  48049. /**
  48050. * optional configuration for the output canvas
  48051. */
  48052. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48053. /**
  48054. * optional UI options. This can be used among other to change session mode and reference space type
  48055. */
  48056. uiOptions?: WebXREnterExitUIOptions;
  48057. /**
  48058. * When loading teleportation and pointer select, use stable versions instead of latest.
  48059. */
  48060. useStablePlugins?: boolean;
  48061. /**
  48062. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48063. */
  48064. renderingGroupId?: number;
  48065. /**
  48066. * A list of optional features to init the session with
  48067. * If set to true, all features we support will be added
  48068. */
  48069. optionalFeatures?: boolean | string[];
  48070. }
  48071. /**
  48072. * Default experience which provides a similar setup to the previous webVRExperience
  48073. */
  48074. export class WebXRDefaultExperience {
  48075. /**
  48076. * Base experience
  48077. */
  48078. baseExperience: WebXRExperienceHelper;
  48079. /**
  48080. * Enables ui for entering/exiting xr
  48081. */
  48082. enterExitUI: WebXREnterExitUI;
  48083. /**
  48084. * Input experience extension
  48085. */
  48086. input: WebXRInput;
  48087. /**
  48088. * Enables laser pointer and selection
  48089. */
  48090. pointerSelection: WebXRControllerPointerSelection;
  48091. /**
  48092. * Default target xr should render to
  48093. */
  48094. renderTarget: WebXRRenderTarget;
  48095. /**
  48096. * Enables teleportation
  48097. */
  48098. teleportation: WebXRMotionControllerTeleportation;
  48099. private constructor();
  48100. /**
  48101. * Creates the default xr experience
  48102. * @param scene scene
  48103. * @param options options for basic configuration
  48104. * @returns resulting WebXRDefaultExperience
  48105. */
  48106. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48107. /**
  48108. * DIsposes of the experience helper
  48109. */
  48110. dispose(): void;
  48111. }
  48112. }
  48113. declare module BABYLON {
  48114. /**
  48115. * Options to modify the vr teleportation behavior.
  48116. */
  48117. export interface VRTeleportationOptions {
  48118. /**
  48119. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48120. */
  48121. floorMeshName?: string;
  48122. /**
  48123. * A list of meshes to be used as the teleportation floor. (default: empty)
  48124. */
  48125. floorMeshes?: Mesh[];
  48126. /**
  48127. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48128. */
  48129. teleportationMode?: number;
  48130. /**
  48131. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48132. */
  48133. teleportationTime?: number;
  48134. /**
  48135. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48136. */
  48137. teleportationSpeed?: number;
  48138. /**
  48139. * The easing function used in the animation or null for Linear. (default CircleEase)
  48140. */
  48141. easingFunction?: EasingFunction;
  48142. }
  48143. /**
  48144. * Options to modify the vr experience helper's behavior.
  48145. */
  48146. export interface VRExperienceHelperOptions extends WebVROptions {
  48147. /**
  48148. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48149. */
  48150. createDeviceOrientationCamera?: boolean;
  48151. /**
  48152. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48153. */
  48154. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48155. /**
  48156. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48157. */
  48158. laserToggle?: boolean;
  48159. /**
  48160. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48161. */
  48162. floorMeshes?: Mesh[];
  48163. /**
  48164. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48165. */
  48166. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48167. /**
  48168. * Defines if WebXR should be used instead of WebVR (if available)
  48169. */
  48170. useXR?: boolean;
  48171. }
  48172. /**
  48173. * Event containing information after VR has been entered
  48174. */
  48175. export class OnAfterEnteringVRObservableEvent {
  48176. /**
  48177. * If entering vr was successful
  48178. */
  48179. success: boolean;
  48180. }
  48181. /**
  48182. * Helps to quickly add VR support to an existing scene.
  48183. * See http://doc.babylonjs.com/how_to/webvr_helper
  48184. */
  48185. export class VRExperienceHelper {
  48186. /** Options to modify the vr experience helper's behavior. */
  48187. webVROptions: VRExperienceHelperOptions;
  48188. private _scene;
  48189. private _position;
  48190. private _btnVR;
  48191. private _btnVRDisplayed;
  48192. private _webVRsupported;
  48193. private _webVRready;
  48194. private _webVRrequesting;
  48195. private _webVRpresenting;
  48196. private _hasEnteredVR;
  48197. private _fullscreenVRpresenting;
  48198. private _inputElement;
  48199. private _webVRCamera;
  48200. private _vrDeviceOrientationCamera;
  48201. private _deviceOrientationCamera;
  48202. private _existingCamera;
  48203. private _onKeyDown;
  48204. private _onVrDisplayPresentChange;
  48205. private _onVRDisplayChanged;
  48206. private _onVRRequestPresentStart;
  48207. private _onVRRequestPresentComplete;
  48208. /**
  48209. * 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)
  48210. */
  48211. enableGazeEvenWhenNoPointerLock: boolean;
  48212. /**
  48213. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48214. */
  48215. exitVROnDoubleTap: boolean;
  48216. /**
  48217. * Observable raised right before entering VR.
  48218. */
  48219. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48220. /**
  48221. * Observable raised when entering VR has completed.
  48222. */
  48223. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48224. /**
  48225. * Observable raised when exiting VR.
  48226. */
  48227. onExitingVRObservable: Observable<VRExperienceHelper>;
  48228. /**
  48229. * Observable raised when controller mesh is loaded.
  48230. */
  48231. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48232. /** Return this.onEnteringVRObservable
  48233. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48234. */
  48235. get onEnteringVR(): Observable<VRExperienceHelper>;
  48236. /** Return this.onExitingVRObservable
  48237. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48238. */
  48239. get onExitingVR(): Observable<VRExperienceHelper>;
  48240. /** Return this.onControllerMeshLoadedObservable
  48241. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48242. */
  48243. get onControllerMeshLoaded(): Observable<WebVRController>;
  48244. private _rayLength;
  48245. private _useCustomVRButton;
  48246. private _teleportationRequested;
  48247. private _teleportActive;
  48248. private _floorMeshName;
  48249. private _floorMeshesCollection;
  48250. private _teleportationMode;
  48251. private _teleportationTime;
  48252. private _teleportationSpeed;
  48253. private _teleportationEasing;
  48254. private _rotationAllowed;
  48255. private _teleportBackwardsVector;
  48256. private _teleportationTarget;
  48257. private _isDefaultTeleportationTarget;
  48258. private _postProcessMove;
  48259. private _teleportationFillColor;
  48260. private _teleportationBorderColor;
  48261. private _rotationAngle;
  48262. private _haloCenter;
  48263. private _cameraGazer;
  48264. private _padSensibilityUp;
  48265. private _padSensibilityDown;
  48266. private _leftController;
  48267. private _rightController;
  48268. private _gazeColor;
  48269. private _laserColor;
  48270. private _pickedLaserColor;
  48271. private _pickedGazeColor;
  48272. /**
  48273. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48274. */
  48275. onNewMeshSelected: Observable<AbstractMesh>;
  48276. /**
  48277. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48278. * This observable will provide the mesh and the controller used to select the mesh
  48279. */
  48280. onMeshSelectedWithController: Observable<{
  48281. mesh: AbstractMesh;
  48282. controller: WebVRController;
  48283. }>;
  48284. /**
  48285. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48286. */
  48287. onNewMeshPicked: Observable<PickingInfo>;
  48288. private _circleEase;
  48289. /**
  48290. * Observable raised before camera teleportation
  48291. */
  48292. onBeforeCameraTeleport: Observable<Vector3>;
  48293. /**
  48294. * Observable raised after camera teleportation
  48295. */
  48296. onAfterCameraTeleport: Observable<Vector3>;
  48297. /**
  48298. * Observable raised when current selected mesh gets unselected
  48299. */
  48300. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48301. private _raySelectionPredicate;
  48302. /**
  48303. * To be optionaly changed by user to define custom ray selection
  48304. */
  48305. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48306. /**
  48307. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48308. */
  48309. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48310. /**
  48311. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48312. */
  48313. teleportationEnabled: boolean;
  48314. private _defaultHeight;
  48315. private _teleportationInitialized;
  48316. private _interactionsEnabled;
  48317. private _interactionsRequested;
  48318. private _displayGaze;
  48319. private _displayLaserPointer;
  48320. /**
  48321. * The mesh used to display where the user is going to teleport.
  48322. */
  48323. get teleportationTarget(): Mesh;
  48324. /**
  48325. * Sets the mesh to be used to display where the user is going to teleport.
  48326. */
  48327. set teleportationTarget(value: Mesh);
  48328. /**
  48329. * 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
  48330. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48331. * See http://doc.babylonjs.com/resources/baking_transformations
  48332. */
  48333. get gazeTrackerMesh(): Mesh;
  48334. set gazeTrackerMesh(value: Mesh);
  48335. /**
  48336. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48337. */
  48338. updateGazeTrackerScale: boolean;
  48339. /**
  48340. * If the gaze trackers color should be updated when selecting meshes
  48341. */
  48342. updateGazeTrackerColor: boolean;
  48343. /**
  48344. * If the controller laser color should be updated when selecting meshes
  48345. */
  48346. updateControllerLaserColor: boolean;
  48347. /**
  48348. * The gaze tracking mesh corresponding to the left controller
  48349. */
  48350. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48351. /**
  48352. * The gaze tracking mesh corresponding to the right controller
  48353. */
  48354. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48355. /**
  48356. * If the ray of the gaze should be displayed.
  48357. */
  48358. get displayGaze(): boolean;
  48359. /**
  48360. * Sets if the ray of the gaze should be displayed.
  48361. */
  48362. set displayGaze(value: boolean);
  48363. /**
  48364. * If the ray of the LaserPointer should be displayed.
  48365. */
  48366. get displayLaserPointer(): boolean;
  48367. /**
  48368. * Sets if the ray of the LaserPointer should be displayed.
  48369. */
  48370. set displayLaserPointer(value: boolean);
  48371. /**
  48372. * The deviceOrientationCamera used as the camera when not in VR.
  48373. */
  48374. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48375. /**
  48376. * Based on the current WebVR support, returns the current VR camera used.
  48377. */
  48378. get currentVRCamera(): Nullable<Camera>;
  48379. /**
  48380. * The webVRCamera which is used when in VR.
  48381. */
  48382. get webVRCamera(): WebVRFreeCamera;
  48383. /**
  48384. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48385. */
  48386. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48387. /**
  48388. * The html button that is used to trigger entering into VR.
  48389. */
  48390. get vrButton(): Nullable<HTMLButtonElement>;
  48391. private get _teleportationRequestInitiated();
  48392. /**
  48393. * Defines whether or not Pointer lock should be requested when switching to
  48394. * full screen.
  48395. */
  48396. requestPointerLockOnFullScreen: boolean;
  48397. /**
  48398. * If asking to force XR, this will be populated with the default xr experience
  48399. */
  48400. xr: WebXRDefaultExperience;
  48401. /**
  48402. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48403. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48404. */
  48405. xrTestDone: boolean;
  48406. /**
  48407. * Instantiates a VRExperienceHelper.
  48408. * Helps to quickly add VR support to an existing scene.
  48409. * @param scene The scene the VRExperienceHelper belongs to.
  48410. * @param webVROptions Options to modify the vr experience helper's behavior.
  48411. */
  48412. constructor(scene: Scene,
  48413. /** Options to modify the vr experience helper's behavior. */
  48414. webVROptions?: VRExperienceHelperOptions);
  48415. private completeVRInit;
  48416. private _onDefaultMeshLoaded;
  48417. private _onResize;
  48418. private _onFullscreenChange;
  48419. /**
  48420. * Gets a value indicating if we are currently in VR mode.
  48421. */
  48422. get isInVRMode(): boolean;
  48423. private onVrDisplayPresentChange;
  48424. private onVRDisplayChanged;
  48425. private moveButtonToBottomRight;
  48426. private displayVRButton;
  48427. private updateButtonVisibility;
  48428. private _cachedAngularSensibility;
  48429. /**
  48430. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48431. * Otherwise, will use the fullscreen API.
  48432. */
  48433. enterVR(): void;
  48434. /**
  48435. * Attempt to exit VR, or fullscreen.
  48436. */
  48437. exitVR(): void;
  48438. /**
  48439. * The position of the vr experience helper.
  48440. */
  48441. get position(): Vector3;
  48442. /**
  48443. * Sets the position of the vr experience helper.
  48444. */
  48445. set position(value: Vector3);
  48446. /**
  48447. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48448. */
  48449. enableInteractions(): void;
  48450. private get _noControllerIsActive();
  48451. private beforeRender;
  48452. private _isTeleportationFloor;
  48453. /**
  48454. * Adds a floor mesh to be used for teleportation.
  48455. * @param floorMesh the mesh to be used for teleportation.
  48456. */
  48457. addFloorMesh(floorMesh: Mesh): void;
  48458. /**
  48459. * Removes a floor mesh from being used for teleportation.
  48460. * @param floorMesh the mesh to be removed.
  48461. */
  48462. removeFloorMesh(floorMesh: Mesh): void;
  48463. /**
  48464. * Enables interactions and teleportation using the VR controllers and gaze.
  48465. * @param vrTeleportationOptions options to modify teleportation behavior.
  48466. */
  48467. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48468. private _onNewGamepadConnected;
  48469. private _tryEnableInteractionOnController;
  48470. private _onNewGamepadDisconnected;
  48471. private _enableInteractionOnController;
  48472. private _checkTeleportWithRay;
  48473. private _checkRotate;
  48474. private _checkTeleportBackwards;
  48475. private _enableTeleportationOnController;
  48476. private _createTeleportationCircles;
  48477. private _displayTeleportationTarget;
  48478. private _hideTeleportationTarget;
  48479. private _rotateCamera;
  48480. private _moveTeleportationSelectorTo;
  48481. private _workingVector;
  48482. private _workingQuaternion;
  48483. private _workingMatrix;
  48484. /**
  48485. * Time Constant Teleportation Mode
  48486. */
  48487. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48488. /**
  48489. * Speed Constant Teleportation Mode
  48490. */
  48491. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48492. /**
  48493. * Teleports the users feet to the desired location
  48494. * @param location The location where the user's feet should be placed
  48495. */
  48496. teleportCamera(location: Vector3): void;
  48497. private _convertNormalToDirectionOfRay;
  48498. private _castRayAndSelectObject;
  48499. private _notifySelectedMeshUnselected;
  48500. /**
  48501. * Permanently set new colors for the laser pointer
  48502. * @param color the new laser color
  48503. * @param pickedColor the new laser color when picked mesh detected
  48504. */
  48505. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48506. /**
  48507. * Set lighting enabled / disabled on the laser pointer of both controllers
  48508. * @param enabled should the lighting be enabled on the laser pointer
  48509. */
  48510. setLaserLightingState(enabled?: boolean): void;
  48511. /**
  48512. * Permanently set new colors for the gaze pointer
  48513. * @param color the new gaze color
  48514. * @param pickedColor the new gaze color when picked mesh detected
  48515. */
  48516. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48517. /**
  48518. * Sets the color of the laser ray from the vr controllers.
  48519. * @param color new color for the ray.
  48520. */
  48521. changeLaserColor(color: Color3): void;
  48522. /**
  48523. * Sets the color of the ray from the vr headsets gaze.
  48524. * @param color new color for the ray.
  48525. */
  48526. changeGazeColor(color: Color3): void;
  48527. /**
  48528. * Exits VR and disposes of the vr experience helper
  48529. */
  48530. dispose(): void;
  48531. /**
  48532. * Gets the name of the VRExperienceHelper class
  48533. * @returns "VRExperienceHelper"
  48534. */
  48535. getClassName(): string;
  48536. }
  48537. }
  48538. declare module BABYLON {
  48539. /**
  48540. * Contains an array of blocks representing the octree
  48541. */
  48542. export interface IOctreeContainer<T> {
  48543. /**
  48544. * Blocks within the octree
  48545. */
  48546. blocks: Array<OctreeBlock<T>>;
  48547. }
  48548. /**
  48549. * Class used to store a cell in an octree
  48550. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48551. */
  48552. export class OctreeBlock<T> {
  48553. /**
  48554. * Gets the content of the current block
  48555. */
  48556. entries: T[];
  48557. /**
  48558. * Gets the list of block children
  48559. */
  48560. blocks: Array<OctreeBlock<T>>;
  48561. private _depth;
  48562. private _maxDepth;
  48563. private _capacity;
  48564. private _minPoint;
  48565. private _maxPoint;
  48566. private _boundingVectors;
  48567. private _creationFunc;
  48568. /**
  48569. * Creates a new block
  48570. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48571. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48572. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48573. * @param depth defines the current depth of this block in the octree
  48574. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48575. * @param creationFunc defines a callback to call when an element is added to the block
  48576. */
  48577. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48578. /**
  48579. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48580. */
  48581. get capacity(): number;
  48582. /**
  48583. * Gets the minimum vector (in world space) of the block's bounding box
  48584. */
  48585. get minPoint(): Vector3;
  48586. /**
  48587. * Gets the maximum vector (in world space) of the block's bounding box
  48588. */
  48589. get maxPoint(): Vector3;
  48590. /**
  48591. * Add a new element to this block
  48592. * @param entry defines the element to add
  48593. */
  48594. addEntry(entry: T): void;
  48595. /**
  48596. * Remove an element from this block
  48597. * @param entry defines the element to remove
  48598. */
  48599. removeEntry(entry: T): void;
  48600. /**
  48601. * Add an array of elements to this block
  48602. * @param entries defines the array of elements to add
  48603. */
  48604. addEntries(entries: T[]): void;
  48605. /**
  48606. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48607. * @param frustumPlanes defines the frustum planes to test
  48608. * @param selection defines the array to store current content if selection is positive
  48609. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48610. */
  48611. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48612. /**
  48613. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48614. * @param sphereCenter defines the bounding sphere center
  48615. * @param sphereRadius defines the bounding sphere radius
  48616. * @param selection defines the array to store current content if selection is positive
  48617. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48618. */
  48619. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48620. /**
  48621. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48622. * @param ray defines the ray to test with
  48623. * @param selection defines the array to store current content if selection is positive
  48624. */
  48625. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48626. /**
  48627. * Subdivide the content into child blocks (this block will then be empty)
  48628. */
  48629. createInnerBlocks(): void;
  48630. /**
  48631. * @hidden
  48632. */
  48633. 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;
  48634. }
  48635. }
  48636. declare module BABYLON {
  48637. /**
  48638. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48639. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48640. */
  48641. export class Octree<T> {
  48642. /** 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.) */
  48643. maxDepth: number;
  48644. /**
  48645. * Blocks within the octree containing objects
  48646. */
  48647. blocks: Array<OctreeBlock<T>>;
  48648. /**
  48649. * Content stored in the octree
  48650. */
  48651. dynamicContent: T[];
  48652. private _maxBlockCapacity;
  48653. private _selectionContent;
  48654. private _creationFunc;
  48655. /**
  48656. * Creates a octree
  48657. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48658. * @param creationFunc function to be used to instatiate the octree
  48659. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48660. * @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.)
  48661. */
  48662. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48663. /** 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.) */
  48664. maxDepth?: number);
  48665. /**
  48666. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48667. * @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);
  48668. * @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);
  48669. * @param entries meshes to be added to the octree blocks
  48670. */
  48671. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48672. /**
  48673. * Adds a mesh to the octree
  48674. * @param entry Mesh to add to the octree
  48675. */
  48676. addMesh(entry: T): void;
  48677. /**
  48678. * Remove an element from the octree
  48679. * @param entry defines the element to remove
  48680. */
  48681. removeMesh(entry: T): void;
  48682. /**
  48683. * Selects an array of meshes within the frustum
  48684. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48685. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48686. * @returns array of meshes within the frustum
  48687. */
  48688. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48689. /**
  48690. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48691. * @param sphereCenter defines the bounding sphere center
  48692. * @param sphereRadius defines the bounding sphere radius
  48693. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48694. * @returns an array of objects that intersect the sphere
  48695. */
  48696. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48697. /**
  48698. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48699. * @param ray defines the ray to test with
  48700. * @returns array of intersected objects
  48701. */
  48702. intersectsRay(ray: Ray): SmartArray<T>;
  48703. /**
  48704. * Adds a mesh into the octree block if it intersects the block
  48705. */
  48706. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48707. /**
  48708. * Adds a submesh into the octree block if it intersects the block
  48709. */
  48710. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48711. }
  48712. }
  48713. declare module BABYLON {
  48714. interface Scene {
  48715. /**
  48716. * @hidden
  48717. * Backing Filed
  48718. */
  48719. _selectionOctree: Octree<AbstractMesh>;
  48720. /**
  48721. * Gets the octree used to boost mesh selection (picking)
  48722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48723. */
  48724. selectionOctree: Octree<AbstractMesh>;
  48725. /**
  48726. * Creates or updates the octree used to boost selection (picking)
  48727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48728. * @param maxCapacity defines the maximum capacity per leaf
  48729. * @param maxDepth defines the maximum depth of the octree
  48730. * @returns an octree of AbstractMesh
  48731. */
  48732. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48733. }
  48734. interface AbstractMesh {
  48735. /**
  48736. * @hidden
  48737. * Backing Field
  48738. */
  48739. _submeshesOctree: Octree<SubMesh>;
  48740. /**
  48741. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48742. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48743. * @param maxCapacity defines the maximum size of each block (64 by default)
  48744. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48745. * @returns the new octree
  48746. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48748. */
  48749. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48750. }
  48751. /**
  48752. * Defines the octree scene component responsible to manage any octrees
  48753. * in a given scene.
  48754. */
  48755. export class OctreeSceneComponent {
  48756. /**
  48757. * The component name help to identify the component in the list of scene components.
  48758. */
  48759. readonly name: string;
  48760. /**
  48761. * The scene the component belongs to.
  48762. */
  48763. scene: Scene;
  48764. /**
  48765. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48766. */
  48767. readonly checksIsEnabled: boolean;
  48768. /**
  48769. * Creates a new instance of the component for the given scene
  48770. * @param scene Defines the scene to register the component in
  48771. */
  48772. constructor(scene: Scene);
  48773. /**
  48774. * Registers the component in a given scene
  48775. */
  48776. register(): void;
  48777. /**
  48778. * Return the list of active meshes
  48779. * @returns the list of active meshes
  48780. */
  48781. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48782. /**
  48783. * Return the list of active sub meshes
  48784. * @param mesh The mesh to get the candidates sub meshes from
  48785. * @returns the list of active sub meshes
  48786. */
  48787. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48788. private _tempRay;
  48789. /**
  48790. * Return the list of sub meshes intersecting with a given local ray
  48791. * @param mesh defines the mesh to find the submesh for
  48792. * @param localRay defines the ray in local space
  48793. * @returns the list of intersecting sub meshes
  48794. */
  48795. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48796. /**
  48797. * Return the list of sub meshes colliding with a collider
  48798. * @param mesh defines the mesh to find the submesh for
  48799. * @param collider defines the collider to evaluate the collision against
  48800. * @returns the list of colliding sub meshes
  48801. */
  48802. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48803. /**
  48804. * Rebuilds the elements related to this component in case of
  48805. * context lost for instance.
  48806. */
  48807. rebuild(): void;
  48808. /**
  48809. * Disposes the component and the associated ressources.
  48810. */
  48811. dispose(): void;
  48812. }
  48813. }
  48814. declare module BABYLON {
  48815. /**
  48816. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48817. */
  48818. export class Gizmo implements IDisposable {
  48819. /** The utility layer the gizmo will be added to */
  48820. gizmoLayer: UtilityLayerRenderer;
  48821. /**
  48822. * The root mesh of the gizmo
  48823. */
  48824. _rootMesh: Mesh;
  48825. private _attachedMesh;
  48826. /**
  48827. * Ratio for the scale of the gizmo (Default: 1)
  48828. */
  48829. scaleRatio: number;
  48830. /**
  48831. * If a custom mesh has been set (Default: false)
  48832. */
  48833. protected _customMeshSet: boolean;
  48834. /**
  48835. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48836. * * When set, interactions will be enabled
  48837. */
  48838. get attachedMesh(): Nullable<AbstractMesh>;
  48839. set attachedMesh(value: Nullable<AbstractMesh>);
  48840. /**
  48841. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48842. * @param mesh The mesh to replace the default mesh of the gizmo
  48843. */
  48844. setCustomMesh(mesh: Mesh): void;
  48845. /**
  48846. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48847. */
  48848. updateGizmoRotationToMatchAttachedMesh: boolean;
  48849. /**
  48850. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48851. */
  48852. updateGizmoPositionToMatchAttachedMesh: boolean;
  48853. /**
  48854. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48855. */
  48856. updateScale: boolean;
  48857. protected _interactionsEnabled: boolean;
  48858. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48859. private _beforeRenderObserver;
  48860. private _tempVector;
  48861. /**
  48862. * Creates a gizmo
  48863. * @param gizmoLayer The utility layer the gizmo will be added to
  48864. */
  48865. constructor(
  48866. /** The utility layer the gizmo will be added to */
  48867. gizmoLayer?: UtilityLayerRenderer);
  48868. /**
  48869. * Updates the gizmo to match the attached mesh's position/rotation
  48870. */
  48871. protected _update(): void;
  48872. /**
  48873. * Disposes of the gizmo
  48874. */
  48875. dispose(): void;
  48876. }
  48877. }
  48878. declare module BABYLON {
  48879. /**
  48880. * Single plane drag gizmo
  48881. */
  48882. export class PlaneDragGizmo extends Gizmo {
  48883. /**
  48884. * Drag behavior responsible for the gizmos dragging interactions
  48885. */
  48886. dragBehavior: PointerDragBehavior;
  48887. private _pointerObserver;
  48888. /**
  48889. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48890. */
  48891. snapDistance: number;
  48892. /**
  48893. * Event that fires each time the gizmo snaps to a new location.
  48894. * * snapDistance is the the change in distance
  48895. */
  48896. onSnapObservable: Observable<{
  48897. snapDistance: number;
  48898. }>;
  48899. private _plane;
  48900. private _coloredMaterial;
  48901. private _hoverMaterial;
  48902. private _isEnabled;
  48903. private _parent;
  48904. /** @hidden */
  48905. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48906. /** @hidden */
  48907. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48908. /**
  48909. * Creates a PlaneDragGizmo
  48910. * @param gizmoLayer The utility layer the gizmo will be added to
  48911. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48912. * @param color The color of the gizmo
  48913. */
  48914. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48915. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48916. /**
  48917. * If the gizmo is enabled
  48918. */
  48919. set isEnabled(value: boolean);
  48920. get isEnabled(): boolean;
  48921. /**
  48922. * Disposes of the gizmo
  48923. */
  48924. dispose(): void;
  48925. }
  48926. }
  48927. declare module BABYLON {
  48928. /**
  48929. * Gizmo that enables dragging a mesh along 3 axis
  48930. */
  48931. export class PositionGizmo extends Gizmo {
  48932. /**
  48933. * Internal gizmo used for interactions on the x axis
  48934. */
  48935. xGizmo: AxisDragGizmo;
  48936. /**
  48937. * Internal gizmo used for interactions on the y axis
  48938. */
  48939. yGizmo: AxisDragGizmo;
  48940. /**
  48941. * Internal gizmo used for interactions on the z axis
  48942. */
  48943. zGizmo: AxisDragGizmo;
  48944. /**
  48945. * Internal gizmo used for interactions on the yz plane
  48946. */
  48947. xPlaneGizmo: PlaneDragGizmo;
  48948. /**
  48949. * Internal gizmo used for interactions on the xz plane
  48950. */
  48951. yPlaneGizmo: PlaneDragGizmo;
  48952. /**
  48953. * Internal gizmo used for interactions on the xy plane
  48954. */
  48955. zPlaneGizmo: PlaneDragGizmo;
  48956. /**
  48957. * private variables
  48958. */
  48959. private _meshAttached;
  48960. private _updateGizmoRotationToMatchAttachedMesh;
  48961. private _snapDistance;
  48962. private _scaleRatio;
  48963. /** Fires an event when any of it's sub gizmos are dragged */
  48964. onDragStartObservable: Observable<unknown>;
  48965. /** Fires an event when any of it's sub gizmos are released from dragging */
  48966. onDragEndObservable: Observable<unknown>;
  48967. /**
  48968. * If set to true, planar drag is enabled
  48969. */
  48970. private _planarGizmoEnabled;
  48971. get attachedMesh(): Nullable<AbstractMesh>;
  48972. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48973. /**
  48974. * Creates a PositionGizmo
  48975. * @param gizmoLayer The utility layer the gizmo will be added to
  48976. */
  48977. constructor(gizmoLayer?: UtilityLayerRenderer);
  48978. /**
  48979. * If the planar drag gizmo is enabled
  48980. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48981. */
  48982. set planarGizmoEnabled(value: boolean);
  48983. get planarGizmoEnabled(): boolean;
  48984. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48985. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48986. /**
  48987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48988. */
  48989. set snapDistance(value: number);
  48990. get snapDistance(): number;
  48991. /**
  48992. * Ratio for the scale of the gizmo (Default: 1)
  48993. */
  48994. set scaleRatio(value: number);
  48995. get scaleRatio(): number;
  48996. /**
  48997. * Disposes of the gizmo
  48998. */
  48999. dispose(): void;
  49000. /**
  49001. * CustomMeshes are not supported by this gizmo
  49002. * @param mesh The mesh to replace the default mesh of the gizmo
  49003. */
  49004. setCustomMesh(mesh: Mesh): void;
  49005. }
  49006. }
  49007. declare module BABYLON {
  49008. /**
  49009. * Single axis drag gizmo
  49010. */
  49011. export class AxisDragGizmo extends Gizmo {
  49012. /**
  49013. * Drag behavior responsible for the gizmos dragging interactions
  49014. */
  49015. dragBehavior: PointerDragBehavior;
  49016. private _pointerObserver;
  49017. /**
  49018. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49019. */
  49020. snapDistance: number;
  49021. /**
  49022. * Event that fires each time the gizmo snaps to a new location.
  49023. * * snapDistance is the the change in distance
  49024. */
  49025. onSnapObservable: Observable<{
  49026. snapDistance: number;
  49027. }>;
  49028. private _isEnabled;
  49029. private _parent;
  49030. private _arrow;
  49031. private _coloredMaterial;
  49032. private _hoverMaterial;
  49033. /** @hidden */
  49034. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49035. /** @hidden */
  49036. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49037. /**
  49038. * Creates an AxisDragGizmo
  49039. * @param gizmoLayer The utility layer the gizmo will be added to
  49040. * @param dragAxis The axis which the gizmo will be able to drag on
  49041. * @param color The color of the gizmo
  49042. */
  49043. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49044. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49045. /**
  49046. * If the gizmo is enabled
  49047. */
  49048. set isEnabled(value: boolean);
  49049. get isEnabled(): boolean;
  49050. /**
  49051. * Disposes of the gizmo
  49052. */
  49053. dispose(): void;
  49054. }
  49055. }
  49056. declare module BABYLON.Debug {
  49057. /**
  49058. * The Axes viewer will show 3 axes in a specific point in space
  49059. */
  49060. export class AxesViewer {
  49061. private _xAxis;
  49062. private _yAxis;
  49063. private _zAxis;
  49064. private _scaleLinesFactor;
  49065. private _instanced;
  49066. /**
  49067. * Gets the hosting scene
  49068. */
  49069. scene: Scene;
  49070. /**
  49071. * Gets or sets a number used to scale line length
  49072. */
  49073. scaleLines: number;
  49074. /** Gets the node hierarchy used to render x-axis */
  49075. get xAxis(): TransformNode;
  49076. /** Gets the node hierarchy used to render y-axis */
  49077. get yAxis(): TransformNode;
  49078. /** Gets the node hierarchy used to render z-axis */
  49079. get zAxis(): TransformNode;
  49080. /**
  49081. * Creates a new AxesViewer
  49082. * @param scene defines the hosting scene
  49083. * @param scaleLines defines a number used to scale line length (1 by default)
  49084. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49085. * @param xAxis defines the node hierarchy used to render the x-axis
  49086. * @param yAxis defines the node hierarchy used to render the y-axis
  49087. * @param zAxis defines the node hierarchy used to render the z-axis
  49088. */
  49089. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49090. /**
  49091. * Force the viewer to update
  49092. * @param position defines the position of the viewer
  49093. * @param xaxis defines the x axis of the viewer
  49094. * @param yaxis defines the y axis of the viewer
  49095. * @param zaxis defines the z axis of the viewer
  49096. */
  49097. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49098. /**
  49099. * Creates an instance of this axes viewer.
  49100. * @returns a new axes viewer with instanced meshes
  49101. */
  49102. createInstance(): AxesViewer;
  49103. /** Releases resources */
  49104. dispose(): void;
  49105. private static _SetRenderingGroupId;
  49106. }
  49107. }
  49108. declare module BABYLON.Debug {
  49109. /**
  49110. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49111. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49112. */
  49113. export class BoneAxesViewer extends AxesViewer {
  49114. /**
  49115. * Gets or sets the target mesh where to display the axes viewer
  49116. */
  49117. mesh: Nullable<Mesh>;
  49118. /**
  49119. * Gets or sets the target bone where to display the axes viewer
  49120. */
  49121. bone: Nullable<Bone>;
  49122. /** Gets current position */
  49123. pos: Vector3;
  49124. /** Gets direction of X axis */
  49125. xaxis: Vector3;
  49126. /** Gets direction of Y axis */
  49127. yaxis: Vector3;
  49128. /** Gets direction of Z axis */
  49129. zaxis: Vector3;
  49130. /**
  49131. * Creates a new BoneAxesViewer
  49132. * @param scene defines the hosting scene
  49133. * @param bone defines the target bone
  49134. * @param mesh defines the target mesh
  49135. * @param scaleLines defines a scaling factor for line length (1 by default)
  49136. */
  49137. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49138. /**
  49139. * Force the viewer to update
  49140. */
  49141. update(): void;
  49142. /** Releases resources */
  49143. dispose(): void;
  49144. }
  49145. }
  49146. declare module BABYLON {
  49147. /**
  49148. * Interface used to define scene explorer extensibility option
  49149. */
  49150. export interface IExplorerExtensibilityOption {
  49151. /**
  49152. * Define the option label
  49153. */
  49154. label: string;
  49155. /**
  49156. * Defines the action to execute on click
  49157. */
  49158. action: (entity: any) => void;
  49159. }
  49160. /**
  49161. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49162. */
  49163. export interface IExplorerExtensibilityGroup {
  49164. /**
  49165. * Defines a predicate to test if a given type mut be extended
  49166. */
  49167. predicate: (entity: any) => boolean;
  49168. /**
  49169. * Gets the list of options added to a type
  49170. */
  49171. entries: IExplorerExtensibilityOption[];
  49172. }
  49173. /**
  49174. * Interface used to define the options to use to create the Inspector
  49175. */
  49176. export interface IInspectorOptions {
  49177. /**
  49178. * Display in overlay mode (default: false)
  49179. */
  49180. overlay?: boolean;
  49181. /**
  49182. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49183. */
  49184. globalRoot?: HTMLElement;
  49185. /**
  49186. * Display the Scene explorer
  49187. */
  49188. showExplorer?: boolean;
  49189. /**
  49190. * Display the property inspector
  49191. */
  49192. showInspector?: boolean;
  49193. /**
  49194. * Display in embed mode (both panes on the right)
  49195. */
  49196. embedMode?: boolean;
  49197. /**
  49198. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49199. */
  49200. handleResize?: boolean;
  49201. /**
  49202. * Allow the panes to popup (default: true)
  49203. */
  49204. enablePopup?: boolean;
  49205. /**
  49206. * Allow the panes to be closed by users (default: true)
  49207. */
  49208. enableClose?: boolean;
  49209. /**
  49210. * Optional list of extensibility entries
  49211. */
  49212. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49213. /**
  49214. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49215. */
  49216. inspectorURL?: string;
  49217. /**
  49218. * Optional initial tab (default to DebugLayerTab.Properties)
  49219. */
  49220. initialTab?: DebugLayerTab;
  49221. }
  49222. interface Scene {
  49223. /**
  49224. * @hidden
  49225. * Backing field
  49226. */
  49227. _debugLayer: DebugLayer;
  49228. /**
  49229. * Gets the debug layer (aka Inspector) associated with the scene
  49230. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49231. */
  49232. debugLayer: DebugLayer;
  49233. }
  49234. /**
  49235. * Enum of inspector action tab
  49236. */
  49237. export enum DebugLayerTab {
  49238. /**
  49239. * Properties tag (default)
  49240. */
  49241. Properties = 0,
  49242. /**
  49243. * Debug tab
  49244. */
  49245. Debug = 1,
  49246. /**
  49247. * Statistics tab
  49248. */
  49249. Statistics = 2,
  49250. /**
  49251. * Tools tab
  49252. */
  49253. Tools = 3,
  49254. /**
  49255. * Settings tab
  49256. */
  49257. Settings = 4
  49258. }
  49259. /**
  49260. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49261. * what is happening in your scene
  49262. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49263. */
  49264. export class DebugLayer {
  49265. /**
  49266. * Define the url to get the inspector script from.
  49267. * By default it uses the babylonjs CDN.
  49268. * @ignoreNaming
  49269. */
  49270. static InspectorURL: string;
  49271. private _scene;
  49272. private BJSINSPECTOR;
  49273. private _onPropertyChangedObservable?;
  49274. /**
  49275. * Observable triggered when a property is changed through the inspector.
  49276. */
  49277. get onPropertyChangedObservable(): any;
  49278. /**
  49279. * Instantiates a new debug layer.
  49280. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49281. * what is happening in your scene
  49282. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49283. * @param scene Defines the scene to inspect
  49284. */
  49285. constructor(scene: Scene);
  49286. /** Creates the inspector window. */
  49287. private _createInspector;
  49288. /**
  49289. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49290. * @param entity defines the entity to select
  49291. * @param lineContainerTitle defines the specific block to highlight
  49292. */
  49293. select(entity: any, lineContainerTitle?: string): void;
  49294. /** Get the inspector from bundle or global */
  49295. private _getGlobalInspector;
  49296. /**
  49297. * Get if the inspector is visible or not.
  49298. * @returns true if visible otherwise, false
  49299. */
  49300. isVisible(): boolean;
  49301. /**
  49302. * Hide the inspector and close its window.
  49303. */
  49304. hide(): void;
  49305. /**
  49306. * Update the scene in the inspector
  49307. */
  49308. setAsActiveScene(): void;
  49309. /**
  49310. * Launch the debugLayer.
  49311. * @param config Define the configuration of the inspector
  49312. * @return a promise fulfilled when the debug layer is visible
  49313. */
  49314. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49315. }
  49316. }
  49317. declare module BABYLON {
  49318. /**
  49319. * Class containing static functions to help procedurally build meshes
  49320. */
  49321. export class BoxBuilder {
  49322. /**
  49323. * Creates a box mesh
  49324. * * The parameter `size` sets the size (float) of each box side (default 1)
  49325. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49326. * * 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)
  49327. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49329. * * 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
  49330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49331. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49332. * @param name defines the name of the mesh
  49333. * @param options defines the options used to create the mesh
  49334. * @param scene defines the hosting scene
  49335. * @returns the box mesh
  49336. */
  49337. static CreateBox(name: string, options: {
  49338. size?: number;
  49339. width?: number;
  49340. height?: number;
  49341. depth?: number;
  49342. faceUV?: Vector4[];
  49343. faceColors?: Color4[];
  49344. sideOrientation?: number;
  49345. frontUVs?: Vector4;
  49346. backUVs?: Vector4;
  49347. wrap?: boolean;
  49348. topBaseAt?: number;
  49349. bottomBaseAt?: number;
  49350. updatable?: boolean;
  49351. }, scene?: Nullable<Scene>): Mesh;
  49352. }
  49353. }
  49354. declare module BABYLON.Debug {
  49355. /**
  49356. * Used to show the physics impostor around the specific mesh
  49357. */
  49358. export class PhysicsViewer {
  49359. /** @hidden */
  49360. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49361. /** @hidden */
  49362. protected _meshes: Array<Nullable<AbstractMesh>>;
  49363. /** @hidden */
  49364. protected _scene: Nullable<Scene>;
  49365. /** @hidden */
  49366. protected _numMeshes: number;
  49367. /** @hidden */
  49368. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49369. private _renderFunction;
  49370. private _utilityLayer;
  49371. private _debugBoxMesh;
  49372. private _debugSphereMesh;
  49373. private _debugCylinderMesh;
  49374. private _debugMaterial;
  49375. private _debugMeshMeshes;
  49376. /**
  49377. * Creates a new PhysicsViewer
  49378. * @param scene defines the hosting scene
  49379. */
  49380. constructor(scene: Scene);
  49381. /** @hidden */
  49382. protected _updateDebugMeshes(): void;
  49383. /**
  49384. * Renders a specified physic impostor
  49385. * @param impostor defines the impostor to render
  49386. * @param targetMesh defines the mesh represented by the impostor
  49387. * @returns the new debug mesh used to render the impostor
  49388. */
  49389. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49390. /**
  49391. * Hides a specified physic impostor
  49392. * @param impostor defines the impostor to hide
  49393. */
  49394. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49395. private _getDebugMaterial;
  49396. private _getDebugBoxMesh;
  49397. private _getDebugSphereMesh;
  49398. private _getDebugCylinderMesh;
  49399. private _getDebugMeshMesh;
  49400. private _getDebugMesh;
  49401. /** Releases all resources */
  49402. dispose(): void;
  49403. }
  49404. }
  49405. declare module BABYLON {
  49406. /**
  49407. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49408. * in order to better appreciate the issue one might have.
  49409. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49410. */
  49411. export class RayHelper {
  49412. /**
  49413. * Defines the ray we are currently tryin to visualize.
  49414. */
  49415. ray: Nullable<Ray>;
  49416. private _renderPoints;
  49417. private _renderLine;
  49418. private _renderFunction;
  49419. private _scene;
  49420. private _updateToMeshFunction;
  49421. private _attachedToMesh;
  49422. private _meshSpaceDirection;
  49423. private _meshSpaceOrigin;
  49424. /**
  49425. * Helper function to create a colored helper in a scene in one line.
  49426. * @param ray Defines the ray we are currently tryin to visualize
  49427. * @param scene Defines the scene the ray is used in
  49428. * @param color Defines the color we want to see the ray in
  49429. * @returns The newly created ray helper.
  49430. */
  49431. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49432. /**
  49433. * Instantiate a new ray helper.
  49434. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49435. * in order to better appreciate the issue one might have.
  49436. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49437. * @param ray Defines the ray we are currently tryin to visualize
  49438. */
  49439. constructor(ray: Ray);
  49440. /**
  49441. * Shows the ray we are willing to debug.
  49442. * @param scene Defines the scene the ray needs to be rendered in
  49443. * @param color Defines the color the ray needs to be rendered in
  49444. */
  49445. show(scene: Scene, color?: Color3): void;
  49446. /**
  49447. * Hides the ray we are debugging.
  49448. */
  49449. hide(): void;
  49450. private _render;
  49451. /**
  49452. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49453. * @param mesh Defines the mesh we want the helper attached to
  49454. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49455. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49456. * @param length Defines the length of the ray
  49457. */
  49458. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49459. /**
  49460. * Detach the ray helper from the mesh it has previously been attached to.
  49461. */
  49462. detachFromMesh(): void;
  49463. private _updateToMesh;
  49464. /**
  49465. * Dispose the helper and release its associated resources.
  49466. */
  49467. dispose(): void;
  49468. }
  49469. }
  49470. declare module BABYLON.Debug {
  49471. /**
  49472. * Class used to render a debug view of a given skeleton
  49473. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49474. */
  49475. export class SkeletonViewer {
  49476. /** defines the skeleton to render */
  49477. skeleton: Skeleton;
  49478. /** defines the mesh attached to the skeleton */
  49479. mesh: AbstractMesh;
  49480. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49481. autoUpdateBonesMatrices: boolean;
  49482. /** defines the rendering group id to use with the viewer */
  49483. renderingGroupId: number;
  49484. /** Gets or sets the color used to render the skeleton */
  49485. color: Color3;
  49486. private _scene;
  49487. private _debugLines;
  49488. private _debugMesh;
  49489. private _isEnabled;
  49490. private _renderFunction;
  49491. private _utilityLayer;
  49492. /**
  49493. * Returns the mesh used to render the bones
  49494. */
  49495. get debugMesh(): Nullable<LinesMesh>;
  49496. /**
  49497. * Creates a new SkeletonViewer
  49498. * @param skeleton defines the skeleton to render
  49499. * @param mesh defines the mesh attached to the skeleton
  49500. * @param scene defines the hosting scene
  49501. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49502. * @param renderingGroupId defines the rendering group id to use with the viewer
  49503. */
  49504. constructor(
  49505. /** defines the skeleton to render */
  49506. skeleton: Skeleton,
  49507. /** defines the mesh attached to the skeleton */
  49508. mesh: AbstractMesh, scene: Scene,
  49509. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49510. autoUpdateBonesMatrices?: boolean,
  49511. /** defines the rendering group id to use with the viewer */
  49512. renderingGroupId?: number);
  49513. /** Gets or sets a boolean indicating if the viewer is enabled */
  49514. set isEnabled(value: boolean);
  49515. get isEnabled(): boolean;
  49516. private _getBonePosition;
  49517. private _getLinesForBonesWithLength;
  49518. private _getLinesForBonesNoLength;
  49519. /** Update the viewer to sync with current skeleton state */
  49520. update(): void;
  49521. /** Release associated resources */
  49522. dispose(): void;
  49523. }
  49524. }
  49525. declare module BABYLON {
  49526. /**
  49527. * Enum for Device Types
  49528. */
  49529. export enum DeviceType {
  49530. /** Generic */
  49531. Generic = 0,
  49532. /** Keyboard */
  49533. Keyboard = 1,
  49534. /** Mouse */
  49535. Mouse = 2,
  49536. /** Touch Pointers */
  49537. Touch = 3,
  49538. /** PS4 Dual Shock */
  49539. DualShock = 4,
  49540. /** Xbox */
  49541. Xbox = 5,
  49542. /** Switch Controller */
  49543. Switch = 6
  49544. }
  49545. /**
  49546. * Enum for All Pointers (Touch/Mouse)
  49547. */
  49548. export enum PointerInput {
  49549. /** Horizontal Axis */
  49550. Horizontal = 0,
  49551. /** Vertical Axis */
  49552. Vertical = 1,
  49553. /** Left Click or Touch */
  49554. LeftClick = 2,
  49555. /** Middle Click */
  49556. MiddleClick = 3,
  49557. /** Right Click */
  49558. RightClick = 4,
  49559. /** Browser Back */
  49560. BrowserBack = 5,
  49561. /** Browser Forward */
  49562. BrowserForward = 6
  49563. }
  49564. /**
  49565. * Enum for Dual Shock Gamepad
  49566. */
  49567. export enum DualShockInput {
  49568. /** Cross */
  49569. Cross = 0,
  49570. /** Circle */
  49571. Circle = 1,
  49572. /** Square */
  49573. Square = 2,
  49574. /** Triangle */
  49575. Triangle = 3,
  49576. /** L1 */
  49577. L1 = 4,
  49578. /** R1 */
  49579. R1 = 5,
  49580. /** L2 */
  49581. L2 = 6,
  49582. /** R2 */
  49583. R2 = 7,
  49584. /** Share */
  49585. Share = 8,
  49586. /** Options */
  49587. Options = 9,
  49588. /** L3 */
  49589. L3 = 10,
  49590. /** R3 */
  49591. R3 = 11,
  49592. /** DPadUp */
  49593. DPadUp = 12,
  49594. /** DPadDown */
  49595. DPadDown = 13,
  49596. /** DPadLeft */
  49597. DPadLeft = 14,
  49598. /** DRight */
  49599. DPadRight = 15,
  49600. /** Home */
  49601. Home = 16,
  49602. /** TouchPad */
  49603. TouchPad = 17,
  49604. /** LStickXAxis */
  49605. LStickXAxis = 18,
  49606. /** LStickYAxis */
  49607. LStickYAxis = 19,
  49608. /** RStickXAxis */
  49609. RStickXAxis = 20,
  49610. /** RStickYAxis */
  49611. RStickYAxis = 21
  49612. }
  49613. /**
  49614. * Enum for Xbox Gamepad
  49615. */
  49616. export enum XboxInput {
  49617. /** A */
  49618. A = 0,
  49619. /** B */
  49620. B = 1,
  49621. /** X */
  49622. X = 2,
  49623. /** Y */
  49624. Y = 3,
  49625. /** LB */
  49626. LB = 4,
  49627. /** RB */
  49628. RB = 5,
  49629. /** LT */
  49630. LT = 6,
  49631. /** RT */
  49632. RT = 7,
  49633. /** Back */
  49634. Back = 8,
  49635. /** Start */
  49636. Start = 9,
  49637. /** LS */
  49638. LS = 10,
  49639. /** RS */
  49640. RS = 11,
  49641. /** DPadUp */
  49642. DPadUp = 12,
  49643. /** DPadDown */
  49644. DPadDown = 13,
  49645. /** DPadLeft */
  49646. DPadLeft = 14,
  49647. /** DRight */
  49648. DPadRight = 15,
  49649. /** Home */
  49650. Home = 16,
  49651. /** LStickXAxis */
  49652. LStickXAxis = 17,
  49653. /** LStickYAxis */
  49654. LStickYAxis = 18,
  49655. /** RStickXAxis */
  49656. RStickXAxis = 19,
  49657. /** RStickYAxis */
  49658. RStickYAxis = 20
  49659. }
  49660. /**
  49661. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49662. */
  49663. export enum SwitchInput {
  49664. /** B */
  49665. B = 0,
  49666. /** A */
  49667. A = 1,
  49668. /** Y */
  49669. Y = 2,
  49670. /** X */
  49671. X = 3,
  49672. /** L */
  49673. L = 4,
  49674. /** R */
  49675. R = 5,
  49676. /** ZL */
  49677. ZL = 6,
  49678. /** ZR */
  49679. ZR = 7,
  49680. /** Minus */
  49681. Minus = 8,
  49682. /** Plus */
  49683. Plus = 9,
  49684. /** LS */
  49685. LS = 10,
  49686. /** RS */
  49687. RS = 11,
  49688. /** DPadUp */
  49689. DPadUp = 12,
  49690. /** DPadDown */
  49691. DPadDown = 13,
  49692. /** DPadLeft */
  49693. DPadLeft = 14,
  49694. /** DRight */
  49695. DPadRight = 15,
  49696. /** Home */
  49697. Home = 16,
  49698. /** Capture */
  49699. Capture = 17,
  49700. /** LStickXAxis */
  49701. LStickXAxis = 18,
  49702. /** LStickYAxis */
  49703. LStickYAxis = 19,
  49704. /** RStickXAxis */
  49705. RStickXAxis = 20,
  49706. /** RStickYAxis */
  49707. RStickYAxis = 21
  49708. }
  49709. }
  49710. declare module BABYLON {
  49711. /**
  49712. * This class will take all inputs from Keyboard, Pointer, and
  49713. * any Gamepads and provide a polling system that all devices
  49714. * will use. This class assumes that there will only be one
  49715. * pointer device and one keyboard.
  49716. */
  49717. export class DeviceInputSystem implements IDisposable {
  49718. /**
  49719. * Callback to be triggered when a device is connected
  49720. */
  49721. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49722. /**
  49723. * Callback to be triggered when a device is disconnected
  49724. */
  49725. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49726. /**
  49727. * Callback to be triggered when event driven input is updated
  49728. */
  49729. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49730. private _inputs;
  49731. private _gamepads;
  49732. private _keyboardActive;
  49733. private _pointerActive;
  49734. private _elementToAttachTo;
  49735. private _keyboardDownEvent;
  49736. private _keyboardUpEvent;
  49737. private _pointerMoveEvent;
  49738. private _pointerDownEvent;
  49739. private _pointerUpEvent;
  49740. private _gamepadConnectedEvent;
  49741. private _gamepadDisconnectedEvent;
  49742. private static _MAX_KEYCODES;
  49743. private static _MAX_POINTER_INPUTS;
  49744. /**
  49745. * Default Constructor
  49746. * @param engine - engine to pull input element from
  49747. */
  49748. constructor(engine: Engine);
  49749. /**
  49750. * Checks for current device input value, given an id and input index
  49751. * @param deviceName Id of connected device
  49752. * @param inputIndex Index of device input
  49753. * @returns Current value of input
  49754. */
  49755. /**
  49756. * Checks for current device input value, given an id and input index
  49757. * @param deviceType Enum specifiying device type
  49758. * @param deviceSlot "Slot" or index that device is referenced in
  49759. * @param inputIndex Id of input to be checked
  49760. * @returns Current value of input
  49761. */
  49762. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49763. /**
  49764. * Dispose of all the eventlisteners
  49765. */
  49766. dispose(): void;
  49767. /**
  49768. * Add device and inputs to device array
  49769. * @param deviceType Enum specifiying device type
  49770. * @param deviceSlot "Slot" or index that device is referenced in
  49771. * @param numberOfInputs Number of input entries to create for given device
  49772. */
  49773. private _registerDevice;
  49774. /**
  49775. * Given a specific device name, remove that device from the device map
  49776. * @param deviceType Enum specifiying device type
  49777. * @param deviceSlot "Slot" or index that device is referenced in
  49778. */
  49779. private _unregisterDevice;
  49780. /**
  49781. * Handle all actions that come from keyboard interaction
  49782. */
  49783. private _handleKeyActions;
  49784. /**
  49785. * Handle all actions that come from pointer interaction
  49786. */
  49787. private _handlePointerActions;
  49788. /**
  49789. * Handle all actions that come from gamepad interaction
  49790. */
  49791. private _handleGamepadActions;
  49792. /**
  49793. * Update all non-event based devices with each frame
  49794. * @param deviceType Enum specifiying device type
  49795. * @param deviceSlot "Slot" or index that device is referenced in
  49796. * @param inputIndex Id of input to be checked
  49797. */
  49798. private _updateDevice;
  49799. /**
  49800. * Gets DeviceType from the device name
  49801. * @param deviceName Name of Device from DeviceInputSystem
  49802. * @returns DeviceType enum value
  49803. */
  49804. private _getGamepadDeviceType;
  49805. }
  49806. }
  49807. declare module BABYLON {
  49808. /**
  49809. * Type to handle enforcement of inputs
  49810. */
  49811. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  49812. }
  49813. declare module BABYLON {
  49814. /**
  49815. * Class that handles all input for a specific device
  49816. */
  49817. export class DeviceSource<T extends DeviceType> {
  49818. /** Type of device */
  49819. readonly deviceType: DeviceType;
  49820. /** "Slot" or index that device is referenced in */
  49821. readonly deviceSlot: number;
  49822. /**
  49823. * Observable to handle device input changes per device
  49824. */
  49825. readonly onInputChangedObservable: Observable<{
  49826. inputIndex: DeviceInput<T>;
  49827. previousState: Nullable<number>;
  49828. currentState: Nullable<number>;
  49829. }>;
  49830. private readonly _deviceInputSystem;
  49831. /**
  49832. * Default Constructor
  49833. * @param deviceInputSystem Reference to DeviceInputSystem
  49834. * @param deviceType Type of device
  49835. * @param deviceSlot "Slot" or index that device is referenced in
  49836. */
  49837. constructor(deviceInputSystem: DeviceInputSystem,
  49838. /** Type of device */
  49839. deviceType: DeviceType,
  49840. /** "Slot" or index that device is referenced in */
  49841. deviceSlot?: number);
  49842. /**
  49843. * Get input for specific input
  49844. * @param inputIndex index of specific input on device
  49845. * @returns Input value from DeviceInputSystem
  49846. */
  49847. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49848. }
  49849. /**
  49850. * Class to keep track of devices
  49851. */
  49852. export class DeviceSourceManager implements IDisposable {
  49853. /**
  49854. * Observable to be triggered when before a device is connected
  49855. */
  49856. readonly onBeforeDeviceConnectedObservable: Observable<{
  49857. deviceType: DeviceType;
  49858. deviceSlot: number;
  49859. }>;
  49860. /**
  49861. * Observable to be triggered when before a device is disconnected
  49862. */
  49863. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49864. deviceType: DeviceType;
  49865. deviceSlot: number;
  49866. }>;
  49867. /**
  49868. * Observable to be triggered when after a device is connected
  49869. */
  49870. readonly onAfterDeviceConnectedObservable: Observable<{
  49871. deviceType: DeviceType;
  49872. deviceSlot: number;
  49873. }>;
  49874. /**
  49875. * Observable to be triggered when after a device is disconnected
  49876. */
  49877. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49878. deviceType: DeviceType;
  49879. deviceSlot: number;
  49880. }>;
  49881. private readonly _devices;
  49882. private readonly _firstDevice;
  49883. private readonly _deviceInputSystem;
  49884. /**
  49885. * Default Constructor
  49886. * @param engine engine to pull input element from
  49887. */
  49888. constructor(engine: Engine);
  49889. /**
  49890. * Gets a DeviceSource, given a type and slot
  49891. * @param deviceType Enum specifying device type
  49892. * @param deviceSlot "Slot" or index that device is referenced in
  49893. * @returns DeviceSource object
  49894. */
  49895. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49896. /**
  49897. * Gets an array of DeviceSource objects for a given device type
  49898. * @param deviceType Enum specifying device type
  49899. * @returns Array of DeviceSource objects
  49900. */
  49901. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49902. /**
  49903. * Dispose of DeviceInputSystem and other parts
  49904. */
  49905. dispose(): void;
  49906. /**
  49907. * Function to add device name to device list
  49908. * @param deviceType Enum specifying device type
  49909. * @param deviceSlot "Slot" or index that device is referenced in
  49910. */
  49911. private _addDevice;
  49912. /**
  49913. * Function to remove device name to device list
  49914. * @param deviceType Enum specifying device type
  49915. * @param deviceSlot "Slot" or index that device is referenced in
  49916. */
  49917. private _removeDevice;
  49918. /**
  49919. * Updates array storing first connected device of each type
  49920. * @param type Type of Device
  49921. */
  49922. private _updateFirstDevices;
  49923. }
  49924. }
  49925. declare module BABYLON {
  49926. /**
  49927. * Options to create the null engine
  49928. */
  49929. export class NullEngineOptions {
  49930. /**
  49931. * Render width (Default: 512)
  49932. */
  49933. renderWidth: number;
  49934. /**
  49935. * Render height (Default: 256)
  49936. */
  49937. renderHeight: number;
  49938. /**
  49939. * Texture size (Default: 512)
  49940. */
  49941. textureSize: number;
  49942. /**
  49943. * If delta time between frames should be constant
  49944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49945. */
  49946. deterministicLockstep: boolean;
  49947. /**
  49948. * Maximum about of steps between frames (Default: 4)
  49949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49950. */
  49951. lockstepMaxSteps: number;
  49952. }
  49953. /**
  49954. * The null engine class provides support for headless version of babylon.js.
  49955. * This can be used in server side scenario or for testing purposes
  49956. */
  49957. export class NullEngine extends Engine {
  49958. private _options;
  49959. /**
  49960. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49961. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49962. * @returns true if engine is in deterministic lock step mode
  49963. */
  49964. isDeterministicLockStep(): boolean;
  49965. /**
  49966. * Gets the max steps when engine is running in deterministic lock step
  49967. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49968. * @returns the max steps
  49969. */
  49970. getLockstepMaxSteps(): number;
  49971. /**
  49972. * Gets the current hardware scaling level.
  49973. * By default the hardware scaling level is computed from the window device ratio.
  49974. * 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.
  49975. * @returns a number indicating the current hardware scaling level
  49976. */
  49977. getHardwareScalingLevel(): number;
  49978. constructor(options?: NullEngineOptions);
  49979. /**
  49980. * Creates a vertex buffer
  49981. * @param vertices the data for the vertex buffer
  49982. * @returns the new WebGL static buffer
  49983. */
  49984. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49985. /**
  49986. * Creates a new index buffer
  49987. * @param indices defines the content of the index buffer
  49988. * @param updatable defines if the index buffer must be updatable
  49989. * @returns a new webGL buffer
  49990. */
  49991. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49992. /**
  49993. * Clear the current render buffer or the current render target (if any is set up)
  49994. * @param color defines the color to use
  49995. * @param backBuffer defines if the back buffer must be cleared
  49996. * @param depth defines if the depth buffer must be cleared
  49997. * @param stencil defines if the stencil buffer must be cleared
  49998. */
  49999. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50000. /**
  50001. * Gets the current render width
  50002. * @param useScreen defines if screen size must be used (or the current render target if any)
  50003. * @returns a number defining the current render width
  50004. */
  50005. getRenderWidth(useScreen?: boolean): number;
  50006. /**
  50007. * Gets the current render height
  50008. * @param useScreen defines if screen size must be used (or the current render target if any)
  50009. * @returns a number defining the current render height
  50010. */
  50011. getRenderHeight(useScreen?: boolean): number;
  50012. /**
  50013. * Set the WebGL's viewport
  50014. * @param viewport defines the viewport element to be used
  50015. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50016. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50017. */
  50018. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50019. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50020. /**
  50021. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50022. * @param pipelineContext defines the pipeline context to use
  50023. * @param uniformsNames defines the list of uniform names
  50024. * @returns an array of webGL uniform locations
  50025. */
  50026. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50027. /**
  50028. * Gets the lsit of active attributes for a given webGL program
  50029. * @param pipelineContext defines the pipeline context to use
  50030. * @param attributesNames defines the list of attribute names to get
  50031. * @returns an array of indices indicating the offset of each attribute
  50032. */
  50033. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50034. /**
  50035. * Binds an effect to the webGL context
  50036. * @param effect defines the effect to bind
  50037. */
  50038. bindSamplers(effect: Effect): void;
  50039. /**
  50040. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50041. * @param effect defines the effect to activate
  50042. */
  50043. enableEffect(effect: Effect): void;
  50044. /**
  50045. * Set various states to the webGL context
  50046. * @param culling defines backface culling state
  50047. * @param zOffset defines the value to apply to zOffset (0 by default)
  50048. * @param force defines if states must be applied even if cache is up to date
  50049. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50050. */
  50051. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50052. /**
  50053. * Set the value of an uniform to an array of int32
  50054. * @param uniform defines the webGL uniform location where to store the value
  50055. * @param array defines the array of int32 to store
  50056. */
  50057. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50058. /**
  50059. * Set the value of an uniform to an array of int32 (stored as vec2)
  50060. * @param uniform defines the webGL uniform location where to store the value
  50061. * @param array defines the array of int32 to store
  50062. */
  50063. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50064. /**
  50065. * Set the value of an uniform to an array of int32 (stored as vec3)
  50066. * @param uniform defines the webGL uniform location where to store the value
  50067. * @param array defines the array of int32 to store
  50068. */
  50069. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50070. /**
  50071. * Set the value of an uniform to an array of int32 (stored as vec4)
  50072. * @param uniform defines the webGL uniform location where to store the value
  50073. * @param array defines the array of int32 to store
  50074. */
  50075. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50076. /**
  50077. * Set the value of an uniform to an array of float32
  50078. * @param uniform defines the webGL uniform location where to store the value
  50079. * @param array defines the array of float32 to store
  50080. */
  50081. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50082. /**
  50083. * Set the value of an uniform to an array of float32 (stored as vec2)
  50084. * @param uniform defines the webGL uniform location where to store the value
  50085. * @param array defines the array of float32 to store
  50086. */
  50087. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50088. /**
  50089. * Set the value of an uniform to an array of float32 (stored as vec3)
  50090. * @param uniform defines the webGL uniform location where to store the value
  50091. * @param array defines the array of float32 to store
  50092. */
  50093. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50094. /**
  50095. * Set the value of an uniform to an array of float32 (stored as vec4)
  50096. * @param uniform defines the webGL uniform location where to store the value
  50097. * @param array defines the array of float32 to store
  50098. */
  50099. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50100. /**
  50101. * Set the value of an uniform to an array of number
  50102. * @param uniform defines the webGL uniform location where to store the value
  50103. * @param array defines the array of number to store
  50104. */
  50105. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50106. /**
  50107. * Set the value of an uniform to an array of number (stored as vec2)
  50108. * @param uniform defines the webGL uniform location where to store the value
  50109. * @param array defines the array of number to store
  50110. */
  50111. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50112. /**
  50113. * Set the value of an uniform to an array of number (stored as vec3)
  50114. * @param uniform defines the webGL uniform location where to store the value
  50115. * @param array defines the array of number to store
  50116. */
  50117. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50118. /**
  50119. * Set the value of an uniform to an array of number (stored as vec4)
  50120. * @param uniform defines the webGL uniform location where to store the value
  50121. * @param array defines the array of number to store
  50122. */
  50123. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50124. /**
  50125. * Set the value of an uniform to an array of float32 (stored as matrices)
  50126. * @param uniform defines the webGL uniform location where to store the value
  50127. * @param matrices defines the array of float32 to store
  50128. */
  50129. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50130. /**
  50131. * Set the value of an uniform to a matrix (3x3)
  50132. * @param uniform defines the webGL uniform location where to store the value
  50133. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50134. */
  50135. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50136. /**
  50137. * Set the value of an uniform to a matrix (2x2)
  50138. * @param uniform defines the webGL uniform location where to store the value
  50139. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50140. */
  50141. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50142. /**
  50143. * Set the value of an uniform to a number (float)
  50144. * @param uniform defines the webGL uniform location where to store the value
  50145. * @param value defines the float number to store
  50146. */
  50147. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50148. /**
  50149. * Set the value of an uniform to a vec2
  50150. * @param uniform defines the webGL uniform location where to store the value
  50151. * @param x defines the 1st component of the value
  50152. * @param y defines the 2nd component of the value
  50153. */
  50154. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50155. /**
  50156. * Set the value of an uniform to a vec3
  50157. * @param uniform defines the webGL uniform location where to store the value
  50158. * @param x defines the 1st component of the value
  50159. * @param y defines the 2nd component of the value
  50160. * @param z defines the 3rd component of the value
  50161. */
  50162. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50163. /**
  50164. * Set the value of an uniform to a boolean
  50165. * @param uniform defines the webGL uniform location where to store the value
  50166. * @param bool defines the boolean to store
  50167. */
  50168. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50169. /**
  50170. * Set the value of an uniform to a vec4
  50171. * @param uniform defines the webGL uniform location where to store the value
  50172. * @param x defines the 1st component of the value
  50173. * @param y defines the 2nd component of the value
  50174. * @param z defines the 3rd component of the value
  50175. * @param w defines the 4th component of the value
  50176. */
  50177. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50178. /**
  50179. * Sets the current alpha mode
  50180. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50181. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50182. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50183. */
  50184. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50185. /**
  50186. * Bind webGl buffers directly to the webGL context
  50187. * @param vertexBuffers defines the vertex buffer to bind
  50188. * @param indexBuffer defines the index buffer to bind
  50189. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50190. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50191. * @param effect defines the effect associated with the vertex buffer
  50192. */
  50193. bindBuffers(vertexBuffers: {
  50194. [key: string]: VertexBuffer;
  50195. }, indexBuffer: DataBuffer, effect: Effect): void;
  50196. /**
  50197. * Force the entire cache to be cleared
  50198. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50199. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50200. */
  50201. wipeCaches(bruteForce?: boolean): void;
  50202. /**
  50203. * Send a draw order
  50204. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50205. * @param indexStart defines the starting index
  50206. * @param indexCount defines the number of index to draw
  50207. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50208. */
  50209. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50210. /**
  50211. * Draw a list of indexed primitives
  50212. * @param fillMode defines the primitive to use
  50213. * @param indexStart defines the starting index
  50214. * @param indexCount defines the number of index to draw
  50215. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50216. */
  50217. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50218. /**
  50219. * Draw a list of unindexed primitives
  50220. * @param fillMode defines the primitive to use
  50221. * @param verticesStart defines the index of first vertex to draw
  50222. * @param verticesCount defines the count of vertices to draw
  50223. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50224. */
  50225. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50226. /** @hidden */
  50227. _createTexture(): WebGLTexture;
  50228. /** @hidden */
  50229. _releaseTexture(texture: InternalTexture): void;
  50230. /**
  50231. * Usually called from Texture.ts.
  50232. * Passed information to create a WebGLTexture
  50233. * @param urlArg defines a value which contains one of the following:
  50234. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50235. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50236. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50237. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50238. * @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)
  50239. * @param scene needed for loading to the correct scene
  50240. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50241. * @param onLoad optional callback to be called upon successful completion
  50242. * @param onError optional callback to be called upon failure
  50243. * @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
  50244. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50245. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50246. * @param forcedExtension defines the extension to use to pick the right loader
  50247. * @param mimeType defines an optional mime type
  50248. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50249. */
  50250. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  50251. /**
  50252. * Creates a new render target texture
  50253. * @param size defines the size of the texture
  50254. * @param options defines the options used to create the texture
  50255. * @returns a new render target texture stored in an InternalTexture
  50256. */
  50257. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50258. /**
  50259. * Update the sampling mode of a given texture
  50260. * @param samplingMode defines the required sampling mode
  50261. * @param texture defines the texture to update
  50262. */
  50263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50264. /**
  50265. * Binds the frame buffer to the specified texture.
  50266. * @param texture The texture to render to or null for the default canvas
  50267. * @param faceIndex The face of the texture to render to in case of cube texture
  50268. * @param requiredWidth The width of the target to render to
  50269. * @param requiredHeight The height of the target to render to
  50270. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50271. * @param lodLevel defines le lod level to bind to the frame buffer
  50272. */
  50273. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50274. /**
  50275. * Unbind the current render target texture from the webGL context
  50276. * @param texture defines the render target texture to unbind
  50277. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50278. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50279. */
  50280. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50281. /**
  50282. * Creates a dynamic vertex buffer
  50283. * @param vertices the data for the dynamic vertex buffer
  50284. * @returns the new WebGL dynamic buffer
  50285. */
  50286. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50287. /**
  50288. * Update the content of a dynamic texture
  50289. * @param texture defines the texture to update
  50290. * @param canvas defines the canvas containing the source
  50291. * @param invertY defines if data must be stored with Y axis inverted
  50292. * @param premulAlpha defines if alpha is stored as premultiplied
  50293. * @param format defines the format of the data
  50294. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50295. */
  50296. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50297. /**
  50298. * Gets a boolean indicating if all created effects are ready
  50299. * @returns true if all effects are ready
  50300. */
  50301. areAllEffectsReady(): boolean;
  50302. /**
  50303. * @hidden
  50304. * Get the current error code of the webGL context
  50305. * @returns the error code
  50306. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50307. */
  50308. getError(): number;
  50309. /** @hidden */
  50310. _getUnpackAlignement(): number;
  50311. /** @hidden */
  50312. _unpackFlipY(value: boolean): void;
  50313. /**
  50314. * Update a dynamic index buffer
  50315. * @param indexBuffer defines the target index buffer
  50316. * @param indices defines the data to update
  50317. * @param offset defines the offset in the target index buffer where update should start
  50318. */
  50319. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50320. /**
  50321. * Updates a dynamic vertex buffer.
  50322. * @param vertexBuffer the vertex buffer to update
  50323. * @param vertices the data used to update the vertex buffer
  50324. * @param byteOffset the byte offset of the data (optional)
  50325. * @param byteLength the byte length of the data (optional)
  50326. */
  50327. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50328. /** @hidden */
  50329. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50330. /** @hidden */
  50331. _bindTexture(channel: number, texture: InternalTexture): void;
  50332. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50333. /**
  50334. * 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
  50335. */
  50336. releaseEffects(): void;
  50337. displayLoadingUI(): void;
  50338. hideLoadingUI(): void;
  50339. /** @hidden */
  50340. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50341. /** @hidden */
  50342. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50343. /** @hidden */
  50344. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50345. /** @hidden */
  50346. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50347. }
  50348. }
  50349. declare module BABYLON {
  50350. /**
  50351. * @hidden
  50352. **/
  50353. export class _TimeToken {
  50354. _startTimeQuery: Nullable<WebGLQuery>;
  50355. _endTimeQuery: Nullable<WebGLQuery>;
  50356. _timeElapsedQuery: Nullable<WebGLQuery>;
  50357. _timeElapsedQueryEnded: boolean;
  50358. }
  50359. }
  50360. declare module BABYLON {
  50361. /** @hidden */
  50362. export class _OcclusionDataStorage {
  50363. /** @hidden */
  50364. occlusionInternalRetryCounter: number;
  50365. /** @hidden */
  50366. isOcclusionQueryInProgress: boolean;
  50367. /** @hidden */
  50368. isOccluded: boolean;
  50369. /** @hidden */
  50370. occlusionRetryCount: number;
  50371. /** @hidden */
  50372. occlusionType: number;
  50373. /** @hidden */
  50374. occlusionQueryAlgorithmType: number;
  50375. }
  50376. interface Engine {
  50377. /**
  50378. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50379. * @return the new query
  50380. */
  50381. createQuery(): WebGLQuery;
  50382. /**
  50383. * Delete and release a webGL query
  50384. * @param query defines the query to delete
  50385. * @return the current engine
  50386. */
  50387. deleteQuery(query: WebGLQuery): Engine;
  50388. /**
  50389. * Check if a given query has resolved and got its value
  50390. * @param query defines the query to check
  50391. * @returns true if the query got its value
  50392. */
  50393. isQueryResultAvailable(query: WebGLQuery): boolean;
  50394. /**
  50395. * Gets the value of a given query
  50396. * @param query defines the query to check
  50397. * @returns the value of the query
  50398. */
  50399. getQueryResult(query: WebGLQuery): number;
  50400. /**
  50401. * Initiates an occlusion query
  50402. * @param algorithmType defines the algorithm to use
  50403. * @param query defines the query to use
  50404. * @returns the current engine
  50405. * @see http://doc.babylonjs.com/features/occlusionquery
  50406. */
  50407. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50408. /**
  50409. * Ends an occlusion query
  50410. * @see http://doc.babylonjs.com/features/occlusionquery
  50411. * @param algorithmType defines the algorithm to use
  50412. * @returns the current engine
  50413. */
  50414. endOcclusionQuery(algorithmType: number): Engine;
  50415. /**
  50416. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50417. * Please note that only one query can be issued at a time
  50418. * @returns a time token used to track the time span
  50419. */
  50420. startTimeQuery(): Nullable<_TimeToken>;
  50421. /**
  50422. * Ends a time query
  50423. * @param token defines the token used to measure the time span
  50424. * @returns the time spent (in ns)
  50425. */
  50426. endTimeQuery(token: _TimeToken): int;
  50427. /** @hidden */
  50428. _currentNonTimestampToken: Nullable<_TimeToken>;
  50429. /** @hidden */
  50430. _createTimeQuery(): WebGLQuery;
  50431. /** @hidden */
  50432. _deleteTimeQuery(query: WebGLQuery): void;
  50433. /** @hidden */
  50434. _getGlAlgorithmType(algorithmType: number): number;
  50435. /** @hidden */
  50436. _getTimeQueryResult(query: WebGLQuery): any;
  50437. /** @hidden */
  50438. _getTimeQueryAvailability(query: WebGLQuery): any;
  50439. }
  50440. interface AbstractMesh {
  50441. /**
  50442. * Backing filed
  50443. * @hidden
  50444. */
  50445. __occlusionDataStorage: _OcclusionDataStorage;
  50446. /**
  50447. * Access property
  50448. * @hidden
  50449. */
  50450. _occlusionDataStorage: _OcclusionDataStorage;
  50451. /**
  50452. * 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.
  50453. * The default value is -1 which means don't break the query and wait till the result
  50454. * @see http://doc.babylonjs.com/features/occlusionquery
  50455. */
  50456. occlusionRetryCount: number;
  50457. /**
  50458. * 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:
  50459. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50460. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50461. * * 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.
  50462. * @see http://doc.babylonjs.com/features/occlusionquery
  50463. */
  50464. occlusionType: number;
  50465. /**
  50466. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50467. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50468. * * 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.
  50469. * @see http://doc.babylonjs.com/features/occlusionquery
  50470. */
  50471. occlusionQueryAlgorithmType: number;
  50472. /**
  50473. * 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
  50474. * @see http://doc.babylonjs.com/features/occlusionquery
  50475. */
  50476. isOccluded: boolean;
  50477. /**
  50478. * Flag to check the progress status of the query
  50479. * @see http://doc.babylonjs.com/features/occlusionquery
  50480. */
  50481. isOcclusionQueryInProgress: boolean;
  50482. }
  50483. }
  50484. declare module BABYLON {
  50485. /** @hidden */
  50486. export var _forceTransformFeedbackToBundle: boolean;
  50487. interface Engine {
  50488. /**
  50489. * Creates a webGL transform feedback object
  50490. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50491. * @returns the webGL transform feedback object
  50492. */
  50493. createTransformFeedback(): WebGLTransformFeedback;
  50494. /**
  50495. * Delete a webGL transform feedback object
  50496. * @param value defines the webGL transform feedback object to delete
  50497. */
  50498. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50499. /**
  50500. * Bind a webGL transform feedback object to the webgl context
  50501. * @param value defines the webGL transform feedback object to bind
  50502. */
  50503. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50504. /**
  50505. * Begins a transform feedback operation
  50506. * @param usePoints defines if points or triangles must be used
  50507. */
  50508. beginTransformFeedback(usePoints: boolean): void;
  50509. /**
  50510. * Ends a transform feedback operation
  50511. */
  50512. endTransformFeedback(): void;
  50513. /**
  50514. * Specify the varyings to use with transform feedback
  50515. * @param program defines the associated webGL program
  50516. * @param value defines the list of strings representing the varying names
  50517. */
  50518. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50519. /**
  50520. * Bind a webGL buffer for a transform feedback operation
  50521. * @param value defines the webGL buffer to bind
  50522. */
  50523. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50524. }
  50525. }
  50526. declare module BABYLON {
  50527. /**
  50528. * Creation options of the multi render target texture.
  50529. */
  50530. export interface IMultiRenderTargetOptions {
  50531. /**
  50532. * Define if the texture needs to create mip maps after render.
  50533. */
  50534. generateMipMaps?: boolean;
  50535. /**
  50536. * Define the types of all the draw buffers we want to create
  50537. */
  50538. types?: number[];
  50539. /**
  50540. * Define the sampling modes of all the draw buffers we want to create
  50541. */
  50542. samplingModes?: number[];
  50543. /**
  50544. * Define if a depth buffer is required
  50545. */
  50546. generateDepthBuffer?: boolean;
  50547. /**
  50548. * Define if a stencil buffer is required
  50549. */
  50550. generateStencilBuffer?: boolean;
  50551. /**
  50552. * Define if a depth texture is required instead of a depth buffer
  50553. */
  50554. generateDepthTexture?: boolean;
  50555. /**
  50556. * Define the number of desired draw buffers
  50557. */
  50558. textureCount?: number;
  50559. /**
  50560. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50561. */
  50562. doNotChangeAspectRatio?: boolean;
  50563. /**
  50564. * Define the default type of the buffers we are creating
  50565. */
  50566. defaultType?: number;
  50567. }
  50568. /**
  50569. * A multi render target, like a render target provides the ability to render to a texture.
  50570. * Unlike the render target, it can render to several draw buffers in one draw.
  50571. * This is specially interesting in deferred rendering or for any effects requiring more than
  50572. * just one color from a single pass.
  50573. */
  50574. export class MultiRenderTarget extends RenderTargetTexture {
  50575. private _internalTextures;
  50576. private _textures;
  50577. private _multiRenderTargetOptions;
  50578. /**
  50579. * Get if draw buffers are currently supported by the used hardware and browser.
  50580. */
  50581. get isSupported(): boolean;
  50582. /**
  50583. * Get the list of textures generated by the multi render target.
  50584. */
  50585. get textures(): Texture[];
  50586. /**
  50587. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50588. */
  50589. get depthTexture(): Texture;
  50590. /**
  50591. * Set the wrapping mode on U of all the textures we are rendering to.
  50592. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50593. */
  50594. set wrapU(wrap: number);
  50595. /**
  50596. * Set the wrapping mode on V of all the textures we are rendering to.
  50597. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50598. */
  50599. set wrapV(wrap: number);
  50600. /**
  50601. * Instantiate a new multi render target texture.
  50602. * A multi render target, like a render target provides the ability to render to a texture.
  50603. * Unlike the render target, it can render to several draw buffers in one draw.
  50604. * This is specially interesting in deferred rendering or for any effects requiring more than
  50605. * just one color from a single pass.
  50606. * @param name Define the name of the texture
  50607. * @param size Define the size of the buffers to render to
  50608. * @param count Define the number of target we are rendering into
  50609. * @param scene Define the scene the texture belongs to
  50610. * @param options Define the options used to create the multi render target
  50611. */
  50612. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50613. /** @hidden */
  50614. _rebuild(): void;
  50615. private _createInternalTextures;
  50616. private _createTextures;
  50617. /**
  50618. * Define the number of samples used if MSAA is enabled.
  50619. */
  50620. get samples(): number;
  50621. set samples(value: number);
  50622. /**
  50623. * Resize all the textures in the multi render target.
  50624. * Be carrefull as it will recreate all the data in the new texture.
  50625. * @param size Define the new size
  50626. */
  50627. resize(size: any): void;
  50628. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50629. /**
  50630. * Dispose the render targets and their associated resources
  50631. */
  50632. dispose(): void;
  50633. /**
  50634. * Release all the underlying texture used as draw buffers.
  50635. */
  50636. releaseInternalTextures(): void;
  50637. }
  50638. }
  50639. declare module BABYLON {
  50640. interface ThinEngine {
  50641. /**
  50642. * Unbind a list of render target textures from the webGL context
  50643. * This is used only when drawBuffer extension or webGL2 are active
  50644. * @param textures defines the render target textures to unbind
  50645. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50646. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50647. */
  50648. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50649. /**
  50650. * Create a multi render target texture
  50651. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50652. * @param size defines the size of the texture
  50653. * @param options defines the creation options
  50654. * @returns the cube texture as an InternalTexture
  50655. */
  50656. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50657. /**
  50658. * Update the sample count for a given multiple render target texture
  50659. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50660. * @param textures defines the textures to update
  50661. * @param samples defines the sample count to set
  50662. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50663. */
  50664. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50665. }
  50666. }
  50667. declare module BABYLON {
  50668. /**
  50669. * Class used to define an additional view for the engine
  50670. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50671. */
  50672. export class EngineView {
  50673. /** Defines the canvas where to render the view */
  50674. target: HTMLCanvasElement;
  50675. /** Defines an optional camera used to render the view (will use active camera else) */
  50676. camera?: Camera;
  50677. }
  50678. interface Engine {
  50679. /**
  50680. * Gets or sets the HTML element to use for attaching events
  50681. */
  50682. inputElement: Nullable<HTMLElement>;
  50683. /**
  50684. * Gets the current engine view
  50685. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50686. */
  50687. activeView: Nullable<EngineView>;
  50688. /** Gets or sets the list of views */
  50689. views: EngineView[];
  50690. /**
  50691. * Register a new child canvas
  50692. * @param canvas defines the canvas to register
  50693. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50694. * @returns the associated view
  50695. */
  50696. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50697. /**
  50698. * Remove a registered child canvas
  50699. * @param canvas defines the canvas to remove
  50700. * @returns the current engine
  50701. */
  50702. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50703. }
  50704. }
  50705. declare module BABYLON {
  50706. interface Engine {
  50707. /** @hidden */
  50708. _excludedCompressedTextures: string[];
  50709. /** @hidden */
  50710. _textureFormatInUse: string;
  50711. /**
  50712. * Gets the list of texture formats supported
  50713. */
  50714. readonly texturesSupported: Array<string>;
  50715. /**
  50716. * Gets the texture format in use
  50717. */
  50718. readonly textureFormatInUse: Nullable<string>;
  50719. /**
  50720. * Set the compressed texture extensions or file names to skip.
  50721. *
  50722. * @param skippedFiles defines the list of those texture files you want to skip
  50723. * Example: [".dds", ".env", "myfile.png"]
  50724. */
  50725. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50726. /**
  50727. * Set the compressed texture format to use, based on the formats you have, and the formats
  50728. * supported by the hardware / browser.
  50729. *
  50730. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50731. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50732. * to API arguments needed to compressed textures. This puts the burden on the container
  50733. * generator to house the arcane code for determining these for current & future formats.
  50734. *
  50735. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50736. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50737. *
  50738. * Note: The result of this call is not taken into account when a texture is base64.
  50739. *
  50740. * @param formatsAvailable defines the list of those format families you have created
  50741. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50742. *
  50743. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50744. * @returns The extension selected.
  50745. */
  50746. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50747. }
  50748. }
  50749. declare module BABYLON {
  50750. /**
  50751. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50752. */
  50753. export interface CubeMapInfo {
  50754. /**
  50755. * The pixel array for the front face.
  50756. * This is stored in format, left to right, up to down format.
  50757. */
  50758. front: Nullable<ArrayBufferView>;
  50759. /**
  50760. * The pixel array for the back face.
  50761. * This is stored in format, left to right, up to down format.
  50762. */
  50763. back: Nullable<ArrayBufferView>;
  50764. /**
  50765. * The pixel array for the left face.
  50766. * This is stored in format, left to right, up to down format.
  50767. */
  50768. left: Nullable<ArrayBufferView>;
  50769. /**
  50770. * The pixel array for the right face.
  50771. * This is stored in format, left to right, up to down format.
  50772. */
  50773. right: Nullable<ArrayBufferView>;
  50774. /**
  50775. * The pixel array for the up face.
  50776. * This is stored in format, left to right, up to down format.
  50777. */
  50778. up: Nullable<ArrayBufferView>;
  50779. /**
  50780. * The pixel array for the down face.
  50781. * This is stored in format, left to right, up to down format.
  50782. */
  50783. down: Nullable<ArrayBufferView>;
  50784. /**
  50785. * The size of the cubemap stored.
  50786. *
  50787. * Each faces will be size * size pixels.
  50788. */
  50789. size: number;
  50790. /**
  50791. * The format of the texture.
  50792. *
  50793. * RGBA, RGB.
  50794. */
  50795. format: number;
  50796. /**
  50797. * The type of the texture data.
  50798. *
  50799. * UNSIGNED_INT, FLOAT.
  50800. */
  50801. type: number;
  50802. /**
  50803. * Specifies whether the texture is in gamma space.
  50804. */
  50805. gammaSpace: boolean;
  50806. }
  50807. /**
  50808. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50809. */
  50810. export class PanoramaToCubeMapTools {
  50811. private static FACE_LEFT;
  50812. private static FACE_RIGHT;
  50813. private static FACE_FRONT;
  50814. private static FACE_BACK;
  50815. private static FACE_DOWN;
  50816. private static FACE_UP;
  50817. /**
  50818. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50819. *
  50820. * @param float32Array The source data.
  50821. * @param inputWidth The width of the input panorama.
  50822. * @param inputHeight The height of the input panorama.
  50823. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50824. * @return The cubemap data
  50825. */
  50826. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50827. private static CreateCubemapTexture;
  50828. private static CalcProjectionSpherical;
  50829. }
  50830. }
  50831. declare module BABYLON {
  50832. /**
  50833. * Helper class dealing with the extraction of spherical polynomial dataArray
  50834. * from a cube map.
  50835. */
  50836. export class CubeMapToSphericalPolynomialTools {
  50837. private static FileFaces;
  50838. /**
  50839. * Converts a texture to the according Spherical Polynomial data.
  50840. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50841. *
  50842. * @param texture The texture to extract the information from.
  50843. * @return The Spherical Polynomial data.
  50844. */
  50845. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50846. /**
  50847. * Converts a cubemap to the according Spherical Polynomial data.
  50848. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50849. *
  50850. * @param cubeInfo The Cube map to extract the information from.
  50851. * @return The Spherical Polynomial data.
  50852. */
  50853. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50854. }
  50855. }
  50856. declare module BABYLON {
  50857. interface BaseTexture {
  50858. /**
  50859. * Get the polynomial representation of the texture data.
  50860. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50861. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50862. */
  50863. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50864. }
  50865. }
  50866. declare module BABYLON {
  50867. /** @hidden */
  50868. export var rgbdEncodePixelShader: {
  50869. name: string;
  50870. shader: string;
  50871. };
  50872. }
  50873. declare module BABYLON {
  50874. /** @hidden */
  50875. export var rgbdDecodePixelShader: {
  50876. name: string;
  50877. shader: string;
  50878. };
  50879. }
  50880. declare module BABYLON {
  50881. /**
  50882. * Raw texture data and descriptor sufficient for WebGL texture upload
  50883. */
  50884. export interface EnvironmentTextureInfo {
  50885. /**
  50886. * Version of the environment map
  50887. */
  50888. version: number;
  50889. /**
  50890. * Width of image
  50891. */
  50892. width: number;
  50893. /**
  50894. * Irradiance information stored in the file.
  50895. */
  50896. irradiance: any;
  50897. /**
  50898. * Specular information stored in the file.
  50899. */
  50900. specular: any;
  50901. }
  50902. /**
  50903. * Defines One Image in the file. It requires only the position in the file
  50904. * as well as the length.
  50905. */
  50906. interface BufferImageData {
  50907. /**
  50908. * Length of the image data.
  50909. */
  50910. length: number;
  50911. /**
  50912. * Position of the data from the null terminator delimiting the end of the JSON.
  50913. */
  50914. position: number;
  50915. }
  50916. /**
  50917. * Defines the specular data enclosed in the file.
  50918. * This corresponds to the version 1 of the data.
  50919. */
  50920. export interface EnvironmentTextureSpecularInfoV1 {
  50921. /**
  50922. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50923. */
  50924. specularDataPosition?: number;
  50925. /**
  50926. * This contains all the images data needed to reconstruct the cubemap.
  50927. */
  50928. mipmaps: Array<BufferImageData>;
  50929. /**
  50930. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50931. */
  50932. lodGenerationScale: number;
  50933. }
  50934. /**
  50935. * Sets of helpers addressing the serialization and deserialization of environment texture
  50936. * stored in a BabylonJS env file.
  50937. * Those files are usually stored as .env files.
  50938. */
  50939. export class EnvironmentTextureTools {
  50940. /**
  50941. * Magic number identifying the env file.
  50942. */
  50943. private static _MagicBytes;
  50944. /**
  50945. * Gets the environment info from an env file.
  50946. * @param data The array buffer containing the .env bytes.
  50947. * @returns the environment file info (the json header) if successfully parsed.
  50948. */
  50949. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50950. /**
  50951. * Creates an environment texture from a loaded cube texture.
  50952. * @param texture defines the cube texture to convert in env file
  50953. * @return a promise containing the environment data if succesfull.
  50954. */
  50955. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50956. /**
  50957. * Creates a JSON representation of the spherical data.
  50958. * @param texture defines the texture containing the polynomials
  50959. * @return the JSON representation of the spherical info
  50960. */
  50961. private static _CreateEnvTextureIrradiance;
  50962. /**
  50963. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50964. * @param data the image data
  50965. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50966. * @return the views described by info providing access to the underlying buffer
  50967. */
  50968. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50969. /**
  50970. * Uploads the texture info contained in the env file to the GPU.
  50971. * @param texture defines the internal texture to upload to
  50972. * @param data defines the data to load
  50973. * @param info defines the texture info retrieved through the GetEnvInfo method
  50974. * @returns a promise
  50975. */
  50976. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50977. private static _OnImageReadyAsync;
  50978. /**
  50979. * Uploads the levels of image data to the GPU.
  50980. * @param texture defines the internal texture to upload to
  50981. * @param imageData defines the array buffer views of image data [mipmap][face]
  50982. * @returns a promise
  50983. */
  50984. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50985. /**
  50986. * Uploads spherical polynomials information to the texture.
  50987. * @param texture defines the texture we are trying to upload the information to
  50988. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50989. */
  50990. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50991. /** @hidden */
  50992. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50993. }
  50994. }
  50995. declare module BABYLON {
  50996. /** @hidden */
  50997. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50998. private _genericAttributeLocation;
  50999. private _varyingLocationCount;
  51000. private _varyingLocationMap;
  51001. private _replacements;
  51002. private _textureCount;
  51003. private _uniforms;
  51004. lineProcessor(line: string): string;
  51005. attributeProcessor(attribute: string): string;
  51006. varyingProcessor(varying: string, isFragment: boolean): string;
  51007. uniformProcessor(uniform: string): string;
  51008. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51009. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51010. }
  51011. }
  51012. declare module BABYLON {
  51013. /**
  51014. * Class used to inline functions in shader code
  51015. */
  51016. export class ShaderCodeInliner {
  51017. private static readonly _RegexpFindFunctionNameAndType;
  51018. private _sourceCode;
  51019. private _functionDescr;
  51020. private _numMaxIterations;
  51021. /** Gets or sets the token used to mark the functions to inline */
  51022. inlineToken: string;
  51023. /** Gets or sets the debug mode */
  51024. debug: boolean;
  51025. /** Gets the code after the inlining process */
  51026. get code(): string;
  51027. /**
  51028. * Initializes the inliner
  51029. * @param sourceCode shader code source to inline
  51030. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51031. */
  51032. constructor(sourceCode: string, numMaxIterations?: number);
  51033. /**
  51034. * Start the processing of the shader code
  51035. */
  51036. processCode(): void;
  51037. private _collectFunctions;
  51038. private _processInlining;
  51039. private _extractBetweenMarkers;
  51040. private _skipWhitespaces;
  51041. private _removeComments;
  51042. private _replaceFunctionCallsByCode;
  51043. private _findBackward;
  51044. private _escapeRegExp;
  51045. private _replaceNames;
  51046. }
  51047. }
  51048. declare module BABYLON {
  51049. /**
  51050. * Container for accessors for natively-stored mesh data buffers.
  51051. */
  51052. class NativeDataBuffer extends DataBuffer {
  51053. /**
  51054. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51055. */
  51056. nativeIndexBuffer?: any;
  51057. /**
  51058. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51059. */
  51060. nativeVertexBuffer?: any;
  51061. }
  51062. /** @hidden */
  51063. class NativeTexture extends InternalTexture {
  51064. getInternalTexture(): InternalTexture;
  51065. getViewCount(): number;
  51066. }
  51067. /** @hidden */
  51068. export class NativeEngine extends Engine {
  51069. private readonly _native;
  51070. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51071. private readonly INVALID_HANDLE;
  51072. getHardwareScalingLevel(): number;
  51073. constructor();
  51074. dispose(): void;
  51075. /**
  51076. * Can be used to override the current requestAnimationFrame requester.
  51077. * @hidden
  51078. */
  51079. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51080. /**
  51081. * Override default engine behavior.
  51082. * @param color
  51083. * @param backBuffer
  51084. * @param depth
  51085. * @param stencil
  51086. */
  51087. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51088. /**
  51089. * Gets host document
  51090. * @returns the host document object
  51091. */
  51092. getHostDocument(): Nullable<Document>;
  51093. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51094. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51095. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51096. recordVertexArrayObject(vertexBuffers: {
  51097. [key: string]: VertexBuffer;
  51098. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51099. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51100. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51101. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51102. /**
  51103. * Draw a list of indexed primitives
  51104. * @param fillMode defines the primitive to use
  51105. * @param indexStart defines the starting index
  51106. * @param indexCount defines the number of index to draw
  51107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51108. */
  51109. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51110. /**
  51111. * Draw a list of unindexed primitives
  51112. * @param fillMode defines the primitive to use
  51113. * @param verticesStart defines the index of first vertex to draw
  51114. * @param verticesCount defines the count of vertices to draw
  51115. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51116. */
  51117. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51118. createPipelineContext(): IPipelineContext;
  51119. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51120. /** @hidden */
  51121. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51122. /** @hidden */
  51123. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51124. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51125. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51126. protected _setProgram(program: WebGLProgram): void;
  51127. _releaseEffect(effect: Effect): void;
  51128. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51129. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51130. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51131. bindSamplers(effect: Effect): void;
  51132. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51133. getRenderWidth(useScreen?: boolean): number;
  51134. getRenderHeight(useScreen?: boolean): number;
  51135. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51136. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51137. /**
  51138. * Set the z offset to apply to current rendering
  51139. * @param value defines the offset to apply
  51140. */
  51141. setZOffset(value: number): void;
  51142. /**
  51143. * Gets the current value of the zOffset
  51144. * @returns the current zOffset state
  51145. */
  51146. getZOffset(): number;
  51147. /**
  51148. * Enable or disable depth buffering
  51149. * @param enable defines the state to set
  51150. */
  51151. setDepthBuffer(enable: boolean): void;
  51152. /**
  51153. * Gets a boolean indicating if depth writing is enabled
  51154. * @returns the current depth writing state
  51155. */
  51156. getDepthWrite(): boolean;
  51157. /**
  51158. * Enable or disable depth writing
  51159. * @param enable defines the state to set
  51160. */
  51161. setDepthWrite(enable: boolean): void;
  51162. /**
  51163. * Enable or disable color writing
  51164. * @param enable defines the state to set
  51165. */
  51166. setColorWrite(enable: boolean): void;
  51167. /**
  51168. * Gets a boolean indicating if color writing is enabled
  51169. * @returns the current color writing state
  51170. */
  51171. getColorWrite(): boolean;
  51172. /**
  51173. * Sets alpha constants used by some alpha blending modes
  51174. * @param r defines the red component
  51175. * @param g defines the green component
  51176. * @param b defines the blue component
  51177. * @param a defines the alpha component
  51178. */
  51179. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51180. /**
  51181. * Sets the current alpha mode
  51182. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51183. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51184. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51185. */
  51186. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51187. /**
  51188. * Gets the current alpha mode
  51189. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51190. * @returns the current alpha mode
  51191. */
  51192. getAlphaMode(): number;
  51193. setInt(uniform: WebGLUniformLocation, int: number): void;
  51194. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51195. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51196. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51197. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51198. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51199. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51200. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51201. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51202. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51203. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51204. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51205. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51206. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51207. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51208. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51209. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51210. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51211. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51212. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51213. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51214. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51215. wipeCaches(bruteForce?: boolean): void;
  51216. _createTexture(): WebGLTexture;
  51217. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51218. /**
  51219. * Usually called from Texture.ts.
  51220. * Passed information to create a WebGLTexture
  51221. * @param url defines a value which contains one of the following:
  51222. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51223. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51224. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51225. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51226. * @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)
  51227. * @param scene needed for loading to the correct scene
  51228. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51229. * @param onLoad optional callback to be called upon successful completion
  51230. * @param onError optional callback to be called upon failure
  51231. * @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
  51232. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51233. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51234. * @param forcedExtension defines the extension to use to pick the right loader
  51235. * @param mimeType defines an optional mime type
  51236. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51237. */
  51238. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  51239. /**
  51240. * Creates a cube texture
  51241. * @param rootUrl defines the url where the files to load is located
  51242. * @param scene defines the current scene
  51243. * @param files defines the list of files to load (1 per face)
  51244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51245. * @param onLoad defines an optional callback raised when the texture is loaded
  51246. * @param onError defines an optional callback raised if there is an issue to load the texture
  51247. * @param format defines the format of the data
  51248. * @param forcedExtension defines the extension to use to pick the right loader
  51249. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51250. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51251. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51252. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51253. * @returns the cube texture as an InternalTexture
  51254. */
  51255. 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;
  51256. private _getSamplingFilter;
  51257. private static _GetNativeTextureFormat;
  51258. createRenderTargetTexture(size: number | {
  51259. width: number;
  51260. height: number;
  51261. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51262. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51263. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51264. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51265. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51266. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51267. /**
  51268. * Updates a dynamic vertex buffer.
  51269. * @param vertexBuffer the vertex buffer to update
  51270. * @param data the data used to update the vertex buffer
  51271. * @param byteOffset the byte offset of the data (optional)
  51272. * @param byteLength the byte length of the data (optional)
  51273. */
  51274. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51275. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51276. private _updateAnisotropicLevel;
  51277. private _getAddressMode;
  51278. /** @hidden */
  51279. _bindTexture(channel: number, texture: InternalTexture): void;
  51280. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51281. releaseEffects(): void;
  51282. /** @hidden */
  51283. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51284. /** @hidden */
  51285. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51286. /** @hidden */
  51287. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51288. /** @hidden */
  51289. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51290. }
  51291. }
  51292. declare module BABYLON {
  51293. /**
  51294. * Gather the list of clipboard event types as constants.
  51295. */
  51296. export class ClipboardEventTypes {
  51297. /**
  51298. * The clipboard event is fired when a copy command is active (pressed).
  51299. */
  51300. static readonly COPY: number;
  51301. /**
  51302. * The clipboard event is fired when a cut command is active (pressed).
  51303. */
  51304. static readonly CUT: number;
  51305. /**
  51306. * The clipboard event is fired when a paste command is active (pressed).
  51307. */
  51308. static readonly PASTE: number;
  51309. }
  51310. /**
  51311. * This class is used to store clipboard related info for the onClipboardObservable event.
  51312. */
  51313. export class ClipboardInfo {
  51314. /**
  51315. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51316. */
  51317. type: number;
  51318. /**
  51319. * Defines the related dom event
  51320. */
  51321. event: ClipboardEvent;
  51322. /**
  51323. *Creates an instance of ClipboardInfo.
  51324. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51325. * @param event Defines the related dom event
  51326. */
  51327. constructor(
  51328. /**
  51329. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51330. */
  51331. type: number,
  51332. /**
  51333. * Defines the related dom event
  51334. */
  51335. event: ClipboardEvent);
  51336. /**
  51337. * Get the clipboard event's type from the keycode.
  51338. * @param keyCode Defines the keyCode for the current keyboard event.
  51339. * @return {number}
  51340. */
  51341. static GetTypeFromCharacter(keyCode: number): number;
  51342. }
  51343. }
  51344. declare module BABYLON {
  51345. /**
  51346. * Google Daydream controller
  51347. */
  51348. export class DaydreamController extends WebVRController {
  51349. /**
  51350. * Base Url for the controller model.
  51351. */
  51352. static MODEL_BASE_URL: string;
  51353. /**
  51354. * File name for the controller model.
  51355. */
  51356. static MODEL_FILENAME: string;
  51357. /**
  51358. * Gamepad Id prefix used to identify Daydream Controller.
  51359. */
  51360. static readonly GAMEPAD_ID_PREFIX: string;
  51361. /**
  51362. * Creates a new DaydreamController from a gamepad
  51363. * @param vrGamepad the gamepad that the controller should be created from
  51364. */
  51365. constructor(vrGamepad: any);
  51366. /**
  51367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51368. * @param scene scene in which to add meshes
  51369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51370. */
  51371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51372. /**
  51373. * Called once for each button that changed state since the last frame
  51374. * @param buttonIdx Which button index changed
  51375. * @param state New state of the button
  51376. * @param changes Which properties on the state changed since last frame
  51377. */
  51378. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51379. }
  51380. }
  51381. declare module BABYLON {
  51382. /**
  51383. * Gear VR Controller
  51384. */
  51385. export class GearVRController extends WebVRController {
  51386. /**
  51387. * Base Url for the controller model.
  51388. */
  51389. static MODEL_BASE_URL: string;
  51390. /**
  51391. * File name for the controller model.
  51392. */
  51393. static MODEL_FILENAME: string;
  51394. /**
  51395. * Gamepad Id prefix used to identify this controller.
  51396. */
  51397. static readonly GAMEPAD_ID_PREFIX: string;
  51398. private readonly _buttonIndexToObservableNameMap;
  51399. /**
  51400. * Creates a new GearVRController from a gamepad
  51401. * @param vrGamepad the gamepad that the controller should be created from
  51402. */
  51403. constructor(vrGamepad: any);
  51404. /**
  51405. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51406. * @param scene scene in which to add meshes
  51407. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51408. */
  51409. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51410. /**
  51411. * Called once for each button that changed state since the last frame
  51412. * @param buttonIdx Which button index changed
  51413. * @param state New state of the button
  51414. * @param changes Which properties on the state changed since last frame
  51415. */
  51416. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51417. }
  51418. }
  51419. declare module BABYLON {
  51420. /**
  51421. * Generic Controller
  51422. */
  51423. export class GenericController extends WebVRController {
  51424. /**
  51425. * Base Url for the controller model.
  51426. */
  51427. static readonly MODEL_BASE_URL: string;
  51428. /**
  51429. * File name for the controller model.
  51430. */
  51431. static readonly MODEL_FILENAME: string;
  51432. /**
  51433. * Creates a new GenericController from a gamepad
  51434. * @param vrGamepad the gamepad that the controller should be created from
  51435. */
  51436. constructor(vrGamepad: any);
  51437. /**
  51438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51439. * @param scene scene in which to add meshes
  51440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51441. */
  51442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51443. /**
  51444. * Called once for each button that changed state since the last frame
  51445. * @param buttonIdx Which button index changed
  51446. * @param state New state of the button
  51447. * @param changes Which properties on the state changed since last frame
  51448. */
  51449. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51450. }
  51451. }
  51452. declare module BABYLON {
  51453. /**
  51454. * Oculus Touch Controller
  51455. */
  51456. export class OculusTouchController extends WebVRController {
  51457. /**
  51458. * Base Url for the controller model.
  51459. */
  51460. static MODEL_BASE_URL: string;
  51461. /**
  51462. * File name for the left controller model.
  51463. */
  51464. static MODEL_LEFT_FILENAME: string;
  51465. /**
  51466. * File name for the right controller model.
  51467. */
  51468. static MODEL_RIGHT_FILENAME: string;
  51469. /**
  51470. * Base Url for the Quest controller model.
  51471. */
  51472. static QUEST_MODEL_BASE_URL: string;
  51473. /**
  51474. * @hidden
  51475. * If the controllers are running on a device that needs the updated Quest controller models
  51476. */
  51477. static _IsQuest: boolean;
  51478. /**
  51479. * Fired when the secondary trigger on this controller is modified
  51480. */
  51481. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51482. /**
  51483. * Fired when the thumb rest on this controller is modified
  51484. */
  51485. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51486. /**
  51487. * Creates a new OculusTouchController from a gamepad
  51488. * @param vrGamepad the gamepad that the controller should be created from
  51489. */
  51490. constructor(vrGamepad: any);
  51491. /**
  51492. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51493. * @param scene scene in which to add meshes
  51494. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51495. */
  51496. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51497. /**
  51498. * Fired when the A button on this controller is modified
  51499. */
  51500. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51501. /**
  51502. * Fired when the B button on this controller is modified
  51503. */
  51504. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51505. /**
  51506. * Fired when the X button on this controller is modified
  51507. */
  51508. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51509. /**
  51510. * Fired when the Y button on this controller is modified
  51511. */
  51512. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51513. /**
  51514. * Called once for each button that changed state since the last frame
  51515. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51516. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51517. * 2) secondary trigger (same)
  51518. * 3) A (right) X (left), touch, pressed = value
  51519. * 4) B / Y
  51520. * 5) thumb rest
  51521. * @param buttonIdx Which button index changed
  51522. * @param state New state of the button
  51523. * @param changes Which properties on the state changed since last frame
  51524. */
  51525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51526. }
  51527. }
  51528. declare module BABYLON {
  51529. /**
  51530. * Vive Controller
  51531. */
  51532. export class ViveController extends WebVRController {
  51533. /**
  51534. * Base Url for the controller model.
  51535. */
  51536. static MODEL_BASE_URL: string;
  51537. /**
  51538. * File name for the controller model.
  51539. */
  51540. static MODEL_FILENAME: string;
  51541. /**
  51542. * Creates a new ViveController from a gamepad
  51543. * @param vrGamepad the gamepad that the controller should be created from
  51544. */
  51545. constructor(vrGamepad: any);
  51546. /**
  51547. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51548. * @param scene scene in which to add meshes
  51549. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51550. */
  51551. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51552. /**
  51553. * Fired when the left button on this controller is modified
  51554. */
  51555. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51556. /**
  51557. * Fired when the right button on this controller is modified
  51558. */
  51559. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51560. /**
  51561. * Fired when the menu button on this controller is modified
  51562. */
  51563. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51564. /**
  51565. * Called once for each button that changed state since the last frame
  51566. * Vive mapping:
  51567. * 0: touchpad
  51568. * 1: trigger
  51569. * 2: left AND right buttons
  51570. * 3: menu button
  51571. * @param buttonIdx Which button index changed
  51572. * @param state New state of the button
  51573. * @param changes Which properties on the state changed since last frame
  51574. */
  51575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51576. }
  51577. }
  51578. declare module BABYLON {
  51579. /**
  51580. * Defines the WindowsMotionController object that the state of the windows motion controller
  51581. */
  51582. export class WindowsMotionController extends WebVRController {
  51583. /**
  51584. * The base url used to load the left and right controller models
  51585. */
  51586. static MODEL_BASE_URL: string;
  51587. /**
  51588. * The name of the left controller model file
  51589. */
  51590. static MODEL_LEFT_FILENAME: string;
  51591. /**
  51592. * The name of the right controller model file
  51593. */
  51594. static MODEL_RIGHT_FILENAME: string;
  51595. /**
  51596. * The controller name prefix for this controller type
  51597. */
  51598. static readonly GAMEPAD_ID_PREFIX: string;
  51599. /**
  51600. * The controller id pattern for this controller type
  51601. */
  51602. private static readonly GAMEPAD_ID_PATTERN;
  51603. private _loadedMeshInfo;
  51604. protected readonly _mapping: {
  51605. buttons: string[];
  51606. buttonMeshNames: {
  51607. trigger: string;
  51608. menu: string;
  51609. grip: string;
  51610. thumbstick: string;
  51611. trackpad: string;
  51612. };
  51613. buttonObservableNames: {
  51614. trigger: string;
  51615. menu: string;
  51616. grip: string;
  51617. thumbstick: string;
  51618. trackpad: string;
  51619. };
  51620. axisMeshNames: string[];
  51621. pointingPoseMeshName: string;
  51622. };
  51623. /**
  51624. * Fired when the trackpad on this controller is clicked
  51625. */
  51626. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51627. /**
  51628. * Fired when the trackpad on this controller is modified
  51629. */
  51630. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51631. /**
  51632. * The current x and y values of this controller's trackpad
  51633. */
  51634. trackpad: StickValues;
  51635. /**
  51636. * Creates a new WindowsMotionController from a gamepad
  51637. * @param vrGamepad the gamepad that the controller should be created from
  51638. */
  51639. constructor(vrGamepad: any);
  51640. /**
  51641. * Fired when the trigger on this controller is modified
  51642. */
  51643. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51644. /**
  51645. * Fired when the menu button on this controller is modified
  51646. */
  51647. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51648. /**
  51649. * Fired when the grip button on this controller is modified
  51650. */
  51651. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51652. /**
  51653. * Fired when the thumbstick button on this controller is modified
  51654. */
  51655. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51656. /**
  51657. * Fired when the touchpad button on this controller is modified
  51658. */
  51659. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51660. /**
  51661. * Fired when the touchpad values on this controller are modified
  51662. */
  51663. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51664. protected _updateTrackpad(): void;
  51665. /**
  51666. * Called once per frame by the engine.
  51667. */
  51668. update(): void;
  51669. /**
  51670. * Called once for each button that changed state since the last frame
  51671. * @param buttonIdx Which button index changed
  51672. * @param state New state of the button
  51673. * @param changes Which properties on the state changed since last frame
  51674. */
  51675. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51676. /**
  51677. * Moves the buttons on the controller mesh based on their current state
  51678. * @param buttonName the name of the button to move
  51679. * @param buttonValue the value of the button which determines the buttons new position
  51680. */
  51681. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51682. /**
  51683. * Moves the axis on the controller mesh based on its current state
  51684. * @param axis the index of the axis
  51685. * @param axisValue the value of the axis which determines the meshes new position
  51686. * @hidden
  51687. */
  51688. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51689. /**
  51690. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51691. * @param scene scene in which to add meshes
  51692. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51693. */
  51694. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51695. /**
  51696. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51697. * can be transformed by button presses and axes values, based on this._mapping.
  51698. *
  51699. * @param scene scene in which the meshes exist
  51700. * @param meshes list of meshes that make up the controller model to process
  51701. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51702. */
  51703. private processModel;
  51704. private createMeshInfo;
  51705. /**
  51706. * Gets the ray of the controller in the direction the controller is pointing
  51707. * @param length the length the resulting ray should be
  51708. * @returns a ray in the direction the controller is pointing
  51709. */
  51710. getForwardRay(length?: number): Ray;
  51711. /**
  51712. * Disposes of the controller
  51713. */
  51714. dispose(): void;
  51715. }
  51716. /**
  51717. * This class represents a new windows motion controller in XR.
  51718. */
  51719. export class XRWindowsMotionController extends WindowsMotionController {
  51720. /**
  51721. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51722. */
  51723. protected readonly _mapping: {
  51724. buttons: string[];
  51725. buttonMeshNames: {
  51726. trigger: string;
  51727. menu: string;
  51728. grip: string;
  51729. thumbstick: string;
  51730. trackpad: string;
  51731. };
  51732. buttonObservableNames: {
  51733. trigger: string;
  51734. menu: string;
  51735. grip: string;
  51736. thumbstick: string;
  51737. trackpad: string;
  51738. };
  51739. axisMeshNames: string[];
  51740. pointingPoseMeshName: string;
  51741. };
  51742. /**
  51743. * Construct a new XR-Based windows motion controller
  51744. *
  51745. * @param gamepadInfo the gamepad object from the browser
  51746. */
  51747. constructor(gamepadInfo: any);
  51748. /**
  51749. * holds the thumbstick values (X,Y)
  51750. */
  51751. thumbstickValues: StickValues;
  51752. /**
  51753. * Fired when the thumbstick on this controller is clicked
  51754. */
  51755. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51756. /**
  51757. * Fired when the thumbstick on this controller is modified
  51758. */
  51759. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51760. /**
  51761. * Fired when the touchpad button on this controller is modified
  51762. */
  51763. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51764. /**
  51765. * Fired when the touchpad values on this controller are modified
  51766. */
  51767. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51768. /**
  51769. * Fired when the thumbstick button on this controller is modified
  51770. * here to prevent breaking changes
  51771. */
  51772. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51773. /**
  51774. * updating the thumbstick(!) and not the trackpad.
  51775. * This is named this way due to the difference between WebVR and XR and to avoid
  51776. * changing the parent class.
  51777. */
  51778. protected _updateTrackpad(): void;
  51779. /**
  51780. * Disposes the class with joy
  51781. */
  51782. dispose(): void;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * Class containing static functions to help procedurally build meshes
  51788. */
  51789. export class PolyhedronBuilder {
  51790. /**
  51791. * Creates a polyhedron mesh
  51792. * * 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
  51793. * * The parameter `size` (positive float, default 1) sets the polygon size
  51794. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51795. * * 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`
  51796. * * 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
  51797. * * 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)`)
  51798. * * 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
  51799. * * 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
  51800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51801. * * 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
  51802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51803. * @param name defines the name of the mesh
  51804. * @param options defines the options used to create the mesh
  51805. * @param scene defines the hosting scene
  51806. * @returns the polyhedron mesh
  51807. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51808. */
  51809. static CreatePolyhedron(name: string, options: {
  51810. type?: number;
  51811. size?: number;
  51812. sizeX?: number;
  51813. sizeY?: number;
  51814. sizeZ?: number;
  51815. custom?: any;
  51816. faceUV?: Vector4[];
  51817. faceColors?: Color4[];
  51818. flat?: boolean;
  51819. updatable?: boolean;
  51820. sideOrientation?: number;
  51821. frontUVs?: Vector4;
  51822. backUVs?: Vector4;
  51823. }, scene?: Nullable<Scene>): Mesh;
  51824. }
  51825. }
  51826. declare module BABYLON {
  51827. /**
  51828. * Gizmo that enables scaling a mesh along 3 axis
  51829. */
  51830. export class ScaleGizmo extends Gizmo {
  51831. /**
  51832. * Internal gizmo used for interactions on the x axis
  51833. */
  51834. xGizmo: AxisScaleGizmo;
  51835. /**
  51836. * Internal gizmo used for interactions on the y axis
  51837. */
  51838. yGizmo: AxisScaleGizmo;
  51839. /**
  51840. * Internal gizmo used for interactions on the z axis
  51841. */
  51842. zGizmo: AxisScaleGizmo;
  51843. /**
  51844. * Internal gizmo used to scale all axis equally
  51845. */
  51846. uniformScaleGizmo: AxisScaleGizmo;
  51847. private _meshAttached;
  51848. private _updateGizmoRotationToMatchAttachedMesh;
  51849. private _snapDistance;
  51850. private _scaleRatio;
  51851. private _uniformScalingMesh;
  51852. private _octahedron;
  51853. private _sensitivity;
  51854. /** Fires an event when any of it's sub gizmos are dragged */
  51855. onDragStartObservable: Observable<unknown>;
  51856. /** Fires an event when any of it's sub gizmos are released from dragging */
  51857. onDragEndObservable: Observable<unknown>;
  51858. get attachedMesh(): Nullable<AbstractMesh>;
  51859. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51860. /**
  51861. * Creates a ScaleGizmo
  51862. * @param gizmoLayer The utility layer the gizmo will be added to
  51863. */
  51864. constructor(gizmoLayer?: UtilityLayerRenderer);
  51865. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51866. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51867. /**
  51868. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51869. */
  51870. set snapDistance(value: number);
  51871. get snapDistance(): number;
  51872. /**
  51873. * Ratio for the scale of the gizmo (Default: 1)
  51874. */
  51875. set scaleRatio(value: number);
  51876. get scaleRatio(): number;
  51877. /**
  51878. * Sensitivity factor for dragging (Default: 1)
  51879. */
  51880. set sensitivity(value: number);
  51881. get sensitivity(): number;
  51882. /**
  51883. * Disposes of the gizmo
  51884. */
  51885. dispose(): void;
  51886. }
  51887. }
  51888. declare module BABYLON {
  51889. /**
  51890. * Single axis scale gizmo
  51891. */
  51892. export class AxisScaleGizmo extends Gizmo {
  51893. /**
  51894. * Drag behavior responsible for the gizmos dragging interactions
  51895. */
  51896. dragBehavior: PointerDragBehavior;
  51897. private _pointerObserver;
  51898. /**
  51899. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51900. */
  51901. snapDistance: number;
  51902. /**
  51903. * Event that fires each time the gizmo snaps to a new location.
  51904. * * snapDistance is the the change in distance
  51905. */
  51906. onSnapObservable: Observable<{
  51907. snapDistance: number;
  51908. }>;
  51909. /**
  51910. * If the scaling operation should be done on all axis (default: false)
  51911. */
  51912. uniformScaling: boolean;
  51913. /**
  51914. * Custom sensitivity value for the drag strength
  51915. */
  51916. sensitivity: number;
  51917. private _isEnabled;
  51918. private _parent;
  51919. private _arrow;
  51920. private _coloredMaterial;
  51921. private _hoverMaterial;
  51922. /**
  51923. * Creates an AxisScaleGizmo
  51924. * @param gizmoLayer The utility layer the gizmo will be added to
  51925. * @param dragAxis The axis which the gizmo will be able to scale on
  51926. * @param color The color of the gizmo
  51927. */
  51928. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51929. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51930. /**
  51931. * If the gizmo is enabled
  51932. */
  51933. set isEnabled(value: boolean);
  51934. get isEnabled(): boolean;
  51935. /**
  51936. * Disposes of the gizmo
  51937. */
  51938. dispose(): void;
  51939. /**
  51940. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51941. * @param mesh The mesh to replace the default mesh of the gizmo
  51942. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51943. */
  51944. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51945. }
  51946. }
  51947. declare module BABYLON {
  51948. /**
  51949. * Bounding box gizmo
  51950. */
  51951. export class BoundingBoxGizmo extends Gizmo {
  51952. private _lineBoundingBox;
  51953. private _rotateSpheresParent;
  51954. private _scaleBoxesParent;
  51955. private _boundingDimensions;
  51956. private _renderObserver;
  51957. private _pointerObserver;
  51958. private _scaleDragSpeed;
  51959. private _tmpQuaternion;
  51960. private _tmpVector;
  51961. private _tmpRotationMatrix;
  51962. /**
  51963. * 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)
  51964. */
  51965. ignoreChildren: boolean;
  51966. /**
  51967. * 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)
  51968. */
  51969. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51970. /**
  51971. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51972. */
  51973. rotationSphereSize: number;
  51974. /**
  51975. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51976. */
  51977. scaleBoxSize: number;
  51978. /**
  51979. * 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)
  51980. */
  51981. fixedDragMeshScreenSize: boolean;
  51982. /**
  51983. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51984. */
  51985. fixedDragMeshScreenSizeDistanceFactor: number;
  51986. /**
  51987. * Fired when a rotation sphere or scale box is dragged
  51988. */
  51989. onDragStartObservable: Observable<{}>;
  51990. /**
  51991. * Fired when a scale box is dragged
  51992. */
  51993. onScaleBoxDragObservable: Observable<{}>;
  51994. /**
  51995. * Fired when a scale box drag is ended
  51996. */
  51997. onScaleBoxDragEndObservable: Observable<{}>;
  51998. /**
  51999. * Fired when a rotation sphere is dragged
  52000. */
  52001. onRotationSphereDragObservable: Observable<{}>;
  52002. /**
  52003. * Fired when a rotation sphere drag is ended
  52004. */
  52005. onRotationSphereDragEndObservable: Observable<{}>;
  52006. /**
  52007. * 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)
  52008. */
  52009. scalePivot: Nullable<Vector3>;
  52010. /**
  52011. * Mesh used as a pivot to rotate the attached mesh
  52012. */
  52013. private _anchorMesh;
  52014. private _existingMeshScale;
  52015. private _dragMesh;
  52016. private pointerDragBehavior;
  52017. private coloredMaterial;
  52018. private hoverColoredMaterial;
  52019. /**
  52020. * Sets the color of the bounding box gizmo
  52021. * @param color the color to set
  52022. */
  52023. setColor(color: Color3): void;
  52024. /**
  52025. * Creates an BoundingBoxGizmo
  52026. * @param gizmoLayer The utility layer the gizmo will be added to
  52027. * @param color The color of the gizmo
  52028. */
  52029. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52030. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52031. private _selectNode;
  52032. /**
  52033. * Updates the bounding box information for the Gizmo
  52034. */
  52035. updateBoundingBox(): void;
  52036. private _updateRotationSpheres;
  52037. private _updateScaleBoxes;
  52038. /**
  52039. * Enables rotation on the specified axis and disables rotation on the others
  52040. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52041. */
  52042. setEnabledRotationAxis(axis: string): void;
  52043. /**
  52044. * Enables/disables scaling
  52045. * @param enable if scaling should be enabled
  52046. * @param homogeneousScaling defines if scaling should only be homogeneous
  52047. */
  52048. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52049. private _updateDummy;
  52050. /**
  52051. * Enables a pointer drag behavior on the bounding box of the gizmo
  52052. */
  52053. enableDragBehavior(): void;
  52054. /**
  52055. * Disposes of the gizmo
  52056. */
  52057. dispose(): void;
  52058. /**
  52059. * 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)
  52060. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52061. * @returns the bounding box mesh with the passed in mesh as a child
  52062. */
  52063. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52064. /**
  52065. * CustomMeshes are not supported by this gizmo
  52066. * @param mesh The mesh to replace the default mesh of the gizmo
  52067. */
  52068. setCustomMesh(mesh: Mesh): void;
  52069. }
  52070. }
  52071. declare module BABYLON {
  52072. /**
  52073. * Single plane rotation gizmo
  52074. */
  52075. export class PlaneRotationGizmo extends Gizmo {
  52076. /**
  52077. * Drag behavior responsible for the gizmos dragging interactions
  52078. */
  52079. dragBehavior: PointerDragBehavior;
  52080. private _pointerObserver;
  52081. /**
  52082. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52083. */
  52084. snapDistance: number;
  52085. /**
  52086. * Event that fires each time the gizmo snaps to a new location.
  52087. * * snapDistance is the the change in distance
  52088. */
  52089. onSnapObservable: Observable<{
  52090. snapDistance: number;
  52091. }>;
  52092. private _isEnabled;
  52093. private _parent;
  52094. /**
  52095. * Creates a PlaneRotationGizmo
  52096. * @param gizmoLayer The utility layer the gizmo will be added to
  52097. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52098. * @param color The color of the gizmo
  52099. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52100. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52101. */
  52102. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52103. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52104. /**
  52105. * If the gizmo is enabled
  52106. */
  52107. set isEnabled(value: boolean);
  52108. get isEnabled(): boolean;
  52109. /**
  52110. * Disposes of the gizmo
  52111. */
  52112. dispose(): void;
  52113. }
  52114. }
  52115. declare module BABYLON {
  52116. /**
  52117. * Gizmo that enables rotating a mesh along 3 axis
  52118. */
  52119. export class RotationGizmo extends Gizmo {
  52120. /**
  52121. * Internal gizmo used for interactions on the x axis
  52122. */
  52123. xGizmo: PlaneRotationGizmo;
  52124. /**
  52125. * Internal gizmo used for interactions on the y axis
  52126. */
  52127. yGizmo: PlaneRotationGizmo;
  52128. /**
  52129. * Internal gizmo used for interactions on the z axis
  52130. */
  52131. zGizmo: PlaneRotationGizmo;
  52132. /** Fires an event when any of it's sub gizmos are dragged */
  52133. onDragStartObservable: Observable<unknown>;
  52134. /** Fires an event when any of it's sub gizmos are released from dragging */
  52135. onDragEndObservable: Observable<unknown>;
  52136. private _meshAttached;
  52137. get attachedMesh(): Nullable<AbstractMesh>;
  52138. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52139. /**
  52140. * Creates a RotationGizmo
  52141. * @param gizmoLayer The utility layer the gizmo will be added to
  52142. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52143. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52144. */
  52145. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52146. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52147. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52148. /**
  52149. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52150. */
  52151. set snapDistance(value: number);
  52152. get snapDistance(): number;
  52153. /**
  52154. * Ratio for the scale of the gizmo (Default: 1)
  52155. */
  52156. set scaleRatio(value: number);
  52157. get scaleRatio(): number;
  52158. /**
  52159. * Disposes of the gizmo
  52160. */
  52161. dispose(): void;
  52162. /**
  52163. * CustomMeshes are not supported by this gizmo
  52164. * @param mesh The mesh to replace the default mesh of the gizmo
  52165. */
  52166. setCustomMesh(mesh: Mesh): void;
  52167. }
  52168. }
  52169. declare module BABYLON {
  52170. /**
  52171. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52172. */
  52173. export class GizmoManager implements IDisposable {
  52174. private scene;
  52175. /**
  52176. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52177. */
  52178. gizmos: {
  52179. positionGizmo: Nullable<PositionGizmo>;
  52180. rotationGizmo: Nullable<RotationGizmo>;
  52181. scaleGizmo: Nullable<ScaleGizmo>;
  52182. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52183. };
  52184. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52185. clearGizmoOnEmptyPointerEvent: boolean;
  52186. /** Fires an event when the manager is attached to a mesh */
  52187. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52188. private _gizmosEnabled;
  52189. private _pointerObserver;
  52190. private _attachedMesh;
  52191. private _boundingBoxColor;
  52192. private _defaultUtilityLayer;
  52193. private _defaultKeepDepthUtilityLayer;
  52194. /**
  52195. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52196. */
  52197. boundingBoxDragBehavior: SixDofDragBehavior;
  52198. /**
  52199. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52200. */
  52201. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52202. /**
  52203. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52204. */
  52205. usePointerToAttachGizmos: boolean;
  52206. /**
  52207. * Utility layer that the bounding box gizmo belongs to
  52208. */
  52209. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52210. /**
  52211. * Utility layer that all gizmos besides bounding box belong to
  52212. */
  52213. get utilityLayer(): UtilityLayerRenderer;
  52214. /**
  52215. * Instatiates a gizmo manager
  52216. * @param scene the scene to overlay the gizmos on top of
  52217. */
  52218. constructor(scene: Scene);
  52219. /**
  52220. * Attaches a set of gizmos to the specified mesh
  52221. * @param mesh The mesh the gizmo's should be attached to
  52222. */
  52223. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52224. /**
  52225. * If the position gizmo is enabled
  52226. */
  52227. set positionGizmoEnabled(value: boolean);
  52228. get positionGizmoEnabled(): boolean;
  52229. /**
  52230. * If the rotation gizmo is enabled
  52231. */
  52232. set rotationGizmoEnabled(value: boolean);
  52233. get rotationGizmoEnabled(): boolean;
  52234. /**
  52235. * If the scale gizmo is enabled
  52236. */
  52237. set scaleGizmoEnabled(value: boolean);
  52238. get scaleGizmoEnabled(): boolean;
  52239. /**
  52240. * If the boundingBox gizmo is enabled
  52241. */
  52242. set boundingBoxGizmoEnabled(value: boolean);
  52243. get boundingBoxGizmoEnabled(): boolean;
  52244. /**
  52245. * Disposes of the gizmo manager
  52246. */
  52247. dispose(): void;
  52248. }
  52249. }
  52250. declare module BABYLON {
  52251. /**
  52252. * A directional light is defined by a direction (what a surprise!).
  52253. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52254. * 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.
  52255. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52256. */
  52257. export class DirectionalLight extends ShadowLight {
  52258. private _shadowFrustumSize;
  52259. /**
  52260. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52261. */
  52262. get shadowFrustumSize(): number;
  52263. /**
  52264. * Specifies a fix frustum size for the shadow generation.
  52265. */
  52266. set shadowFrustumSize(value: number);
  52267. private _shadowOrthoScale;
  52268. /**
  52269. * Gets the shadow projection scale against the optimal computed one.
  52270. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52271. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52272. */
  52273. get shadowOrthoScale(): number;
  52274. /**
  52275. * Sets the shadow projection scale against the optimal computed one.
  52276. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52277. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52278. */
  52279. set shadowOrthoScale(value: number);
  52280. /**
  52281. * Automatically compute the projection matrix to best fit (including all the casters)
  52282. * on each frame.
  52283. */
  52284. autoUpdateExtends: boolean;
  52285. /**
  52286. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52287. * on each frame. autoUpdateExtends must be set to true for this to work
  52288. */
  52289. autoCalcShadowZBounds: boolean;
  52290. private _orthoLeft;
  52291. private _orthoRight;
  52292. private _orthoTop;
  52293. private _orthoBottom;
  52294. /**
  52295. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52296. * The directional light is emitted from everywhere in the given direction.
  52297. * It can cast shadows.
  52298. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52299. * @param name The friendly name of the light
  52300. * @param direction The direction of the light
  52301. * @param scene The scene the light belongs to
  52302. */
  52303. constructor(name: string, direction: Vector3, scene: Scene);
  52304. /**
  52305. * Returns the string "DirectionalLight".
  52306. * @return The class name
  52307. */
  52308. getClassName(): string;
  52309. /**
  52310. * Returns the integer 1.
  52311. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52312. */
  52313. getTypeID(): number;
  52314. /**
  52315. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52316. * Returns the DirectionalLight Shadow projection matrix.
  52317. */
  52318. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52319. /**
  52320. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52321. * Returns the DirectionalLight Shadow projection matrix.
  52322. */
  52323. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52324. /**
  52325. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52326. * Returns the DirectionalLight Shadow projection matrix.
  52327. */
  52328. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52329. protected _buildUniformLayout(): void;
  52330. /**
  52331. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52332. * @param effect The effect to update
  52333. * @param lightIndex The index of the light in the effect to update
  52334. * @returns The directional light
  52335. */
  52336. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52337. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52338. /**
  52339. * Gets the minZ used for shadow according to both the scene and the light.
  52340. *
  52341. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52342. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52343. * @param activeCamera The camera we are returning the min for
  52344. * @returns the depth min z
  52345. */
  52346. getDepthMinZ(activeCamera: Camera): number;
  52347. /**
  52348. * Gets the maxZ used for shadow according to both the scene and the light.
  52349. *
  52350. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52351. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52352. * @param activeCamera The camera we are returning the max for
  52353. * @returns the depth max z
  52354. */
  52355. getDepthMaxZ(activeCamera: Camera): number;
  52356. /**
  52357. * Prepares the list of defines specific to the light type.
  52358. * @param defines the list of defines
  52359. * @param lightIndex defines the index of the light for the effect
  52360. */
  52361. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52362. }
  52363. }
  52364. declare module BABYLON {
  52365. /**
  52366. * Class containing static functions to help procedurally build meshes
  52367. */
  52368. export class HemisphereBuilder {
  52369. /**
  52370. * Creates a hemisphere mesh
  52371. * @param name defines the name of the mesh
  52372. * @param options defines the options used to create the mesh
  52373. * @param scene defines the hosting scene
  52374. * @returns the hemisphere mesh
  52375. */
  52376. static CreateHemisphere(name: string, options: {
  52377. segments?: number;
  52378. diameter?: number;
  52379. sideOrientation?: number;
  52380. }, scene: any): Mesh;
  52381. }
  52382. }
  52383. declare module BABYLON {
  52384. /**
  52385. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52386. * These values define a cone of light starting from the position, emitting toward the direction.
  52387. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52388. * and the exponent defines the speed of the decay of the light with distance (reach).
  52389. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52390. */
  52391. export class SpotLight extends ShadowLight {
  52392. private _angle;
  52393. private _innerAngle;
  52394. private _cosHalfAngle;
  52395. private _lightAngleScale;
  52396. private _lightAngleOffset;
  52397. /**
  52398. * Gets the cone angle of the spot light in Radians.
  52399. */
  52400. get angle(): number;
  52401. /**
  52402. * Sets the cone angle of the spot light in Radians.
  52403. */
  52404. set angle(value: number);
  52405. /**
  52406. * Only used in gltf falloff mode, this defines the angle where
  52407. * the directional falloff will start before cutting at angle which could be seen
  52408. * as outer angle.
  52409. */
  52410. get innerAngle(): number;
  52411. /**
  52412. * Only used in gltf falloff mode, this defines the angle where
  52413. * the directional falloff will start before cutting at angle which could be seen
  52414. * as outer angle.
  52415. */
  52416. set innerAngle(value: number);
  52417. private _shadowAngleScale;
  52418. /**
  52419. * Allows scaling the angle of the light for shadow generation only.
  52420. */
  52421. get shadowAngleScale(): number;
  52422. /**
  52423. * Allows scaling the angle of the light for shadow generation only.
  52424. */
  52425. set shadowAngleScale(value: number);
  52426. /**
  52427. * The light decay speed with the distance from the emission spot.
  52428. */
  52429. exponent: number;
  52430. private _projectionTextureMatrix;
  52431. /**
  52432. * Allows reading the projecton texture
  52433. */
  52434. get projectionTextureMatrix(): Matrix;
  52435. protected _projectionTextureLightNear: number;
  52436. /**
  52437. * Gets the near clip of the Spotlight for texture projection.
  52438. */
  52439. get projectionTextureLightNear(): number;
  52440. /**
  52441. * Sets the near clip of the Spotlight for texture projection.
  52442. */
  52443. set projectionTextureLightNear(value: number);
  52444. protected _projectionTextureLightFar: number;
  52445. /**
  52446. * Gets the far clip of the Spotlight for texture projection.
  52447. */
  52448. get projectionTextureLightFar(): number;
  52449. /**
  52450. * Sets the far clip of the Spotlight for texture projection.
  52451. */
  52452. set projectionTextureLightFar(value: number);
  52453. protected _projectionTextureUpDirection: Vector3;
  52454. /**
  52455. * Gets the Up vector of the Spotlight for texture projection.
  52456. */
  52457. get projectionTextureUpDirection(): Vector3;
  52458. /**
  52459. * Sets the Up vector of the Spotlight for texture projection.
  52460. */
  52461. set projectionTextureUpDirection(value: Vector3);
  52462. private _projectionTexture;
  52463. /**
  52464. * Gets the projection texture of the light.
  52465. */
  52466. get projectionTexture(): Nullable<BaseTexture>;
  52467. /**
  52468. * Sets the projection texture of the light.
  52469. */
  52470. set projectionTexture(value: Nullable<BaseTexture>);
  52471. private _projectionTextureViewLightDirty;
  52472. private _projectionTextureProjectionLightDirty;
  52473. private _projectionTextureDirty;
  52474. private _projectionTextureViewTargetVector;
  52475. private _projectionTextureViewLightMatrix;
  52476. private _projectionTextureProjectionLightMatrix;
  52477. private _projectionTextureScalingMatrix;
  52478. /**
  52479. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52480. * It can cast shadows.
  52481. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52482. * @param name The light friendly name
  52483. * @param position The position of the spot light in the scene
  52484. * @param direction The direction of the light in the scene
  52485. * @param angle The cone angle of the light in Radians
  52486. * @param exponent The light decay speed with the distance from the emission spot
  52487. * @param scene The scene the lights belongs to
  52488. */
  52489. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52490. /**
  52491. * Returns the string "SpotLight".
  52492. * @returns the class name
  52493. */
  52494. getClassName(): string;
  52495. /**
  52496. * Returns the integer 2.
  52497. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52498. */
  52499. getTypeID(): number;
  52500. /**
  52501. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52502. */
  52503. protected _setDirection(value: Vector3): void;
  52504. /**
  52505. * Overrides the position setter to recompute the projection texture view light Matrix.
  52506. */
  52507. protected _setPosition(value: Vector3): void;
  52508. /**
  52509. * 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.
  52510. * Returns the SpotLight.
  52511. */
  52512. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52513. protected _computeProjectionTextureViewLightMatrix(): void;
  52514. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52515. /**
  52516. * Main function for light texture projection matrix computing.
  52517. */
  52518. protected _computeProjectionTextureMatrix(): void;
  52519. protected _buildUniformLayout(): void;
  52520. private _computeAngleValues;
  52521. /**
  52522. * Sets the passed Effect "effect" with the Light textures.
  52523. * @param effect The effect to update
  52524. * @param lightIndex The index of the light in the effect to update
  52525. * @returns The light
  52526. */
  52527. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52528. /**
  52529. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52530. * @param effect The effect to update
  52531. * @param lightIndex The index of the light in the effect to update
  52532. * @returns The spot light
  52533. */
  52534. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52535. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52536. /**
  52537. * Disposes the light and the associated resources.
  52538. */
  52539. dispose(): void;
  52540. /**
  52541. * Prepares the list of defines specific to the light type.
  52542. * @param defines the list of defines
  52543. * @param lightIndex defines the index of the light for the effect
  52544. */
  52545. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52546. }
  52547. }
  52548. declare module BABYLON {
  52549. /**
  52550. * Gizmo that enables viewing a light
  52551. */
  52552. export class LightGizmo extends Gizmo {
  52553. private _lightMesh;
  52554. private _material;
  52555. private _cachedPosition;
  52556. private _cachedForward;
  52557. private _attachedMeshParent;
  52558. /**
  52559. * Creates a LightGizmo
  52560. * @param gizmoLayer The utility layer the gizmo will be added to
  52561. */
  52562. constructor(gizmoLayer?: UtilityLayerRenderer);
  52563. private _light;
  52564. /**
  52565. * The light that the gizmo is attached to
  52566. */
  52567. set light(light: Nullable<Light>);
  52568. get light(): Nullable<Light>;
  52569. /**
  52570. * Gets the material used to render the light gizmo
  52571. */
  52572. get material(): StandardMaterial;
  52573. /**
  52574. * @hidden
  52575. * Updates the gizmo to match the attached mesh's position/rotation
  52576. */
  52577. protected _update(): void;
  52578. private static _Scale;
  52579. /**
  52580. * Creates the lines for a light mesh
  52581. */
  52582. private static _CreateLightLines;
  52583. /**
  52584. * Disposes of the light gizmo
  52585. */
  52586. dispose(): void;
  52587. private static _CreateHemisphericLightMesh;
  52588. private static _CreatePointLightMesh;
  52589. private static _CreateSpotLightMesh;
  52590. private static _CreateDirectionalLightMesh;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /** @hidden */
  52595. export var backgroundFragmentDeclaration: {
  52596. name: string;
  52597. shader: string;
  52598. };
  52599. }
  52600. declare module BABYLON {
  52601. /** @hidden */
  52602. export var backgroundUboDeclaration: {
  52603. name: string;
  52604. shader: string;
  52605. };
  52606. }
  52607. declare module BABYLON {
  52608. /** @hidden */
  52609. export var backgroundPixelShader: {
  52610. name: string;
  52611. shader: string;
  52612. };
  52613. }
  52614. declare module BABYLON {
  52615. /** @hidden */
  52616. export var backgroundVertexDeclaration: {
  52617. name: string;
  52618. shader: string;
  52619. };
  52620. }
  52621. declare module BABYLON {
  52622. /** @hidden */
  52623. export var backgroundVertexShader: {
  52624. name: string;
  52625. shader: string;
  52626. };
  52627. }
  52628. declare module BABYLON {
  52629. /**
  52630. * Background material used to create an efficient environement around your scene.
  52631. */
  52632. export class BackgroundMaterial extends PushMaterial {
  52633. /**
  52634. * Standard reflectance value at parallel view angle.
  52635. */
  52636. static StandardReflectance0: number;
  52637. /**
  52638. * Standard reflectance value at grazing angle.
  52639. */
  52640. static StandardReflectance90: number;
  52641. protected _primaryColor: Color3;
  52642. /**
  52643. * Key light Color (multiply against the environement texture)
  52644. */
  52645. primaryColor: Color3;
  52646. protected __perceptualColor: Nullable<Color3>;
  52647. /**
  52648. * Experimental Internal Use Only.
  52649. *
  52650. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52651. * This acts as a helper to set the primary color to a more "human friendly" value.
  52652. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52653. * output color as close as possible from the chosen value.
  52654. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52655. * part of lighting setup.)
  52656. */
  52657. get _perceptualColor(): Nullable<Color3>;
  52658. set _perceptualColor(value: Nullable<Color3>);
  52659. protected _primaryColorShadowLevel: float;
  52660. /**
  52661. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52662. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52663. */
  52664. get primaryColorShadowLevel(): float;
  52665. set primaryColorShadowLevel(value: float);
  52666. protected _primaryColorHighlightLevel: float;
  52667. /**
  52668. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52669. * The primary color is used at the level chosen to define what the white area would look.
  52670. */
  52671. get primaryColorHighlightLevel(): float;
  52672. set primaryColorHighlightLevel(value: float);
  52673. protected _reflectionTexture: Nullable<BaseTexture>;
  52674. /**
  52675. * Reflection Texture used in the material.
  52676. * Should be author in a specific way for the best result (refer to the documentation).
  52677. */
  52678. reflectionTexture: Nullable<BaseTexture>;
  52679. protected _reflectionBlur: float;
  52680. /**
  52681. * Reflection Texture level of blur.
  52682. *
  52683. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52684. * texture twice.
  52685. */
  52686. reflectionBlur: float;
  52687. protected _diffuseTexture: Nullable<BaseTexture>;
  52688. /**
  52689. * Diffuse Texture used in the material.
  52690. * Should be author in a specific way for the best result (refer to the documentation).
  52691. */
  52692. diffuseTexture: Nullable<BaseTexture>;
  52693. protected _shadowLights: Nullable<IShadowLight[]>;
  52694. /**
  52695. * Specify the list of lights casting shadow on the material.
  52696. * All scene shadow lights will be included if null.
  52697. */
  52698. shadowLights: Nullable<IShadowLight[]>;
  52699. protected _shadowLevel: float;
  52700. /**
  52701. * Helps adjusting the shadow to a softer level if required.
  52702. * 0 means black shadows and 1 means no shadows.
  52703. */
  52704. shadowLevel: float;
  52705. protected _sceneCenter: Vector3;
  52706. /**
  52707. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52708. * It is usually zero but might be interesting to modify according to your setup.
  52709. */
  52710. sceneCenter: Vector3;
  52711. protected _opacityFresnel: boolean;
  52712. /**
  52713. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52714. * This helps ensuring a nice transition when the camera goes under the ground.
  52715. */
  52716. opacityFresnel: boolean;
  52717. protected _reflectionFresnel: boolean;
  52718. /**
  52719. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52720. * This helps adding a mirror texture on the ground.
  52721. */
  52722. reflectionFresnel: boolean;
  52723. protected _reflectionFalloffDistance: number;
  52724. /**
  52725. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52726. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52727. */
  52728. reflectionFalloffDistance: number;
  52729. protected _reflectionAmount: number;
  52730. /**
  52731. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52732. */
  52733. reflectionAmount: number;
  52734. protected _reflectionReflectance0: number;
  52735. /**
  52736. * This specifies the weight of the reflection at grazing angle.
  52737. */
  52738. reflectionReflectance0: number;
  52739. protected _reflectionReflectance90: number;
  52740. /**
  52741. * This specifies the weight of the reflection at a perpendicular point of view.
  52742. */
  52743. reflectionReflectance90: number;
  52744. /**
  52745. * Sets the reflection reflectance fresnel values according to the default standard
  52746. * empirically know to work well :-)
  52747. */
  52748. set reflectionStandardFresnelWeight(value: number);
  52749. protected _useRGBColor: boolean;
  52750. /**
  52751. * Helps to directly use the maps channels instead of their level.
  52752. */
  52753. useRGBColor: boolean;
  52754. protected _enableNoise: boolean;
  52755. /**
  52756. * This helps reducing the banding effect that could occur on the background.
  52757. */
  52758. enableNoise: boolean;
  52759. /**
  52760. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52761. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52762. * Recommended to be keep at 1.0 except for special cases.
  52763. */
  52764. get fovMultiplier(): number;
  52765. set fovMultiplier(value: number);
  52766. private _fovMultiplier;
  52767. /**
  52768. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52769. */
  52770. useEquirectangularFOV: boolean;
  52771. private _maxSimultaneousLights;
  52772. /**
  52773. * Number of Simultaneous lights allowed on the material.
  52774. */
  52775. maxSimultaneousLights: int;
  52776. /**
  52777. * Default configuration related to image processing available in the Background Material.
  52778. */
  52779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52780. /**
  52781. * Keep track of the image processing observer to allow dispose and replace.
  52782. */
  52783. private _imageProcessingObserver;
  52784. /**
  52785. * Attaches a new image processing configuration to the PBR Material.
  52786. * @param configuration (if null the scene configuration will be use)
  52787. */
  52788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52789. /**
  52790. * Gets the image processing configuration used either in this material.
  52791. */
  52792. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52793. /**
  52794. * Sets the Default image processing configuration used either in the this material.
  52795. *
  52796. * If sets to null, the scene one is in use.
  52797. */
  52798. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52799. /**
  52800. * Gets wether the color curves effect is enabled.
  52801. */
  52802. get cameraColorCurvesEnabled(): boolean;
  52803. /**
  52804. * Sets wether the color curves effect is enabled.
  52805. */
  52806. set cameraColorCurvesEnabled(value: boolean);
  52807. /**
  52808. * Gets wether the color grading effect is enabled.
  52809. */
  52810. get cameraColorGradingEnabled(): boolean;
  52811. /**
  52812. * Gets wether the color grading effect is enabled.
  52813. */
  52814. set cameraColorGradingEnabled(value: boolean);
  52815. /**
  52816. * Gets wether tonemapping is enabled or not.
  52817. */
  52818. get cameraToneMappingEnabled(): boolean;
  52819. /**
  52820. * Sets wether tonemapping is enabled or not
  52821. */
  52822. set cameraToneMappingEnabled(value: boolean);
  52823. /**
  52824. * The camera exposure used on this material.
  52825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52826. * This corresponds to a photographic exposure.
  52827. */
  52828. get cameraExposure(): float;
  52829. /**
  52830. * The camera exposure used on this material.
  52831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52832. * This corresponds to a photographic exposure.
  52833. */
  52834. set cameraExposure(value: float);
  52835. /**
  52836. * Gets The camera contrast used on this material.
  52837. */
  52838. get cameraContrast(): float;
  52839. /**
  52840. * Sets The camera contrast used on this material.
  52841. */
  52842. set cameraContrast(value: float);
  52843. /**
  52844. * Gets the Color Grading 2D Lookup Texture.
  52845. */
  52846. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52847. /**
  52848. * Sets the Color Grading 2D Lookup Texture.
  52849. */
  52850. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52851. /**
  52852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52854. * 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;
  52855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52856. */
  52857. get cameraColorCurves(): Nullable<ColorCurves>;
  52858. /**
  52859. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52860. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52861. * 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;
  52862. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52863. */
  52864. set cameraColorCurves(value: Nullable<ColorCurves>);
  52865. /**
  52866. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52867. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52868. */
  52869. switchToBGR: boolean;
  52870. private _renderTargets;
  52871. private _reflectionControls;
  52872. private _white;
  52873. private _primaryShadowColor;
  52874. private _primaryHighlightColor;
  52875. /**
  52876. * Instantiates a Background Material in the given scene
  52877. * @param name The friendly name of the material
  52878. * @param scene The scene to add the material to
  52879. */
  52880. constructor(name: string, scene: Scene);
  52881. /**
  52882. * Gets a boolean indicating that current material needs to register RTT
  52883. */
  52884. get hasRenderTargetTextures(): boolean;
  52885. /**
  52886. * The entire material has been created in order to prevent overdraw.
  52887. * @returns false
  52888. */
  52889. needAlphaTesting(): boolean;
  52890. /**
  52891. * The entire material has been created in order to prevent overdraw.
  52892. * @returns true if blending is enable
  52893. */
  52894. needAlphaBlending(): boolean;
  52895. /**
  52896. * Checks wether the material is ready to be rendered for a given mesh.
  52897. * @param mesh The mesh to render
  52898. * @param subMesh The submesh to check against
  52899. * @param useInstances Specify wether or not the material is used with instances
  52900. * @returns true if all the dependencies are ready (Textures, Effects...)
  52901. */
  52902. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52903. /**
  52904. * Compute the primary color according to the chosen perceptual color.
  52905. */
  52906. private _computePrimaryColorFromPerceptualColor;
  52907. /**
  52908. * Compute the highlights and shadow colors according to their chosen levels.
  52909. */
  52910. private _computePrimaryColors;
  52911. /**
  52912. * Build the uniform buffer used in the material.
  52913. */
  52914. buildUniformLayout(): void;
  52915. /**
  52916. * Unbind the material.
  52917. */
  52918. unbind(): void;
  52919. /**
  52920. * Bind only the world matrix to the material.
  52921. * @param world The world matrix to bind.
  52922. */
  52923. bindOnlyWorldMatrix(world: Matrix): void;
  52924. /**
  52925. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52926. * @param world The world matrix to bind.
  52927. * @param subMesh The submesh to bind for.
  52928. */
  52929. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52930. /**
  52931. * Checks to see if a texture is used in the material.
  52932. * @param texture - Base texture to use.
  52933. * @returns - Boolean specifying if a texture is used in the material.
  52934. */
  52935. hasTexture(texture: BaseTexture): boolean;
  52936. /**
  52937. * Dispose the material.
  52938. * @param forceDisposeEffect Force disposal of the associated effect.
  52939. * @param forceDisposeTextures Force disposal of the associated textures.
  52940. */
  52941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52942. /**
  52943. * Clones the material.
  52944. * @param name The cloned name.
  52945. * @returns The cloned material.
  52946. */
  52947. clone(name: string): BackgroundMaterial;
  52948. /**
  52949. * Serializes the current material to its JSON representation.
  52950. * @returns The JSON representation.
  52951. */
  52952. serialize(): any;
  52953. /**
  52954. * Gets the class name of the material
  52955. * @returns "BackgroundMaterial"
  52956. */
  52957. getClassName(): string;
  52958. /**
  52959. * Parse a JSON input to create back a background material.
  52960. * @param source The JSON data to parse
  52961. * @param scene The scene to create the parsed material in
  52962. * @param rootUrl The root url of the assets the material depends upon
  52963. * @returns the instantiated BackgroundMaterial.
  52964. */
  52965. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52966. }
  52967. }
  52968. declare module BABYLON {
  52969. /**
  52970. * Represents the different options available during the creation of
  52971. * a Environment helper.
  52972. *
  52973. * This can control the default ground, skybox and image processing setup of your scene.
  52974. */
  52975. export interface IEnvironmentHelperOptions {
  52976. /**
  52977. * Specifies whether or not to create a ground.
  52978. * True by default.
  52979. */
  52980. createGround: boolean;
  52981. /**
  52982. * Specifies the ground size.
  52983. * 15 by default.
  52984. */
  52985. groundSize: number;
  52986. /**
  52987. * The texture used on the ground for the main color.
  52988. * Comes from the BabylonJS CDN by default.
  52989. *
  52990. * Remarks: Can be either a texture or a url.
  52991. */
  52992. groundTexture: string | BaseTexture;
  52993. /**
  52994. * The color mixed in the ground texture by default.
  52995. * BabylonJS clearColor by default.
  52996. */
  52997. groundColor: Color3;
  52998. /**
  52999. * Specifies the ground opacity.
  53000. * 1 by default.
  53001. */
  53002. groundOpacity: number;
  53003. /**
  53004. * Enables the ground to receive shadows.
  53005. * True by default.
  53006. */
  53007. enableGroundShadow: boolean;
  53008. /**
  53009. * Helps preventing the shadow to be fully black on the ground.
  53010. * 0.5 by default.
  53011. */
  53012. groundShadowLevel: number;
  53013. /**
  53014. * Creates a mirror texture attach to the ground.
  53015. * false by default.
  53016. */
  53017. enableGroundMirror: boolean;
  53018. /**
  53019. * Specifies the ground mirror size ratio.
  53020. * 0.3 by default as the default kernel is 64.
  53021. */
  53022. groundMirrorSizeRatio: number;
  53023. /**
  53024. * Specifies the ground mirror blur kernel size.
  53025. * 64 by default.
  53026. */
  53027. groundMirrorBlurKernel: number;
  53028. /**
  53029. * Specifies the ground mirror visibility amount.
  53030. * 1 by default
  53031. */
  53032. groundMirrorAmount: number;
  53033. /**
  53034. * Specifies the ground mirror reflectance weight.
  53035. * This uses the standard weight of the background material to setup the fresnel effect
  53036. * of the mirror.
  53037. * 1 by default.
  53038. */
  53039. groundMirrorFresnelWeight: number;
  53040. /**
  53041. * Specifies the ground mirror Falloff distance.
  53042. * This can helps reducing the size of the reflection.
  53043. * 0 by Default.
  53044. */
  53045. groundMirrorFallOffDistance: number;
  53046. /**
  53047. * Specifies the ground mirror texture type.
  53048. * Unsigned Int by Default.
  53049. */
  53050. groundMirrorTextureType: number;
  53051. /**
  53052. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53053. * the shown objects.
  53054. */
  53055. groundYBias: number;
  53056. /**
  53057. * Specifies whether or not to create a skybox.
  53058. * True by default.
  53059. */
  53060. createSkybox: boolean;
  53061. /**
  53062. * Specifies the skybox size.
  53063. * 20 by default.
  53064. */
  53065. skyboxSize: number;
  53066. /**
  53067. * The texture used on the skybox for the main color.
  53068. * Comes from the BabylonJS CDN by default.
  53069. *
  53070. * Remarks: Can be either a texture or a url.
  53071. */
  53072. skyboxTexture: string | BaseTexture;
  53073. /**
  53074. * The color mixed in the skybox texture by default.
  53075. * BabylonJS clearColor by default.
  53076. */
  53077. skyboxColor: Color3;
  53078. /**
  53079. * The background rotation around the Y axis of the scene.
  53080. * This helps aligning the key lights of your scene with the background.
  53081. * 0 by default.
  53082. */
  53083. backgroundYRotation: number;
  53084. /**
  53085. * Compute automatically the size of the elements to best fit with the scene.
  53086. */
  53087. sizeAuto: boolean;
  53088. /**
  53089. * Default position of the rootMesh if autoSize is not true.
  53090. */
  53091. rootPosition: Vector3;
  53092. /**
  53093. * Sets up the image processing in the scene.
  53094. * true by default.
  53095. */
  53096. setupImageProcessing: boolean;
  53097. /**
  53098. * The texture used as your environment texture in the scene.
  53099. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53100. *
  53101. * Remarks: Can be either a texture or a url.
  53102. */
  53103. environmentTexture: string | BaseTexture;
  53104. /**
  53105. * The value of the exposure to apply to the scene.
  53106. * 0.6 by default if setupImageProcessing is true.
  53107. */
  53108. cameraExposure: number;
  53109. /**
  53110. * The value of the contrast to apply to the scene.
  53111. * 1.6 by default if setupImageProcessing is true.
  53112. */
  53113. cameraContrast: number;
  53114. /**
  53115. * Specifies whether or not tonemapping should be enabled in the scene.
  53116. * true by default if setupImageProcessing is true.
  53117. */
  53118. toneMappingEnabled: boolean;
  53119. }
  53120. /**
  53121. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53122. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53123. * It also helps with the default setup of your imageProcessing configuration.
  53124. */
  53125. export class EnvironmentHelper {
  53126. /**
  53127. * Default ground texture URL.
  53128. */
  53129. private static _groundTextureCDNUrl;
  53130. /**
  53131. * Default skybox texture URL.
  53132. */
  53133. private static _skyboxTextureCDNUrl;
  53134. /**
  53135. * Default environment texture URL.
  53136. */
  53137. private static _environmentTextureCDNUrl;
  53138. /**
  53139. * Creates the default options for the helper.
  53140. */
  53141. private static _getDefaultOptions;
  53142. private _rootMesh;
  53143. /**
  53144. * Gets the root mesh created by the helper.
  53145. */
  53146. get rootMesh(): Mesh;
  53147. private _skybox;
  53148. /**
  53149. * Gets the skybox created by the helper.
  53150. */
  53151. get skybox(): Nullable<Mesh>;
  53152. private _skyboxTexture;
  53153. /**
  53154. * Gets the skybox texture created by the helper.
  53155. */
  53156. get skyboxTexture(): Nullable<BaseTexture>;
  53157. private _skyboxMaterial;
  53158. /**
  53159. * Gets the skybox material created by the helper.
  53160. */
  53161. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53162. private _ground;
  53163. /**
  53164. * Gets the ground mesh created by the helper.
  53165. */
  53166. get ground(): Nullable<Mesh>;
  53167. private _groundTexture;
  53168. /**
  53169. * Gets the ground texture created by the helper.
  53170. */
  53171. get groundTexture(): Nullable<BaseTexture>;
  53172. private _groundMirror;
  53173. /**
  53174. * Gets the ground mirror created by the helper.
  53175. */
  53176. get groundMirror(): Nullable<MirrorTexture>;
  53177. /**
  53178. * Gets the ground mirror render list to helps pushing the meshes
  53179. * you wish in the ground reflection.
  53180. */
  53181. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53182. private _groundMaterial;
  53183. /**
  53184. * Gets the ground material created by the helper.
  53185. */
  53186. get groundMaterial(): Nullable<BackgroundMaterial>;
  53187. /**
  53188. * Stores the creation options.
  53189. */
  53190. private readonly _scene;
  53191. private _options;
  53192. /**
  53193. * This observable will be notified with any error during the creation of the environment,
  53194. * mainly texture creation errors.
  53195. */
  53196. onErrorObservable: Observable<{
  53197. message?: string;
  53198. exception?: any;
  53199. }>;
  53200. /**
  53201. * constructor
  53202. * @param options Defines the options we want to customize the helper
  53203. * @param scene The scene to add the material to
  53204. */
  53205. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53206. /**
  53207. * Updates the background according to the new options
  53208. * @param options
  53209. */
  53210. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53211. /**
  53212. * Sets the primary color of all the available elements.
  53213. * @param color the main color to affect to the ground and the background
  53214. */
  53215. setMainColor(color: Color3): void;
  53216. /**
  53217. * Setup the image processing according to the specified options.
  53218. */
  53219. private _setupImageProcessing;
  53220. /**
  53221. * Setup the environment texture according to the specified options.
  53222. */
  53223. private _setupEnvironmentTexture;
  53224. /**
  53225. * Setup the background according to the specified options.
  53226. */
  53227. private _setupBackground;
  53228. /**
  53229. * Get the scene sizes according to the setup.
  53230. */
  53231. private _getSceneSize;
  53232. /**
  53233. * Setup the ground according to the specified options.
  53234. */
  53235. private _setupGround;
  53236. /**
  53237. * Setup the ground material according to the specified options.
  53238. */
  53239. private _setupGroundMaterial;
  53240. /**
  53241. * Setup the ground diffuse texture according to the specified options.
  53242. */
  53243. private _setupGroundDiffuseTexture;
  53244. /**
  53245. * Setup the ground mirror texture according to the specified options.
  53246. */
  53247. private _setupGroundMirrorTexture;
  53248. /**
  53249. * Setup the ground to receive the mirror texture.
  53250. */
  53251. private _setupMirrorInGroundMaterial;
  53252. /**
  53253. * Setup the skybox according to the specified options.
  53254. */
  53255. private _setupSkybox;
  53256. /**
  53257. * Setup the skybox material according to the specified options.
  53258. */
  53259. private _setupSkyboxMaterial;
  53260. /**
  53261. * Setup the skybox reflection texture according to the specified options.
  53262. */
  53263. private _setupSkyboxReflectionTexture;
  53264. private _errorHandler;
  53265. /**
  53266. * Dispose all the elements created by the Helper.
  53267. */
  53268. dispose(): void;
  53269. }
  53270. }
  53271. declare module BABYLON {
  53272. /**
  53273. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53274. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53275. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53276. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53277. */
  53278. export class PhotoDome extends TransformNode {
  53279. /**
  53280. * Define the image as a Monoscopic panoramic 360 image.
  53281. */
  53282. static readonly MODE_MONOSCOPIC: number;
  53283. /**
  53284. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53285. */
  53286. static readonly MODE_TOPBOTTOM: number;
  53287. /**
  53288. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53289. */
  53290. static readonly MODE_SIDEBYSIDE: number;
  53291. private _useDirectMapping;
  53292. /**
  53293. * The texture being displayed on the sphere
  53294. */
  53295. protected _photoTexture: Texture;
  53296. /**
  53297. * Gets or sets the texture being displayed on the sphere
  53298. */
  53299. get photoTexture(): Texture;
  53300. set photoTexture(value: Texture);
  53301. /**
  53302. * Observable raised when an error occured while loading the 360 image
  53303. */
  53304. onLoadErrorObservable: Observable<string>;
  53305. /**
  53306. * The skybox material
  53307. */
  53308. protected _material: BackgroundMaterial;
  53309. /**
  53310. * The surface used for the skybox
  53311. */
  53312. protected _mesh: Mesh;
  53313. /**
  53314. * Gets the mesh used for the skybox.
  53315. */
  53316. get mesh(): Mesh;
  53317. /**
  53318. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53319. * Also see the options.resolution property.
  53320. */
  53321. get fovMultiplier(): number;
  53322. set fovMultiplier(value: number);
  53323. private _imageMode;
  53324. /**
  53325. * Gets or set the current video mode for the video. It can be:
  53326. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53327. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53328. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53329. */
  53330. get imageMode(): number;
  53331. set imageMode(value: number);
  53332. /**
  53333. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53334. * @param name Element's name, child elements will append suffixes for their own names.
  53335. * @param urlsOfPhoto defines the url of the photo to display
  53336. * @param options defines an object containing optional or exposed sub element properties
  53337. * @param onError defines a callback called when an error occured while loading the texture
  53338. */
  53339. constructor(name: string, urlOfPhoto: string, options: {
  53340. resolution?: number;
  53341. size?: number;
  53342. useDirectMapping?: boolean;
  53343. faceForward?: boolean;
  53344. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53345. private _onBeforeCameraRenderObserver;
  53346. private _changeImageMode;
  53347. /**
  53348. * Releases resources associated with this node.
  53349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53351. */
  53352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53353. }
  53354. }
  53355. declare module BABYLON {
  53356. /**
  53357. * Class used to host RGBD texture specific utilities
  53358. */
  53359. export class RGBDTextureTools {
  53360. /**
  53361. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53362. * @param texture the texture to expand.
  53363. */
  53364. static ExpandRGBDTexture(texture: Texture): void;
  53365. }
  53366. }
  53367. declare module BABYLON {
  53368. /**
  53369. * Class used to host texture specific utilities
  53370. */
  53371. export class BRDFTextureTools {
  53372. /**
  53373. * Prevents texture cache collision
  53374. */
  53375. private static _instanceNumber;
  53376. /**
  53377. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53378. * @param scene defines the hosting scene
  53379. * @returns the environment BRDF texture
  53380. */
  53381. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53382. private static _environmentBRDFBase64Texture;
  53383. }
  53384. }
  53385. declare module BABYLON {
  53386. /**
  53387. * @hidden
  53388. */
  53389. export interface IMaterialClearCoatDefines {
  53390. CLEARCOAT: boolean;
  53391. CLEARCOAT_DEFAULTIOR: boolean;
  53392. CLEARCOAT_TEXTURE: boolean;
  53393. CLEARCOAT_TEXTUREDIRECTUV: number;
  53394. CLEARCOAT_BUMP: boolean;
  53395. CLEARCOAT_BUMPDIRECTUV: number;
  53396. CLEARCOAT_TINT: boolean;
  53397. CLEARCOAT_TINT_TEXTURE: boolean;
  53398. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53399. /** @hidden */
  53400. _areTexturesDirty: boolean;
  53401. }
  53402. /**
  53403. * Define the code related to the clear coat parameters of the pbr material.
  53404. */
  53405. export class PBRClearCoatConfiguration {
  53406. /**
  53407. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53408. * The default fits with a polyurethane material.
  53409. */
  53410. private static readonly _DefaultIndexOfRefraction;
  53411. private _isEnabled;
  53412. /**
  53413. * Defines if the clear coat is enabled in the material.
  53414. */
  53415. isEnabled: boolean;
  53416. /**
  53417. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53418. */
  53419. intensity: number;
  53420. /**
  53421. * Defines the clear coat layer roughness.
  53422. */
  53423. roughness: number;
  53424. private _indexOfRefraction;
  53425. /**
  53426. * Defines the index of refraction of the clear coat.
  53427. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53428. * The default fits with a polyurethane material.
  53429. * Changing the default value is more performance intensive.
  53430. */
  53431. indexOfRefraction: number;
  53432. private _texture;
  53433. /**
  53434. * Stores the clear coat values in a texture.
  53435. */
  53436. texture: Nullable<BaseTexture>;
  53437. private _bumpTexture;
  53438. /**
  53439. * Define the clear coat specific bump texture.
  53440. */
  53441. bumpTexture: Nullable<BaseTexture>;
  53442. private _isTintEnabled;
  53443. /**
  53444. * Defines if the clear coat tint is enabled in the material.
  53445. */
  53446. isTintEnabled: boolean;
  53447. /**
  53448. * Defines the clear coat tint of the material.
  53449. * This is only use if tint is enabled
  53450. */
  53451. tintColor: Color3;
  53452. /**
  53453. * Defines the distance at which the tint color should be found in the
  53454. * clear coat media.
  53455. * This is only use if tint is enabled
  53456. */
  53457. tintColorAtDistance: number;
  53458. /**
  53459. * Defines the clear coat layer thickness.
  53460. * This is only use if tint is enabled
  53461. */
  53462. tintThickness: number;
  53463. private _tintTexture;
  53464. /**
  53465. * Stores the clear tint values in a texture.
  53466. * rgb is tint
  53467. * a is a thickness factor
  53468. */
  53469. tintTexture: Nullable<BaseTexture>;
  53470. /** @hidden */
  53471. private _internalMarkAllSubMeshesAsTexturesDirty;
  53472. /** @hidden */
  53473. _markAllSubMeshesAsTexturesDirty(): void;
  53474. /**
  53475. * Instantiate a new istance of clear coat configuration.
  53476. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53477. */
  53478. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53479. /**
  53480. * Gets wehter the submesh is ready to be used or not.
  53481. * @param defines the list of "defines" to update.
  53482. * @param scene defines the scene the material belongs to.
  53483. * @param engine defines the engine the material belongs to.
  53484. * @param disableBumpMap defines wether the material disables bump or not.
  53485. * @returns - boolean indicating that the submesh is ready or not.
  53486. */
  53487. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53488. /**
  53489. * Checks to see if a texture is used in the material.
  53490. * @param defines the list of "defines" to update.
  53491. * @param scene defines the scene to the material belongs to.
  53492. */
  53493. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53494. /**
  53495. * Binds the material data.
  53496. * @param uniformBuffer defines the Uniform buffer to fill in.
  53497. * @param scene defines the scene the material belongs to.
  53498. * @param engine defines the engine the material belongs to.
  53499. * @param disableBumpMap defines wether the material disables bump or not.
  53500. * @param isFrozen defines wether the material is frozen or not.
  53501. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53502. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53503. */
  53504. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53505. /**
  53506. * Checks to see if a texture is used in the material.
  53507. * @param texture - Base texture to use.
  53508. * @returns - Boolean specifying if a texture is used in the material.
  53509. */
  53510. hasTexture(texture: BaseTexture): boolean;
  53511. /**
  53512. * Returns an array of the actively used textures.
  53513. * @param activeTextures Array of BaseTextures
  53514. */
  53515. getActiveTextures(activeTextures: BaseTexture[]): void;
  53516. /**
  53517. * Returns the animatable textures.
  53518. * @param animatables Array of animatable textures.
  53519. */
  53520. getAnimatables(animatables: IAnimatable[]): void;
  53521. /**
  53522. * Disposes the resources of the material.
  53523. * @param forceDisposeTextures - Forces the disposal of all textures.
  53524. */
  53525. dispose(forceDisposeTextures?: boolean): void;
  53526. /**
  53527. * Get the current class name of the texture useful for serialization or dynamic coding.
  53528. * @returns "PBRClearCoatConfiguration"
  53529. */
  53530. getClassName(): string;
  53531. /**
  53532. * Add fallbacks to the effect fallbacks list.
  53533. * @param defines defines the Base texture to use.
  53534. * @param fallbacks defines the current fallback list.
  53535. * @param currentRank defines the current fallback rank.
  53536. * @returns the new fallback rank.
  53537. */
  53538. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53539. /**
  53540. * Add the required uniforms to the current list.
  53541. * @param uniforms defines the current uniform list.
  53542. */
  53543. static AddUniforms(uniforms: string[]): void;
  53544. /**
  53545. * Add the required samplers to the current list.
  53546. * @param samplers defines the current sampler list.
  53547. */
  53548. static AddSamplers(samplers: string[]): void;
  53549. /**
  53550. * Add the required uniforms to the current buffer.
  53551. * @param uniformBuffer defines the current uniform buffer.
  53552. */
  53553. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53554. /**
  53555. * Makes a duplicate of the current configuration into another one.
  53556. * @param clearCoatConfiguration define the config where to copy the info
  53557. */
  53558. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53559. /**
  53560. * Serializes this clear coat configuration.
  53561. * @returns - An object with the serialized config.
  53562. */
  53563. serialize(): any;
  53564. /**
  53565. * Parses a anisotropy Configuration from a serialized object.
  53566. * @param source - Serialized object.
  53567. * @param scene Defines the scene we are parsing for
  53568. * @param rootUrl Defines the rootUrl to load from
  53569. */
  53570. parse(source: any, scene: Scene, rootUrl: string): void;
  53571. }
  53572. }
  53573. declare module BABYLON {
  53574. /**
  53575. * @hidden
  53576. */
  53577. export interface IMaterialAnisotropicDefines {
  53578. ANISOTROPIC: boolean;
  53579. ANISOTROPIC_TEXTURE: boolean;
  53580. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53581. MAINUV1: boolean;
  53582. _areTexturesDirty: boolean;
  53583. _needUVs: boolean;
  53584. }
  53585. /**
  53586. * Define the code related to the anisotropic parameters of the pbr material.
  53587. */
  53588. export class PBRAnisotropicConfiguration {
  53589. private _isEnabled;
  53590. /**
  53591. * Defines if the anisotropy is enabled in the material.
  53592. */
  53593. isEnabled: boolean;
  53594. /**
  53595. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53596. */
  53597. intensity: number;
  53598. /**
  53599. * Defines if the effect is along the tangents, bitangents or in between.
  53600. * By default, the effect is "strectching" the highlights along the tangents.
  53601. */
  53602. direction: Vector2;
  53603. private _texture;
  53604. /**
  53605. * Stores the anisotropy values in a texture.
  53606. * rg is direction (like normal from -1 to 1)
  53607. * b is a intensity
  53608. */
  53609. texture: Nullable<BaseTexture>;
  53610. /** @hidden */
  53611. private _internalMarkAllSubMeshesAsTexturesDirty;
  53612. /** @hidden */
  53613. _markAllSubMeshesAsTexturesDirty(): void;
  53614. /**
  53615. * Instantiate a new istance of anisotropy configuration.
  53616. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53617. */
  53618. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53619. /**
  53620. * Specifies that the submesh is ready to be used.
  53621. * @param defines the list of "defines" to update.
  53622. * @param scene defines the scene the material belongs to.
  53623. * @returns - boolean indicating that the submesh is ready or not.
  53624. */
  53625. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53626. /**
  53627. * Checks to see if a texture is used in the material.
  53628. * @param defines the list of "defines" to update.
  53629. * @param mesh the mesh we are preparing the defines for.
  53630. * @param scene defines the scene the material belongs to.
  53631. */
  53632. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53633. /**
  53634. * Binds the material data.
  53635. * @param uniformBuffer defines the Uniform buffer to fill in.
  53636. * @param scene defines the scene the material belongs to.
  53637. * @param isFrozen defines wether the material is frozen or not.
  53638. */
  53639. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53640. /**
  53641. * Checks to see if a texture is used in the material.
  53642. * @param texture - Base texture to use.
  53643. * @returns - Boolean specifying if a texture is used in the material.
  53644. */
  53645. hasTexture(texture: BaseTexture): boolean;
  53646. /**
  53647. * Returns an array of the actively used textures.
  53648. * @param activeTextures Array of BaseTextures
  53649. */
  53650. getActiveTextures(activeTextures: BaseTexture[]): void;
  53651. /**
  53652. * Returns the animatable textures.
  53653. * @param animatables Array of animatable textures.
  53654. */
  53655. getAnimatables(animatables: IAnimatable[]): void;
  53656. /**
  53657. * Disposes the resources of the material.
  53658. * @param forceDisposeTextures - Forces the disposal of all textures.
  53659. */
  53660. dispose(forceDisposeTextures?: boolean): void;
  53661. /**
  53662. * Get the current class name of the texture useful for serialization or dynamic coding.
  53663. * @returns "PBRAnisotropicConfiguration"
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Add fallbacks to the effect fallbacks list.
  53668. * @param defines defines the Base texture to use.
  53669. * @param fallbacks defines the current fallback list.
  53670. * @param currentRank defines the current fallback rank.
  53671. * @returns the new fallback rank.
  53672. */
  53673. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53674. /**
  53675. * Add the required uniforms to the current list.
  53676. * @param uniforms defines the current uniform list.
  53677. */
  53678. static AddUniforms(uniforms: string[]): void;
  53679. /**
  53680. * Add the required uniforms to the current buffer.
  53681. * @param uniformBuffer defines the current uniform buffer.
  53682. */
  53683. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53684. /**
  53685. * Add the required samplers to the current list.
  53686. * @param samplers defines the current sampler list.
  53687. */
  53688. static AddSamplers(samplers: string[]): void;
  53689. /**
  53690. * Makes a duplicate of the current configuration into another one.
  53691. * @param anisotropicConfiguration define the config where to copy the info
  53692. */
  53693. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53694. /**
  53695. * Serializes this anisotropy configuration.
  53696. * @returns - An object with the serialized config.
  53697. */
  53698. serialize(): any;
  53699. /**
  53700. * Parses a anisotropy Configuration from a serialized object.
  53701. * @param source - Serialized object.
  53702. * @param scene Defines the scene we are parsing for
  53703. * @param rootUrl Defines the rootUrl to load from
  53704. */
  53705. parse(source: any, scene: Scene, rootUrl: string): void;
  53706. }
  53707. }
  53708. declare module BABYLON {
  53709. /**
  53710. * @hidden
  53711. */
  53712. export interface IMaterialBRDFDefines {
  53713. BRDF_V_HEIGHT_CORRELATED: boolean;
  53714. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53715. SPHERICAL_HARMONICS: boolean;
  53716. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53717. /** @hidden */
  53718. _areMiscDirty: boolean;
  53719. }
  53720. /**
  53721. * Define the code related to the BRDF parameters of the pbr material.
  53722. */
  53723. export class PBRBRDFConfiguration {
  53724. /**
  53725. * Default value used for the energy conservation.
  53726. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53727. */
  53728. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53729. /**
  53730. * Default value used for the Smith Visibility Height Correlated mode.
  53731. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53732. */
  53733. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53734. /**
  53735. * Default value used for the IBL diffuse part.
  53736. * This can help switching back to the polynomials mode globally which is a tiny bit
  53737. * less GPU intensive at the drawback of a lower quality.
  53738. */
  53739. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53740. /**
  53741. * Default value used for activating energy conservation for the specular workflow.
  53742. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53743. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53744. */
  53745. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53746. private _useEnergyConservation;
  53747. /**
  53748. * Defines if the material uses energy conservation.
  53749. */
  53750. useEnergyConservation: boolean;
  53751. private _useSmithVisibilityHeightCorrelated;
  53752. /**
  53753. * LEGACY Mode set to false
  53754. * Defines if the material uses height smith correlated visibility term.
  53755. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53756. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53757. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53758. * Not relying on height correlated will also disable energy conservation.
  53759. */
  53760. useSmithVisibilityHeightCorrelated: boolean;
  53761. private _useSphericalHarmonics;
  53762. /**
  53763. * LEGACY Mode set to false
  53764. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53765. * diffuse part of the IBL.
  53766. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53767. * to the ground truth.
  53768. */
  53769. useSphericalHarmonics: boolean;
  53770. private _useSpecularGlossinessInputEnergyConservation;
  53771. /**
  53772. * Defines if the material uses energy conservation, when the specular workflow is active.
  53773. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53774. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53775. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53776. */
  53777. useSpecularGlossinessInputEnergyConservation: boolean;
  53778. /** @hidden */
  53779. private _internalMarkAllSubMeshesAsMiscDirty;
  53780. /** @hidden */
  53781. _markAllSubMeshesAsMiscDirty(): void;
  53782. /**
  53783. * Instantiate a new istance of clear coat configuration.
  53784. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53785. */
  53786. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53787. /**
  53788. * Checks to see if a texture is used in the material.
  53789. * @param defines the list of "defines" to update.
  53790. */
  53791. prepareDefines(defines: IMaterialBRDFDefines): void;
  53792. /**
  53793. * Get the current class name of the texture useful for serialization or dynamic coding.
  53794. * @returns "PBRClearCoatConfiguration"
  53795. */
  53796. getClassName(): string;
  53797. /**
  53798. * Makes a duplicate of the current configuration into another one.
  53799. * @param brdfConfiguration define the config where to copy the info
  53800. */
  53801. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53802. /**
  53803. * Serializes this BRDF configuration.
  53804. * @returns - An object with the serialized config.
  53805. */
  53806. serialize(): any;
  53807. /**
  53808. * Parses a anisotropy Configuration from a serialized object.
  53809. * @param source - Serialized object.
  53810. * @param scene Defines the scene we are parsing for
  53811. * @param rootUrl Defines the rootUrl to load from
  53812. */
  53813. parse(source: any, scene: Scene, rootUrl: string): void;
  53814. }
  53815. }
  53816. declare module BABYLON {
  53817. /**
  53818. * @hidden
  53819. */
  53820. export interface IMaterialSheenDefines {
  53821. SHEEN: boolean;
  53822. SHEEN_TEXTURE: boolean;
  53823. SHEEN_TEXTUREDIRECTUV: number;
  53824. SHEEN_LINKWITHALBEDO: boolean;
  53825. SHEEN_ROUGHNESS: boolean;
  53826. SHEEN_ALBEDOSCALING: boolean;
  53827. /** @hidden */
  53828. _areTexturesDirty: boolean;
  53829. }
  53830. /**
  53831. * Define the code related to the Sheen parameters of the pbr material.
  53832. */
  53833. export class PBRSheenConfiguration {
  53834. private _isEnabled;
  53835. /**
  53836. * Defines if the material uses sheen.
  53837. */
  53838. isEnabled: boolean;
  53839. private _linkSheenWithAlbedo;
  53840. /**
  53841. * Defines if the sheen is linked to the sheen color.
  53842. */
  53843. linkSheenWithAlbedo: boolean;
  53844. /**
  53845. * Defines the sheen intensity.
  53846. */
  53847. intensity: number;
  53848. /**
  53849. * Defines the sheen color.
  53850. */
  53851. color: Color3;
  53852. private _texture;
  53853. /**
  53854. * Stores the sheen tint values in a texture.
  53855. * rgb is tint
  53856. * a is a intensity
  53857. */
  53858. texture: Nullable<BaseTexture>;
  53859. private _roughness;
  53860. /**
  53861. * Defines the sheen roughness.
  53862. * It is not taken into account if linkSheenWithAlbedo is true.
  53863. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53864. */
  53865. roughness: Nullable<number>;
  53866. private _albedoScaling;
  53867. /**
  53868. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53869. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53870. * making it easier to setup and tweak the effect
  53871. */
  53872. albedoScaling: boolean;
  53873. /** @hidden */
  53874. private _internalMarkAllSubMeshesAsTexturesDirty;
  53875. /** @hidden */
  53876. _markAllSubMeshesAsTexturesDirty(): void;
  53877. /**
  53878. * Instantiate a new istance of clear coat configuration.
  53879. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53880. */
  53881. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53882. /**
  53883. * Specifies that the submesh is ready to be used.
  53884. * @param defines the list of "defines" to update.
  53885. * @param scene defines the scene the material belongs to.
  53886. * @returns - boolean indicating that the submesh is ready or not.
  53887. */
  53888. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53889. /**
  53890. * Checks to see if a texture is used in the material.
  53891. * @param defines the list of "defines" to update.
  53892. * @param scene defines the scene the material belongs to.
  53893. */
  53894. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53895. /**
  53896. * Binds the material data.
  53897. * @param uniformBuffer defines the Uniform buffer to fill in.
  53898. * @param scene defines the scene the material belongs to.
  53899. * @param isFrozen defines wether the material is frozen or not.
  53900. */
  53901. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53902. /**
  53903. * Checks to see if a texture is used in the material.
  53904. * @param texture - Base texture to use.
  53905. * @returns - Boolean specifying if a texture is used in the material.
  53906. */
  53907. hasTexture(texture: BaseTexture): boolean;
  53908. /**
  53909. * Returns an array of the actively used textures.
  53910. * @param activeTextures Array of BaseTextures
  53911. */
  53912. getActiveTextures(activeTextures: BaseTexture[]): void;
  53913. /**
  53914. * Returns the animatable textures.
  53915. * @param animatables Array of animatable textures.
  53916. */
  53917. getAnimatables(animatables: IAnimatable[]): void;
  53918. /**
  53919. * Disposes the resources of the material.
  53920. * @param forceDisposeTextures - Forces the disposal of all textures.
  53921. */
  53922. dispose(forceDisposeTextures?: boolean): void;
  53923. /**
  53924. * Get the current class name of the texture useful for serialization or dynamic coding.
  53925. * @returns "PBRSheenConfiguration"
  53926. */
  53927. getClassName(): string;
  53928. /**
  53929. * Add fallbacks to the effect fallbacks list.
  53930. * @param defines defines the Base texture to use.
  53931. * @param fallbacks defines the current fallback list.
  53932. * @param currentRank defines the current fallback rank.
  53933. * @returns the new fallback rank.
  53934. */
  53935. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53936. /**
  53937. * Add the required uniforms to the current list.
  53938. * @param uniforms defines the current uniform list.
  53939. */
  53940. static AddUniforms(uniforms: string[]): void;
  53941. /**
  53942. * Add the required uniforms to the current buffer.
  53943. * @param uniformBuffer defines the current uniform buffer.
  53944. */
  53945. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53946. /**
  53947. * Add the required samplers to the current list.
  53948. * @param samplers defines the current sampler list.
  53949. */
  53950. static AddSamplers(samplers: string[]): void;
  53951. /**
  53952. * Makes a duplicate of the current configuration into another one.
  53953. * @param sheenConfiguration define the config where to copy the info
  53954. */
  53955. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53956. /**
  53957. * Serializes this BRDF configuration.
  53958. * @returns - An object with the serialized config.
  53959. */
  53960. serialize(): any;
  53961. /**
  53962. * Parses a anisotropy Configuration from a serialized object.
  53963. * @param source - Serialized object.
  53964. * @param scene Defines the scene we are parsing for
  53965. * @param rootUrl Defines the rootUrl to load from
  53966. */
  53967. parse(source: any, scene: Scene, rootUrl: string): void;
  53968. }
  53969. }
  53970. declare module BABYLON {
  53971. /**
  53972. * @hidden
  53973. */
  53974. export interface IMaterialSubSurfaceDefines {
  53975. SUBSURFACE: boolean;
  53976. SS_REFRACTION: boolean;
  53977. SS_TRANSLUCENCY: boolean;
  53978. SS_SCATERRING: boolean;
  53979. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53980. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53981. SS_REFRACTIONMAP_3D: boolean;
  53982. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53983. SS_LODINREFRACTIONALPHA: boolean;
  53984. SS_GAMMAREFRACTION: boolean;
  53985. SS_RGBDREFRACTION: boolean;
  53986. SS_LINEARSPECULARREFRACTION: boolean;
  53987. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53988. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53989. /** @hidden */
  53990. _areTexturesDirty: boolean;
  53991. }
  53992. /**
  53993. * Define the code related to the sub surface parameters of the pbr material.
  53994. */
  53995. export class PBRSubSurfaceConfiguration {
  53996. private _isRefractionEnabled;
  53997. /**
  53998. * Defines if the refraction is enabled in the material.
  53999. */
  54000. isRefractionEnabled: boolean;
  54001. private _isTranslucencyEnabled;
  54002. /**
  54003. * Defines if the translucency is enabled in the material.
  54004. */
  54005. isTranslucencyEnabled: boolean;
  54006. private _isScatteringEnabled;
  54007. /**
  54008. * Defines the refraction intensity of the material.
  54009. * The refraction when enabled replaces the Diffuse part of the material.
  54010. * The intensity helps transitionning between diffuse and refraction.
  54011. */
  54012. refractionIntensity: number;
  54013. /**
  54014. * Defines the translucency intensity of the material.
  54015. * When translucency has been enabled, this defines how much of the "translucency"
  54016. * is addded to the diffuse part of the material.
  54017. */
  54018. translucencyIntensity: number;
  54019. /**
  54020. * Defines the scattering intensity of the material.
  54021. * When scattering has been enabled, this defines how much of the "scattered light"
  54022. * is addded to the diffuse part of the material.
  54023. */
  54024. scatteringIntensity: number;
  54025. private _thicknessTexture;
  54026. /**
  54027. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54028. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54029. * 0 would mean minimumThickness
  54030. * 1 would mean maximumThickness
  54031. * The other channels might be use as a mask to vary the different effects intensity.
  54032. */
  54033. thicknessTexture: Nullable<BaseTexture>;
  54034. private _refractionTexture;
  54035. /**
  54036. * Defines the texture to use for refraction.
  54037. */
  54038. refractionTexture: Nullable<BaseTexture>;
  54039. private _indexOfRefraction;
  54040. /**
  54041. * Index of refraction of the material base layer.
  54042. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54043. *
  54044. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54045. *
  54046. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54047. */
  54048. indexOfRefraction: number;
  54049. private _invertRefractionY;
  54050. /**
  54051. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54052. */
  54053. invertRefractionY: boolean;
  54054. private _linkRefractionWithTransparency;
  54055. /**
  54056. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54057. * Materials half opaque for instance using refraction could benefit from this control.
  54058. */
  54059. linkRefractionWithTransparency: boolean;
  54060. /**
  54061. * Defines the minimum thickness stored in the thickness map.
  54062. * If no thickness map is defined, this value will be used to simulate thickness.
  54063. */
  54064. minimumThickness: number;
  54065. /**
  54066. * Defines the maximum thickness stored in the thickness map.
  54067. */
  54068. maximumThickness: number;
  54069. /**
  54070. * Defines the volume tint of the material.
  54071. * This is used for both translucency and scattering.
  54072. */
  54073. tintColor: Color3;
  54074. /**
  54075. * Defines the distance at which the tint color should be found in the media.
  54076. * This is used for refraction only.
  54077. */
  54078. tintColorAtDistance: number;
  54079. /**
  54080. * Defines how far each channel transmit through the media.
  54081. * It is defined as a color to simplify it selection.
  54082. */
  54083. diffusionDistance: Color3;
  54084. private _useMaskFromThicknessTexture;
  54085. /**
  54086. * Stores the intensity of the different subsurface effects in the thickness texture.
  54087. * * the green channel is the translucency intensity.
  54088. * * the blue channel is the scattering intensity.
  54089. * * the alpha channel is the refraction intensity.
  54090. */
  54091. useMaskFromThicknessTexture: boolean;
  54092. /** @hidden */
  54093. private _internalMarkAllSubMeshesAsTexturesDirty;
  54094. /** @hidden */
  54095. _markAllSubMeshesAsTexturesDirty(): void;
  54096. /**
  54097. * Instantiate a new istance of sub surface configuration.
  54098. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54099. */
  54100. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54101. /**
  54102. * Gets wehter the submesh is ready to be used or not.
  54103. * @param defines the list of "defines" to update.
  54104. * @param scene defines the scene the material belongs to.
  54105. * @returns - boolean indicating that the submesh is ready or not.
  54106. */
  54107. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54108. /**
  54109. * Checks to see if a texture is used in the material.
  54110. * @param defines the list of "defines" to update.
  54111. * @param scene defines the scene to the material belongs to.
  54112. */
  54113. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54114. /**
  54115. * Binds the material data.
  54116. * @param uniformBuffer defines the Uniform buffer to fill in.
  54117. * @param scene defines the scene the material belongs to.
  54118. * @param engine defines the engine the material belongs to.
  54119. * @param isFrozen defines whether the material is frozen or not.
  54120. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54121. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54122. */
  54123. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54124. /**
  54125. * Unbinds the material from the mesh.
  54126. * @param activeEffect defines the effect that should be unbound from.
  54127. * @returns true if unbound, otherwise false
  54128. */
  54129. unbind(activeEffect: Effect): boolean;
  54130. /**
  54131. * Returns the texture used for refraction or null if none is used.
  54132. * @param scene defines the scene the material belongs to.
  54133. * @returns - Refraction texture if present. If no refraction texture and refraction
  54134. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54135. */
  54136. private _getRefractionTexture;
  54137. /**
  54138. * Returns true if alpha blending should be disabled.
  54139. */
  54140. get disableAlphaBlending(): boolean;
  54141. /**
  54142. * Fills the list of render target textures.
  54143. * @param renderTargets the list of render targets to update
  54144. */
  54145. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54146. /**
  54147. * Checks to see if a texture is used in the material.
  54148. * @param texture - Base texture to use.
  54149. * @returns - Boolean specifying if a texture is used in the material.
  54150. */
  54151. hasTexture(texture: BaseTexture): boolean;
  54152. /**
  54153. * Gets a boolean indicating that current material needs to register RTT
  54154. * @returns true if this uses a render target otherwise false.
  54155. */
  54156. hasRenderTargetTextures(): boolean;
  54157. /**
  54158. * Returns an array of the actively used textures.
  54159. * @param activeTextures Array of BaseTextures
  54160. */
  54161. getActiveTextures(activeTextures: BaseTexture[]): void;
  54162. /**
  54163. * Returns the animatable textures.
  54164. * @param animatables Array of animatable textures.
  54165. */
  54166. getAnimatables(animatables: IAnimatable[]): void;
  54167. /**
  54168. * Disposes the resources of the material.
  54169. * @param forceDisposeTextures - Forces the disposal of all textures.
  54170. */
  54171. dispose(forceDisposeTextures?: boolean): void;
  54172. /**
  54173. * Get the current class name of the texture useful for serialization or dynamic coding.
  54174. * @returns "PBRSubSurfaceConfiguration"
  54175. */
  54176. getClassName(): string;
  54177. /**
  54178. * Add fallbacks to the effect fallbacks list.
  54179. * @param defines defines the Base texture to use.
  54180. * @param fallbacks defines the current fallback list.
  54181. * @param currentRank defines the current fallback rank.
  54182. * @returns the new fallback rank.
  54183. */
  54184. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54185. /**
  54186. * Add the required uniforms to the current list.
  54187. * @param uniforms defines the current uniform list.
  54188. */
  54189. static AddUniforms(uniforms: string[]): void;
  54190. /**
  54191. * Add the required samplers to the current list.
  54192. * @param samplers defines the current sampler list.
  54193. */
  54194. static AddSamplers(samplers: string[]): void;
  54195. /**
  54196. * Add the required uniforms to the current buffer.
  54197. * @param uniformBuffer defines the current uniform buffer.
  54198. */
  54199. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54200. /**
  54201. * Makes a duplicate of the current configuration into another one.
  54202. * @param configuration define the config where to copy the info
  54203. */
  54204. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54205. /**
  54206. * Serializes this Sub Surface configuration.
  54207. * @returns - An object with the serialized config.
  54208. */
  54209. serialize(): any;
  54210. /**
  54211. * Parses a anisotropy Configuration from a serialized object.
  54212. * @param source - Serialized object.
  54213. * @param scene Defines the scene we are parsing for
  54214. * @param rootUrl Defines the rootUrl to load from
  54215. */
  54216. parse(source: any, scene: Scene, rootUrl: string): void;
  54217. }
  54218. }
  54219. declare module BABYLON {
  54220. /** @hidden */
  54221. export var pbrFragmentDeclaration: {
  54222. name: string;
  54223. shader: string;
  54224. };
  54225. }
  54226. declare module BABYLON {
  54227. /** @hidden */
  54228. export var pbrUboDeclaration: {
  54229. name: string;
  54230. shader: string;
  54231. };
  54232. }
  54233. declare module BABYLON {
  54234. /** @hidden */
  54235. export var pbrFragmentExtraDeclaration: {
  54236. name: string;
  54237. shader: string;
  54238. };
  54239. }
  54240. declare module BABYLON {
  54241. /** @hidden */
  54242. export var pbrFragmentSamplersDeclaration: {
  54243. name: string;
  54244. shader: string;
  54245. };
  54246. }
  54247. declare module BABYLON {
  54248. /** @hidden */
  54249. export var importanceSampling: {
  54250. name: string;
  54251. shader: string;
  54252. };
  54253. }
  54254. declare module BABYLON {
  54255. /** @hidden */
  54256. export var pbrHelperFunctions: {
  54257. name: string;
  54258. shader: string;
  54259. };
  54260. }
  54261. declare module BABYLON {
  54262. /** @hidden */
  54263. export var harmonicsFunctions: {
  54264. name: string;
  54265. shader: string;
  54266. };
  54267. }
  54268. declare module BABYLON {
  54269. /** @hidden */
  54270. export var pbrDirectLightingSetupFunctions: {
  54271. name: string;
  54272. shader: string;
  54273. };
  54274. }
  54275. declare module BABYLON {
  54276. /** @hidden */
  54277. export var pbrDirectLightingFalloffFunctions: {
  54278. name: string;
  54279. shader: string;
  54280. };
  54281. }
  54282. declare module BABYLON {
  54283. /** @hidden */
  54284. export var pbrBRDFFunctions: {
  54285. name: string;
  54286. shader: string;
  54287. };
  54288. }
  54289. declare module BABYLON {
  54290. /** @hidden */
  54291. export var hdrFilteringFunctions: {
  54292. name: string;
  54293. shader: string;
  54294. };
  54295. }
  54296. declare module BABYLON {
  54297. /** @hidden */
  54298. export var pbrDirectLightingFunctions: {
  54299. name: string;
  54300. shader: string;
  54301. };
  54302. }
  54303. declare module BABYLON {
  54304. /** @hidden */
  54305. export var pbrIBLFunctions: {
  54306. name: string;
  54307. shader: string;
  54308. };
  54309. }
  54310. declare module BABYLON {
  54311. /** @hidden */
  54312. export var pbrBlockAlbedoOpacity: {
  54313. name: string;
  54314. shader: string;
  54315. };
  54316. }
  54317. declare module BABYLON {
  54318. /** @hidden */
  54319. export var pbrBlockReflectivity: {
  54320. name: string;
  54321. shader: string;
  54322. };
  54323. }
  54324. declare module BABYLON {
  54325. /** @hidden */
  54326. export var pbrBlockAmbientOcclusion: {
  54327. name: string;
  54328. shader: string;
  54329. };
  54330. }
  54331. declare module BABYLON {
  54332. /** @hidden */
  54333. export var pbrBlockAlphaFresnel: {
  54334. name: string;
  54335. shader: string;
  54336. };
  54337. }
  54338. declare module BABYLON {
  54339. /** @hidden */
  54340. export var pbrBlockAnisotropic: {
  54341. name: string;
  54342. shader: string;
  54343. };
  54344. }
  54345. declare module BABYLON {
  54346. /** @hidden */
  54347. export var pbrBlockReflection: {
  54348. name: string;
  54349. shader: string;
  54350. };
  54351. }
  54352. declare module BABYLON {
  54353. /** @hidden */
  54354. export var pbrBlockSheen: {
  54355. name: string;
  54356. shader: string;
  54357. };
  54358. }
  54359. declare module BABYLON {
  54360. /** @hidden */
  54361. export var pbrBlockClearcoat: {
  54362. name: string;
  54363. shader: string;
  54364. };
  54365. }
  54366. declare module BABYLON {
  54367. /** @hidden */
  54368. export var pbrBlockSubSurface: {
  54369. name: string;
  54370. shader: string;
  54371. };
  54372. }
  54373. declare module BABYLON {
  54374. /** @hidden */
  54375. export var pbrBlockNormalGeometric: {
  54376. name: string;
  54377. shader: string;
  54378. };
  54379. }
  54380. declare module BABYLON {
  54381. /** @hidden */
  54382. export var pbrBlockNormalFinal: {
  54383. name: string;
  54384. shader: string;
  54385. };
  54386. }
  54387. declare module BABYLON {
  54388. /** @hidden */
  54389. export var pbrBlockGeometryInfo: {
  54390. name: string;
  54391. shader: string;
  54392. };
  54393. }
  54394. declare module BABYLON {
  54395. /** @hidden */
  54396. export var pbrBlockReflectance0: {
  54397. name: string;
  54398. shader: string;
  54399. };
  54400. }
  54401. declare module BABYLON {
  54402. /** @hidden */
  54403. export var pbrBlockReflectance: {
  54404. name: string;
  54405. shader: string;
  54406. };
  54407. }
  54408. declare module BABYLON {
  54409. /** @hidden */
  54410. export var pbrBlockDirectLighting: {
  54411. name: string;
  54412. shader: string;
  54413. };
  54414. }
  54415. declare module BABYLON {
  54416. /** @hidden */
  54417. export var pbrBlockFinalLitComponents: {
  54418. name: string;
  54419. shader: string;
  54420. };
  54421. }
  54422. declare module BABYLON {
  54423. /** @hidden */
  54424. export var pbrBlockFinalUnlitComponents: {
  54425. name: string;
  54426. shader: string;
  54427. };
  54428. }
  54429. declare module BABYLON {
  54430. /** @hidden */
  54431. export var pbrBlockFinalColorComposition: {
  54432. name: string;
  54433. shader: string;
  54434. };
  54435. }
  54436. declare module BABYLON {
  54437. /** @hidden */
  54438. export var pbrBlockImageProcessing: {
  54439. name: string;
  54440. shader: string;
  54441. };
  54442. }
  54443. declare module BABYLON {
  54444. /** @hidden */
  54445. export var pbrDebug: {
  54446. name: string;
  54447. shader: string;
  54448. };
  54449. }
  54450. declare module BABYLON {
  54451. /** @hidden */
  54452. export var pbrPixelShader: {
  54453. name: string;
  54454. shader: string;
  54455. };
  54456. }
  54457. declare module BABYLON {
  54458. /** @hidden */
  54459. export var pbrVertexDeclaration: {
  54460. name: string;
  54461. shader: string;
  54462. };
  54463. }
  54464. declare module BABYLON {
  54465. /** @hidden */
  54466. export var pbrVertexShader: {
  54467. name: string;
  54468. shader: string;
  54469. };
  54470. }
  54471. declare module BABYLON {
  54472. /**
  54473. * Manages the defines for the PBR Material.
  54474. * @hidden
  54475. */
  54476. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54477. PBR: boolean;
  54478. NUM_SAMPLES: string;
  54479. REALTIME_FILTERING: boolean;
  54480. MAINUV1: boolean;
  54481. MAINUV2: boolean;
  54482. UV1: boolean;
  54483. UV2: boolean;
  54484. ALBEDO: boolean;
  54485. GAMMAALBEDO: boolean;
  54486. ALBEDODIRECTUV: number;
  54487. VERTEXCOLOR: boolean;
  54488. AMBIENT: boolean;
  54489. AMBIENTDIRECTUV: number;
  54490. AMBIENTINGRAYSCALE: boolean;
  54491. OPACITY: boolean;
  54492. VERTEXALPHA: boolean;
  54493. OPACITYDIRECTUV: number;
  54494. OPACITYRGB: boolean;
  54495. ALPHATEST: boolean;
  54496. DEPTHPREPASS: boolean;
  54497. ALPHABLEND: boolean;
  54498. ALPHAFROMALBEDO: boolean;
  54499. ALPHATESTVALUE: string;
  54500. SPECULAROVERALPHA: boolean;
  54501. RADIANCEOVERALPHA: boolean;
  54502. ALPHAFRESNEL: boolean;
  54503. LINEARALPHAFRESNEL: boolean;
  54504. PREMULTIPLYALPHA: boolean;
  54505. EMISSIVE: boolean;
  54506. EMISSIVEDIRECTUV: number;
  54507. REFLECTIVITY: boolean;
  54508. REFLECTIVITYDIRECTUV: number;
  54509. SPECULARTERM: boolean;
  54510. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54511. MICROSURFACEAUTOMATIC: boolean;
  54512. LODBASEDMICROSFURACE: boolean;
  54513. MICROSURFACEMAP: boolean;
  54514. MICROSURFACEMAPDIRECTUV: number;
  54515. METALLICWORKFLOW: boolean;
  54516. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54517. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54518. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54519. AOSTOREINMETALMAPRED: boolean;
  54520. METALLIC_REFLECTANCE: boolean;
  54521. METALLIC_REFLECTANCEDIRECTUV: number;
  54522. ENVIRONMENTBRDF: boolean;
  54523. ENVIRONMENTBRDF_RGBD: boolean;
  54524. NORMAL: boolean;
  54525. TANGENT: boolean;
  54526. BUMP: boolean;
  54527. BUMPDIRECTUV: number;
  54528. OBJECTSPACE_NORMALMAP: boolean;
  54529. PARALLAX: boolean;
  54530. PARALLAXOCCLUSION: boolean;
  54531. NORMALXYSCALE: boolean;
  54532. LIGHTMAP: boolean;
  54533. LIGHTMAPDIRECTUV: number;
  54534. USELIGHTMAPASSHADOWMAP: boolean;
  54535. GAMMALIGHTMAP: boolean;
  54536. RGBDLIGHTMAP: boolean;
  54537. REFLECTION: boolean;
  54538. REFLECTIONMAP_3D: boolean;
  54539. REFLECTIONMAP_SPHERICAL: boolean;
  54540. REFLECTIONMAP_PLANAR: boolean;
  54541. REFLECTIONMAP_CUBIC: boolean;
  54542. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54543. REFLECTIONMAP_PROJECTION: boolean;
  54544. REFLECTIONMAP_SKYBOX: boolean;
  54545. REFLECTIONMAP_EXPLICIT: boolean;
  54546. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54547. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54548. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54549. INVERTCUBICMAP: boolean;
  54550. USESPHERICALFROMREFLECTIONMAP: boolean;
  54551. USEIRRADIANCEMAP: boolean;
  54552. SPHERICAL_HARMONICS: boolean;
  54553. USESPHERICALINVERTEX: boolean;
  54554. REFLECTIONMAP_OPPOSITEZ: boolean;
  54555. LODINREFLECTIONALPHA: boolean;
  54556. GAMMAREFLECTION: boolean;
  54557. RGBDREFLECTION: boolean;
  54558. LINEARSPECULARREFLECTION: boolean;
  54559. RADIANCEOCCLUSION: boolean;
  54560. HORIZONOCCLUSION: boolean;
  54561. INSTANCES: boolean;
  54562. NUM_BONE_INFLUENCERS: number;
  54563. BonesPerMesh: number;
  54564. BONETEXTURE: boolean;
  54565. NONUNIFORMSCALING: boolean;
  54566. MORPHTARGETS: boolean;
  54567. MORPHTARGETS_NORMAL: boolean;
  54568. MORPHTARGETS_TANGENT: boolean;
  54569. MORPHTARGETS_UV: boolean;
  54570. NUM_MORPH_INFLUENCERS: number;
  54571. IMAGEPROCESSING: boolean;
  54572. VIGNETTE: boolean;
  54573. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54574. VIGNETTEBLENDMODEOPAQUE: boolean;
  54575. TONEMAPPING: boolean;
  54576. TONEMAPPING_ACES: boolean;
  54577. CONTRAST: boolean;
  54578. COLORCURVES: boolean;
  54579. COLORGRADING: boolean;
  54580. COLORGRADING3D: boolean;
  54581. SAMPLER3DGREENDEPTH: boolean;
  54582. SAMPLER3DBGRMAP: boolean;
  54583. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54584. EXPOSURE: boolean;
  54585. MULTIVIEW: boolean;
  54586. USEPHYSICALLIGHTFALLOFF: boolean;
  54587. USEGLTFLIGHTFALLOFF: boolean;
  54588. TWOSIDEDLIGHTING: boolean;
  54589. SHADOWFLOAT: boolean;
  54590. CLIPPLANE: boolean;
  54591. CLIPPLANE2: boolean;
  54592. CLIPPLANE3: boolean;
  54593. CLIPPLANE4: boolean;
  54594. CLIPPLANE5: boolean;
  54595. CLIPPLANE6: boolean;
  54596. POINTSIZE: boolean;
  54597. FOG: boolean;
  54598. LOGARITHMICDEPTH: boolean;
  54599. FORCENORMALFORWARD: boolean;
  54600. SPECULARAA: boolean;
  54601. CLEARCOAT: boolean;
  54602. CLEARCOAT_DEFAULTIOR: boolean;
  54603. CLEARCOAT_TEXTURE: boolean;
  54604. CLEARCOAT_TEXTUREDIRECTUV: number;
  54605. CLEARCOAT_BUMP: boolean;
  54606. CLEARCOAT_BUMPDIRECTUV: number;
  54607. CLEARCOAT_TINT: boolean;
  54608. CLEARCOAT_TINT_TEXTURE: boolean;
  54609. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54610. ANISOTROPIC: boolean;
  54611. ANISOTROPIC_TEXTURE: boolean;
  54612. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54613. BRDF_V_HEIGHT_CORRELATED: boolean;
  54614. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54615. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54616. SHEEN: boolean;
  54617. SHEEN_TEXTURE: boolean;
  54618. SHEEN_TEXTUREDIRECTUV: number;
  54619. SHEEN_LINKWITHALBEDO: boolean;
  54620. SHEEN_ROUGHNESS: boolean;
  54621. SHEEN_ALBEDOSCALING: boolean;
  54622. SUBSURFACE: boolean;
  54623. SS_REFRACTION: boolean;
  54624. SS_TRANSLUCENCY: boolean;
  54625. SS_SCATERRING: boolean;
  54626. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54627. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54628. SS_REFRACTIONMAP_3D: boolean;
  54629. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54630. SS_LODINREFRACTIONALPHA: boolean;
  54631. SS_GAMMAREFRACTION: boolean;
  54632. SS_RGBDREFRACTION: boolean;
  54633. SS_LINEARSPECULARREFRACTION: boolean;
  54634. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54635. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54636. UNLIT: boolean;
  54637. DEBUGMODE: number;
  54638. /**
  54639. * Initializes the PBR Material defines.
  54640. */
  54641. constructor();
  54642. /**
  54643. * Resets the PBR Material defines.
  54644. */
  54645. reset(): void;
  54646. }
  54647. /**
  54648. * The Physically based material base class of BJS.
  54649. *
  54650. * This offers the main features of a standard PBR material.
  54651. * For more information, please refer to the documentation :
  54652. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54653. */
  54654. export abstract class PBRBaseMaterial extends PushMaterial {
  54655. /**
  54656. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54657. */
  54658. static readonly PBRMATERIAL_OPAQUE: number;
  54659. /**
  54660. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54661. */
  54662. static readonly PBRMATERIAL_ALPHATEST: number;
  54663. /**
  54664. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54665. */
  54666. static readonly PBRMATERIAL_ALPHABLEND: number;
  54667. /**
  54668. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54669. * They are also discarded below the alpha cutoff threshold to improve performances.
  54670. */
  54671. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54672. /**
  54673. * Defines the default value of how much AO map is occluding the analytical lights
  54674. * (point spot...).
  54675. */
  54676. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54677. /**
  54678. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54679. */
  54680. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54681. /**
  54682. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54683. * to enhance interoperability with other engines.
  54684. */
  54685. static readonly LIGHTFALLOFF_GLTF: number;
  54686. /**
  54687. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54688. * to enhance interoperability with other materials.
  54689. */
  54690. static readonly LIGHTFALLOFF_STANDARD: number;
  54691. /**
  54692. * Intensity of the direct lights e.g. the four lights available in your scene.
  54693. * This impacts both the direct diffuse and specular highlights.
  54694. */
  54695. protected _directIntensity: number;
  54696. /**
  54697. * Intensity of the emissive part of the material.
  54698. * This helps controlling the emissive effect without modifying the emissive color.
  54699. */
  54700. protected _emissiveIntensity: number;
  54701. /**
  54702. * Intensity of the environment e.g. how much the environment will light the object
  54703. * either through harmonics for rough material or through the refelction for shiny ones.
  54704. */
  54705. protected _environmentIntensity: number;
  54706. /**
  54707. * This is a special control allowing the reduction of the specular highlights coming from the
  54708. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54709. */
  54710. protected _specularIntensity: number;
  54711. /**
  54712. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54713. */
  54714. private _lightingInfos;
  54715. /**
  54716. * Debug Control allowing disabling the bump map on this material.
  54717. */
  54718. protected _disableBumpMap: boolean;
  54719. /**
  54720. * AKA Diffuse Texture in standard nomenclature.
  54721. */
  54722. protected _albedoTexture: Nullable<BaseTexture>;
  54723. /**
  54724. * AKA Occlusion Texture in other nomenclature.
  54725. */
  54726. protected _ambientTexture: Nullable<BaseTexture>;
  54727. /**
  54728. * AKA Occlusion Texture Intensity in other nomenclature.
  54729. */
  54730. protected _ambientTextureStrength: number;
  54731. /**
  54732. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54733. * 1 means it completely occludes it
  54734. * 0 mean it has no impact
  54735. */
  54736. protected _ambientTextureImpactOnAnalyticalLights: number;
  54737. /**
  54738. * Stores the alpha values in a texture.
  54739. */
  54740. protected _opacityTexture: Nullable<BaseTexture>;
  54741. /**
  54742. * Stores the reflection values in a texture.
  54743. */
  54744. protected _reflectionTexture: Nullable<BaseTexture>;
  54745. /**
  54746. * Stores the emissive values in a texture.
  54747. */
  54748. protected _emissiveTexture: Nullable<BaseTexture>;
  54749. /**
  54750. * AKA Specular texture in other nomenclature.
  54751. */
  54752. protected _reflectivityTexture: Nullable<BaseTexture>;
  54753. /**
  54754. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54755. */
  54756. protected _metallicTexture: Nullable<BaseTexture>;
  54757. /**
  54758. * Specifies the metallic scalar of the metallic/roughness workflow.
  54759. * Can also be used to scale the metalness values of the metallic texture.
  54760. */
  54761. protected _metallic: Nullable<number>;
  54762. /**
  54763. * Specifies the roughness scalar of the metallic/roughness workflow.
  54764. * Can also be used to scale the roughness values of the metallic texture.
  54765. */
  54766. protected _roughness: Nullable<number>;
  54767. /**
  54768. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54769. * By default the indexOfrefraction is used to compute F0;
  54770. *
  54771. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54772. *
  54773. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54774. * F90 = metallicReflectanceColor;
  54775. */
  54776. protected _metallicF0Factor: number;
  54777. /**
  54778. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54779. * By default the F90 is always 1;
  54780. *
  54781. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54782. *
  54783. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54784. * F90 = metallicReflectanceColor;
  54785. */
  54786. protected _metallicReflectanceColor: Color3;
  54787. /**
  54788. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54789. * This is multiply against the scalar values defined in the material.
  54790. */
  54791. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54792. /**
  54793. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54794. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54795. */
  54796. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54797. /**
  54798. * Stores surface normal data used to displace a mesh in a texture.
  54799. */
  54800. protected _bumpTexture: Nullable<BaseTexture>;
  54801. /**
  54802. * Stores the pre-calculated light information of a mesh in a texture.
  54803. */
  54804. protected _lightmapTexture: Nullable<BaseTexture>;
  54805. /**
  54806. * The color of a material in ambient lighting.
  54807. */
  54808. protected _ambientColor: Color3;
  54809. /**
  54810. * AKA Diffuse Color in other nomenclature.
  54811. */
  54812. protected _albedoColor: Color3;
  54813. /**
  54814. * AKA Specular Color in other nomenclature.
  54815. */
  54816. protected _reflectivityColor: Color3;
  54817. /**
  54818. * The color applied when light is reflected from a material.
  54819. */
  54820. protected _reflectionColor: Color3;
  54821. /**
  54822. * The color applied when light is emitted from a material.
  54823. */
  54824. protected _emissiveColor: Color3;
  54825. /**
  54826. * AKA Glossiness in other nomenclature.
  54827. */
  54828. protected _microSurface: number;
  54829. /**
  54830. * Specifies that the material will use the light map as a show map.
  54831. */
  54832. protected _useLightmapAsShadowmap: boolean;
  54833. /**
  54834. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54835. * makes the reflect vector face the model (under horizon).
  54836. */
  54837. protected _useHorizonOcclusion: boolean;
  54838. /**
  54839. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54840. * too much the area relying on ambient texture to define their ambient occlusion.
  54841. */
  54842. protected _useRadianceOcclusion: boolean;
  54843. /**
  54844. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54845. */
  54846. protected _useAlphaFromAlbedoTexture: boolean;
  54847. /**
  54848. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54849. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54850. */
  54851. protected _useSpecularOverAlpha: boolean;
  54852. /**
  54853. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54854. */
  54855. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54856. /**
  54857. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54858. */
  54859. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54860. /**
  54861. * Specifies if the metallic texture contains the roughness information in its green channel.
  54862. */
  54863. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54864. /**
  54865. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54866. */
  54867. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54868. /**
  54869. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54870. */
  54871. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54872. /**
  54873. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54874. */
  54875. protected _useAmbientInGrayScale: boolean;
  54876. /**
  54877. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54878. * The material will try to infer what glossiness each pixel should be.
  54879. */
  54880. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54881. /**
  54882. * Defines the falloff type used in this material.
  54883. * It by default is Physical.
  54884. */
  54885. protected _lightFalloff: number;
  54886. /**
  54887. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54888. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54889. */
  54890. protected _useRadianceOverAlpha: boolean;
  54891. /**
  54892. * Allows using an object space normal map (instead of tangent space).
  54893. */
  54894. protected _useObjectSpaceNormalMap: boolean;
  54895. /**
  54896. * Allows using the bump map in parallax mode.
  54897. */
  54898. protected _useParallax: boolean;
  54899. /**
  54900. * Allows using the bump map in parallax occlusion mode.
  54901. */
  54902. protected _useParallaxOcclusion: boolean;
  54903. /**
  54904. * Controls the scale bias of the parallax mode.
  54905. */
  54906. protected _parallaxScaleBias: number;
  54907. /**
  54908. * If sets to true, disables all the lights affecting the material.
  54909. */
  54910. protected _disableLighting: boolean;
  54911. /**
  54912. * Number of Simultaneous lights allowed on the material.
  54913. */
  54914. protected _maxSimultaneousLights: number;
  54915. /**
  54916. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54917. */
  54918. protected _invertNormalMapX: boolean;
  54919. /**
  54920. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54921. */
  54922. protected _invertNormalMapY: boolean;
  54923. /**
  54924. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54925. */
  54926. protected _twoSidedLighting: boolean;
  54927. /**
  54928. * Defines the alpha limits in alpha test mode.
  54929. */
  54930. protected _alphaCutOff: number;
  54931. /**
  54932. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54933. */
  54934. protected _forceAlphaTest: boolean;
  54935. /**
  54936. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54937. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54938. */
  54939. protected _useAlphaFresnel: boolean;
  54940. /**
  54941. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54942. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54943. */
  54944. protected _useLinearAlphaFresnel: boolean;
  54945. /**
  54946. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54947. * from cos thetav and roughness:
  54948. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54949. */
  54950. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54951. /**
  54952. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54953. */
  54954. protected _forceIrradianceInFragment: boolean;
  54955. private _realTimeFiltering;
  54956. /**
  54957. * Enables realtime filtering on the texture.
  54958. */
  54959. get realTimeFiltering(): boolean;
  54960. set realTimeFiltering(b: boolean);
  54961. private _realTimeFilteringQuality;
  54962. /**
  54963. * Quality switch for realtime filtering
  54964. */
  54965. get realTimeFilteringQuality(): number;
  54966. set realTimeFilteringQuality(n: number);
  54967. /**
  54968. * Force normal to face away from face.
  54969. */
  54970. protected _forceNormalForward: boolean;
  54971. /**
  54972. * Enables specular anti aliasing in the PBR shader.
  54973. * It will both interacts on the Geometry for analytical and IBL lighting.
  54974. * It also prefilter the roughness map based on the bump values.
  54975. */
  54976. protected _enableSpecularAntiAliasing: boolean;
  54977. /**
  54978. * Default configuration related to image processing available in the PBR Material.
  54979. */
  54980. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54981. /**
  54982. * Keep track of the image processing observer to allow dispose and replace.
  54983. */
  54984. private _imageProcessingObserver;
  54985. /**
  54986. * Attaches a new image processing configuration to the PBR Material.
  54987. * @param configuration
  54988. */
  54989. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54990. /**
  54991. * Stores the available render targets.
  54992. */
  54993. private _renderTargets;
  54994. /**
  54995. * Sets the global ambient color for the material used in lighting calculations.
  54996. */
  54997. private _globalAmbientColor;
  54998. /**
  54999. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55000. */
  55001. private _useLogarithmicDepth;
  55002. /**
  55003. * If set to true, no lighting calculations will be applied.
  55004. */
  55005. private _unlit;
  55006. private _debugMode;
  55007. /**
  55008. * @hidden
  55009. * This is reserved for the inspector.
  55010. * Defines the material debug mode.
  55011. * It helps seeing only some components of the material while troubleshooting.
  55012. */
  55013. debugMode: number;
  55014. /**
  55015. * @hidden
  55016. * This is reserved for the inspector.
  55017. * Specify from where on screen the debug mode should start.
  55018. * The value goes from -1 (full screen) to 1 (not visible)
  55019. * It helps with side by side comparison against the final render
  55020. * This defaults to -1
  55021. */
  55022. private debugLimit;
  55023. /**
  55024. * @hidden
  55025. * This is reserved for the inspector.
  55026. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55027. * You can use the factor to better multiply the final value.
  55028. */
  55029. private debugFactor;
  55030. /**
  55031. * Defines the clear coat layer parameters for the material.
  55032. */
  55033. readonly clearCoat: PBRClearCoatConfiguration;
  55034. /**
  55035. * Defines the anisotropic parameters for the material.
  55036. */
  55037. readonly anisotropy: PBRAnisotropicConfiguration;
  55038. /**
  55039. * Defines the BRDF parameters for the material.
  55040. */
  55041. readonly brdf: PBRBRDFConfiguration;
  55042. /**
  55043. * Defines the Sheen parameters for the material.
  55044. */
  55045. readonly sheen: PBRSheenConfiguration;
  55046. /**
  55047. * Defines the SubSurface parameters for the material.
  55048. */
  55049. readonly subSurface: PBRSubSurfaceConfiguration;
  55050. protected _rebuildInParallel: boolean;
  55051. /**
  55052. * Instantiates a new PBRMaterial instance.
  55053. *
  55054. * @param name The material name
  55055. * @param scene The scene the material will be use in.
  55056. */
  55057. constructor(name: string, scene: Scene);
  55058. /**
  55059. * Gets a boolean indicating that current material needs to register RTT
  55060. */
  55061. get hasRenderTargetTextures(): boolean;
  55062. /**
  55063. * Gets the name of the material class.
  55064. */
  55065. getClassName(): string;
  55066. /**
  55067. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55068. */
  55069. get useLogarithmicDepth(): boolean;
  55070. /**
  55071. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55072. */
  55073. set useLogarithmicDepth(value: boolean);
  55074. /**
  55075. * Returns true if alpha blending should be disabled.
  55076. */
  55077. protected get _disableAlphaBlending(): boolean;
  55078. /**
  55079. * Specifies whether or not this material should be rendered in alpha blend mode.
  55080. */
  55081. needAlphaBlending(): boolean;
  55082. /**
  55083. * Specifies whether or not this material should be rendered in alpha test mode.
  55084. */
  55085. needAlphaTesting(): boolean;
  55086. /**
  55087. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55088. */
  55089. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55090. /**
  55091. * Gets the texture used for the alpha test.
  55092. */
  55093. getAlphaTestTexture(): Nullable<BaseTexture>;
  55094. /**
  55095. * Specifies that the submesh is ready to be used.
  55096. * @param mesh - BJS mesh.
  55097. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55098. * @param useInstances - Specifies that instances should be used.
  55099. * @returns - boolean indicating that the submesh is ready or not.
  55100. */
  55101. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55102. /**
  55103. * Specifies if the material uses metallic roughness workflow.
  55104. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55105. */
  55106. isMetallicWorkflow(): boolean;
  55107. private _prepareEffect;
  55108. private _prepareDefines;
  55109. /**
  55110. * Force shader compilation
  55111. */
  55112. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55113. /**
  55114. * Initializes the uniform buffer layout for the shader.
  55115. */
  55116. buildUniformLayout(): void;
  55117. /**
  55118. * Unbinds the material from the mesh
  55119. */
  55120. unbind(): void;
  55121. /**
  55122. * Binds the submesh data.
  55123. * @param world - The world matrix.
  55124. * @param mesh - The BJS mesh.
  55125. * @param subMesh - A submesh of the BJS mesh.
  55126. */
  55127. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55128. /**
  55129. * Returns the animatable textures.
  55130. * @returns - Array of animatable textures.
  55131. */
  55132. getAnimatables(): IAnimatable[];
  55133. /**
  55134. * Returns the texture used for reflections.
  55135. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55136. */
  55137. private _getReflectionTexture;
  55138. /**
  55139. * Returns an array of the actively used textures.
  55140. * @returns - Array of BaseTextures
  55141. */
  55142. getActiveTextures(): BaseTexture[];
  55143. /**
  55144. * Checks to see if a texture is used in the material.
  55145. * @param texture - Base texture to use.
  55146. * @returns - Boolean specifying if a texture is used in the material.
  55147. */
  55148. hasTexture(texture: BaseTexture): boolean;
  55149. /**
  55150. * Disposes the resources of the material.
  55151. * @param forceDisposeEffect - Forces the disposal of effects.
  55152. * @param forceDisposeTextures - Forces the disposal of all textures.
  55153. */
  55154. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55155. }
  55156. }
  55157. declare module BABYLON {
  55158. /**
  55159. * The Physically based material of BJS.
  55160. *
  55161. * This offers the main features of a standard PBR material.
  55162. * For more information, please refer to the documentation :
  55163. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55164. */
  55165. export class PBRMaterial extends PBRBaseMaterial {
  55166. /**
  55167. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55168. */
  55169. static readonly PBRMATERIAL_OPAQUE: number;
  55170. /**
  55171. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55172. */
  55173. static readonly PBRMATERIAL_ALPHATEST: number;
  55174. /**
  55175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55176. */
  55177. static readonly PBRMATERIAL_ALPHABLEND: number;
  55178. /**
  55179. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55180. * They are also discarded below the alpha cutoff threshold to improve performances.
  55181. */
  55182. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55183. /**
  55184. * Defines the default value of how much AO map is occluding the analytical lights
  55185. * (point spot...).
  55186. */
  55187. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55188. /**
  55189. * Intensity of the direct lights e.g. the four lights available in your scene.
  55190. * This impacts both the direct diffuse and specular highlights.
  55191. */
  55192. directIntensity: number;
  55193. /**
  55194. * Intensity of the emissive part of the material.
  55195. * This helps controlling the emissive effect without modifying the emissive color.
  55196. */
  55197. emissiveIntensity: number;
  55198. /**
  55199. * Intensity of the environment e.g. how much the environment will light the object
  55200. * either through harmonics for rough material or through the refelction for shiny ones.
  55201. */
  55202. environmentIntensity: number;
  55203. /**
  55204. * This is a special control allowing the reduction of the specular highlights coming from the
  55205. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55206. */
  55207. specularIntensity: number;
  55208. /**
  55209. * Debug Control allowing disabling the bump map on this material.
  55210. */
  55211. disableBumpMap: boolean;
  55212. /**
  55213. * AKA Diffuse Texture in standard nomenclature.
  55214. */
  55215. albedoTexture: BaseTexture;
  55216. /**
  55217. * AKA Occlusion Texture in other nomenclature.
  55218. */
  55219. ambientTexture: BaseTexture;
  55220. /**
  55221. * AKA Occlusion Texture Intensity in other nomenclature.
  55222. */
  55223. ambientTextureStrength: number;
  55224. /**
  55225. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55226. * 1 means it completely occludes it
  55227. * 0 mean it has no impact
  55228. */
  55229. ambientTextureImpactOnAnalyticalLights: number;
  55230. /**
  55231. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55232. */
  55233. opacityTexture: BaseTexture;
  55234. /**
  55235. * Stores the reflection values in a texture.
  55236. */
  55237. reflectionTexture: Nullable<BaseTexture>;
  55238. /**
  55239. * Stores the emissive values in a texture.
  55240. */
  55241. emissiveTexture: BaseTexture;
  55242. /**
  55243. * AKA Specular texture in other nomenclature.
  55244. */
  55245. reflectivityTexture: BaseTexture;
  55246. /**
  55247. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55248. */
  55249. metallicTexture: BaseTexture;
  55250. /**
  55251. * Specifies the metallic scalar of the metallic/roughness workflow.
  55252. * Can also be used to scale the metalness values of the metallic texture.
  55253. */
  55254. metallic: Nullable<number>;
  55255. /**
  55256. * Specifies the roughness scalar of the metallic/roughness workflow.
  55257. * Can also be used to scale the roughness values of the metallic texture.
  55258. */
  55259. roughness: Nullable<number>;
  55260. /**
  55261. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55262. * By default the indexOfrefraction is used to compute F0;
  55263. *
  55264. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55265. *
  55266. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55267. * F90 = metallicReflectanceColor;
  55268. */
  55269. metallicF0Factor: number;
  55270. /**
  55271. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55272. * By default the F90 is always 1;
  55273. *
  55274. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55275. *
  55276. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55277. * F90 = metallicReflectanceColor;
  55278. */
  55279. metallicReflectanceColor: Color3;
  55280. /**
  55281. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55282. * This is multiply against the scalar values defined in the material.
  55283. */
  55284. metallicReflectanceTexture: Nullable<BaseTexture>;
  55285. /**
  55286. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55287. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55288. */
  55289. microSurfaceTexture: BaseTexture;
  55290. /**
  55291. * Stores surface normal data used to displace a mesh in a texture.
  55292. */
  55293. bumpTexture: BaseTexture;
  55294. /**
  55295. * Stores the pre-calculated light information of a mesh in a texture.
  55296. */
  55297. lightmapTexture: BaseTexture;
  55298. /**
  55299. * Stores the refracted light information in a texture.
  55300. */
  55301. get refractionTexture(): Nullable<BaseTexture>;
  55302. set refractionTexture(value: Nullable<BaseTexture>);
  55303. /**
  55304. * The color of a material in ambient lighting.
  55305. */
  55306. ambientColor: Color3;
  55307. /**
  55308. * AKA Diffuse Color in other nomenclature.
  55309. */
  55310. albedoColor: Color3;
  55311. /**
  55312. * AKA Specular Color in other nomenclature.
  55313. */
  55314. reflectivityColor: Color3;
  55315. /**
  55316. * The color reflected from the material.
  55317. */
  55318. reflectionColor: Color3;
  55319. /**
  55320. * The color emitted from the material.
  55321. */
  55322. emissiveColor: Color3;
  55323. /**
  55324. * AKA Glossiness in other nomenclature.
  55325. */
  55326. microSurface: number;
  55327. /**
  55328. * Index of refraction of the material base layer.
  55329. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55330. *
  55331. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55332. *
  55333. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55334. */
  55335. get indexOfRefraction(): number;
  55336. set indexOfRefraction(value: number);
  55337. /**
  55338. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55339. */
  55340. get invertRefractionY(): boolean;
  55341. set invertRefractionY(value: boolean);
  55342. /**
  55343. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55344. * Materials half opaque for instance using refraction could benefit from this control.
  55345. */
  55346. get linkRefractionWithTransparency(): boolean;
  55347. set linkRefractionWithTransparency(value: boolean);
  55348. /**
  55349. * If true, the light map contains occlusion information instead of lighting info.
  55350. */
  55351. useLightmapAsShadowmap: boolean;
  55352. /**
  55353. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55354. */
  55355. useAlphaFromAlbedoTexture: boolean;
  55356. /**
  55357. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55358. */
  55359. forceAlphaTest: boolean;
  55360. /**
  55361. * Defines the alpha limits in alpha test mode.
  55362. */
  55363. alphaCutOff: number;
  55364. /**
  55365. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55366. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55367. */
  55368. useSpecularOverAlpha: boolean;
  55369. /**
  55370. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55371. */
  55372. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55373. /**
  55374. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55375. */
  55376. useRoughnessFromMetallicTextureAlpha: boolean;
  55377. /**
  55378. * Specifies if the metallic texture contains the roughness information in its green channel.
  55379. */
  55380. useRoughnessFromMetallicTextureGreen: boolean;
  55381. /**
  55382. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55383. */
  55384. useMetallnessFromMetallicTextureBlue: boolean;
  55385. /**
  55386. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55387. */
  55388. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55389. /**
  55390. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55391. */
  55392. useAmbientInGrayScale: boolean;
  55393. /**
  55394. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55395. * The material will try to infer what glossiness each pixel should be.
  55396. */
  55397. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55398. /**
  55399. * BJS is using an harcoded light falloff based on a manually sets up range.
  55400. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55401. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55402. */
  55403. get usePhysicalLightFalloff(): boolean;
  55404. /**
  55405. * BJS is using an harcoded light falloff based on a manually sets up range.
  55406. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55407. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55408. */
  55409. set usePhysicalLightFalloff(value: boolean);
  55410. /**
  55411. * In order to support the falloff compatibility with gltf, a special mode has been added
  55412. * to reproduce the gltf light falloff.
  55413. */
  55414. get useGLTFLightFalloff(): boolean;
  55415. /**
  55416. * In order to support the falloff compatibility with gltf, a special mode has been added
  55417. * to reproduce the gltf light falloff.
  55418. */
  55419. set useGLTFLightFalloff(value: boolean);
  55420. /**
  55421. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55422. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55423. */
  55424. useRadianceOverAlpha: boolean;
  55425. /**
  55426. * Allows using an object space normal map (instead of tangent space).
  55427. */
  55428. useObjectSpaceNormalMap: boolean;
  55429. /**
  55430. * Allows using the bump map in parallax mode.
  55431. */
  55432. useParallax: boolean;
  55433. /**
  55434. * Allows using the bump map in parallax occlusion mode.
  55435. */
  55436. useParallaxOcclusion: boolean;
  55437. /**
  55438. * Controls the scale bias of the parallax mode.
  55439. */
  55440. parallaxScaleBias: number;
  55441. /**
  55442. * If sets to true, disables all the lights affecting the material.
  55443. */
  55444. disableLighting: boolean;
  55445. /**
  55446. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55447. */
  55448. forceIrradianceInFragment: boolean;
  55449. /**
  55450. * Number of Simultaneous lights allowed on the material.
  55451. */
  55452. maxSimultaneousLights: number;
  55453. /**
  55454. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55455. */
  55456. invertNormalMapX: boolean;
  55457. /**
  55458. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55459. */
  55460. invertNormalMapY: boolean;
  55461. /**
  55462. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55463. */
  55464. twoSidedLighting: boolean;
  55465. /**
  55466. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55467. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55468. */
  55469. useAlphaFresnel: boolean;
  55470. /**
  55471. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55472. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55473. */
  55474. useLinearAlphaFresnel: boolean;
  55475. /**
  55476. * Let user defines the brdf lookup texture used for IBL.
  55477. * A default 8bit version is embedded but you could point at :
  55478. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55479. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55480. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55481. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55482. */
  55483. environmentBRDFTexture: Nullable<BaseTexture>;
  55484. /**
  55485. * Force normal to face away from face.
  55486. */
  55487. forceNormalForward: boolean;
  55488. /**
  55489. * Enables specular anti aliasing in the PBR shader.
  55490. * It will both interacts on the Geometry for analytical and IBL lighting.
  55491. * It also prefilter the roughness map based on the bump values.
  55492. */
  55493. enableSpecularAntiAliasing: boolean;
  55494. /**
  55495. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55496. * makes the reflect vector face the model (under horizon).
  55497. */
  55498. useHorizonOcclusion: boolean;
  55499. /**
  55500. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55501. * too much the area relying on ambient texture to define their ambient occlusion.
  55502. */
  55503. useRadianceOcclusion: boolean;
  55504. /**
  55505. * If set to true, no lighting calculations will be applied.
  55506. */
  55507. unlit: boolean;
  55508. /**
  55509. * Gets the image processing configuration used either in this material.
  55510. */
  55511. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55512. /**
  55513. * Sets the Default image processing configuration used either in the this material.
  55514. *
  55515. * If sets to null, the scene one is in use.
  55516. */
  55517. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55518. /**
  55519. * Gets wether the color curves effect is enabled.
  55520. */
  55521. get cameraColorCurvesEnabled(): boolean;
  55522. /**
  55523. * Sets wether the color curves effect is enabled.
  55524. */
  55525. set cameraColorCurvesEnabled(value: boolean);
  55526. /**
  55527. * Gets wether the color grading effect is enabled.
  55528. */
  55529. get cameraColorGradingEnabled(): boolean;
  55530. /**
  55531. * Gets wether the color grading effect is enabled.
  55532. */
  55533. set cameraColorGradingEnabled(value: boolean);
  55534. /**
  55535. * Gets wether tonemapping is enabled or not.
  55536. */
  55537. get cameraToneMappingEnabled(): boolean;
  55538. /**
  55539. * Sets wether tonemapping is enabled or not
  55540. */
  55541. set cameraToneMappingEnabled(value: boolean);
  55542. /**
  55543. * The camera exposure used on this material.
  55544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55545. * This corresponds to a photographic exposure.
  55546. */
  55547. get cameraExposure(): number;
  55548. /**
  55549. * The camera exposure used on this material.
  55550. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55551. * This corresponds to a photographic exposure.
  55552. */
  55553. set cameraExposure(value: number);
  55554. /**
  55555. * Gets The camera contrast used on this material.
  55556. */
  55557. get cameraContrast(): number;
  55558. /**
  55559. * Sets The camera contrast used on this material.
  55560. */
  55561. set cameraContrast(value: number);
  55562. /**
  55563. * Gets the Color Grading 2D Lookup Texture.
  55564. */
  55565. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55566. /**
  55567. * Sets the Color Grading 2D Lookup Texture.
  55568. */
  55569. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55570. /**
  55571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55573. * 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;
  55574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55575. */
  55576. get cameraColorCurves(): Nullable<ColorCurves>;
  55577. /**
  55578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55580. * 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;
  55581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55582. */
  55583. set cameraColorCurves(value: Nullable<ColorCurves>);
  55584. /**
  55585. * Instantiates a new PBRMaterial instance.
  55586. *
  55587. * @param name The material name
  55588. * @param scene The scene the material will be use in.
  55589. */
  55590. constructor(name: string, scene: Scene);
  55591. /**
  55592. * Returns the name of this material class.
  55593. */
  55594. getClassName(): string;
  55595. /**
  55596. * Makes a duplicate of the current material.
  55597. * @param name - name to use for the new material.
  55598. */
  55599. clone(name: string): PBRMaterial;
  55600. /**
  55601. * Serializes this PBR Material.
  55602. * @returns - An object with the serialized material.
  55603. */
  55604. serialize(): any;
  55605. /**
  55606. * Parses a PBR Material from a serialized object.
  55607. * @param source - Serialized object.
  55608. * @param scene - BJS scene instance.
  55609. * @param rootUrl - url for the scene object
  55610. * @returns - PBRMaterial
  55611. */
  55612. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55613. }
  55614. }
  55615. declare module BABYLON {
  55616. /**
  55617. * Direct draw surface info
  55618. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55619. */
  55620. export interface DDSInfo {
  55621. /**
  55622. * Width of the texture
  55623. */
  55624. width: number;
  55625. /**
  55626. * Width of the texture
  55627. */
  55628. height: number;
  55629. /**
  55630. * Number of Mipmaps for the texture
  55631. * @see https://en.wikipedia.org/wiki/Mipmap
  55632. */
  55633. mipmapCount: number;
  55634. /**
  55635. * If the textures format is a known fourCC format
  55636. * @see https://www.fourcc.org/
  55637. */
  55638. isFourCC: boolean;
  55639. /**
  55640. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55641. */
  55642. isRGB: boolean;
  55643. /**
  55644. * If the texture is a lumincance format
  55645. */
  55646. isLuminance: boolean;
  55647. /**
  55648. * If this is a cube texture
  55649. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55650. */
  55651. isCube: boolean;
  55652. /**
  55653. * If the texture is a compressed format eg. FOURCC_DXT1
  55654. */
  55655. isCompressed: boolean;
  55656. /**
  55657. * The dxgiFormat of the texture
  55658. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55659. */
  55660. dxgiFormat: number;
  55661. /**
  55662. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55663. */
  55664. textureType: number;
  55665. /**
  55666. * Sphericle polynomial created for the dds texture
  55667. */
  55668. sphericalPolynomial?: SphericalPolynomial;
  55669. }
  55670. /**
  55671. * Class used to provide DDS decompression tools
  55672. */
  55673. export class DDSTools {
  55674. /**
  55675. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55676. */
  55677. static StoreLODInAlphaChannel: boolean;
  55678. /**
  55679. * Gets DDS information from an array buffer
  55680. * @param data defines the array buffer view to read data from
  55681. * @returns the DDS information
  55682. */
  55683. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55684. private static _FloatView;
  55685. private static _Int32View;
  55686. private static _ToHalfFloat;
  55687. private static _FromHalfFloat;
  55688. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55689. private static _GetHalfFloatRGBAArrayBuffer;
  55690. private static _GetFloatRGBAArrayBuffer;
  55691. private static _GetFloatAsUIntRGBAArrayBuffer;
  55692. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55693. private static _GetRGBAArrayBuffer;
  55694. private static _ExtractLongWordOrder;
  55695. private static _GetRGBArrayBuffer;
  55696. private static _GetLuminanceArrayBuffer;
  55697. /**
  55698. * Uploads DDS Levels to a Babylon Texture
  55699. * @hidden
  55700. */
  55701. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55702. }
  55703. interface ThinEngine {
  55704. /**
  55705. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55706. * @param rootUrl defines the url where the file to load is located
  55707. * @param scene defines the current scene
  55708. * @param lodScale defines scale to apply to the mip map selection
  55709. * @param lodOffset defines offset to apply to the mip map selection
  55710. * @param onLoad defines an optional callback raised when the texture is loaded
  55711. * @param onError defines an optional callback raised if there is an issue to load the texture
  55712. * @param format defines the format of the data
  55713. * @param forcedExtension defines the extension to use to pick the right loader
  55714. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55715. * @returns the cube texture as an InternalTexture
  55716. */
  55717. 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;
  55718. }
  55719. }
  55720. declare module BABYLON {
  55721. /**
  55722. * Implementation of the DDS Texture Loader.
  55723. * @hidden
  55724. */
  55725. export class _DDSTextureLoader implements IInternalTextureLoader {
  55726. /**
  55727. * Defines wether the loader supports cascade loading the different faces.
  55728. */
  55729. readonly supportCascades: boolean;
  55730. /**
  55731. * This returns if the loader support the current file information.
  55732. * @param extension defines the file extension of the file being loaded
  55733. * @returns true if the loader can load the specified file
  55734. */
  55735. canLoad(extension: string): boolean;
  55736. /**
  55737. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55738. * @param data contains the texture data
  55739. * @param texture defines the BabylonJS internal texture
  55740. * @param createPolynomials will be true if polynomials have been requested
  55741. * @param onLoad defines the callback to trigger once the texture is ready
  55742. * @param onError defines the callback to trigger in case of error
  55743. */
  55744. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55745. /**
  55746. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55747. * @param data contains the texture data
  55748. * @param texture defines the BabylonJS internal texture
  55749. * @param callback defines the method to call once ready to upload
  55750. */
  55751. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55752. }
  55753. }
  55754. declare module BABYLON {
  55755. /**
  55756. * Implementation of the ENV Texture Loader.
  55757. * @hidden
  55758. */
  55759. export class _ENVTextureLoader implements IInternalTextureLoader {
  55760. /**
  55761. * Defines wether the loader supports cascade loading the different faces.
  55762. */
  55763. readonly supportCascades: boolean;
  55764. /**
  55765. * This returns if the loader support the current file information.
  55766. * @param extension defines the file extension of the file being loaded
  55767. * @returns true if the loader can load the specified file
  55768. */
  55769. canLoad(extension: string): boolean;
  55770. /**
  55771. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55772. * @param data contains the texture data
  55773. * @param texture defines the BabylonJS internal texture
  55774. * @param createPolynomials will be true if polynomials have been requested
  55775. * @param onLoad defines the callback to trigger once the texture is ready
  55776. * @param onError defines the callback to trigger in case of error
  55777. */
  55778. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55779. /**
  55780. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55781. * @param data contains the texture data
  55782. * @param texture defines the BabylonJS internal texture
  55783. * @param callback defines the method to call once ready to upload
  55784. */
  55785. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55786. }
  55787. }
  55788. declare module BABYLON {
  55789. /**
  55790. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55791. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55792. */
  55793. export class KhronosTextureContainer {
  55794. /** contents of the KTX container file */
  55795. data: ArrayBufferView;
  55796. private static HEADER_LEN;
  55797. private static COMPRESSED_2D;
  55798. private static COMPRESSED_3D;
  55799. private static TEX_2D;
  55800. private static TEX_3D;
  55801. /**
  55802. * Gets the openGL type
  55803. */
  55804. glType: number;
  55805. /**
  55806. * Gets the openGL type size
  55807. */
  55808. glTypeSize: number;
  55809. /**
  55810. * Gets the openGL format
  55811. */
  55812. glFormat: number;
  55813. /**
  55814. * Gets the openGL internal format
  55815. */
  55816. glInternalFormat: number;
  55817. /**
  55818. * Gets the base internal format
  55819. */
  55820. glBaseInternalFormat: number;
  55821. /**
  55822. * Gets image width in pixel
  55823. */
  55824. pixelWidth: number;
  55825. /**
  55826. * Gets image height in pixel
  55827. */
  55828. pixelHeight: number;
  55829. /**
  55830. * Gets image depth in pixels
  55831. */
  55832. pixelDepth: number;
  55833. /**
  55834. * Gets the number of array elements
  55835. */
  55836. numberOfArrayElements: number;
  55837. /**
  55838. * Gets the number of faces
  55839. */
  55840. numberOfFaces: number;
  55841. /**
  55842. * Gets the number of mipmap levels
  55843. */
  55844. numberOfMipmapLevels: number;
  55845. /**
  55846. * Gets the bytes of key value data
  55847. */
  55848. bytesOfKeyValueData: number;
  55849. /**
  55850. * Gets the load type
  55851. */
  55852. loadType: number;
  55853. /**
  55854. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55855. */
  55856. isInvalid: boolean;
  55857. /**
  55858. * Creates a new KhronosTextureContainer
  55859. * @param data contents of the KTX container file
  55860. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55861. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55862. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55863. */
  55864. constructor(
  55865. /** contents of the KTX container file */
  55866. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55867. /**
  55868. * Uploads KTX content to a Babylon Texture.
  55869. * It is assumed that the texture has already been created & is currently bound
  55870. * @hidden
  55871. */
  55872. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55873. private _upload2DCompressedLevels;
  55874. /**
  55875. * Checks if the given data starts with a KTX file identifier.
  55876. * @param data the data to check
  55877. * @returns true if the data is a KTX file or false otherwise
  55878. */
  55879. static IsValid(data: ArrayBufferView): boolean;
  55880. }
  55881. }
  55882. declare module BABYLON {
  55883. /**
  55884. * Class for loading KTX2 files
  55885. * !!! Experimental Extension Subject to Changes !!!
  55886. * @hidden
  55887. */
  55888. export class KhronosTextureContainer2 {
  55889. private static _ModulePromise;
  55890. private static _TranscodeFormat;
  55891. constructor(engine: ThinEngine);
  55892. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55893. private _determineTranscodeFormat;
  55894. /**
  55895. * Checks if the given data starts with a KTX2 file identifier.
  55896. * @param data the data to check
  55897. * @returns true if the data is a KTX2 file or false otherwise
  55898. */
  55899. static IsValid(data: ArrayBufferView): boolean;
  55900. }
  55901. }
  55902. declare module BABYLON {
  55903. /**
  55904. * Implementation of the KTX Texture Loader.
  55905. * @hidden
  55906. */
  55907. export class _KTXTextureLoader implements IInternalTextureLoader {
  55908. /**
  55909. * Defines wether the loader supports cascade loading the different faces.
  55910. */
  55911. readonly supportCascades: boolean;
  55912. /**
  55913. * This returns if the loader support the current file information.
  55914. * @param extension defines the file extension of the file being loaded
  55915. * @returns true if the loader can load the specified file
  55916. */
  55917. canLoad(extension: string): boolean;
  55918. /**
  55919. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55920. * @param data contains the texture data
  55921. * @param texture defines the BabylonJS internal texture
  55922. * @param createPolynomials will be true if polynomials have been requested
  55923. * @param onLoad defines the callback to trigger once the texture is ready
  55924. * @param onError defines the callback to trigger in case of error
  55925. */
  55926. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55927. /**
  55928. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55929. * @param data contains the texture data
  55930. * @param texture defines the BabylonJS internal texture
  55931. * @param callback defines the method to call once ready to upload
  55932. */
  55933. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55934. }
  55935. }
  55936. declare module BABYLON {
  55937. /** @hidden */
  55938. export var _forceSceneHelpersToBundle: boolean;
  55939. interface Scene {
  55940. /**
  55941. * Creates a default light for the scene.
  55942. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55943. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55944. */
  55945. createDefaultLight(replace?: boolean): void;
  55946. /**
  55947. * Creates a default camera for the scene.
  55948. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55949. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55950. * @param replace has default false, when true replaces the active camera in the scene
  55951. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55952. */
  55953. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55954. /**
  55955. * Creates a default camera and a default light.
  55956. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55957. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55958. * @param replace has the default false, when true replaces the active camera/light in the scene
  55959. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55960. */
  55961. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55962. /**
  55963. * Creates a new sky box
  55964. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55965. * @param environmentTexture defines the texture to use as environment texture
  55966. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55967. * @param scale defines the overall scale of the skybox
  55968. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55969. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55970. * @returns a new mesh holding the sky box
  55971. */
  55972. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55973. /**
  55974. * Creates a new environment
  55975. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55976. * @param options defines the options you can use to configure the environment
  55977. * @returns the new EnvironmentHelper
  55978. */
  55979. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55980. /**
  55981. * Creates a new VREXperienceHelper
  55982. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55983. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55984. * @returns a new VREXperienceHelper
  55985. */
  55986. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55987. /**
  55988. * Creates a new WebXRDefaultExperience
  55989. * @see http://doc.babylonjs.com/how_to/webxr
  55990. * @param options experience options
  55991. * @returns a promise for a new WebXRDefaultExperience
  55992. */
  55993. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55994. }
  55995. }
  55996. declare module BABYLON {
  55997. /**
  55998. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55999. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56000. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56001. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56002. */
  56003. export class VideoDome extends TransformNode {
  56004. /**
  56005. * Define the video source as a Monoscopic panoramic 360 video.
  56006. */
  56007. static readonly MODE_MONOSCOPIC: number;
  56008. /**
  56009. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56010. */
  56011. static readonly MODE_TOPBOTTOM: number;
  56012. /**
  56013. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56014. */
  56015. static readonly MODE_SIDEBYSIDE: number;
  56016. private _halfDome;
  56017. private _useDirectMapping;
  56018. /**
  56019. * The video texture being displayed on the sphere
  56020. */
  56021. protected _videoTexture: VideoTexture;
  56022. /**
  56023. * Gets the video texture being displayed on the sphere
  56024. */
  56025. get videoTexture(): VideoTexture;
  56026. /**
  56027. * The skybox material
  56028. */
  56029. protected _material: BackgroundMaterial;
  56030. /**
  56031. * The surface used for the skybox
  56032. */
  56033. protected _mesh: Mesh;
  56034. /**
  56035. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56036. */
  56037. private _halfDomeMask;
  56038. /**
  56039. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56040. * Also see the options.resolution property.
  56041. */
  56042. get fovMultiplier(): number;
  56043. set fovMultiplier(value: number);
  56044. private _videoMode;
  56045. /**
  56046. * Gets or set the current video mode for the video. It can be:
  56047. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56048. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56049. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56050. */
  56051. get videoMode(): number;
  56052. set videoMode(value: number);
  56053. /**
  56054. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56055. *
  56056. */
  56057. get halfDome(): boolean;
  56058. /**
  56059. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56060. */
  56061. set halfDome(enabled: boolean);
  56062. /**
  56063. * Oberserver used in Stereoscopic VR Mode.
  56064. */
  56065. private _onBeforeCameraRenderObserver;
  56066. /**
  56067. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56068. * @param name Element's name, child elements will append suffixes for their own names.
  56069. * @param urlsOrVideo defines the url(s) or the video element to use
  56070. * @param options An object containing optional or exposed sub element properties
  56071. */
  56072. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56073. resolution?: number;
  56074. clickToPlay?: boolean;
  56075. autoPlay?: boolean;
  56076. loop?: boolean;
  56077. size?: number;
  56078. poster?: string;
  56079. faceForward?: boolean;
  56080. useDirectMapping?: boolean;
  56081. halfDomeMode?: boolean;
  56082. }, scene: Scene);
  56083. private _changeVideoMode;
  56084. /**
  56085. * Releases resources associated with this node.
  56086. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56087. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56088. */
  56089. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56090. }
  56091. }
  56092. declare module BABYLON {
  56093. /**
  56094. * This class can be used to get instrumentation data from a Babylon engine
  56095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56096. */
  56097. export class EngineInstrumentation implements IDisposable {
  56098. /**
  56099. * Define the instrumented engine.
  56100. */
  56101. engine: Engine;
  56102. private _captureGPUFrameTime;
  56103. private _gpuFrameTimeToken;
  56104. private _gpuFrameTime;
  56105. private _captureShaderCompilationTime;
  56106. private _shaderCompilationTime;
  56107. private _onBeginFrameObserver;
  56108. private _onEndFrameObserver;
  56109. private _onBeforeShaderCompilationObserver;
  56110. private _onAfterShaderCompilationObserver;
  56111. /**
  56112. * Gets the perf counter used for GPU frame time
  56113. */
  56114. get gpuFrameTimeCounter(): PerfCounter;
  56115. /**
  56116. * Gets the GPU frame time capture status
  56117. */
  56118. get captureGPUFrameTime(): boolean;
  56119. /**
  56120. * Enable or disable the GPU frame time capture
  56121. */
  56122. set captureGPUFrameTime(value: boolean);
  56123. /**
  56124. * Gets the perf counter used for shader compilation time
  56125. */
  56126. get shaderCompilationTimeCounter(): PerfCounter;
  56127. /**
  56128. * Gets the shader compilation time capture status
  56129. */
  56130. get captureShaderCompilationTime(): boolean;
  56131. /**
  56132. * Enable or disable the shader compilation time capture
  56133. */
  56134. set captureShaderCompilationTime(value: boolean);
  56135. /**
  56136. * Instantiates a new engine instrumentation.
  56137. * This class can be used to get instrumentation data from a Babylon engine
  56138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56139. * @param engine Defines the engine to instrument
  56140. */
  56141. constructor(
  56142. /**
  56143. * Define the instrumented engine.
  56144. */
  56145. engine: Engine);
  56146. /**
  56147. * Dispose and release associated resources.
  56148. */
  56149. dispose(): void;
  56150. }
  56151. }
  56152. declare module BABYLON {
  56153. /**
  56154. * This class can be used to get instrumentation data from a Babylon engine
  56155. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56156. */
  56157. export class SceneInstrumentation implements IDisposable {
  56158. /**
  56159. * Defines the scene to instrument
  56160. */
  56161. scene: Scene;
  56162. private _captureActiveMeshesEvaluationTime;
  56163. private _activeMeshesEvaluationTime;
  56164. private _captureRenderTargetsRenderTime;
  56165. private _renderTargetsRenderTime;
  56166. private _captureFrameTime;
  56167. private _frameTime;
  56168. private _captureRenderTime;
  56169. private _renderTime;
  56170. private _captureInterFrameTime;
  56171. private _interFrameTime;
  56172. private _captureParticlesRenderTime;
  56173. private _particlesRenderTime;
  56174. private _captureSpritesRenderTime;
  56175. private _spritesRenderTime;
  56176. private _capturePhysicsTime;
  56177. private _physicsTime;
  56178. private _captureAnimationsTime;
  56179. private _animationsTime;
  56180. private _captureCameraRenderTime;
  56181. private _cameraRenderTime;
  56182. private _onBeforeActiveMeshesEvaluationObserver;
  56183. private _onAfterActiveMeshesEvaluationObserver;
  56184. private _onBeforeRenderTargetsRenderObserver;
  56185. private _onAfterRenderTargetsRenderObserver;
  56186. private _onAfterRenderObserver;
  56187. private _onBeforeDrawPhaseObserver;
  56188. private _onAfterDrawPhaseObserver;
  56189. private _onBeforeAnimationsObserver;
  56190. private _onBeforeParticlesRenderingObserver;
  56191. private _onAfterParticlesRenderingObserver;
  56192. private _onBeforeSpritesRenderingObserver;
  56193. private _onAfterSpritesRenderingObserver;
  56194. private _onBeforePhysicsObserver;
  56195. private _onAfterPhysicsObserver;
  56196. private _onAfterAnimationsObserver;
  56197. private _onBeforeCameraRenderObserver;
  56198. private _onAfterCameraRenderObserver;
  56199. /**
  56200. * Gets the perf counter used for active meshes evaluation time
  56201. */
  56202. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56203. /**
  56204. * Gets the active meshes evaluation time capture status
  56205. */
  56206. get captureActiveMeshesEvaluationTime(): boolean;
  56207. /**
  56208. * Enable or disable the active meshes evaluation time capture
  56209. */
  56210. set captureActiveMeshesEvaluationTime(value: boolean);
  56211. /**
  56212. * Gets the perf counter used for render targets render time
  56213. */
  56214. get renderTargetsRenderTimeCounter(): PerfCounter;
  56215. /**
  56216. * Gets the render targets render time capture status
  56217. */
  56218. get captureRenderTargetsRenderTime(): boolean;
  56219. /**
  56220. * Enable or disable the render targets render time capture
  56221. */
  56222. set captureRenderTargetsRenderTime(value: boolean);
  56223. /**
  56224. * Gets the perf counter used for particles render time
  56225. */
  56226. get particlesRenderTimeCounter(): PerfCounter;
  56227. /**
  56228. * Gets the particles render time capture status
  56229. */
  56230. get captureParticlesRenderTime(): boolean;
  56231. /**
  56232. * Enable or disable the particles render time capture
  56233. */
  56234. set captureParticlesRenderTime(value: boolean);
  56235. /**
  56236. * Gets the perf counter used for sprites render time
  56237. */
  56238. get spritesRenderTimeCounter(): PerfCounter;
  56239. /**
  56240. * Gets the sprites render time capture status
  56241. */
  56242. get captureSpritesRenderTime(): boolean;
  56243. /**
  56244. * Enable or disable the sprites render time capture
  56245. */
  56246. set captureSpritesRenderTime(value: boolean);
  56247. /**
  56248. * Gets the perf counter used for physics time
  56249. */
  56250. get physicsTimeCounter(): PerfCounter;
  56251. /**
  56252. * Gets the physics time capture status
  56253. */
  56254. get capturePhysicsTime(): boolean;
  56255. /**
  56256. * Enable or disable the physics time capture
  56257. */
  56258. set capturePhysicsTime(value: boolean);
  56259. /**
  56260. * Gets the perf counter used for animations time
  56261. */
  56262. get animationsTimeCounter(): PerfCounter;
  56263. /**
  56264. * Gets the animations time capture status
  56265. */
  56266. get captureAnimationsTime(): boolean;
  56267. /**
  56268. * Enable or disable the animations time capture
  56269. */
  56270. set captureAnimationsTime(value: boolean);
  56271. /**
  56272. * Gets the perf counter used for frame time capture
  56273. */
  56274. get frameTimeCounter(): PerfCounter;
  56275. /**
  56276. * Gets the frame time capture status
  56277. */
  56278. get captureFrameTime(): boolean;
  56279. /**
  56280. * Enable or disable the frame time capture
  56281. */
  56282. set captureFrameTime(value: boolean);
  56283. /**
  56284. * Gets the perf counter used for inter-frames time capture
  56285. */
  56286. get interFrameTimeCounter(): PerfCounter;
  56287. /**
  56288. * Gets the inter-frames time capture status
  56289. */
  56290. get captureInterFrameTime(): boolean;
  56291. /**
  56292. * Enable or disable the inter-frames time capture
  56293. */
  56294. set captureInterFrameTime(value: boolean);
  56295. /**
  56296. * Gets the perf counter used for render time capture
  56297. */
  56298. get renderTimeCounter(): PerfCounter;
  56299. /**
  56300. * Gets the render time capture status
  56301. */
  56302. get captureRenderTime(): boolean;
  56303. /**
  56304. * Enable or disable the render time capture
  56305. */
  56306. set captureRenderTime(value: boolean);
  56307. /**
  56308. * Gets the perf counter used for camera render time capture
  56309. */
  56310. get cameraRenderTimeCounter(): PerfCounter;
  56311. /**
  56312. * Gets the camera render time capture status
  56313. */
  56314. get captureCameraRenderTime(): boolean;
  56315. /**
  56316. * Enable or disable the camera render time capture
  56317. */
  56318. set captureCameraRenderTime(value: boolean);
  56319. /**
  56320. * Gets the perf counter used for draw calls
  56321. */
  56322. get drawCallsCounter(): PerfCounter;
  56323. /**
  56324. * Instantiates a new scene instrumentation.
  56325. * This class can be used to get instrumentation data from a Babylon engine
  56326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56327. * @param scene Defines the scene to instrument
  56328. */
  56329. constructor(
  56330. /**
  56331. * Defines the scene to instrument
  56332. */
  56333. scene: Scene);
  56334. /**
  56335. * Dispose and release associated resources.
  56336. */
  56337. dispose(): void;
  56338. }
  56339. }
  56340. declare module BABYLON {
  56341. /** @hidden */
  56342. export var glowMapGenerationPixelShader: {
  56343. name: string;
  56344. shader: string;
  56345. };
  56346. }
  56347. declare module BABYLON {
  56348. /** @hidden */
  56349. export var glowMapGenerationVertexShader: {
  56350. name: string;
  56351. shader: string;
  56352. };
  56353. }
  56354. declare module BABYLON {
  56355. /**
  56356. * Effect layer options. This helps customizing the behaviour
  56357. * of the effect layer.
  56358. */
  56359. export interface IEffectLayerOptions {
  56360. /**
  56361. * Multiplication factor apply to the canvas size to compute the render target size
  56362. * used to generated the objects (the smaller the faster).
  56363. */
  56364. mainTextureRatio: number;
  56365. /**
  56366. * Enforces a fixed size texture to ensure effect stability across devices.
  56367. */
  56368. mainTextureFixedSize?: number;
  56369. /**
  56370. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56371. */
  56372. alphaBlendingMode: number;
  56373. /**
  56374. * The camera attached to the layer.
  56375. */
  56376. camera: Nullable<Camera>;
  56377. /**
  56378. * The rendering group to draw the layer in.
  56379. */
  56380. renderingGroupId: number;
  56381. }
  56382. /**
  56383. * The effect layer Helps adding post process effect blended with the main pass.
  56384. *
  56385. * This can be for instance use to generate glow or higlight effects on the scene.
  56386. *
  56387. * The effect layer class can not be used directly and is intented to inherited from to be
  56388. * customized per effects.
  56389. */
  56390. export abstract class EffectLayer {
  56391. private _vertexBuffers;
  56392. private _indexBuffer;
  56393. private _cachedDefines;
  56394. private _effectLayerMapGenerationEffect;
  56395. private _effectLayerOptions;
  56396. private _mergeEffect;
  56397. protected _scene: Scene;
  56398. protected _engine: Engine;
  56399. protected _maxSize: number;
  56400. protected _mainTextureDesiredSize: ISize;
  56401. protected _mainTexture: RenderTargetTexture;
  56402. protected _shouldRender: boolean;
  56403. protected _postProcesses: PostProcess[];
  56404. protected _textures: BaseTexture[];
  56405. protected _emissiveTextureAndColor: {
  56406. texture: Nullable<BaseTexture>;
  56407. color: Color4;
  56408. };
  56409. /**
  56410. * The name of the layer
  56411. */
  56412. name: string;
  56413. /**
  56414. * The clear color of the texture used to generate the glow map.
  56415. */
  56416. neutralColor: Color4;
  56417. /**
  56418. * Specifies whether the highlight layer is enabled or not.
  56419. */
  56420. isEnabled: boolean;
  56421. /**
  56422. * Gets the camera attached to the layer.
  56423. */
  56424. get camera(): Nullable<Camera>;
  56425. /**
  56426. * Gets the rendering group id the layer should render in.
  56427. */
  56428. get renderingGroupId(): number;
  56429. set renderingGroupId(renderingGroupId: number);
  56430. /**
  56431. * An event triggered when the effect layer has been disposed.
  56432. */
  56433. onDisposeObservable: Observable<EffectLayer>;
  56434. /**
  56435. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56436. */
  56437. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56438. /**
  56439. * An event triggered when the generated texture is being merged in the scene.
  56440. */
  56441. onBeforeComposeObservable: Observable<EffectLayer>;
  56442. /**
  56443. * An event triggered when the mesh is rendered into the effect render target.
  56444. */
  56445. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56446. /**
  56447. * An event triggered after the mesh has been rendered into the effect render target.
  56448. */
  56449. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56450. /**
  56451. * An event triggered when the generated texture has been merged in the scene.
  56452. */
  56453. onAfterComposeObservable: Observable<EffectLayer>;
  56454. /**
  56455. * An event triggered when the efffect layer changes its size.
  56456. */
  56457. onSizeChangedObservable: Observable<EffectLayer>;
  56458. /** @hidden */
  56459. static _SceneComponentInitialization: (scene: Scene) => void;
  56460. /**
  56461. * Instantiates a new effect Layer and references it in the scene.
  56462. * @param name The name of the layer
  56463. * @param scene The scene to use the layer in
  56464. */
  56465. constructor(
  56466. /** The Friendly of the effect in the scene */
  56467. name: string, scene: Scene);
  56468. /**
  56469. * Get the effect name of the layer.
  56470. * @return The effect name
  56471. */
  56472. abstract getEffectName(): string;
  56473. /**
  56474. * Checks for the readiness of the element composing the layer.
  56475. * @param subMesh the mesh to check for
  56476. * @param useInstances specify whether or not to use instances to render the mesh
  56477. * @return true if ready otherwise, false
  56478. */
  56479. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56480. /**
  56481. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56482. * @returns true if the effect requires stencil during the main canvas render pass.
  56483. */
  56484. abstract needStencil(): boolean;
  56485. /**
  56486. * Create the merge effect. This is the shader use to blit the information back
  56487. * to the main canvas at the end of the scene rendering.
  56488. * @returns The effect containing the shader used to merge the effect on the main canvas
  56489. */
  56490. protected abstract _createMergeEffect(): Effect;
  56491. /**
  56492. * Creates the render target textures and post processes used in the effect layer.
  56493. */
  56494. protected abstract _createTextureAndPostProcesses(): void;
  56495. /**
  56496. * Implementation specific of rendering the generating effect on the main canvas.
  56497. * @param effect The effect used to render through
  56498. */
  56499. protected abstract _internalRender(effect: Effect): void;
  56500. /**
  56501. * Sets the required values for both the emissive texture and and the main color.
  56502. */
  56503. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56504. /**
  56505. * Free any resources and references associated to a mesh.
  56506. * Internal use
  56507. * @param mesh The mesh to free.
  56508. */
  56509. abstract _disposeMesh(mesh: Mesh): void;
  56510. /**
  56511. * Serializes this layer (Glow or Highlight for example)
  56512. * @returns a serialized layer object
  56513. */
  56514. abstract serialize?(): any;
  56515. /**
  56516. * Initializes the effect layer with the required options.
  56517. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56518. */
  56519. protected _init(options: Partial<IEffectLayerOptions>): void;
  56520. /**
  56521. * Generates the index buffer of the full screen quad blending to the main canvas.
  56522. */
  56523. private _generateIndexBuffer;
  56524. /**
  56525. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56526. */
  56527. private _generateVertexBuffer;
  56528. /**
  56529. * Sets the main texture desired size which is the closest power of two
  56530. * of the engine canvas size.
  56531. */
  56532. private _setMainTextureSize;
  56533. /**
  56534. * Creates the main texture for the effect layer.
  56535. */
  56536. protected _createMainTexture(): void;
  56537. /**
  56538. * Adds specific effects defines.
  56539. * @param defines The defines to add specifics to.
  56540. */
  56541. protected _addCustomEffectDefines(defines: string[]): void;
  56542. /**
  56543. * Checks for the readiness of the element composing the layer.
  56544. * @param subMesh the mesh to check for
  56545. * @param useInstances specify whether or not to use instances to render the mesh
  56546. * @param emissiveTexture the associated emissive texture used to generate the glow
  56547. * @return true if ready otherwise, false
  56548. */
  56549. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56550. /**
  56551. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56552. */
  56553. render(): void;
  56554. /**
  56555. * Determine if a given mesh will be used in the current effect.
  56556. * @param mesh mesh to test
  56557. * @returns true if the mesh will be used
  56558. */
  56559. hasMesh(mesh: AbstractMesh): boolean;
  56560. /**
  56561. * Returns true if the layer contains information to display, otherwise false.
  56562. * @returns true if the glow layer should be rendered
  56563. */
  56564. shouldRender(): boolean;
  56565. /**
  56566. * Returns true if the mesh should render, otherwise false.
  56567. * @param mesh The mesh to render
  56568. * @returns true if it should render otherwise false
  56569. */
  56570. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56571. /**
  56572. * Returns true if the mesh can be rendered, otherwise false.
  56573. * @param mesh The mesh to render
  56574. * @param material The material used on the mesh
  56575. * @returns true if it can be rendered otherwise false
  56576. */
  56577. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56578. /**
  56579. * Returns true if the mesh should render, otherwise false.
  56580. * @param mesh The mesh to render
  56581. * @returns true if it should render otherwise false
  56582. */
  56583. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56584. /**
  56585. * Renders the submesh passed in parameter to the generation map.
  56586. */
  56587. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56588. /**
  56589. * Defines whether the current material of the mesh should be use to render the effect.
  56590. * @param mesh defines the current mesh to render
  56591. */
  56592. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56593. /**
  56594. * Rebuild the required buffers.
  56595. * @hidden Internal use only.
  56596. */
  56597. _rebuild(): void;
  56598. /**
  56599. * Dispose only the render target textures and post process.
  56600. */
  56601. private _disposeTextureAndPostProcesses;
  56602. /**
  56603. * Dispose the highlight layer and free resources.
  56604. */
  56605. dispose(): void;
  56606. /**
  56607. * Gets the class name of the effect layer
  56608. * @returns the string with the class name of the effect layer
  56609. */
  56610. getClassName(): string;
  56611. /**
  56612. * Creates an effect layer from parsed effect layer data
  56613. * @param parsedEffectLayer defines effect layer data
  56614. * @param scene defines the current scene
  56615. * @param rootUrl defines the root URL containing the effect layer information
  56616. * @returns a parsed effect Layer
  56617. */
  56618. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56619. }
  56620. }
  56621. declare module BABYLON {
  56622. interface AbstractScene {
  56623. /**
  56624. * The list of effect layers (highlights/glow) added to the scene
  56625. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56626. * @see http://doc.babylonjs.com/how_to/glow_layer
  56627. */
  56628. effectLayers: Array<EffectLayer>;
  56629. /**
  56630. * Removes the given effect layer from this scene.
  56631. * @param toRemove defines the effect layer to remove
  56632. * @returns the index of the removed effect layer
  56633. */
  56634. removeEffectLayer(toRemove: EffectLayer): number;
  56635. /**
  56636. * Adds the given effect layer to this scene
  56637. * @param newEffectLayer defines the effect layer to add
  56638. */
  56639. addEffectLayer(newEffectLayer: EffectLayer): void;
  56640. }
  56641. /**
  56642. * Defines the layer scene component responsible to manage any effect layers
  56643. * in a given scene.
  56644. */
  56645. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56646. /**
  56647. * The component name helpfull to identify the component in the list of scene components.
  56648. */
  56649. readonly name: string;
  56650. /**
  56651. * The scene the component belongs to.
  56652. */
  56653. scene: Scene;
  56654. private _engine;
  56655. private _renderEffects;
  56656. private _needStencil;
  56657. private _previousStencilState;
  56658. /**
  56659. * Creates a new instance of the component for the given scene
  56660. * @param scene Defines the scene to register the component in
  56661. */
  56662. constructor(scene: Scene);
  56663. /**
  56664. * Registers the component in a given scene
  56665. */
  56666. register(): void;
  56667. /**
  56668. * Rebuilds the elements related to this component in case of
  56669. * context lost for instance.
  56670. */
  56671. rebuild(): void;
  56672. /**
  56673. * Serializes the component data to the specified json object
  56674. * @param serializationObject The object to serialize to
  56675. */
  56676. serialize(serializationObject: any): void;
  56677. /**
  56678. * Adds all the elements from the container to the scene
  56679. * @param container the container holding the elements
  56680. */
  56681. addFromContainer(container: AbstractScene): void;
  56682. /**
  56683. * Removes all the elements in the container from the scene
  56684. * @param container contains the elements to remove
  56685. * @param dispose if the removed element should be disposed (default: false)
  56686. */
  56687. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56688. /**
  56689. * Disposes the component and the associated ressources.
  56690. */
  56691. dispose(): void;
  56692. private _isReadyForMesh;
  56693. private _renderMainTexture;
  56694. private _setStencil;
  56695. private _setStencilBack;
  56696. private _draw;
  56697. private _drawCamera;
  56698. private _drawRenderingGroup;
  56699. }
  56700. }
  56701. declare module BABYLON {
  56702. /** @hidden */
  56703. export var glowMapMergePixelShader: {
  56704. name: string;
  56705. shader: string;
  56706. };
  56707. }
  56708. declare module BABYLON {
  56709. /** @hidden */
  56710. export var glowMapMergeVertexShader: {
  56711. name: string;
  56712. shader: string;
  56713. };
  56714. }
  56715. declare module BABYLON {
  56716. interface AbstractScene {
  56717. /**
  56718. * Return a the first highlight layer of the scene with a given name.
  56719. * @param name The name of the highlight layer to look for.
  56720. * @return The highlight layer if found otherwise null.
  56721. */
  56722. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56723. }
  56724. /**
  56725. * Glow layer options. This helps customizing the behaviour
  56726. * of the glow layer.
  56727. */
  56728. export interface IGlowLayerOptions {
  56729. /**
  56730. * Multiplication factor apply to the canvas size to compute the render target size
  56731. * used to generated the glowing objects (the smaller the faster).
  56732. */
  56733. mainTextureRatio: number;
  56734. /**
  56735. * Enforces a fixed size texture to ensure resize independant blur.
  56736. */
  56737. mainTextureFixedSize?: number;
  56738. /**
  56739. * How big is the kernel of the blur texture.
  56740. */
  56741. blurKernelSize: number;
  56742. /**
  56743. * The camera attached to the layer.
  56744. */
  56745. camera: Nullable<Camera>;
  56746. /**
  56747. * Enable MSAA by chosing the number of samples.
  56748. */
  56749. mainTextureSamples?: number;
  56750. /**
  56751. * The rendering group to draw the layer in.
  56752. */
  56753. renderingGroupId: number;
  56754. }
  56755. /**
  56756. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56757. *
  56758. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56759. *
  56760. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56761. */
  56762. export class GlowLayer extends EffectLayer {
  56763. /**
  56764. * Effect Name of the layer.
  56765. */
  56766. static readonly EffectName: string;
  56767. /**
  56768. * The default blur kernel size used for the glow.
  56769. */
  56770. static DefaultBlurKernelSize: number;
  56771. /**
  56772. * The default texture size ratio used for the glow.
  56773. */
  56774. static DefaultTextureRatio: number;
  56775. /**
  56776. * Sets the kernel size of the blur.
  56777. */
  56778. set blurKernelSize(value: number);
  56779. /**
  56780. * Gets the kernel size of the blur.
  56781. */
  56782. get blurKernelSize(): number;
  56783. /**
  56784. * Sets the glow intensity.
  56785. */
  56786. set intensity(value: number);
  56787. /**
  56788. * Gets the glow intensity.
  56789. */
  56790. get intensity(): number;
  56791. private _options;
  56792. private _intensity;
  56793. private _horizontalBlurPostprocess1;
  56794. private _verticalBlurPostprocess1;
  56795. private _horizontalBlurPostprocess2;
  56796. private _verticalBlurPostprocess2;
  56797. private _blurTexture1;
  56798. private _blurTexture2;
  56799. private _postProcesses1;
  56800. private _postProcesses2;
  56801. private _includedOnlyMeshes;
  56802. private _excludedMeshes;
  56803. private _meshesUsingTheirOwnMaterials;
  56804. /**
  56805. * Callback used to let the user override the color selection on a per mesh basis
  56806. */
  56807. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56808. /**
  56809. * Callback used to let the user override the texture selection on a per mesh basis
  56810. */
  56811. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56812. /**
  56813. * Instantiates a new glow Layer and references it to the scene.
  56814. * @param name The name of the layer
  56815. * @param scene The scene to use the layer in
  56816. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56817. */
  56818. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56819. /**
  56820. * Get the effect name of the layer.
  56821. * @return The effect name
  56822. */
  56823. getEffectName(): string;
  56824. /**
  56825. * Create the merge effect. This is the shader use to blit the information back
  56826. * to the main canvas at the end of the scene rendering.
  56827. */
  56828. protected _createMergeEffect(): Effect;
  56829. /**
  56830. * Creates the render target textures and post processes used in the glow layer.
  56831. */
  56832. protected _createTextureAndPostProcesses(): void;
  56833. /**
  56834. * Checks for the readiness of the element composing the layer.
  56835. * @param subMesh the mesh to check for
  56836. * @param useInstances specify wether or not to use instances to render the mesh
  56837. * @param emissiveTexture the associated emissive texture used to generate the glow
  56838. * @return true if ready otherwise, false
  56839. */
  56840. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56841. /**
  56842. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56843. */
  56844. needStencil(): boolean;
  56845. /**
  56846. * Returns true if the mesh can be rendered, otherwise false.
  56847. * @param mesh The mesh to render
  56848. * @param material The material used on the mesh
  56849. * @returns true if it can be rendered otherwise false
  56850. */
  56851. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56852. /**
  56853. * Implementation specific of rendering the generating effect on the main canvas.
  56854. * @param effect The effect used to render through
  56855. */
  56856. protected _internalRender(effect: Effect): void;
  56857. /**
  56858. * Sets the required values for both the emissive texture and and the main color.
  56859. */
  56860. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56861. /**
  56862. * Returns true if the mesh should render, otherwise false.
  56863. * @param mesh The mesh to render
  56864. * @returns true if it should render otherwise false
  56865. */
  56866. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56867. /**
  56868. * Adds specific effects defines.
  56869. * @param defines The defines to add specifics to.
  56870. */
  56871. protected _addCustomEffectDefines(defines: string[]): void;
  56872. /**
  56873. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56874. * @param mesh The mesh to exclude from the glow layer
  56875. */
  56876. addExcludedMesh(mesh: Mesh): void;
  56877. /**
  56878. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56879. * @param mesh The mesh to remove
  56880. */
  56881. removeExcludedMesh(mesh: Mesh): void;
  56882. /**
  56883. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56884. * @param mesh The mesh to include in the glow layer
  56885. */
  56886. addIncludedOnlyMesh(mesh: Mesh): void;
  56887. /**
  56888. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56889. * @param mesh The mesh to remove
  56890. */
  56891. removeIncludedOnlyMesh(mesh: Mesh): void;
  56892. /**
  56893. * Determine if a given mesh will be used in the glow layer
  56894. * @param mesh The mesh to test
  56895. * @returns true if the mesh will be highlighted by the current glow layer
  56896. */
  56897. hasMesh(mesh: AbstractMesh): boolean;
  56898. /**
  56899. * Defines whether the current material of the mesh should be use to render the effect.
  56900. * @param mesh defines the current mesh to render
  56901. */
  56902. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56903. /**
  56904. * Add a mesh to be rendered through its own material and not with emissive only.
  56905. * @param mesh The mesh for which we need to use its material
  56906. */
  56907. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56908. /**
  56909. * Remove a mesh from being rendered through its own material and not with emissive only.
  56910. * @param mesh The mesh for which we need to not use its material
  56911. */
  56912. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56913. /**
  56914. * Free any resources and references associated to a mesh.
  56915. * Internal use
  56916. * @param mesh The mesh to free.
  56917. * @hidden
  56918. */
  56919. _disposeMesh(mesh: Mesh): void;
  56920. /**
  56921. * Gets the class name of the effect layer
  56922. * @returns the string with the class name of the effect layer
  56923. */
  56924. getClassName(): string;
  56925. /**
  56926. * Serializes this glow layer
  56927. * @returns a serialized glow layer object
  56928. */
  56929. serialize(): any;
  56930. /**
  56931. * Creates a Glow Layer from parsed glow layer data
  56932. * @param parsedGlowLayer defines glow layer data
  56933. * @param scene defines the current scene
  56934. * @param rootUrl defines the root URL containing the glow layer information
  56935. * @returns a parsed Glow Layer
  56936. */
  56937. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56938. }
  56939. }
  56940. declare module BABYLON {
  56941. /** @hidden */
  56942. export var glowBlurPostProcessPixelShader: {
  56943. name: string;
  56944. shader: string;
  56945. };
  56946. }
  56947. declare module BABYLON {
  56948. interface AbstractScene {
  56949. /**
  56950. * Return a the first highlight layer of the scene with a given name.
  56951. * @param name The name of the highlight layer to look for.
  56952. * @return The highlight layer if found otherwise null.
  56953. */
  56954. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56955. }
  56956. /**
  56957. * Highlight layer options. This helps customizing the behaviour
  56958. * of the highlight layer.
  56959. */
  56960. export interface IHighlightLayerOptions {
  56961. /**
  56962. * Multiplication factor apply to the canvas size to compute the render target size
  56963. * used to generated the glowing objects (the smaller the faster).
  56964. */
  56965. mainTextureRatio: number;
  56966. /**
  56967. * Enforces a fixed size texture to ensure resize independant blur.
  56968. */
  56969. mainTextureFixedSize?: number;
  56970. /**
  56971. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56972. * of the picture to blur (the smaller the faster).
  56973. */
  56974. blurTextureSizeRatio: number;
  56975. /**
  56976. * How big in texel of the blur texture is the vertical blur.
  56977. */
  56978. blurVerticalSize: number;
  56979. /**
  56980. * How big in texel of the blur texture is the horizontal blur.
  56981. */
  56982. blurHorizontalSize: number;
  56983. /**
  56984. * Alpha blending mode used to apply the blur. Default is combine.
  56985. */
  56986. alphaBlendingMode: number;
  56987. /**
  56988. * The camera attached to the layer.
  56989. */
  56990. camera: Nullable<Camera>;
  56991. /**
  56992. * Should we display highlight as a solid stroke?
  56993. */
  56994. isStroke?: boolean;
  56995. /**
  56996. * The rendering group to draw the layer in.
  56997. */
  56998. renderingGroupId: number;
  56999. }
  57000. /**
  57001. * The highlight layer Helps adding a glow effect around a mesh.
  57002. *
  57003. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57004. * glowy meshes to your scene.
  57005. *
  57006. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57007. */
  57008. export class HighlightLayer extends EffectLayer {
  57009. name: string;
  57010. /**
  57011. * Effect Name of the highlight layer.
  57012. */
  57013. static readonly EffectName: string;
  57014. /**
  57015. * The neutral color used during the preparation of the glow effect.
  57016. * This is black by default as the blend operation is a blend operation.
  57017. */
  57018. static NeutralColor: Color4;
  57019. /**
  57020. * Stencil value used for glowing meshes.
  57021. */
  57022. static GlowingMeshStencilReference: number;
  57023. /**
  57024. * Stencil value used for the other meshes in the scene.
  57025. */
  57026. static NormalMeshStencilReference: number;
  57027. /**
  57028. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57029. */
  57030. innerGlow: boolean;
  57031. /**
  57032. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57033. */
  57034. outerGlow: boolean;
  57035. /**
  57036. * Specifies the horizontal size of the blur.
  57037. */
  57038. set blurHorizontalSize(value: number);
  57039. /**
  57040. * Specifies the vertical size of the blur.
  57041. */
  57042. set blurVerticalSize(value: number);
  57043. /**
  57044. * Gets the horizontal size of the blur.
  57045. */
  57046. get blurHorizontalSize(): number;
  57047. /**
  57048. * Gets the vertical size of the blur.
  57049. */
  57050. get blurVerticalSize(): number;
  57051. /**
  57052. * An event triggered when the highlight layer is being blurred.
  57053. */
  57054. onBeforeBlurObservable: Observable<HighlightLayer>;
  57055. /**
  57056. * An event triggered when the highlight layer has been blurred.
  57057. */
  57058. onAfterBlurObservable: Observable<HighlightLayer>;
  57059. private _instanceGlowingMeshStencilReference;
  57060. private _options;
  57061. private _downSamplePostprocess;
  57062. private _horizontalBlurPostprocess;
  57063. private _verticalBlurPostprocess;
  57064. private _blurTexture;
  57065. private _meshes;
  57066. private _excludedMeshes;
  57067. /**
  57068. * Instantiates a new highlight Layer and references it to the scene..
  57069. * @param name The name of the layer
  57070. * @param scene The scene to use the layer in
  57071. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57072. */
  57073. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57074. /**
  57075. * Get the effect name of the layer.
  57076. * @return The effect name
  57077. */
  57078. getEffectName(): string;
  57079. /**
  57080. * Create the merge effect. This is the shader use to blit the information back
  57081. * to the main canvas at the end of the scene rendering.
  57082. */
  57083. protected _createMergeEffect(): Effect;
  57084. /**
  57085. * Creates the render target textures and post processes used in the highlight layer.
  57086. */
  57087. protected _createTextureAndPostProcesses(): void;
  57088. /**
  57089. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57090. */
  57091. needStencil(): boolean;
  57092. /**
  57093. * Checks for the readiness of the element composing the layer.
  57094. * @param subMesh the mesh to check for
  57095. * @param useInstances specify wether or not to use instances to render the mesh
  57096. * @param emissiveTexture the associated emissive texture used to generate the glow
  57097. * @return true if ready otherwise, false
  57098. */
  57099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57100. /**
  57101. * Implementation specific of rendering the generating effect on the main canvas.
  57102. * @param effect The effect used to render through
  57103. */
  57104. protected _internalRender(effect: Effect): void;
  57105. /**
  57106. * Returns true if the layer contains information to display, otherwise false.
  57107. */
  57108. shouldRender(): boolean;
  57109. /**
  57110. * Returns true if the mesh should render, otherwise false.
  57111. * @param mesh The mesh to render
  57112. * @returns true if it should render otherwise false
  57113. */
  57114. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57115. /**
  57116. * Adds specific effects defines.
  57117. * @param defines The defines to add specifics to.
  57118. */
  57119. protected _addCustomEffectDefines(defines: string[]): void;
  57120. /**
  57121. * Sets the required values for both the emissive texture and and the main color.
  57122. */
  57123. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57124. /**
  57125. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57126. * @param mesh The mesh to exclude from the highlight layer
  57127. */
  57128. addExcludedMesh(mesh: Mesh): void;
  57129. /**
  57130. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57131. * @param mesh The mesh to highlight
  57132. */
  57133. removeExcludedMesh(mesh: Mesh): void;
  57134. /**
  57135. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57136. * @param mesh mesh to test
  57137. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57138. */
  57139. hasMesh(mesh: AbstractMesh): boolean;
  57140. /**
  57141. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57142. * @param mesh The mesh to highlight
  57143. * @param color The color of the highlight
  57144. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57145. */
  57146. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57147. /**
  57148. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57149. * @param mesh The mesh to highlight
  57150. */
  57151. removeMesh(mesh: Mesh): void;
  57152. /**
  57153. * Remove all the meshes currently referenced in the highlight layer
  57154. */
  57155. removeAllMeshes(): void;
  57156. /**
  57157. * Force the stencil to the normal expected value for none glowing parts
  57158. */
  57159. private _defaultStencilReference;
  57160. /**
  57161. * Free any resources and references associated to a mesh.
  57162. * Internal use
  57163. * @param mesh The mesh to free.
  57164. * @hidden
  57165. */
  57166. _disposeMesh(mesh: Mesh): void;
  57167. /**
  57168. * Dispose the highlight layer and free resources.
  57169. */
  57170. dispose(): void;
  57171. /**
  57172. * Gets the class name of the effect layer
  57173. * @returns the string with the class name of the effect layer
  57174. */
  57175. getClassName(): string;
  57176. /**
  57177. * Serializes this Highlight layer
  57178. * @returns a serialized Highlight layer object
  57179. */
  57180. serialize(): any;
  57181. /**
  57182. * Creates a Highlight layer from parsed Highlight layer data
  57183. * @param parsedHightlightLayer defines the Highlight layer data
  57184. * @param scene defines the current scene
  57185. * @param rootUrl defines the root URL containing the Highlight layer information
  57186. * @returns a parsed Highlight layer
  57187. */
  57188. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57189. }
  57190. }
  57191. declare module BABYLON {
  57192. interface AbstractScene {
  57193. /**
  57194. * The list of layers (background and foreground) of the scene
  57195. */
  57196. layers: Array<Layer>;
  57197. }
  57198. /**
  57199. * Defines the layer scene component responsible to manage any layers
  57200. * in a given scene.
  57201. */
  57202. export class LayerSceneComponent implements ISceneComponent {
  57203. /**
  57204. * The component name helpfull to identify the component in the list of scene components.
  57205. */
  57206. readonly name: string;
  57207. /**
  57208. * The scene the component belongs to.
  57209. */
  57210. scene: Scene;
  57211. private _engine;
  57212. /**
  57213. * Creates a new instance of the component for the given scene
  57214. * @param scene Defines the scene to register the component in
  57215. */
  57216. constructor(scene: Scene);
  57217. /**
  57218. * Registers the component in a given scene
  57219. */
  57220. register(): void;
  57221. /**
  57222. * Rebuilds the elements related to this component in case of
  57223. * context lost for instance.
  57224. */
  57225. rebuild(): void;
  57226. /**
  57227. * Disposes the component and the associated ressources.
  57228. */
  57229. dispose(): void;
  57230. private _draw;
  57231. private _drawCameraPredicate;
  57232. private _drawCameraBackground;
  57233. private _drawCameraForeground;
  57234. private _drawRenderTargetPredicate;
  57235. private _drawRenderTargetBackground;
  57236. private _drawRenderTargetForeground;
  57237. /**
  57238. * Adds all the elements from the container to the scene
  57239. * @param container the container holding the elements
  57240. */
  57241. addFromContainer(container: AbstractScene): void;
  57242. /**
  57243. * Removes all the elements in the container from the scene
  57244. * @param container contains the elements to remove
  57245. * @param dispose if the removed element should be disposed (default: false)
  57246. */
  57247. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57248. }
  57249. }
  57250. declare module BABYLON {
  57251. /** @hidden */
  57252. export var layerPixelShader: {
  57253. name: string;
  57254. shader: string;
  57255. };
  57256. }
  57257. declare module BABYLON {
  57258. /** @hidden */
  57259. export var layerVertexShader: {
  57260. name: string;
  57261. shader: string;
  57262. };
  57263. }
  57264. declare module BABYLON {
  57265. /**
  57266. * This represents a full screen 2d layer.
  57267. * This can be useful to display a picture in the background of your scene for instance.
  57268. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57269. */
  57270. export class Layer {
  57271. /**
  57272. * Define the name of the layer.
  57273. */
  57274. name: string;
  57275. /**
  57276. * Define the texture the layer should display.
  57277. */
  57278. texture: Nullable<Texture>;
  57279. /**
  57280. * Is the layer in background or foreground.
  57281. */
  57282. isBackground: boolean;
  57283. /**
  57284. * Define the color of the layer (instead of texture).
  57285. */
  57286. color: Color4;
  57287. /**
  57288. * Define the scale of the layer in order to zoom in out of the texture.
  57289. */
  57290. scale: Vector2;
  57291. /**
  57292. * Define an offset for the layer in order to shift the texture.
  57293. */
  57294. offset: Vector2;
  57295. /**
  57296. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57297. */
  57298. alphaBlendingMode: number;
  57299. /**
  57300. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57301. * Alpha test will not mix with the background color in case of transparency.
  57302. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57303. */
  57304. alphaTest: boolean;
  57305. /**
  57306. * Define a mask to restrict the layer to only some of the scene cameras.
  57307. */
  57308. layerMask: number;
  57309. /**
  57310. * Define the list of render target the layer is visible into.
  57311. */
  57312. renderTargetTextures: RenderTargetTexture[];
  57313. /**
  57314. * Define if the layer is only used in renderTarget or if it also
  57315. * renders in the main frame buffer of the canvas.
  57316. */
  57317. renderOnlyInRenderTargetTextures: boolean;
  57318. private _scene;
  57319. private _vertexBuffers;
  57320. private _indexBuffer;
  57321. private _effect;
  57322. private _previousDefines;
  57323. /**
  57324. * An event triggered when the layer is disposed.
  57325. */
  57326. onDisposeObservable: Observable<Layer>;
  57327. private _onDisposeObserver;
  57328. /**
  57329. * Back compatibility with callback before the onDisposeObservable existed.
  57330. * The set callback will be triggered when the layer has been disposed.
  57331. */
  57332. set onDispose(callback: () => void);
  57333. /**
  57334. * An event triggered before rendering the scene
  57335. */
  57336. onBeforeRenderObservable: Observable<Layer>;
  57337. private _onBeforeRenderObserver;
  57338. /**
  57339. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57340. * The set callback will be triggered just before rendering the layer.
  57341. */
  57342. set onBeforeRender(callback: () => void);
  57343. /**
  57344. * An event triggered after rendering the scene
  57345. */
  57346. onAfterRenderObservable: Observable<Layer>;
  57347. private _onAfterRenderObserver;
  57348. /**
  57349. * Back compatibility with callback before the onAfterRenderObservable existed.
  57350. * The set callback will be triggered just after rendering the layer.
  57351. */
  57352. set onAfterRender(callback: () => void);
  57353. /**
  57354. * Instantiates a new layer.
  57355. * This represents a full screen 2d layer.
  57356. * This can be useful to display a picture in the background of your scene for instance.
  57357. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57358. * @param name Define the name of the layer in the scene
  57359. * @param imgUrl Define the url of the texture to display in the layer
  57360. * @param scene Define the scene the layer belongs to
  57361. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57362. * @param color Defines a color for the layer
  57363. */
  57364. constructor(
  57365. /**
  57366. * Define the name of the layer.
  57367. */
  57368. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57369. private _createIndexBuffer;
  57370. /** @hidden */
  57371. _rebuild(): void;
  57372. /**
  57373. * Renders the layer in the scene.
  57374. */
  57375. render(): void;
  57376. /**
  57377. * Disposes and releases the associated ressources.
  57378. */
  57379. dispose(): void;
  57380. }
  57381. }
  57382. declare module BABYLON {
  57383. /** @hidden */
  57384. export var lensFlarePixelShader: {
  57385. name: string;
  57386. shader: string;
  57387. };
  57388. }
  57389. declare module BABYLON {
  57390. /** @hidden */
  57391. export var lensFlareVertexShader: {
  57392. name: string;
  57393. shader: string;
  57394. };
  57395. }
  57396. declare module BABYLON {
  57397. /**
  57398. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57399. * It is usually composed of several `lensFlare`.
  57400. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57401. */
  57402. export class LensFlareSystem {
  57403. /**
  57404. * Define the name of the lens flare system
  57405. */
  57406. name: string;
  57407. /**
  57408. * List of lens flares used in this system.
  57409. */
  57410. lensFlares: LensFlare[];
  57411. /**
  57412. * Define a limit from the border the lens flare can be visible.
  57413. */
  57414. borderLimit: number;
  57415. /**
  57416. * Define a viewport border we do not want to see the lens flare in.
  57417. */
  57418. viewportBorder: number;
  57419. /**
  57420. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57421. */
  57422. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57423. /**
  57424. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57425. */
  57426. layerMask: number;
  57427. /**
  57428. * Define the id of the lens flare system in the scene.
  57429. * (equal to name by default)
  57430. */
  57431. id: string;
  57432. private _scene;
  57433. private _emitter;
  57434. private _vertexBuffers;
  57435. private _indexBuffer;
  57436. private _effect;
  57437. private _positionX;
  57438. private _positionY;
  57439. private _isEnabled;
  57440. /** @hidden */
  57441. static _SceneComponentInitialization: (scene: Scene) => void;
  57442. /**
  57443. * Instantiates a lens flare system.
  57444. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57445. * It is usually composed of several `lensFlare`.
  57446. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57447. * @param name Define the name of the lens flare system in the scene
  57448. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57449. * @param scene Define the scene the lens flare system belongs to
  57450. */
  57451. constructor(
  57452. /**
  57453. * Define the name of the lens flare system
  57454. */
  57455. name: string, emitter: any, scene: Scene);
  57456. /**
  57457. * Define if the lens flare system is enabled.
  57458. */
  57459. get isEnabled(): boolean;
  57460. set isEnabled(value: boolean);
  57461. /**
  57462. * Get the scene the effects belongs to.
  57463. * @returns the scene holding the lens flare system
  57464. */
  57465. getScene(): Scene;
  57466. /**
  57467. * Get the emitter of the lens flare system.
  57468. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57469. * @returns the emitter of the lens flare system
  57470. */
  57471. getEmitter(): any;
  57472. /**
  57473. * Set the emitter of the lens flare system.
  57474. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57475. * @param newEmitter Define the new emitter of the system
  57476. */
  57477. setEmitter(newEmitter: any): void;
  57478. /**
  57479. * Get the lens flare system emitter position.
  57480. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57481. * @returns the position
  57482. */
  57483. getEmitterPosition(): Vector3;
  57484. /**
  57485. * @hidden
  57486. */
  57487. computeEffectivePosition(globalViewport: Viewport): boolean;
  57488. /** @hidden */
  57489. _isVisible(): boolean;
  57490. /**
  57491. * @hidden
  57492. */
  57493. render(): boolean;
  57494. /**
  57495. * Dispose and release the lens flare with its associated resources.
  57496. */
  57497. dispose(): void;
  57498. /**
  57499. * Parse a lens flare system from a JSON repressentation
  57500. * @param parsedLensFlareSystem Define the JSON to parse
  57501. * @param scene Define the scene the parsed system should be instantiated in
  57502. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57503. * @returns the parsed system
  57504. */
  57505. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57506. /**
  57507. * Serialize the current Lens Flare System into a JSON representation.
  57508. * @returns the serialized JSON
  57509. */
  57510. serialize(): any;
  57511. }
  57512. }
  57513. declare module BABYLON {
  57514. /**
  57515. * This represents one of the lens effect in a `lensFlareSystem`.
  57516. * It controls one of the indiviual texture used in the effect.
  57517. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57518. */
  57519. export class LensFlare {
  57520. /**
  57521. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57522. */
  57523. size: number;
  57524. /**
  57525. * 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.
  57526. */
  57527. position: number;
  57528. /**
  57529. * Define the lens color.
  57530. */
  57531. color: Color3;
  57532. /**
  57533. * Define the lens texture.
  57534. */
  57535. texture: Nullable<Texture>;
  57536. /**
  57537. * Define the alpha mode to render this particular lens.
  57538. */
  57539. alphaMode: number;
  57540. private _system;
  57541. /**
  57542. * Creates a new Lens Flare.
  57543. * This represents one of the lens effect in a `lensFlareSystem`.
  57544. * It controls one of the indiviual texture used in the effect.
  57545. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57546. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57547. * @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.
  57548. * @param color Define the lens color
  57549. * @param imgUrl Define the lens texture url
  57550. * @param system Define the `lensFlareSystem` this flare is part of
  57551. * @returns The newly created Lens Flare
  57552. */
  57553. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57554. /**
  57555. * Instantiates a new Lens Flare.
  57556. * This represents one of the lens effect in a `lensFlareSystem`.
  57557. * It controls one of the indiviual texture used in the effect.
  57558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57559. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57560. * @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.
  57561. * @param color Define the lens color
  57562. * @param imgUrl Define the lens texture url
  57563. * @param system Define the `lensFlareSystem` this flare is part of
  57564. */
  57565. constructor(
  57566. /**
  57567. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57568. */
  57569. size: number,
  57570. /**
  57571. * 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.
  57572. */
  57573. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57574. /**
  57575. * Dispose and release the lens flare with its associated resources.
  57576. */
  57577. dispose(): void;
  57578. }
  57579. }
  57580. declare module BABYLON {
  57581. interface AbstractScene {
  57582. /**
  57583. * The list of lens flare system added to the scene
  57584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57585. */
  57586. lensFlareSystems: Array<LensFlareSystem>;
  57587. /**
  57588. * Removes the given lens flare system from this scene.
  57589. * @param toRemove The lens flare system to remove
  57590. * @returns The index of the removed lens flare system
  57591. */
  57592. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57593. /**
  57594. * Adds the given lens flare system to this scene
  57595. * @param newLensFlareSystem The lens flare system to add
  57596. */
  57597. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57598. /**
  57599. * Gets a lens flare system using its name
  57600. * @param name defines the name to look for
  57601. * @returns the lens flare system or null if not found
  57602. */
  57603. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57604. /**
  57605. * Gets a lens flare system using its id
  57606. * @param id defines the id to look for
  57607. * @returns the lens flare system or null if not found
  57608. */
  57609. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57610. }
  57611. /**
  57612. * Defines the lens flare scene component responsible to manage any lens flares
  57613. * in a given scene.
  57614. */
  57615. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57616. /**
  57617. * The component name helpfull to identify the component in the list of scene components.
  57618. */
  57619. readonly name: string;
  57620. /**
  57621. * The scene the component belongs to.
  57622. */
  57623. scene: Scene;
  57624. /**
  57625. * Creates a new instance of the component for the given scene
  57626. * @param scene Defines the scene to register the component in
  57627. */
  57628. constructor(scene: Scene);
  57629. /**
  57630. * Registers the component in a given scene
  57631. */
  57632. register(): void;
  57633. /**
  57634. * Rebuilds the elements related to this component in case of
  57635. * context lost for instance.
  57636. */
  57637. rebuild(): void;
  57638. /**
  57639. * Adds all the elements from the container to the scene
  57640. * @param container the container holding the elements
  57641. */
  57642. addFromContainer(container: AbstractScene): void;
  57643. /**
  57644. * Removes all the elements in the container from the scene
  57645. * @param container contains the elements to remove
  57646. * @param dispose if the removed element should be disposed (default: false)
  57647. */
  57648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57649. /**
  57650. * Serializes the component data to the specified json object
  57651. * @param serializationObject The object to serialize to
  57652. */
  57653. serialize(serializationObject: any): void;
  57654. /**
  57655. * Disposes the component and the associated ressources.
  57656. */
  57657. dispose(): void;
  57658. private _draw;
  57659. }
  57660. }
  57661. declare module BABYLON {
  57662. /** @hidden */
  57663. export var depthPixelShader: {
  57664. name: string;
  57665. shader: string;
  57666. };
  57667. }
  57668. declare module BABYLON {
  57669. /** @hidden */
  57670. export var depthVertexShader: {
  57671. name: string;
  57672. shader: string;
  57673. };
  57674. }
  57675. declare module BABYLON {
  57676. /**
  57677. * This represents a depth renderer in Babylon.
  57678. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57679. */
  57680. export class DepthRenderer {
  57681. private _scene;
  57682. private _depthMap;
  57683. private _effect;
  57684. private readonly _storeNonLinearDepth;
  57685. private readonly _clearColor;
  57686. /** Get if the depth renderer is using packed depth or not */
  57687. readonly isPacked: boolean;
  57688. private _cachedDefines;
  57689. private _camera;
  57690. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57691. enabled: boolean;
  57692. /**
  57693. * Specifiess that the depth renderer will only be used within
  57694. * the camera it is created for.
  57695. * This can help forcing its rendering during the camera processing.
  57696. */
  57697. useOnlyInActiveCamera: boolean;
  57698. /** @hidden */
  57699. static _SceneComponentInitialization: (scene: Scene) => void;
  57700. /**
  57701. * Instantiates a depth renderer
  57702. * @param scene The scene the renderer belongs to
  57703. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57704. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57705. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57706. */
  57707. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57708. /**
  57709. * Creates the depth rendering effect and checks if the effect is ready.
  57710. * @param subMesh The submesh to be used to render the depth map of
  57711. * @param useInstances If multiple world instances should be used
  57712. * @returns if the depth renderer is ready to render the depth map
  57713. */
  57714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57715. /**
  57716. * Gets the texture which the depth map will be written to.
  57717. * @returns The depth map texture
  57718. */
  57719. getDepthMap(): RenderTargetTexture;
  57720. /**
  57721. * Disposes of the depth renderer.
  57722. */
  57723. dispose(): void;
  57724. }
  57725. }
  57726. declare module BABYLON {
  57727. /** @hidden */
  57728. export var minmaxReduxPixelShader: {
  57729. name: string;
  57730. shader: string;
  57731. };
  57732. }
  57733. declare module BABYLON {
  57734. /**
  57735. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57736. * and maximum values from all values of the texture.
  57737. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57738. * The source values are read from the red channel of the texture.
  57739. */
  57740. export class MinMaxReducer {
  57741. /**
  57742. * Observable triggered when the computation has been performed
  57743. */
  57744. onAfterReductionPerformed: Observable<{
  57745. min: number;
  57746. max: number;
  57747. }>;
  57748. protected _camera: Camera;
  57749. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57750. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57751. protected _postProcessManager: PostProcessManager;
  57752. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57753. protected _forceFullscreenViewport: boolean;
  57754. /**
  57755. * Creates a min/max reducer
  57756. * @param camera The camera to use for the post processes
  57757. */
  57758. constructor(camera: Camera);
  57759. /**
  57760. * Gets the texture used to read the values from.
  57761. */
  57762. get sourceTexture(): Nullable<RenderTargetTexture>;
  57763. /**
  57764. * Sets the source texture to read the values from.
  57765. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57766. * because in such textures '1' value must not be taken into account to compute the maximum
  57767. * as this value is used to clear the texture.
  57768. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57769. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57770. * @param depthRedux Indicates if the texture is a depth texture or not
  57771. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57772. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57773. */
  57774. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57775. /**
  57776. * Defines the refresh rate of the computation.
  57777. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57778. */
  57779. get refreshRate(): number;
  57780. set refreshRate(value: number);
  57781. protected _activated: boolean;
  57782. /**
  57783. * Gets the activation status of the reducer
  57784. */
  57785. get activated(): boolean;
  57786. /**
  57787. * Activates the reduction computation.
  57788. * When activated, the observers registered in onAfterReductionPerformed are
  57789. * called after the compuation is performed
  57790. */
  57791. activate(): void;
  57792. /**
  57793. * Deactivates the reduction computation.
  57794. */
  57795. deactivate(): void;
  57796. /**
  57797. * Disposes the min/max reducer
  57798. * @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.
  57799. */
  57800. dispose(disposeAll?: boolean): void;
  57801. }
  57802. }
  57803. declare module BABYLON {
  57804. /**
  57805. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57806. */
  57807. export class DepthReducer extends MinMaxReducer {
  57808. private _depthRenderer;
  57809. private _depthRendererId;
  57810. /**
  57811. * Gets the depth renderer used for the computation.
  57812. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57813. */
  57814. get depthRenderer(): Nullable<DepthRenderer>;
  57815. /**
  57816. * Creates a depth reducer
  57817. * @param camera The camera used to render the depth texture
  57818. */
  57819. constructor(camera: Camera);
  57820. /**
  57821. * Sets the depth renderer to use to generate the depth map
  57822. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57823. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57824. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57825. */
  57826. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57827. /** @hidden */
  57828. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57829. /**
  57830. * Activates the reduction computation.
  57831. * When activated, the observers registered in onAfterReductionPerformed are
  57832. * called after the compuation is performed
  57833. */
  57834. activate(): void;
  57835. /**
  57836. * Deactivates the reduction computation.
  57837. */
  57838. deactivate(): void;
  57839. /**
  57840. * Disposes the depth reducer
  57841. * @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.
  57842. */
  57843. dispose(disposeAll?: boolean): void;
  57844. }
  57845. }
  57846. declare module BABYLON {
  57847. /**
  57848. * A CSM implementation allowing casting shadows on large scenes.
  57849. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57850. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57851. */
  57852. export class CascadedShadowGenerator extends ShadowGenerator {
  57853. private static readonly frustumCornersNDCSpace;
  57854. /**
  57855. * Name of the CSM class
  57856. */
  57857. static CLASSNAME: string;
  57858. /**
  57859. * Defines the default number of cascades used by the CSM.
  57860. */
  57861. static readonly DEFAULT_CASCADES_COUNT: number;
  57862. /**
  57863. * Defines the minimum number of cascades used by the CSM.
  57864. */
  57865. static readonly MIN_CASCADES_COUNT: number;
  57866. /**
  57867. * Defines the maximum number of cascades used by the CSM.
  57868. */
  57869. static readonly MAX_CASCADES_COUNT: number;
  57870. protected _validateFilter(filter: number): number;
  57871. /**
  57872. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57873. */
  57874. penumbraDarkness: number;
  57875. private _numCascades;
  57876. /**
  57877. * Gets or set the number of cascades used by the CSM.
  57878. */
  57879. get numCascades(): number;
  57880. set numCascades(value: number);
  57881. /**
  57882. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57883. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57884. */
  57885. stabilizeCascades: boolean;
  57886. private _freezeShadowCastersBoundingInfo;
  57887. private _freezeShadowCastersBoundingInfoObservable;
  57888. /**
  57889. * Enables or disables the shadow casters bounding info computation.
  57890. * If your shadow casters don't move, you can disable this feature.
  57891. * If it is enabled, the bounding box computation is done every frame.
  57892. */
  57893. get freezeShadowCastersBoundingInfo(): boolean;
  57894. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57895. private _scbiMin;
  57896. private _scbiMax;
  57897. protected _computeShadowCastersBoundingInfo(): void;
  57898. protected _shadowCastersBoundingInfo: BoundingInfo;
  57899. /**
  57900. * Gets or sets the shadow casters bounding info.
  57901. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57902. * so that the system won't overwrite the bounds you provide
  57903. */
  57904. get shadowCastersBoundingInfo(): BoundingInfo;
  57905. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57906. protected _breaksAreDirty: boolean;
  57907. protected _minDistance: number;
  57908. protected _maxDistance: number;
  57909. /**
  57910. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57911. *
  57912. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57913. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57914. * @param min minimal distance for the breaks (default to 0.)
  57915. * @param max maximal distance for the breaks (default to 1.)
  57916. */
  57917. setMinMaxDistance(min: number, max: number): void;
  57918. /** Gets the minimal distance used in the cascade break computation */
  57919. get minDistance(): number;
  57920. /** Gets the maximal distance used in the cascade break computation */
  57921. get maxDistance(): number;
  57922. /**
  57923. * Gets the class name of that object
  57924. * @returns "CascadedShadowGenerator"
  57925. */
  57926. getClassName(): string;
  57927. private _cascadeMinExtents;
  57928. private _cascadeMaxExtents;
  57929. /**
  57930. * Gets a cascade minimum extents
  57931. * @param cascadeIndex index of the cascade
  57932. * @returns the minimum cascade extents
  57933. */
  57934. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57935. /**
  57936. * Gets a cascade maximum extents
  57937. * @param cascadeIndex index of the cascade
  57938. * @returns the maximum cascade extents
  57939. */
  57940. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57941. private _cascades;
  57942. private _currentLayer;
  57943. private _viewSpaceFrustumsZ;
  57944. private _viewMatrices;
  57945. private _projectionMatrices;
  57946. private _transformMatrices;
  57947. private _transformMatricesAsArray;
  57948. private _frustumLengths;
  57949. private _lightSizeUVCorrection;
  57950. private _depthCorrection;
  57951. private _frustumCornersWorldSpace;
  57952. private _frustumCenter;
  57953. private _shadowCameraPos;
  57954. private _shadowMaxZ;
  57955. /**
  57956. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57957. * It defaults to camera.maxZ
  57958. */
  57959. get shadowMaxZ(): number;
  57960. /**
  57961. * Sets the shadow max z distance.
  57962. */
  57963. set shadowMaxZ(value: number);
  57964. protected _debug: boolean;
  57965. /**
  57966. * Gets or sets the debug flag.
  57967. * When enabled, the cascades are materialized by different colors on the screen.
  57968. */
  57969. get debug(): boolean;
  57970. set debug(dbg: boolean);
  57971. private _depthClamp;
  57972. /**
  57973. * Gets or sets the depth clamping value.
  57974. *
  57975. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57976. * to account for the shadow casters far away.
  57977. *
  57978. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57979. */
  57980. get depthClamp(): boolean;
  57981. set depthClamp(value: boolean);
  57982. private _cascadeBlendPercentage;
  57983. /**
  57984. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57985. * It defaults to 0.1 (10% blending).
  57986. */
  57987. get cascadeBlendPercentage(): number;
  57988. set cascadeBlendPercentage(value: number);
  57989. private _lambda;
  57990. /**
  57991. * Gets or set the lambda parameter.
  57992. * This parameter is used to split the camera frustum and create the cascades.
  57993. * 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.
  57994. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57995. */
  57996. get lambda(): number;
  57997. set lambda(value: number);
  57998. /**
  57999. * Gets the view matrix corresponding to a given cascade
  58000. * @param cascadeNum cascade to retrieve the view matrix from
  58001. * @returns the cascade view matrix
  58002. */
  58003. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58004. /**
  58005. * Gets the projection matrix corresponding to a given cascade
  58006. * @param cascadeNum cascade to retrieve the projection matrix from
  58007. * @returns the cascade projection matrix
  58008. */
  58009. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58010. /**
  58011. * Gets the transformation matrix corresponding to a given cascade
  58012. * @param cascadeNum cascade to retrieve the transformation matrix from
  58013. * @returns the cascade transformation matrix
  58014. */
  58015. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58016. private _depthRenderer;
  58017. /**
  58018. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58019. *
  58020. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58021. *
  58022. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58023. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58024. * @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
  58025. */
  58026. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58027. private _depthReducer;
  58028. private _autoCalcDepthBounds;
  58029. /**
  58030. * Gets or sets the autoCalcDepthBounds property.
  58031. *
  58032. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58033. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58034. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58035. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58036. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58037. */
  58038. get autoCalcDepthBounds(): boolean;
  58039. set autoCalcDepthBounds(value: boolean);
  58040. /**
  58041. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58042. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58043. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58044. * for setting the refresh rate on the renderer yourself!
  58045. */
  58046. get autoCalcDepthBoundsRefreshRate(): number;
  58047. set autoCalcDepthBoundsRefreshRate(value: number);
  58048. /**
  58049. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58050. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58051. * you change the camera near/far planes!
  58052. */
  58053. splitFrustum(): void;
  58054. private _splitFrustum;
  58055. private _computeMatrices;
  58056. private _computeFrustumInWorldSpace;
  58057. private _computeCascadeFrustum;
  58058. /**
  58059. * Support test.
  58060. */
  58061. static get IsSupported(): boolean;
  58062. /** @hidden */
  58063. static _SceneComponentInitialization: (scene: Scene) => void;
  58064. /**
  58065. * Creates a Cascaded Shadow Generator object.
  58066. * A ShadowGenerator is the required tool to use the shadows.
  58067. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58068. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58069. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58070. * @param light The directional light object generating the shadows.
  58071. * @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.
  58072. */
  58073. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58074. protected _initializeGenerator(): void;
  58075. protected _createTargetRenderTexture(): void;
  58076. protected _initializeShadowMap(): void;
  58077. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58078. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58079. /**
  58080. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58081. * @param defines Defines of the material we want to update
  58082. * @param lightIndex Index of the light in the enabled light list of the material
  58083. */
  58084. prepareDefines(defines: any, lightIndex: number): void;
  58085. /**
  58086. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58087. * defined in the generator but impacting the effect).
  58088. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58089. * @param effect The effect we are binfing the information for
  58090. */
  58091. bindShadowLight(lightIndex: string, effect: Effect): void;
  58092. /**
  58093. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58094. * (eq to view projection * shadow projection matrices)
  58095. * @returns The transform matrix used to create the shadow map
  58096. */
  58097. getTransformMatrix(): Matrix;
  58098. /**
  58099. * Disposes the ShadowGenerator.
  58100. * Returns nothing.
  58101. */
  58102. dispose(): void;
  58103. /**
  58104. * Serializes the shadow generator setup to a json object.
  58105. * @returns The serialized JSON object
  58106. */
  58107. serialize(): any;
  58108. /**
  58109. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58110. * @param parsedShadowGenerator The JSON object to parse
  58111. * @param scene The scene to create the shadow map for
  58112. * @returns The parsed shadow generator
  58113. */
  58114. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58115. }
  58116. }
  58117. declare module BABYLON {
  58118. /**
  58119. * Defines the shadow generator component responsible to manage any shadow generators
  58120. * in a given scene.
  58121. */
  58122. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58123. /**
  58124. * The component name helpfull to identify the component in the list of scene components.
  58125. */
  58126. readonly name: string;
  58127. /**
  58128. * The scene the component belongs to.
  58129. */
  58130. scene: Scene;
  58131. /**
  58132. * Creates a new instance of the component for the given scene
  58133. * @param scene Defines the scene to register the component in
  58134. */
  58135. constructor(scene: Scene);
  58136. /**
  58137. * Registers the component in a given scene
  58138. */
  58139. register(): void;
  58140. /**
  58141. * Rebuilds the elements related to this component in case of
  58142. * context lost for instance.
  58143. */
  58144. rebuild(): void;
  58145. /**
  58146. * Serializes the component data to the specified json object
  58147. * @param serializationObject The object to serialize to
  58148. */
  58149. serialize(serializationObject: any): void;
  58150. /**
  58151. * Adds all the elements from the container to the scene
  58152. * @param container the container holding the elements
  58153. */
  58154. addFromContainer(container: AbstractScene): void;
  58155. /**
  58156. * Removes all the elements in the container from the scene
  58157. * @param container contains the elements to remove
  58158. * @param dispose if the removed element should be disposed (default: false)
  58159. */
  58160. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58161. /**
  58162. * Rebuilds the elements related to this component in case of
  58163. * context lost for instance.
  58164. */
  58165. dispose(): void;
  58166. private _gatherRenderTargets;
  58167. }
  58168. }
  58169. declare module BABYLON {
  58170. /**
  58171. * A point light is a light defined by an unique point in world space.
  58172. * The light is emitted in every direction from this point.
  58173. * A good example of a point light is a standard light bulb.
  58174. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58175. */
  58176. export class PointLight extends ShadowLight {
  58177. private _shadowAngle;
  58178. /**
  58179. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58180. * This specifies what angle the shadow will use to be created.
  58181. *
  58182. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58183. */
  58184. get shadowAngle(): number;
  58185. /**
  58186. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58187. * This specifies what angle the shadow will use to be created.
  58188. *
  58189. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58190. */
  58191. set shadowAngle(value: number);
  58192. /**
  58193. * Gets the direction if it has been set.
  58194. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58195. */
  58196. get direction(): Vector3;
  58197. /**
  58198. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58199. */
  58200. set direction(value: Vector3);
  58201. /**
  58202. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58203. * A PointLight emits the light in every direction.
  58204. * It can cast shadows.
  58205. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58206. * ```javascript
  58207. * var pointLight = new PointLight("pl", camera.position, scene);
  58208. * ```
  58209. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58210. * @param name The light friendly name
  58211. * @param position The position of the point light in the scene
  58212. * @param scene The scene the lights belongs to
  58213. */
  58214. constructor(name: string, position: Vector3, scene: Scene);
  58215. /**
  58216. * Returns the string "PointLight"
  58217. * @returns the class name
  58218. */
  58219. getClassName(): string;
  58220. /**
  58221. * Returns the integer 0.
  58222. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58223. */
  58224. getTypeID(): number;
  58225. /**
  58226. * Specifies wether or not the shadowmap should be a cube texture.
  58227. * @returns true if the shadowmap needs to be a cube texture.
  58228. */
  58229. needCube(): boolean;
  58230. /**
  58231. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58232. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58233. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58234. */
  58235. getShadowDirection(faceIndex?: number): Vector3;
  58236. /**
  58237. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58238. * - fov = PI / 2
  58239. * - aspect ratio : 1.0
  58240. * - z-near and far equal to the active camera minZ and maxZ.
  58241. * Returns the PointLight.
  58242. */
  58243. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58244. protected _buildUniformLayout(): void;
  58245. /**
  58246. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58247. * @param effect The effect to update
  58248. * @param lightIndex The index of the light in the effect to update
  58249. * @returns The point light
  58250. */
  58251. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58252. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58253. /**
  58254. * Prepares the list of defines specific to the light type.
  58255. * @param defines the list of defines
  58256. * @param lightIndex defines the index of the light for the effect
  58257. */
  58258. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58259. }
  58260. }
  58261. declare module BABYLON {
  58262. /**
  58263. * Header information of HDR texture files.
  58264. */
  58265. export interface HDRInfo {
  58266. /**
  58267. * The height of the texture in pixels.
  58268. */
  58269. height: number;
  58270. /**
  58271. * The width of the texture in pixels.
  58272. */
  58273. width: number;
  58274. /**
  58275. * The index of the beginning of the data in the binary file.
  58276. */
  58277. dataPosition: number;
  58278. }
  58279. /**
  58280. * This groups tools to convert HDR texture to native colors array.
  58281. */
  58282. export class HDRTools {
  58283. private static Ldexp;
  58284. private static Rgbe2float;
  58285. private static readStringLine;
  58286. /**
  58287. * Reads header information from an RGBE texture stored in a native array.
  58288. * More information on this format are available here:
  58289. * https://en.wikipedia.org/wiki/RGBE_image_format
  58290. *
  58291. * @param uint8array The binary file stored in native array.
  58292. * @return The header information.
  58293. */
  58294. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58295. /**
  58296. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58297. * This RGBE texture needs to store the information as a panorama.
  58298. *
  58299. * More information on this format are available here:
  58300. * https://en.wikipedia.org/wiki/RGBE_image_format
  58301. *
  58302. * @param buffer The binary file stored in an array buffer.
  58303. * @param size The expected size of the extracted cubemap.
  58304. * @return The Cube Map information.
  58305. */
  58306. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58307. /**
  58308. * Returns the pixels data extracted from an RGBE texture.
  58309. * This pixels will be stored left to right up to down in the R G B order in one array.
  58310. *
  58311. * More information on this format are available here:
  58312. * https://en.wikipedia.org/wiki/RGBE_image_format
  58313. *
  58314. * @param uint8array The binary file stored in an array buffer.
  58315. * @param hdrInfo The header information of the file.
  58316. * @return The pixels data in RGB right to left up to down order.
  58317. */
  58318. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58319. private static RGBE_ReadPixels_RLE;
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /**
  58324. * Effect Render Options
  58325. */
  58326. export interface IEffectRendererOptions {
  58327. /**
  58328. * Defines the vertices positions.
  58329. */
  58330. positions?: number[];
  58331. /**
  58332. * Defines the indices.
  58333. */
  58334. indices?: number[];
  58335. }
  58336. /**
  58337. * Helper class to render one or more effects.
  58338. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58339. */
  58340. export class EffectRenderer {
  58341. private engine;
  58342. private static _DefaultOptions;
  58343. private _vertexBuffers;
  58344. private _indexBuffer;
  58345. private _fullscreenViewport;
  58346. /**
  58347. * Creates an effect renderer
  58348. * @param engine the engine to use for rendering
  58349. * @param options defines the options of the effect renderer
  58350. */
  58351. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58352. /**
  58353. * Sets the current viewport in normalized coordinates 0-1
  58354. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58355. */
  58356. setViewport(viewport?: Viewport): void;
  58357. /**
  58358. * Binds the embedded attributes buffer to the effect.
  58359. * @param effect Defines the effect to bind the attributes for
  58360. */
  58361. bindBuffers(effect: Effect): void;
  58362. /**
  58363. * Sets the current effect wrapper to use during draw.
  58364. * The effect needs to be ready before calling this api.
  58365. * This also sets the default full screen position attribute.
  58366. * @param effectWrapper Defines the effect to draw with
  58367. */
  58368. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58369. /**
  58370. * Restores engine states
  58371. */
  58372. restoreStates(): void;
  58373. /**
  58374. * Draws a full screen quad.
  58375. */
  58376. draw(): void;
  58377. private isRenderTargetTexture;
  58378. /**
  58379. * renders one or more effects to a specified texture
  58380. * @param effectWrapper the effect to renderer
  58381. * @param outputTexture texture to draw to, if null it will render to the screen.
  58382. */
  58383. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58384. /**
  58385. * Disposes of the effect renderer
  58386. */
  58387. dispose(): void;
  58388. }
  58389. /**
  58390. * Options to create an EffectWrapper
  58391. */
  58392. interface EffectWrapperCreationOptions {
  58393. /**
  58394. * Engine to use to create the effect
  58395. */
  58396. engine: ThinEngine;
  58397. /**
  58398. * Fragment shader for the effect
  58399. */
  58400. fragmentShader: string;
  58401. /**
  58402. * Use the shader store instead of direct source code
  58403. */
  58404. useShaderStore?: boolean;
  58405. /**
  58406. * Vertex shader for the effect
  58407. */
  58408. vertexShader?: string;
  58409. /**
  58410. * Attributes to use in the shader
  58411. */
  58412. attributeNames?: Array<string>;
  58413. /**
  58414. * Uniforms to use in the shader
  58415. */
  58416. uniformNames?: Array<string>;
  58417. /**
  58418. * Texture sampler names to use in the shader
  58419. */
  58420. samplerNames?: Array<string>;
  58421. /**
  58422. * Defines to use in the shader
  58423. */
  58424. defines?: Array<string>;
  58425. /**
  58426. * Callback when effect is compiled
  58427. */
  58428. onCompiled?: Nullable<(effect: Effect) => void>;
  58429. /**
  58430. * The friendly name of the effect displayed in Spector.
  58431. */
  58432. name?: string;
  58433. }
  58434. /**
  58435. * Wraps an effect to be used for rendering
  58436. */
  58437. export class EffectWrapper {
  58438. /**
  58439. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58440. */
  58441. onApplyObservable: Observable<{}>;
  58442. /**
  58443. * The underlying effect
  58444. */
  58445. effect: Effect;
  58446. /**
  58447. * Creates an effect to be renderer
  58448. * @param creationOptions options to create the effect
  58449. */
  58450. constructor(creationOptions: EffectWrapperCreationOptions);
  58451. /**
  58452. * Disposes of the effect wrapper
  58453. */
  58454. dispose(): void;
  58455. }
  58456. }
  58457. declare module BABYLON {
  58458. /** @hidden */
  58459. export var hdrFilteringVertexShader: {
  58460. name: string;
  58461. shader: string;
  58462. };
  58463. }
  58464. declare module BABYLON {
  58465. /** @hidden */
  58466. export var hdrFilteringPixelShader: {
  58467. name: string;
  58468. shader: string;
  58469. };
  58470. }
  58471. declare module BABYLON {
  58472. /**
  58473. * Options for texture filtering
  58474. */
  58475. interface IHDRFilteringOptions {
  58476. /**
  58477. * Scales pixel intensity for the input HDR map.
  58478. */
  58479. hdrScale?: number;
  58480. /**
  58481. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58482. */
  58483. quality?: number;
  58484. }
  58485. /**
  58486. * Filters HDR maps to get correct renderings of PBR reflections
  58487. */
  58488. export class HDRFiltering {
  58489. private _engine;
  58490. private _effectRenderer;
  58491. private _effectWrapper;
  58492. private _lodGenerationOffset;
  58493. private _lodGenerationScale;
  58494. /**
  58495. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58496. * you care about baking speed.
  58497. */
  58498. quality: number;
  58499. /**
  58500. * Scales pixel intensity for the input HDR map.
  58501. */
  58502. hdrScale: number;
  58503. /**
  58504. * Instantiates HDR filter for reflection maps
  58505. *
  58506. * @param engine Thin engine
  58507. * @param options Options
  58508. */
  58509. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58510. private _createRenderTarget;
  58511. private _prefilterInternal;
  58512. private _createEffect;
  58513. /**
  58514. * Get a value indicating if the filter is ready to be used
  58515. * @param texture Texture to filter
  58516. * @returns true if the filter is ready
  58517. */
  58518. isReady(texture: BaseTexture): boolean;
  58519. /**
  58520. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58521. * Prefiltering will be invoked at the end of next rendering pass.
  58522. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58523. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58524. * @param texture Texture to filter
  58525. * @param onFinished Callback when filtering is done
  58526. * @return Promise called when prefiltering is done
  58527. */
  58528. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58529. }
  58530. }
  58531. declare module BABYLON {
  58532. /**
  58533. * This represents a texture coming from an HDR input.
  58534. *
  58535. * The only supported format is currently panorama picture stored in RGBE format.
  58536. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58537. */
  58538. export class HDRCubeTexture extends BaseTexture {
  58539. private static _facesMapping;
  58540. private _generateHarmonics;
  58541. private _noMipmap;
  58542. private _prefilterOnLoad;
  58543. private _textureMatrix;
  58544. private _size;
  58545. private _onLoad;
  58546. private _onError;
  58547. /**
  58548. * The texture URL.
  58549. */
  58550. url: string;
  58551. /**
  58552. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58553. */
  58554. coordinatesMode: number;
  58555. protected _isBlocking: boolean;
  58556. /**
  58557. * Sets wether or not the texture is blocking during loading.
  58558. */
  58559. set isBlocking(value: boolean);
  58560. /**
  58561. * Gets wether or not the texture is blocking during loading.
  58562. */
  58563. get isBlocking(): boolean;
  58564. protected _rotationY: number;
  58565. /**
  58566. * Sets texture matrix rotation angle around Y axis in radians.
  58567. */
  58568. set rotationY(value: number);
  58569. /**
  58570. * Gets texture matrix rotation angle around Y axis radians.
  58571. */
  58572. get rotationY(): number;
  58573. /**
  58574. * Gets or sets the center of the bounding box associated with the cube texture
  58575. * It must define where the camera used to render the texture was set
  58576. */
  58577. boundingBoxPosition: Vector3;
  58578. private _boundingBoxSize;
  58579. /**
  58580. * Gets or sets the size of the bounding box associated with the cube texture
  58581. * When defined, the cubemap will switch to local mode
  58582. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58583. * @example https://www.babylonjs-playground.com/#RNASML
  58584. */
  58585. set boundingBoxSize(value: Vector3);
  58586. get boundingBoxSize(): Vector3;
  58587. /**
  58588. * Instantiates an HDRTexture from the following parameters.
  58589. *
  58590. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58591. * @param sceneOrEngine The scene or engine the texture will be used in
  58592. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58593. * @param noMipmap Forces to not generate the mipmap if true
  58594. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58595. * @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)
  58596. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58597. */
  58598. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58599. /**
  58600. * Get the current class name of the texture useful for serialization or dynamic coding.
  58601. * @returns "HDRCubeTexture"
  58602. */
  58603. getClassName(): string;
  58604. /**
  58605. * Occurs when the file is raw .hdr file.
  58606. */
  58607. private loadTexture;
  58608. clone(): HDRCubeTexture;
  58609. delayLoad(): void;
  58610. /**
  58611. * Get the texture reflection matrix used to rotate/transform the reflection.
  58612. * @returns the reflection matrix
  58613. */
  58614. getReflectionTextureMatrix(): Matrix;
  58615. /**
  58616. * Set the texture reflection matrix used to rotate/transform the reflection.
  58617. * @param value Define the reflection matrix to set
  58618. */
  58619. setReflectionTextureMatrix(value: Matrix): void;
  58620. /**
  58621. * Parses a JSON representation of an HDR Texture in order to create the texture
  58622. * @param parsedTexture Define the JSON representation
  58623. * @param scene Define the scene the texture should be created in
  58624. * @param rootUrl Define the root url in case we need to load relative dependencies
  58625. * @returns the newly created texture after parsing
  58626. */
  58627. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58628. serialize(): any;
  58629. }
  58630. }
  58631. declare module BABYLON {
  58632. /**
  58633. * Class used to control physics engine
  58634. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58635. */
  58636. export class PhysicsEngine implements IPhysicsEngine {
  58637. private _physicsPlugin;
  58638. /**
  58639. * Global value used to control the smallest number supported by the simulation
  58640. */
  58641. static Epsilon: number;
  58642. private _impostors;
  58643. private _joints;
  58644. private _subTimeStep;
  58645. /**
  58646. * Gets the gravity vector used by the simulation
  58647. */
  58648. gravity: Vector3;
  58649. /**
  58650. * Factory used to create the default physics plugin.
  58651. * @returns The default physics plugin
  58652. */
  58653. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58654. /**
  58655. * Creates a new Physics Engine
  58656. * @param gravity defines the gravity vector used by the simulation
  58657. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58658. */
  58659. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58660. /**
  58661. * Sets the gravity vector used by the simulation
  58662. * @param gravity defines the gravity vector to use
  58663. */
  58664. setGravity(gravity: Vector3): void;
  58665. /**
  58666. * Set the time step of the physics engine.
  58667. * Default is 1/60.
  58668. * To slow it down, enter 1/600 for example.
  58669. * To speed it up, 1/30
  58670. * @param newTimeStep defines the new timestep to apply to this world.
  58671. */
  58672. setTimeStep(newTimeStep?: number): void;
  58673. /**
  58674. * Get the time step of the physics engine.
  58675. * @returns the current time step
  58676. */
  58677. getTimeStep(): number;
  58678. /**
  58679. * Set the sub time step of the physics engine.
  58680. * Default is 0 meaning there is no sub steps
  58681. * To increase physics resolution precision, set a small value (like 1 ms)
  58682. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58683. */
  58684. setSubTimeStep(subTimeStep?: number): void;
  58685. /**
  58686. * Get the sub time step of the physics engine.
  58687. * @returns the current sub time step
  58688. */
  58689. getSubTimeStep(): number;
  58690. /**
  58691. * Release all resources
  58692. */
  58693. dispose(): void;
  58694. /**
  58695. * Gets the name of the current physics plugin
  58696. * @returns the name of the plugin
  58697. */
  58698. getPhysicsPluginName(): string;
  58699. /**
  58700. * Adding a new impostor for the impostor tracking.
  58701. * This will be done by the impostor itself.
  58702. * @param impostor the impostor to add
  58703. */
  58704. addImpostor(impostor: PhysicsImpostor): void;
  58705. /**
  58706. * Remove an impostor from the engine.
  58707. * This impostor and its mesh will not longer be updated by the physics engine.
  58708. * @param impostor the impostor to remove
  58709. */
  58710. removeImpostor(impostor: PhysicsImpostor): void;
  58711. /**
  58712. * Add a joint to the physics engine
  58713. * @param mainImpostor defines the main impostor to which the joint is added.
  58714. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58715. * @param joint defines the joint that will connect both impostors.
  58716. */
  58717. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58718. /**
  58719. * Removes a joint from the simulation
  58720. * @param mainImpostor defines the impostor used with the joint
  58721. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58722. * @param joint defines the joint to remove
  58723. */
  58724. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58725. /**
  58726. * Called by the scene. No need to call it.
  58727. * @param delta defines the timespam between frames
  58728. */
  58729. _step(delta: number): void;
  58730. /**
  58731. * Gets the current plugin used to run the simulation
  58732. * @returns current plugin
  58733. */
  58734. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58735. /**
  58736. * Gets the list of physic impostors
  58737. * @returns an array of PhysicsImpostor
  58738. */
  58739. getImpostors(): Array<PhysicsImpostor>;
  58740. /**
  58741. * Gets the impostor for a physics enabled object
  58742. * @param object defines the object impersonated by the impostor
  58743. * @returns the PhysicsImpostor or null if not found
  58744. */
  58745. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58746. /**
  58747. * Gets the impostor for a physics body object
  58748. * @param body defines physics body used by the impostor
  58749. * @returns the PhysicsImpostor or null if not found
  58750. */
  58751. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58752. /**
  58753. * Does a raycast in the physics world
  58754. * @param from when should the ray start?
  58755. * @param to when should the ray end?
  58756. * @returns PhysicsRaycastResult
  58757. */
  58758. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58759. }
  58760. }
  58761. declare module BABYLON {
  58762. /** @hidden */
  58763. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58764. private _useDeltaForWorldStep;
  58765. world: any;
  58766. name: string;
  58767. private _physicsMaterials;
  58768. private _fixedTimeStep;
  58769. private _cannonRaycastResult;
  58770. private _raycastResult;
  58771. private _physicsBodysToRemoveAfterStep;
  58772. private _firstFrame;
  58773. BJSCANNON: any;
  58774. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58775. setGravity(gravity: Vector3): void;
  58776. setTimeStep(timeStep: number): void;
  58777. getTimeStep(): number;
  58778. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58779. private _removeMarkedPhysicsBodiesFromWorld;
  58780. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58781. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58782. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58783. private _processChildMeshes;
  58784. removePhysicsBody(impostor: PhysicsImpostor): void;
  58785. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58786. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58787. private _addMaterial;
  58788. private _checkWithEpsilon;
  58789. private _createShape;
  58790. private _createHeightmap;
  58791. private _minus90X;
  58792. private _plus90X;
  58793. private _tmpPosition;
  58794. private _tmpDeltaPosition;
  58795. private _tmpUnityRotation;
  58796. private _updatePhysicsBodyTransformation;
  58797. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58798. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58799. isSupported(): boolean;
  58800. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58801. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58802. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58803. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58804. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58805. getBodyMass(impostor: PhysicsImpostor): number;
  58806. getBodyFriction(impostor: PhysicsImpostor): number;
  58807. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58808. getBodyRestitution(impostor: PhysicsImpostor): number;
  58809. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58810. sleepBody(impostor: PhysicsImpostor): void;
  58811. wakeUpBody(impostor: PhysicsImpostor): void;
  58812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58813. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58816. getRadius(impostor: PhysicsImpostor): number;
  58817. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58818. dispose(): void;
  58819. private _extendNamespace;
  58820. /**
  58821. * Does a raycast in the physics world
  58822. * @param from when should the ray start?
  58823. * @param to when should the ray end?
  58824. * @returns PhysicsRaycastResult
  58825. */
  58826. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58827. }
  58828. }
  58829. declare module BABYLON {
  58830. /** @hidden */
  58831. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58832. private _useDeltaForWorldStep;
  58833. world: any;
  58834. name: string;
  58835. BJSOIMO: any;
  58836. private _raycastResult;
  58837. private _fixedTimeStep;
  58838. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58839. setGravity(gravity: Vector3): void;
  58840. setTimeStep(timeStep: number): void;
  58841. getTimeStep(): number;
  58842. private _tmpImpostorsArray;
  58843. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58844. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58845. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58846. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58847. private _tmpPositionVector;
  58848. removePhysicsBody(impostor: PhysicsImpostor): void;
  58849. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58850. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58851. isSupported(): boolean;
  58852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58854. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58855. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58856. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58857. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58858. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58859. getBodyMass(impostor: PhysicsImpostor): number;
  58860. getBodyFriction(impostor: PhysicsImpostor): number;
  58861. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58862. getBodyRestitution(impostor: PhysicsImpostor): number;
  58863. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58864. sleepBody(impostor: PhysicsImpostor): void;
  58865. wakeUpBody(impostor: PhysicsImpostor): void;
  58866. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58867. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58870. getRadius(impostor: PhysicsImpostor): number;
  58871. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58872. dispose(): void;
  58873. /**
  58874. * Does a raycast in the physics world
  58875. * @param from when should the ray start?
  58876. * @param to when should the ray end?
  58877. * @returns PhysicsRaycastResult
  58878. */
  58879. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58880. }
  58881. }
  58882. declare module BABYLON {
  58883. /**
  58884. * Class containing static functions to help procedurally build meshes
  58885. */
  58886. export class RibbonBuilder {
  58887. /**
  58888. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58889. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58890. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58891. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58892. * * 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
  58893. * * 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
  58894. * * 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
  58895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58896. * * 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
  58897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58898. * * 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
  58899. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58900. * * 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
  58901. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58903. * @param name defines the name of the mesh
  58904. * @param options defines the options used to create the mesh
  58905. * @param scene defines the hosting scene
  58906. * @returns the ribbon mesh
  58907. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58909. */
  58910. static CreateRibbon(name: string, options: {
  58911. pathArray: Vector3[][];
  58912. closeArray?: boolean;
  58913. closePath?: boolean;
  58914. offset?: number;
  58915. updatable?: boolean;
  58916. sideOrientation?: number;
  58917. frontUVs?: Vector4;
  58918. backUVs?: Vector4;
  58919. instance?: Mesh;
  58920. invertUV?: boolean;
  58921. uvs?: Vector2[];
  58922. colors?: Color4[];
  58923. }, scene?: Nullable<Scene>): Mesh;
  58924. }
  58925. }
  58926. declare module BABYLON {
  58927. /**
  58928. * Class containing static functions to help procedurally build meshes
  58929. */
  58930. export class ShapeBuilder {
  58931. /**
  58932. * 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.
  58933. * * 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.
  58934. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58935. * * 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.
  58936. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58937. * * 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
  58938. * * 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
  58939. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58941. * * 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
  58942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58944. * @param name defines the name of the mesh
  58945. * @param options defines the options used to create the mesh
  58946. * @param scene defines the hosting scene
  58947. * @returns the extruded shape mesh
  58948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58950. */
  58951. static ExtrudeShape(name: string, options: {
  58952. shape: Vector3[];
  58953. path: Vector3[];
  58954. scale?: number;
  58955. rotation?: number;
  58956. cap?: number;
  58957. updatable?: boolean;
  58958. sideOrientation?: number;
  58959. frontUVs?: Vector4;
  58960. backUVs?: Vector4;
  58961. instance?: Mesh;
  58962. invertUV?: boolean;
  58963. }, scene?: Nullable<Scene>): Mesh;
  58964. /**
  58965. * Creates an custom extruded shape mesh.
  58966. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58967. * * 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.
  58968. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58969. * * 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
  58970. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58971. * * 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
  58972. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58973. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58974. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58975. * * 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
  58976. * * 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
  58977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58979. * * 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
  58980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58982. * @param name defines the name of the mesh
  58983. * @param options defines the options used to create the mesh
  58984. * @param scene defines the hosting scene
  58985. * @returns the custom extruded shape mesh
  58986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58989. */
  58990. static ExtrudeShapeCustom(name: string, options: {
  58991. shape: Vector3[];
  58992. path: Vector3[];
  58993. scaleFunction?: any;
  58994. rotationFunction?: any;
  58995. ribbonCloseArray?: boolean;
  58996. ribbonClosePath?: boolean;
  58997. cap?: number;
  58998. updatable?: boolean;
  58999. sideOrientation?: number;
  59000. frontUVs?: Vector4;
  59001. backUVs?: Vector4;
  59002. instance?: Mesh;
  59003. invertUV?: boolean;
  59004. }, scene?: Nullable<Scene>): Mesh;
  59005. private static _ExtrudeShapeGeneric;
  59006. }
  59007. }
  59008. declare module BABYLON {
  59009. /**
  59010. * AmmoJS Physics plugin
  59011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59012. * @see https://github.com/kripken/ammo.js/
  59013. */
  59014. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59015. private _useDeltaForWorldStep;
  59016. /**
  59017. * Reference to the Ammo library
  59018. */
  59019. bjsAMMO: any;
  59020. /**
  59021. * Created ammoJS world which physics bodies are added to
  59022. */
  59023. world: any;
  59024. /**
  59025. * Name of the plugin
  59026. */
  59027. name: string;
  59028. private _timeStep;
  59029. private _fixedTimeStep;
  59030. private _maxSteps;
  59031. private _tmpQuaternion;
  59032. private _tmpAmmoTransform;
  59033. private _tmpAmmoQuaternion;
  59034. private _tmpAmmoConcreteContactResultCallback;
  59035. private _collisionConfiguration;
  59036. private _dispatcher;
  59037. private _overlappingPairCache;
  59038. private _solver;
  59039. private _softBodySolver;
  59040. private _tmpAmmoVectorA;
  59041. private _tmpAmmoVectorB;
  59042. private _tmpAmmoVectorC;
  59043. private _tmpAmmoVectorD;
  59044. private _tmpContactCallbackResult;
  59045. private _tmpAmmoVectorRCA;
  59046. private _tmpAmmoVectorRCB;
  59047. private _raycastResult;
  59048. private static readonly DISABLE_COLLISION_FLAG;
  59049. private static readonly KINEMATIC_FLAG;
  59050. private static readonly DISABLE_DEACTIVATION_FLAG;
  59051. /**
  59052. * Initializes the ammoJS plugin
  59053. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59054. * @param ammoInjection can be used to inject your own ammo reference
  59055. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59056. */
  59057. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59058. /**
  59059. * Sets the gravity of the physics world (m/(s^2))
  59060. * @param gravity Gravity to set
  59061. */
  59062. setGravity(gravity: Vector3): void;
  59063. /**
  59064. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59065. * @param timeStep timestep to use in seconds
  59066. */
  59067. setTimeStep(timeStep: number): void;
  59068. /**
  59069. * 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)
  59070. * @param fixedTimeStep fixedTimeStep to use in seconds
  59071. */
  59072. setFixedTimeStep(fixedTimeStep: number): void;
  59073. /**
  59074. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59075. * @param maxSteps the maximum number of steps by the physics engine per frame
  59076. */
  59077. setMaxSteps(maxSteps: number): void;
  59078. /**
  59079. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59080. * @returns the current timestep in seconds
  59081. */
  59082. getTimeStep(): number;
  59083. /**
  59084. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59085. */
  59086. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59087. private _isImpostorInContact;
  59088. private _isImpostorPairInContact;
  59089. private _stepSimulation;
  59090. /**
  59091. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59092. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59093. * After the step the babylon meshes are set to the position of the physics imposters
  59094. * @param delta amount of time to step forward
  59095. * @param impostors array of imposters to update before/after the step
  59096. */
  59097. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59098. /**
  59099. * Update babylon mesh to match physics world object
  59100. * @param impostor imposter to match
  59101. */
  59102. private _afterSoftStep;
  59103. /**
  59104. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59105. * @param impostor imposter to match
  59106. */
  59107. private _ropeStep;
  59108. /**
  59109. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59110. * @param impostor imposter to match
  59111. */
  59112. private _softbodyOrClothStep;
  59113. private _tmpMatrix;
  59114. /**
  59115. * Applies an impulse on the imposter
  59116. * @param impostor imposter to apply impulse to
  59117. * @param force amount of force to be applied to the imposter
  59118. * @param contactPoint the location to apply the impulse on the imposter
  59119. */
  59120. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59121. /**
  59122. * Applies a force on the imposter
  59123. * @param impostor imposter to apply force
  59124. * @param force amount of force to be applied to the imposter
  59125. * @param contactPoint the location to apply the force on the imposter
  59126. */
  59127. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59128. /**
  59129. * Creates a physics body using the plugin
  59130. * @param impostor the imposter to create the physics body on
  59131. */
  59132. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59133. /**
  59134. * Removes the physics body from the imposter and disposes of the body's memory
  59135. * @param impostor imposter to remove the physics body from
  59136. */
  59137. removePhysicsBody(impostor: PhysicsImpostor): void;
  59138. /**
  59139. * Generates a joint
  59140. * @param impostorJoint the imposter joint to create the joint with
  59141. */
  59142. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59143. /**
  59144. * Removes a joint
  59145. * @param impostorJoint the imposter joint to remove the joint from
  59146. */
  59147. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59148. private _addMeshVerts;
  59149. /**
  59150. * Initialise the soft body vertices to match its object's (mesh) vertices
  59151. * Softbody vertices (nodes) are in world space and to match this
  59152. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59153. * @param impostor to create the softbody for
  59154. */
  59155. private _softVertexData;
  59156. /**
  59157. * Create an impostor's soft body
  59158. * @param impostor to create the softbody for
  59159. */
  59160. private _createSoftbody;
  59161. /**
  59162. * Create cloth for an impostor
  59163. * @param impostor to create the softbody for
  59164. */
  59165. private _createCloth;
  59166. /**
  59167. * Create rope for an impostor
  59168. * @param impostor to create the softbody for
  59169. */
  59170. private _createRope;
  59171. /**
  59172. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59173. * @param impostor to create the custom physics shape for
  59174. */
  59175. private _createCustom;
  59176. private _addHullVerts;
  59177. private _createShape;
  59178. /**
  59179. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59180. * @param impostor imposter containing the physics body and babylon object
  59181. */
  59182. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59183. /**
  59184. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59185. * @param impostor imposter containing the physics body and babylon object
  59186. * @param newPosition new position
  59187. * @param newRotation new rotation
  59188. */
  59189. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59190. /**
  59191. * If this plugin is supported
  59192. * @returns true if its supported
  59193. */
  59194. isSupported(): boolean;
  59195. /**
  59196. * Sets the linear velocity of the physics body
  59197. * @param impostor imposter to set the velocity on
  59198. * @param velocity velocity to set
  59199. */
  59200. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59201. /**
  59202. * Sets the angular velocity of the physics body
  59203. * @param impostor imposter to set the velocity on
  59204. * @param velocity velocity to set
  59205. */
  59206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59207. /**
  59208. * gets the linear velocity
  59209. * @param impostor imposter to get linear velocity from
  59210. * @returns linear velocity
  59211. */
  59212. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59213. /**
  59214. * gets the angular velocity
  59215. * @param impostor imposter to get angular velocity from
  59216. * @returns angular velocity
  59217. */
  59218. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59219. /**
  59220. * Sets the mass of physics body
  59221. * @param impostor imposter to set the mass on
  59222. * @param mass mass to set
  59223. */
  59224. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59225. /**
  59226. * Gets the mass of the physics body
  59227. * @param impostor imposter to get the mass from
  59228. * @returns mass
  59229. */
  59230. getBodyMass(impostor: PhysicsImpostor): number;
  59231. /**
  59232. * Gets friction of the impostor
  59233. * @param impostor impostor to get friction from
  59234. * @returns friction value
  59235. */
  59236. getBodyFriction(impostor: PhysicsImpostor): number;
  59237. /**
  59238. * Sets friction of the impostor
  59239. * @param impostor impostor to set friction on
  59240. * @param friction friction value
  59241. */
  59242. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59243. /**
  59244. * Gets restitution of the impostor
  59245. * @param impostor impostor to get restitution from
  59246. * @returns restitution value
  59247. */
  59248. getBodyRestitution(impostor: PhysicsImpostor): number;
  59249. /**
  59250. * Sets resitution of the impostor
  59251. * @param impostor impostor to set resitution on
  59252. * @param restitution resitution value
  59253. */
  59254. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59255. /**
  59256. * Gets pressure inside the impostor
  59257. * @param impostor impostor to get pressure from
  59258. * @returns pressure value
  59259. */
  59260. getBodyPressure(impostor: PhysicsImpostor): number;
  59261. /**
  59262. * Sets pressure inside a soft body impostor
  59263. * Cloth and rope must remain 0 pressure
  59264. * @param impostor impostor to set pressure on
  59265. * @param pressure pressure value
  59266. */
  59267. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59268. /**
  59269. * Gets stiffness of the impostor
  59270. * @param impostor impostor to get stiffness from
  59271. * @returns pressure value
  59272. */
  59273. getBodyStiffness(impostor: PhysicsImpostor): number;
  59274. /**
  59275. * Sets stiffness of the impostor
  59276. * @param impostor impostor to set stiffness on
  59277. * @param stiffness stiffness value from 0 to 1
  59278. */
  59279. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59280. /**
  59281. * Gets velocityIterations of the impostor
  59282. * @param impostor impostor to get velocity iterations from
  59283. * @returns velocityIterations value
  59284. */
  59285. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59286. /**
  59287. * Sets velocityIterations of the impostor
  59288. * @param impostor impostor to set velocity iterations on
  59289. * @param velocityIterations velocityIterations value
  59290. */
  59291. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59292. /**
  59293. * Gets positionIterations of the impostor
  59294. * @param impostor impostor to get position iterations from
  59295. * @returns positionIterations value
  59296. */
  59297. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59298. /**
  59299. * Sets positionIterations of the impostor
  59300. * @param impostor impostor to set position on
  59301. * @param positionIterations positionIterations value
  59302. */
  59303. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59304. /**
  59305. * Append an anchor to a cloth object
  59306. * @param impostor is the cloth impostor to add anchor to
  59307. * @param otherImpostor is the rigid impostor to anchor to
  59308. * @param width ratio across width from 0 to 1
  59309. * @param height ratio up height from 0 to 1
  59310. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59311. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59312. */
  59313. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59314. /**
  59315. * Append an hook to a rope object
  59316. * @param impostor is the rope impostor to add hook to
  59317. * @param otherImpostor is the rigid impostor to hook to
  59318. * @param length ratio along the rope from 0 to 1
  59319. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59320. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59321. */
  59322. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59323. /**
  59324. * Sleeps the physics body and stops it from being active
  59325. * @param impostor impostor to sleep
  59326. */
  59327. sleepBody(impostor: PhysicsImpostor): void;
  59328. /**
  59329. * Activates the physics body
  59330. * @param impostor impostor to activate
  59331. */
  59332. wakeUpBody(impostor: PhysicsImpostor): void;
  59333. /**
  59334. * Updates the distance parameters of the joint
  59335. * @param joint joint to update
  59336. * @param maxDistance maximum distance of the joint
  59337. * @param minDistance minimum distance of the joint
  59338. */
  59339. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59340. /**
  59341. * Sets a motor on the joint
  59342. * @param joint joint to set motor on
  59343. * @param speed speed of the motor
  59344. * @param maxForce maximum force of the motor
  59345. * @param motorIndex index of the motor
  59346. */
  59347. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59348. /**
  59349. * Sets the motors limit
  59350. * @param joint joint to set limit on
  59351. * @param upperLimit upper limit
  59352. * @param lowerLimit lower limit
  59353. */
  59354. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59355. /**
  59356. * Syncs the position and rotation of a mesh with the impostor
  59357. * @param mesh mesh to sync
  59358. * @param impostor impostor to update the mesh with
  59359. */
  59360. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59361. /**
  59362. * Gets the radius of the impostor
  59363. * @param impostor impostor to get radius from
  59364. * @returns the radius
  59365. */
  59366. getRadius(impostor: PhysicsImpostor): number;
  59367. /**
  59368. * Gets the box size of the impostor
  59369. * @param impostor impostor to get box size from
  59370. * @param result the resulting box size
  59371. */
  59372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59373. /**
  59374. * Disposes of the impostor
  59375. */
  59376. dispose(): void;
  59377. /**
  59378. * Does a raycast in the physics world
  59379. * @param from when should the ray start?
  59380. * @param to when should the ray end?
  59381. * @returns PhysicsRaycastResult
  59382. */
  59383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59384. }
  59385. }
  59386. declare module BABYLON {
  59387. interface AbstractScene {
  59388. /**
  59389. * The list of reflection probes added to the scene
  59390. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59391. */
  59392. reflectionProbes: Array<ReflectionProbe>;
  59393. /**
  59394. * Removes the given reflection probe from this scene.
  59395. * @param toRemove The reflection probe to remove
  59396. * @returns The index of the removed reflection probe
  59397. */
  59398. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59399. /**
  59400. * Adds the given reflection probe to this scene.
  59401. * @param newReflectionProbe The reflection probe to add
  59402. */
  59403. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59404. }
  59405. /**
  59406. * Class used to generate realtime reflection / refraction cube textures
  59407. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59408. */
  59409. export class ReflectionProbe {
  59410. /** defines the name of the probe */
  59411. name: string;
  59412. private _scene;
  59413. private _renderTargetTexture;
  59414. private _projectionMatrix;
  59415. private _viewMatrix;
  59416. private _target;
  59417. private _add;
  59418. private _attachedMesh;
  59419. private _invertYAxis;
  59420. /** Gets or sets probe position (center of the cube map) */
  59421. position: Vector3;
  59422. /**
  59423. * Creates a new reflection probe
  59424. * @param name defines the name of the probe
  59425. * @param size defines the texture resolution (for each face)
  59426. * @param scene defines the hosting scene
  59427. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59428. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59429. */
  59430. constructor(
  59431. /** defines the name of the probe */
  59432. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59433. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59434. get samples(): number;
  59435. set samples(value: number);
  59436. /** Gets or sets the refresh rate to use (on every frame by default) */
  59437. get refreshRate(): number;
  59438. set refreshRate(value: number);
  59439. /**
  59440. * Gets the hosting scene
  59441. * @returns a Scene
  59442. */
  59443. getScene(): Scene;
  59444. /** Gets the internal CubeTexture used to render to */
  59445. get cubeTexture(): RenderTargetTexture;
  59446. /** Gets the list of meshes to render */
  59447. get renderList(): Nullable<AbstractMesh[]>;
  59448. /**
  59449. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59450. * @param mesh defines the mesh to attach to
  59451. */
  59452. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59453. /**
  59454. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59455. * @param renderingGroupId The rendering group id corresponding to its index
  59456. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59457. */
  59458. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59459. /**
  59460. * Clean all associated resources
  59461. */
  59462. dispose(): void;
  59463. /**
  59464. * Converts the reflection probe information to a readable string for debug purpose.
  59465. * @param fullDetails Supports for multiple levels of logging within scene loading
  59466. * @returns the human readable reflection probe info
  59467. */
  59468. toString(fullDetails?: boolean): string;
  59469. /**
  59470. * Get the class name of the relfection probe.
  59471. * @returns "ReflectionProbe"
  59472. */
  59473. getClassName(): string;
  59474. /**
  59475. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59476. * @returns The JSON representation of the texture
  59477. */
  59478. serialize(): any;
  59479. /**
  59480. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59481. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59482. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59483. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59484. * @returns The parsed reflection probe if successful
  59485. */
  59486. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59487. }
  59488. }
  59489. declare module BABYLON {
  59490. /** @hidden */
  59491. export var _BabylonLoaderRegistered: boolean;
  59492. /**
  59493. * Helps setting up some configuration for the babylon file loader.
  59494. */
  59495. export class BabylonFileLoaderConfiguration {
  59496. /**
  59497. * The loader does not allow injecting custom physix engine into the plugins.
  59498. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59499. * So you could set this variable to your engine import to make it work.
  59500. */
  59501. static LoaderInjectedPhysicsEngine: any;
  59502. }
  59503. }
  59504. declare module BABYLON {
  59505. /**
  59506. * The Physically based simple base material of BJS.
  59507. *
  59508. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59509. * It is used as the base class for both the specGloss and metalRough conventions.
  59510. */
  59511. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59512. /**
  59513. * Number of Simultaneous lights allowed on the material.
  59514. */
  59515. maxSimultaneousLights: number;
  59516. /**
  59517. * If sets to true, disables all the lights affecting the material.
  59518. */
  59519. disableLighting: boolean;
  59520. /**
  59521. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59522. */
  59523. environmentTexture: BaseTexture;
  59524. /**
  59525. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59526. */
  59527. invertNormalMapX: boolean;
  59528. /**
  59529. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59530. */
  59531. invertNormalMapY: boolean;
  59532. /**
  59533. * Normal map used in the model.
  59534. */
  59535. normalTexture: BaseTexture;
  59536. /**
  59537. * Emissivie color used to self-illuminate the model.
  59538. */
  59539. emissiveColor: Color3;
  59540. /**
  59541. * Emissivie texture used to self-illuminate the model.
  59542. */
  59543. emissiveTexture: BaseTexture;
  59544. /**
  59545. * Occlusion Channel Strenght.
  59546. */
  59547. occlusionStrength: number;
  59548. /**
  59549. * Occlusion Texture of the material (adding extra occlusion effects).
  59550. */
  59551. occlusionTexture: BaseTexture;
  59552. /**
  59553. * Defines the alpha limits in alpha test mode.
  59554. */
  59555. alphaCutOff: number;
  59556. /**
  59557. * Gets the current double sided mode.
  59558. */
  59559. get doubleSided(): boolean;
  59560. /**
  59561. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59562. */
  59563. set doubleSided(value: boolean);
  59564. /**
  59565. * Stores the pre-calculated light information of a mesh in a texture.
  59566. */
  59567. lightmapTexture: BaseTexture;
  59568. /**
  59569. * If true, the light map contains occlusion information instead of lighting info.
  59570. */
  59571. useLightmapAsShadowmap: boolean;
  59572. /**
  59573. * Instantiates a new PBRMaterial instance.
  59574. *
  59575. * @param name The material name
  59576. * @param scene The scene the material will be use in.
  59577. */
  59578. constructor(name: string, scene: Scene);
  59579. getClassName(): string;
  59580. }
  59581. }
  59582. declare module BABYLON {
  59583. /**
  59584. * The PBR material of BJS following the metal roughness convention.
  59585. *
  59586. * This fits to the PBR convention in the GLTF definition:
  59587. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59588. */
  59589. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59590. /**
  59591. * The base color has two different interpretations depending on the value of metalness.
  59592. * When the material is a metal, the base color is the specific measured reflectance value
  59593. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59594. * of the material.
  59595. */
  59596. baseColor: Color3;
  59597. /**
  59598. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59599. * well as opacity information in the alpha channel.
  59600. */
  59601. baseTexture: BaseTexture;
  59602. /**
  59603. * Specifies the metallic scalar value of the material.
  59604. * Can also be used to scale the metalness values of the metallic texture.
  59605. */
  59606. metallic: number;
  59607. /**
  59608. * Specifies the roughness scalar value of the material.
  59609. * Can also be used to scale the roughness values of the metallic texture.
  59610. */
  59611. roughness: number;
  59612. /**
  59613. * Texture containing both the metallic value in the B channel and the
  59614. * roughness value in the G channel to keep better precision.
  59615. */
  59616. metallicRoughnessTexture: BaseTexture;
  59617. /**
  59618. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59619. *
  59620. * @param name The material name
  59621. * @param scene The scene the material will be use in.
  59622. */
  59623. constructor(name: string, scene: Scene);
  59624. /**
  59625. * Return the currrent class name of the material.
  59626. */
  59627. getClassName(): string;
  59628. /**
  59629. * Makes a duplicate of the current material.
  59630. * @param name - name to use for the new material.
  59631. */
  59632. clone(name: string): PBRMetallicRoughnessMaterial;
  59633. /**
  59634. * Serialize the material to a parsable JSON object.
  59635. */
  59636. serialize(): any;
  59637. /**
  59638. * Parses a JSON object correponding to the serialize function.
  59639. */
  59640. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59641. }
  59642. }
  59643. declare module BABYLON {
  59644. /**
  59645. * The PBR material of BJS following the specular glossiness convention.
  59646. *
  59647. * This fits to the PBR convention in the GLTF definition:
  59648. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59649. */
  59650. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59651. /**
  59652. * Specifies the diffuse color of the material.
  59653. */
  59654. diffuseColor: Color3;
  59655. /**
  59656. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59657. * channel.
  59658. */
  59659. diffuseTexture: BaseTexture;
  59660. /**
  59661. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59662. */
  59663. specularColor: Color3;
  59664. /**
  59665. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59666. */
  59667. glossiness: number;
  59668. /**
  59669. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59670. */
  59671. specularGlossinessTexture: BaseTexture;
  59672. /**
  59673. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59674. *
  59675. * @param name The material name
  59676. * @param scene The scene the material will be use in.
  59677. */
  59678. constructor(name: string, scene: Scene);
  59679. /**
  59680. * Return the currrent class name of the material.
  59681. */
  59682. getClassName(): string;
  59683. /**
  59684. * Makes a duplicate of the current material.
  59685. * @param name - name to use for the new material.
  59686. */
  59687. clone(name: string): PBRSpecularGlossinessMaterial;
  59688. /**
  59689. * Serialize the material to a parsable JSON object.
  59690. */
  59691. serialize(): any;
  59692. /**
  59693. * Parses a JSON object correponding to the serialize function.
  59694. */
  59695. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59696. }
  59697. }
  59698. declare module BABYLON {
  59699. /**
  59700. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59701. * It can help converting any input color in a desired output one. This can then be used to create effects
  59702. * from sepia, black and white to sixties or futuristic rendering...
  59703. *
  59704. * The only supported format is currently 3dl.
  59705. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59706. */
  59707. export class ColorGradingTexture extends BaseTexture {
  59708. /**
  59709. * The texture URL.
  59710. */
  59711. url: string;
  59712. /**
  59713. * Empty line regex stored for GC.
  59714. */
  59715. private static _noneEmptyLineRegex;
  59716. private _textureMatrix;
  59717. private _onLoad;
  59718. /**
  59719. * Instantiates a ColorGradingTexture from the following parameters.
  59720. *
  59721. * @param url The location of the color gradind data (currently only supporting 3dl)
  59722. * @param sceneOrEngine The scene or engine the texture will be used in
  59723. * @param onLoad defines a callback triggered when the texture has been loaded
  59724. */
  59725. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59726. /**
  59727. * Fires the onload event from the constructor if requested.
  59728. */
  59729. private _triggerOnLoad;
  59730. /**
  59731. * Returns the texture matrix used in most of the material.
  59732. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59733. */
  59734. getTextureMatrix(): Matrix;
  59735. /**
  59736. * Occurs when the file being loaded is a .3dl LUT file.
  59737. */
  59738. private load3dlTexture;
  59739. /**
  59740. * Starts the loading process of the texture.
  59741. */
  59742. private loadTexture;
  59743. /**
  59744. * Clones the color gradind texture.
  59745. */
  59746. clone(): ColorGradingTexture;
  59747. /**
  59748. * Called during delayed load for textures.
  59749. */
  59750. delayLoad(): void;
  59751. /**
  59752. * Parses a color grading texture serialized by Babylon.
  59753. * @param parsedTexture The texture information being parsedTexture
  59754. * @param scene The scene to load the texture in
  59755. * @param rootUrl The root url of the data assets to load
  59756. * @return A color gradind texture
  59757. */
  59758. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59759. /**
  59760. * Serializes the LUT texture to json format.
  59761. */
  59762. serialize(): any;
  59763. }
  59764. }
  59765. declare module BABYLON {
  59766. /**
  59767. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59768. */
  59769. export class EquiRectangularCubeTexture extends BaseTexture {
  59770. /** The six faces of the cube. */
  59771. private static _FacesMapping;
  59772. private _noMipmap;
  59773. private _onLoad;
  59774. private _onError;
  59775. /** The size of the cubemap. */
  59776. private _size;
  59777. /** The buffer of the image. */
  59778. private _buffer;
  59779. /** The width of the input image. */
  59780. private _width;
  59781. /** The height of the input image. */
  59782. private _height;
  59783. /** The URL to the image. */
  59784. url: string;
  59785. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59786. coordinatesMode: number;
  59787. /**
  59788. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59789. * @param url The location of the image
  59790. * @param scene The scene the texture will be used in
  59791. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59792. * @param noMipmap Forces to not generate the mipmap if true
  59793. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59794. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59795. * @param onLoad — defines a callback called when texture is loaded
  59796. * @param onError — defines a callback called if there is an error
  59797. */
  59798. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59799. /**
  59800. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59801. */
  59802. private loadImage;
  59803. /**
  59804. * Convert the image buffer into a cubemap and create a CubeTexture.
  59805. */
  59806. private loadTexture;
  59807. /**
  59808. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59809. * @param buffer The ArrayBuffer that should be converted.
  59810. * @returns The buffer as Float32Array.
  59811. */
  59812. private getFloat32ArrayFromArrayBuffer;
  59813. /**
  59814. * Get the current class name of the texture useful for serialization or dynamic coding.
  59815. * @returns "EquiRectangularCubeTexture"
  59816. */
  59817. getClassName(): string;
  59818. /**
  59819. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59820. * @returns A clone of the current EquiRectangularCubeTexture.
  59821. */
  59822. clone(): EquiRectangularCubeTexture;
  59823. }
  59824. }
  59825. declare module BABYLON {
  59826. /**
  59827. * Defines the options related to the creation of an HtmlElementTexture
  59828. */
  59829. export interface IHtmlElementTextureOptions {
  59830. /**
  59831. * Defines wether mip maps should be created or not.
  59832. */
  59833. generateMipMaps?: boolean;
  59834. /**
  59835. * Defines the sampling mode of the texture.
  59836. */
  59837. samplingMode?: number;
  59838. /**
  59839. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59840. */
  59841. engine: Nullable<ThinEngine>;
  59842. /**
  59843. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59844. */
  59845. scene: Nullable<Scene>;
  59846. }
  59847. /**
  59848. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59849. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59850. * is automatically managed.
  59851. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59852. * in your application.
  59853. *
  59854. * As the update is not automatic, you need to call them manually.
  59855. */
  59856. export class HtmlElementTexture extends BaseTexture {
  59857. /**
  59858. * The texture URL.
  59859. */
  59860. element: HTMLVideoElement | HTMLCanvasElement;
  59861. private static readonly DefaultOptions;
  59862. private _textureMatrix;
  59863. private _isVideo;
  59864. private _generateMipMaps;
  59865. private _samplingMode;
  59866. /**
  59867. * Instantiates a HtmlElementTexture from the following parameters.
  59868. *
  59869. * @param name Defines the name of the texture
  59870. * @param element Defines the video or canvas the texture is filled with
  59871. * @param options Defines the other none mandatory texture creation options
  59872. */
  59873. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59874. private _createInternalTexture;
  59875. /**
  59876. * Returns the texture matrix used in most of the material.
  59877. */
  59878. getTextureMatrix(): Matrix;
  59879. /**
  59880. * Updates the content of the texture.
  59881. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59882. */
  59883. update(invertY?: Nullable<boolean>): void;
  59884. }
  59885. }
  59886. declare module BABYLON {
  59887. /**
  59888. * Based on jsTGALoader - Javascript loader for TGA file
  59889. * By Vincent Thibault
  59890. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59891. */
  59892. export class TGATools {
  59893. private static _TYPE_INDEXED;
  59894. private static _TYPE_RGB;
  59895. private static _TYPE_GREY;
  59896. private static _TYPE_RLE_INDEXED;
  59897. private static _TYPE_RLE_RGB;
  59898. private static _TYPE_RLE_GREY;
  59899. private static _ORIGIN_MASK;
  59900. private static _ORIGIN_SHIFT;
  59901. private static _ORIGIN_BL;
  59902. private static _ORIGIN_BR;
  59903. private static _ORIGIN_UL;
  59904. private static _ORIGIN_UR;
  59905. /**
  59906. * Gets the header of a TGA file
  59907. * @param data defines the TGA data
  59908. * @returns the header
  59909. */
  59910. static GetTGAHeader(data: Uint8Array): any;
  59911. /**
  59912. * Uploads TGA content to a Babylon Texture
  59913. * @hidden
  59914. */
  59915. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59916. /** @hidden */
  59917. 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;
  59918. /** @hidden */
  59919. 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;
  59920. /** @hidden */
  59921. 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;
  59922. /** @hidden */
  59923. 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;
  59924. /** @hidden */
  59925. 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;
  59926. /** @hidden */
  59927. 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;
  59928. }
  59929. }
  59930. declare module BABYLON {
  59931. /**
  59932. * Implementation of the TGA Texture Loader.
  59933. * @hidden
  59934. */
  59935. export class _TGATextureLoader implements IInternalTextureLoader {
  59936. /**
  59937. * Defines wether the loader supports cascade loading the different faces.
  59938. */
  59939. readonly supportCascades: boolean;
  59940. /**
  59941. * This returns if the loader support the current file information.
  59942. * @param extension defines the file extension of the file being loaded
  59943. * @returns true if the loader can load the specified file
  59944. */
  59945. canLoad(extension: string): boolean;
  59946. /**
  59947. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59948. * @param data contains the texture data
  59949. * @param texture defines the BabylonJS internal texture
  59950. * @param createPolynomials will be true if polynomials have been requested
  59951. * @param onLoad defines the callback to trigger once the texture is ready
  59952. * @param onError defines the callback to trigger in case of error
  59953. */
  59954. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59955. /**
  59956. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59957. * @param data contains the texture data
  59958. * @param texture defines the BabylonJS internal texture
  59959. * @param callback defines the method to call once ready to upload
  59960. */
  59961. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59962. }
  59963. }
  59964. declare module BABYLON {
  59965. /**
  59966. * Info about the .basis files
  59967. */
  59968. class BasisFileInfo {
  59969. /**
  59970. * If the file has alpha
  59971. */
  59972. hasAlpha: boolean;
  59973. /**
  59974. * Info about each image of the basis file
  59975. */
  59976. images: Array<{
  59977. levels: Array<{
  59978. width: number;
  59979. height: number;
  59980. transcodedPixels: ArrayBufferView;
  59981. }>;
  59982. }>;
  59983. }
  59984. /**
  59985. * Result of transcoding a basis file
  59986. */
  59987. class TranscodeResult {
  59988. /**
  59989. * Info about the .basis file
  59990. */
  59991. fileInfo: BasisFileInfo;
  59992. /**
  59993. * Format to use when loading the file
  59994. */
  59995. format: number;
  59996. }
  59997. /**
  59998. * Configuration options for the Basis transcoder
  59999. */
  60000. export class BasisTranscodeConfiguration {
  60001. /**
  60002. * Supported compression formats used to determine the supported output format of the transcoder
  60003. */
  60004. supportedCompressionFormats?: {
  60005. /**
  60006. * etc1 compression format
  60007. */
  60008. etc1?: boolean;
  60009. /**
  60010. * s3tc compression format
  60011. */
  60012. s3tc?: boolean;
  60013. /**
  60014. * pvrtc compression format
  60015. */
  60016. pvrtc?: boolean;
  60017. /**
  60018. * etc2 compression format
  60019. */
  60020. etc2?: boolean;
  60021. };
  60022. /**
  60023. * If mipmap levels should be loaded for transcoded images (Default: true)
  60024. */
  60025. loadMipmapLevels?: boolean;
  60026. /**
  60027. * Index of a single image to load (Default: all images)
  60028. */
  60029. loadSingleImage?: number;
  60030. }
  60031. /**
  60032. * Used to load .Basis files
  60033. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60034. */
  60035. export class BasisTools {
  60036. private static _IgnoreSupportedFormats;
  60037. /**
  60038. * URL to use when loading the basis transcoder
  60039. */
  60040. static JSModuleURL: string;
  60041. /**
  60042. * URL to use when loading the wasm module for the transcoder
  60043. */
  60044. static WasmModuleURL: string;
  60045. /**
  60046. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60047. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60048. * @returns internal format corresponding to the Basis format
  60049. */
  60050. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60051. private static _WorkerPromise;
  60052. private static _Worker;
  60053. private static _actionId;
  60054. private static _CreateWorkerAsync;
  60055. /**
  60056. * Transcodes a loaded image file to compressed pixel data
  60057. * @param data image data to transcode
  60058. * @param config configuration options for the transcoding
  60059. * @returns a promise resulting in the transcoded image
  60060. */
  60061. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60062. /**
  60063. * Loads a texture from the transcode result
  60064. * @param texture texture load to
  60065. * @param transcodeResult the result of transcoding the basis file to load from
  60066. */
  60067. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60068. }
  60069. }
  60070. declare module BABYLON {
  60071. /**
  60072. * Loader for .basis file format
  60073. */
  60074. export class _BasisTextureLoader implements IInternalTextureLoader {
  60075. /**
  60076. * Defines whether the loader supports cascade loading the different faces.
  60077. */
  60078. readonly supportCascades: boolean;
  60079. /**
  60080. * This returns if the loader support the current file information.
  60081. * @param extension defines the file extension of the file being loaded
  60082. * @returns true if the loader can load the specified file
  60083. */
  60084. canLoad(extension: string): boolean;
  60085. /**
  60086. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60087. * @param data contains the texture data
  60088. * @param texture defines the BabylonJS internal texture
  60089. * @param createPolynomials will be true if polynomials have been requested
  60090. * @param onLoad defines the callback to trigger once the texture is ready
  60091. * @param onError defines the callback to trigger in case of error
  60092. */
  60093. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60094. /**
  60095. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60096. * @param data contains the texture data
  60097. * @param texture defines the BabylonJS internal texture
  60098. * @param callback defines the method to call once ready to upload
  60099. */
  60100. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60101. }
  60102. }
  60103. declare module BABYLON {
  60104. /**
  60105. * Defines the basic options interface of a TexturePacker Frame
  60106. */
  60107. export interface ITexturePackerFrame {
  60108. /**
  60109. * The frame ID
  60110. */
  60111. id: number;
  60112. /**
  60113. * The frames Scale
  60114. */
  60115. scale: Vector2;
  60116. /**
  60117. * The Frames offset
  60118. */
  60119. offset: Vector2;
  60120. }
  60121. /**
  60122. * This is a support class for frame Data on texture packer sets.
  60123. */
  60124. export class TexturePackerFrame implements ITexturePackerFrame {
  60125. /**
  60126. * The frame ID
  60127. */
  60128. id: number;
  60129. /**
  60130. * The frames Scale
  60131. */
  60132. scale: Vector2;
  60133. /**
  60134. * The Frames offset
  60135. */
  60136. offset: Vector2;
  60137. /**
  60138. * Initializes a texture package frame.
  60139. * @param id The numerical frame identifier
  60140. * @param scale Scalar Vector2 for UV frame
  60141. * @param offset Vector2 for the frame position in UV units.
  60142. * @returns TexturePackerFrame
  60143. */
  60144. constructor(id: number, scale: Vector2, offset: Vector2);
  60145. }
  60146. }
  60147. declare module BABYLON {
  60148. /**
  60149. * Defines the basic options interface of a TexturePacker
  60150. */
  60151. export interface ITexturePackerOptions {
  60152. /**
  60153. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60154. */
  60155. map?: string[];
  60156. /**
  60157. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60158. */
  60159. uvsIn?: string;
  60160. /**
  60161. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60162. */
  60163. uvsOut?: string;
  60164. /**
  60165. * number representing the layout style. Defaults to LAYOUT_STRIP
  60166. */
  60167. layout?: number;
  60168. /**
  60169. * number of columns if using custom column count layout(2). This defaults to 4.
  60170. */
  60171. colnum?: number;
  60172. /**
  60173. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60174. */
  60175. updateInputMeshes?: boolean;
  60176. /**
  60177. * boolean flag to dispose all the source textures. Defaults to true.
  60178. */
  60179. disposeSources?: boolean;
  60180. /**
  60181. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60182. */
  60183. fillBlanks?: boolean;
  60184. /**
  60185. * string value representing the context fill style color. Defaults to 'black'.
  60186. */
  60187. customFillColor?: string;
  60188. /**
  60189. * Width and Height Value of each Frame in the TexturePacker Sets
  60190. */
  60191. frameSize?: number;
  60192. /**
  60193. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60194. */
  60195. paddingRatio?: number;
  60196. /**
  60197. * Number that declares the fill method for the padding gutter.
  60198. */
  60199. paddingMode?: number;
  60200. /**
  60201. * If in SUBUV_COLOR padding mode what color to use.
  60202. */
  60203. paddingColor?: Color3 | Color4;
  60204. }
  60205. /**
  60206. * Defines the basic interface of a TexturePacker JSON File
  60207. */
  60208. export interface ITexturePackerJSON {
  60209. /**
  60210. * The frame ID
  60211. */
  60212. name: string;
  60213. /**
  60214. * The base64 channel data
  60215. */
  60216. sets: any;
  60217. /**
  60218. * The options of the Packer
  60219. */
  60220. options: ITexturePackerOptions;
  60221. /**
  60222. * The frame data of the Packer
  60223. */
  60224. frames: Array<number>;
  60225. }
  60226. /**
  60227. * This is a support class that generates a series of packed texture sets.
  60228. * @see https://doc.babylonjs.com/babylon101/materials
  60229. */
  60230. export class TexturePacker {
  60231. /** Packer Layout Constant 0 */
  60232. static readonly LAYOUT_STRIP: number;
  60233. /** Packer Layout Constant 1 */
  60234. static readonly LAYOUT_POWER2: number;
  60235. /** Packer Layout Constant 2 */
  60236. static readonly LAYOUT_COLNUM: number;
  60237. /** Packer Layout Constant 0 */
  60238. static readonly SUBUV_WRAP: number;
  60239. /** Packer Layout Constant 1 */
  60240. static readonly SUBUV_EXTEND: number;
  60241. /** Packer Layout Constant 2 */
  60242. static readonly SUBUV_COLOR: number;
  60243. /** The Name of the Texture Package */
  60244. name: string;
  60245. /** The scene scope of the TexturePacker */
  60246. scene: Scene;
  60247. /** The Meshes to target */
  60248. meshes: AbstractMesh[];
  60249. /** Arguments passed with the Constructor */
  60250. options: ITexturePackerOptions;
  60251. /** The promise that is started upon initialization */
  60252. promise: Nullable<Promise<TexturePacker | string>>;
  60253. /** The Container object for the channel sets that are generated */
  60254. sets: object;
  60255. /** The Container array for the frames that are generated */
  60256. frames: TexturePackerFrame[];
  60257. /** The expected number of textures the system is parsing. */
  60258. private _expecting;
  60259. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60260. private _paddingValue;
  60261. /**
  60262. * Initializes a texture package series from an array of meshes or a single mesh.
  60263. * @param name The name of the package
  60264. * @param meshes The target meshes to compose the package from
  60265. * @param options The arguments that texture packer should follow while building.
  60266. * @param scene The scene which the textures are scoped to.
  60267. * @returns TexturePacker
  60268. */
  60269. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60270. /**
  60271. * Starts the package process
  60272. * @param resolve The promises resolution function
  60273. * @returns TexturePacker
  60274. */
  60275. private _createFrames;
  60276. /**
  60277. * Calculates the Size of the Channel Sets
  60278. * @returns Vector2
  60279. */
  60280. private _calculateSize;
  60281. /**
  60282. * Calculates the UV data for the frames.
  60283. * @param baseSize the base frameSize
  60284. * @param padding the base frame padding
  60285. * @param dtSize size of the Dynamic Texture for that channel
  60286. * @param dtUnits is 1/dtSize
  60287. * @param update flag to update the input meshes
  60288. */
  60289. private _calculateMeshUVFrames;
  60290. /**
  60291. * Calculates the frames Offset.
  60292. * @param index of the frame
  60293. * @returns Vector2
  60294. */
  60295. private _getFrameOffset;
  60296. /**
  60297. * Updates a Mesh to the frame data
  60298. * @param mesh that is the target
  60299. * @param frameID or the frame index
  60300. */
  60301. private _updateMeshUV;
  60302. /**
  60303. * Updates a Meshes materials to use the texture packer channels
  60304. * @param m is the mesh to target
  60305. * @param force all channels on the packer to be set.
  60306. */
  60307. private _updateTextureReferences;
  60308. /**
  60309. * Public method to set a Mesh to a frame
  60310. * @param m that is the target
  60311. * @param frameID or the frame index
  60312. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60313. */
  60314. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60315. /**
  60316. * Starts the async promise to compile the texture packer.
  60317. * @returns Promise<void>
  60318. */
  60319. processAsync(): Promise<void>;
  60320. /**
  60321. * Disposes all textures associated with this packer
  60322. */
  60323. dispose(): void;
  60324. /**
  60325. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60326. * @param imageType is the image type to use.
  60327. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60328. */
  60329. download(imageType?: string, quality?: number): void;
  60330. /**
  60331. * Public method to load a texturePacker JSON file.
  60332. * @param data of the JSON file in string format.
  60333. */
  60334. updateFromJSON(data: string): void;
  60335. }
  60336. }
  60337. declare module BABYLON {
  60338. /**
  60339. * 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.
  60340. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60341. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60342. */
  60343. export class CustomProceduralTexture extends ProceduralTexture {
  60344. private _animate;
  60345. private _time;
  60346. private _config;
  60347. private _texturePath;
  60348. /**
  60349. * Instantiates a new Custom Procedural Texture.
  60350. * 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.
  60351. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60352. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60353. * @param name Define the name of the texture
  60354. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60355. * @param size Define the size of the texture to create
  60356. * @param scene Define the scene the texture belongs to
  60357. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60358. * @param generateMipMaps Define if the texture should creates mip maps or not
  60359. */
  60360. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60361. private _loadJson;
  60362. /**
  60363. * Is the texture ready to be used ? (rendered at least once)
  60364. * @returns true if ready, otherwise, false.
  60365. */
  60366. isReady(): boolean;
  60367. /**
  60368. * Render the texture to its associated render target.
  60369. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60370. */
  60371. render(useCameraPostProcess?: boolean): void;
  60372. /**
  60373. * Update the list of dependant textures samplers in the shader.
  60374. */
  60375. updateTextures(): void;
  60376. /**
  60377. * Update the uniform values of the procedural texture in the shader.
  60378. */
  60379. updateShaderUniforms(): void;
  60380. /**
  60381. * Define if the texture animates or not.
  60382. */
  60383. get animate(): boolean;
  60384. set animate(value: boolean);
  60385. }
  60386. }
  60387. declare module BABYLON {
  60388. /** @hidden */
  60389. export var noisePixelShader: {
  60390. name: string;
  60391. shader: string;
  60392. };
  60393. }
  60394. declare module BABYLON {
  60395. /**
  60396. * Class used to generate noise procedural textures
  60397. */
  60398. export class NoiseProceduralTexture extends ProceduralTexture {
  60399. private _time;
  60400. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60401. brightness: number;
  60402. /** Defines the number of octaves to process */
  60403. octaves: number;
  60404. /** Defines the level of persistence (0.8 by default) */
  60405. persistence: number;
  60406. /** Gets or sets animation speed factor (default is 1) */
  60407. animationSpeedFactor: number;
  60408. /**
  60409. * Creates a new NoiseProceduralTexture
  60410. * @param name defines the name fo the texture
  60411. * @param size defines the size of the texture (default is 256)
  60412. * @param scene defines the hosting scene
  60413. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60414. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60415. */
  60416. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60417. private _updateShaderUniforms;
  60418. protected _getDefines(): string;
  60419. /** Generate the current state of the procedural texture */
  60420. render(useCameraPostProcess?: boolean): void;
  60421. /**
  60422. * Serializes this noise procedural texture
  60423. * @returns a serialized noise procedural texture object
  60424. */
  60425. serialize(): any;
  60426. /**
  60427. * Clone the texture.
  60428. * @returns the cloned texture
  60429. */
  60430. clone(): NoiseProceduralTexture;
  60431. /**
  60432. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60433. * @param parsedTexture defines parsed texture data
  60434. * @param scene defines the current scene
  60435. * @param rootUrl defines the root URL containing noise procedural texture information
  60436. * @returns a parsed NoiseProceduralTexture
  60437. */
  60438. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60439. }
  60440. }
  60441. declare module BABYLON {
  60442. /**
  60443. * Raw cube texture where the raw buffers are passed in
  60444. */
  60445. export class RawCubeTexture extends CubeTexture {
  60446. /**
  60447. * Creates a cube texture where the raw buffers are passed in.
  60448. * @param scene defines the scene the texture is attached to
  60449. * @param data defines the array of data to use to create each face
  60450. * @param size defines the size of the textures
  60451. * @param format defines the format of the data
  60452. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60453. * @param generateMipMaps defines if the engine should generate the mip levels
  60454. * @param invertY defines if data must be stored with Y axis inverted
  60455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60456. * @param compression defines the compression used (null by default)
  60457. */
  60458. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60459. /**
  60460. * Updates the raw cube texture.
  60461. * @param data defines the data to store
  60462. * @param format defines the data format
  60463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60464. * @param invertY defines if data must be stored with Y axis inverted
  60465. * @param compression defines the compression used (null by default)
  60466. * @param level defines which level of the texture to update
  60467. */
  60468. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60469. /**
  60470. * Updates a raw cube texture with RGBD encoded data.
  60471. * @param data defines the array of data [mipmap][face] to use to create each face
  60472. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60473. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60474. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60475. * @returns a promsie that resolves when the operation is complete
  60476. */
  60477. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60478. /**
  60479. * Clones the raw cube texture.
  60480. * @return a new cube texture
  60481. */
  60482. clone(): CubeTexture;
  60483. /** @hidden */
  60484. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60485. }
  60486. }
  60487. declare module BABYLON {
  60488. /**
  60489. * Class used to store 2D array textures containing user data
  60490. */
  60491. export class RawTexture2DArray extends Texture {
  60492. /** Gets or sets the texture format to use */
  60493. format: number;
  60494. /**
  60495. * Create a new RawTexture2DArray
  60496. * @param data defines the data of the texture
  60497. * @param width defines the width of the texture
  60498. * @param height defines the height of the texture
  60499. * @param depth defines the number of layers of the texture
  60500. * @param format defines the texture format to use
  60501. * @param scene defines the hosting scene
  60502. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60503. * @param invertY defines if texture must be stored with Y axis inverted
  60504. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60505. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60506. */
  60507. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60508. /** Gets or sets the texture format to use */
  60509. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60510. /**
  60511. * Update the texture with new data
  60512. * @param data defines the data to store in the texture
  60513. */
  60514. update(data: ArrayBufferView): void;
  60515. }
  60516. }
  60517. declare module BABYLON {
  60518. /**
  60519. * Class used to store 3D textures containing user data
  60520. */
  60521. export class RawTexture3D extends Texture {
  60522. /** Gets or sets the texture format to use */
  60523. format: number;
  60524. /**
  60525. * Create a new RawTexture3D
  60526. * @param data defines the data of the texture
  60527. * @param width defines the width of the texture
  60528. * @param height defines the height of the texture
  60529. * @param depth defines the depth of the texture
  60530. * @param format defines the texture format to use
  60531. * @param scene defines the hosting scene
  60532. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60533. * @param invertY defines if texture must be stored with Y axis inverted
  60534. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60536. */
  60537. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60538. /** Gets or sets the texture format to use */
  60539. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60540. /**
  60541. * Update the texture with new data
  60542. * @param data defines the data to store in the texture
  60543. */
  60544. update(data: ArrayBufferView): void;
  60545. }
  60546. }
  60547. declare module BABYLON {
  60548. /**
  60549. * Creates a refraction texture used by refraction channel of the standard material.
  60550. * It is like a mirror but to see through a material.
  60551. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60552. */
  60553. export class RefractionTexture extends RenderTargetTexture {
  60554. /**
  60555. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60556. * 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.
  60557. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60558. */
  60559. refractionPlane: Plane;
  60560. /**
  60561. * Define how deep under the surface we should see.
  60562. */
  60563. depth: number;
  60564. /**
  60565. * Creates a refraction texture used by refraction channel of the standard material.
  60566. * It is like a mirror but to see through a material.
  60567. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60568. * @param name Define the texture name
  60569. * @param size Define the size of the underlying texture
  60570. * @param scene Define the scene the refraction belongs to
  60571. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60572. */
  60573. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60574. /**
  60575. * Clone the refraction texture.
  60576. * @returns the cloned texture
  60577. */
  60578. clone(): RefractionTexture;
  60579. /**
  60580. * Serialize the texture to a JSON representation you could use in Parse later on
  60581. * @returns the serialized JSON representation
  60582. */
  60583. serialize(): any;
  60584. }
  60585. }
  60586. declare module BABYLON {
  60587. /**
  60588. * Block used to add support for vertex skinning (bones)
  60589. */
  60590. export class BonesBlock extends NodeMaterialBlock {
  60591. /**
  60592. * Creates a new BonesBlock
  60593. * @param name defines the block name
  60594. */
  60595. constructor(name: string);
  60596. /**
  60597. * Initialize the block and prepare the context for build
  60598. * @param state defines the state that will be used for the build
  60599. */
  60600. initialize(state: NodeMaterialBuildState): void;
  60601. /**
  60602. * Gets the current class name
  60603. * @returns the class name
  60604. */
  60605. getClassName(): string;
  60606. /**
  60607. * Gets the matrix indices input component
  60608. */
  60609. get matricesIndices(): NodeMaterialConnectionPoint;
  60610. /**
  60611. * Gets the matrix weights input component
  60612. */
  60613. get matricesWeights(): NodeMaterialConnectionPoint;
  60614. /**
  60615. * Gets the extra matrix indices input component
  60616. */
  60617. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60618. /**
  60619. * Gets the extra matrix weights input component
  60620. */
  60621. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60622. /**
  60623. * Gets the world input component
  60624. */
  60625. get world(): NodeMaterialConnectionPoint;
  60626. /**
  60627. * Gets the output component
  60628. */
  60629. get output(): NodeMaterialConnectionPoint;
  60630. autoConfigure(material: NodeMaterial): void;
  60631. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60634. protected _buildBlock(state: NodeMaterialBuildState): this;
  60635. }
  60636. }
  60637. declare module BABYLON {
  60638. /**
  60639. * Block used to add support for instances
  60640. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60641. */
  60642. export class InstancesBlock extends NodeMaterialBlock {
  60643. /**
  60644. * Creates a new InstancesBlock
  60645. * @param name defines the block name
  60646. */
  60647. constructor(name: string);
  60648. /**
  60649. * Gets the current class name
  60650. * @returns the class name
  60651. */
  60652. getClassName(): string;
  60653. /**
  60654. * Gets the first world row input component
  60655. */
  60656. get world0(): NodeMaterialConnectionPoint;
  60657. /**
  60658. * Gets the second world row input component
  60659. */
  60660. get world1(): NodeMaterialConnectionPoint;
  60661. /**
  60662. * Gets the third world row input component
  60663. */
  60664. get world2(): NodeMaterialConnectionPoint;
  60665. /**
  60666. * Gets the forth world row input component
  60667. */
  60668. get world3(): NodeMaterialConnectionPoint;
  60669. /**
  60670. * Gets the world input component
  60671. */
  60672. get world(): NodeMaterialConnectionPoint;
  60673. /**
  60674. * Gets the output component
  60675. */
  60676. get output(): NodeMaterialConnectionPoint;
  60677. /**
  60678. * Gets the isntanceID component
  60679. */
  60680. get instanceID(): NodeMaterialConnectionPoint;
  60681. autoConfigure(material: NodeMaterial): void;
  60682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60683. protected _buildBlock(state: NodeMaterialBuildState): this;
  60684. }
  60685. }
  60686. declare module BABYLON {
  60687. /**
  60688. * Block used to add morph targets support to vertex shader
  60689. */
  60690. export class MorphTargetsBlock extends NodeMaterialBlock {
  60691. private _repeatableContentAnchor;
  60692. /**
  60693. * Create a new MorphTargetsBlock
  60694. * @param name defines the block name
  60695. */
  60696. constructor(name: string);
  60697. /**
  60698. * Gets the current class name
  60699. * @returns the class name
  60700. */
  60701. getClassName(): string;
  60702. /**
  60703. * Gets the position input component
  60704. */
  60705. get position(): NodeMaterialConnectionPoint;
  60706. /**
  60707. * Gets the normal input component
  60708. */
  60709. get normal(): NodeMaterialConnectionPoint;
  60710. /**
  60711. * Gets the tangent input component
  60712. */
  60713. get tangent(): NodeMaterialConnectionPoint;
  60714. /**
  60715. * Gets the tangent input component
  60716. */
  60717. get uv(): NodeMaterialConnectionPoint;
  60718. /**
  60719. * Gets the position output component
  60720. */
  60721. get positionOutput(): NodeMaterialConnectionPoint;
  60722. /**
  60723. * Gets the normal output component
  60724. */
  60725. get normalOutput(): NodeMaterialConnectionPoint;
  60726. /**
  60727. * Gets the tangent output component
  60728. */
  60729. get tangentOutput(): NodeMaterialConnectionPoint;
  60730. /**
  60731. * Gets the tangent output component
  60732. */
  60733. get uvOutput(): NodeMaterialConnectionPoint;
  60734. initialize(state: NodeMaterialBuildState): void;
  60735. autoConfigure(material: NodeMaterial): void;
  60736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60738. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60739. protected _buildBlock(state: NodeMaterialBuildState): this;
  60740. }
  60741. }
  60742. declare module BABYLON {
  60743. /**
  60744. * Block used to get data information from a light
  60745. */
  60746. export class LightInformationBlock extends NodeMaterialBlock {
  60747. private _lightDataUniformName;
  60748. private _lightColorUniformName;
  60749. private _lightTypeDefineName;
  60750. /**
  60751. * Gets or sets the light associated with this block
  60752. */
  60753. light: Nullable<Light>;
  60754. /**
  60755. * Creates a new LightInformationBlock
  60756. * @param name defines the block name
  60757. */
  60758. constructor(name: string);
  60759. /**
  60760. * Gets the current class name
  60761. * @returns the class name
  60762. */
  60763. getClassName(): string;
  60764. /**
  60765. * Gets the world position input component
  60766. */
  60767. get worldPosition(): NodeMaterialConnectionPoint;
  60768. /**
  60769. * Gets the direction output component
  60770. */
  60771. get direction(): NodeMaterialConnectionPoint;
  60772. /**
  60773. * Gets the direction output component
  60774. */
  60775. get color(): NodeMaterialConnectionPoint;
  60776. /**
  60777. * Gets the direction output component
  60778. */
  60779. get intensity(): NodeMaterialConnectionPoint;
  60780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60782. protected _buildBlock(state: NodeMaterialBuildState): this;
  60783. serialize(): any;
  60784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60785. }
  60786. }
  60787. declare module BABYLON {
  60788. /**
  60789. * Block used to add image processing support to fragment shader
  60790. */
  60791. export class ImageProcessingBlock extends NodeMaterialBlock {
  60792. /**
  60793. * Create a new ImageProcessingBlock
  60794. * @param name defines the block name
  60795. */
  60796. constructor(name: string);
  60797. /**
  60798. * Gets the current class name
  60799. * @returns the class name
  60800. */
  60801. getClassName(): string;
  60802. /**
  60803. * Gets the color input component
  60804. */
  60805. get color(): NodeMaterialConnectionPoint;
  60806. /**
  60807. * Gets the output component
  60808. */
  60809. get output(): NodeMaterialConnectionPoint;
  60810. /**
  60811. * Initialize the block and prepare the context for build
  60812. * @param state defines the state that will be used for the build
  60813. */
  60814. initialize(state: NodeMaterialBuildState): void;
  60815. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60818. protected _buildBlock(state: NodeMaterialBuildState): this;
  60819. }
  60820. }
  60821. declare module BABYLON {
  60822. /**
  60823. * Block used to pertub normals based on a normal map
  60824. */
  60825. export class PerturbNormalBlock extends NodeMaterialBlock {
  60826. private _tangentSpaceParameterName;
  60827. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60828. invertX: boolean;
  60829. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60830. invertY: boolean;
  60831. /**
  60832. * Create a new PerturbNormalBlock
  60833. * @param name defines the block name
  60834. */
  60835. constructor(name: string);
  60836. /**
  60837. * Gets the current class name
  60838. * @returns the class name
  60839. */
  60840. getClassName(): string;
  60841. /**
  60842. * Gets the world position input component
  60843. */
  60844. get worldPosition(): NodeMaterialConnectionPoint;
  60845. /**
  60846. * Gets the world normal input component
  60847. */
  60848. get worldNormal(): NodeMaterialConnectionPoint;
  60849. /**
  60850. * Gets the world tangent input component
  60851. */
  60852. get worldTangent(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the uv input component
  60855. */
  60856. get uv(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the normal map color input component
  60859. */
  60860. get normalMapColor(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the strength input component
  60863. */
  60864. get strength(): NodeMaterialConnectionPoint;
  60865. /**
  60866. * Gets the output component
  60867. */
  60868. get output(): NodeMaterialConnectionPoint;
  60869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60870. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60871. autoConfigure(material: NodeMaterial): void;
  60872. protected _buildBlock(state: NodeMaterialBuildState): this;
  60873. protected _dumpPropertiesCode(): string;
  60874. serialize(): any;
  60875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60876. }
  60877. }
  60878. declare module BABYLON {
  60879. /**
  60880. * Block used to discard a pixel if a value is smaller than a cutoff
  60881. */
  60882. export class DiscardBlock extends NodeMaterialBlock {
  60883. /**
  60884. * Create a new DiscardBlock
  60885. * @param name defines the block name
  60886. */
  60887. constructor(name: string);
  60888. /**
  60889. * Gets the current class name
  60890. * @returns the class name
  60891. */
  60892. getClassName(): string;
  60893. /**
  60894. * Gets the color input component
  60895. */
  60896. get value(): NodeMaterialConnectionPoint;
  60897. /**
  60898. * Gets the cutoff input component
  60899. */
  60900. get cutoff(): NodeMaterialConnectionPoint;
  60901. protected _buildBlock(state: NodeMaterialBuildState): this;
  60902. }
  60903. }
  60904. declare module BABYLON {
  60905. /**
  60906. * Block used to test if the fragment shader is front facing
  60907. */
  60908. export class FrontFacingBlock extends NodeMaterialBlock {
  60909. /**
  60910. * Creates a new FrontFacingBlock
  60911. * @param name defines the block name
  60912. */
  60913. constructor(name: string);
  60914. /**
  60915. * Gets the current class name
  60916. * @returns the class name
  60917. */
  60918. getClassName(): string;
  60919. /**
  60920. * Gets the output component
  60921. */
  60922. get output(): NodeMaterialConnectionPoint;
  60923. protected _buildBlock(state: NodeMaterialBuildState): this;
  60924. }
  60925. }
  60926. declare module BABYLON {
  60927. /**
  60928. * Block used to get the derivative value on x and y of a given input
  60929. */
  60930. export class DerivativeBlock extends NodeMaterialBlock {
  60931. /**
  60932. * Create a new DerivativeBlock
  60933. * @param name defines the block name
  60934. */
  60935. constructor(name: string);
  60936. /**
  60937. * Gets the current class name
  60938. * @returns the class name
  60939. */
  60940. getClassName(): string;
  60941. /**
  60942. * Gets the input component
  60943. */
  60944. get input(): NodeMaterialConnectionPoint;
  60945. /**
  60946. * Gets the derivative output on x
  60947. */
  60948. get dx(): NodeMaterialConnectionPoint;
  60949. /**
  60950. * Gets the derivative output on y
  60951. */
  60952. get dy(): NodeMaterialConnectionPoint;
  60953. protected _buildBlock(state: NodeMaterialBuildState): this;
  60954. }
  60955. }
  60956. declare module BABYLON {
  60957. /**
  60958. * Block used to add support for scene fog
  60959. */
  60960. export class FogBlock extends NodeMaterialBlock {
  60961. private _fogDistanceName;
  60962. private _fogParameters;
  60963. /**
  60964. * Create a new FogBlock
  60965. * @param name defines the block name
  60966. */
  60967. constructor(name: string);
  60968. /**
  60969. * Gets the current class name
  60970. * @returns the class name
  60971. */
  60972. getClassName(): string;
  60973. /**
  60974. * Gets the world position input component
  60975. */
  60976. get worldPosition(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the view input component
  60979. */
  60980. get view(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the color input component
  60983. */
  60984. get input(): NodeMaterialConnectionPoint;
  60985. /**
  60986. * Gets the fog color input component
  60987. */
  60988. get fogColor(): NodeMaterialConnectionPoint;
  60989. /**
  60990. * Gets the output component
  60991. */
  60992. get output(): NodeMaterialConnectionPoint;
  60993. autoConfigure(material: NodeMaterial): void;
  60994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60996. protected _buildBlock(state: NodeMaterialBuildState): this;
  60997. }
  60998. }
  60999. declare module BABYLON {
  61000. /**
  61001. * Block used to add light in the fragment shader
  61002. */
  61003. export class LightBlock extends NodeMaterialBlock {
  61004. private _lightId;
  61005. /**
  61006. * Gets or sets the light associated with this block
  61007. */
  61008. light: Nullable<Light>;
  61009. /**
  61010. * Create a new LightBlock
  61011. * @param name defines the block name
  61012. */
  61013. constructor(name: string);
  61014. /**
  61015. * Gets the current class name
  61016. * @returns the class name
  61017. */
  61018. getClassName(): string;
  61019. /**
  61020. * Gets the world position input component
  61021. */
  61022. get worldPosition(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the world normal input component
  61025. */
  61026. get worldNormal(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the camera (or eye) position component
  61029. */
  61030. get cameraPosition(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the glossiness component
  61033. */
  61034. get glossiness(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the glossinness power component
  61037. */
  61038. get glossPower(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the diffuse color component
  61041. */
  61042. get diffuseColor(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the specular color component
  61045. */
  61046. get specularColor(): NodeMaterialConnectionPoint;
  61047. /**
  61048. * Gets the diffuse output component
  61049. */
  61050. get diffuseOutput(): NodeMaterialConnectionPoint;
  61051. /**
  61052. * Gets the specular output component
  61053. */
  61054. get specularOutput(): NodeMaterialConnectionPoint;
  61055. /**
  61056. * Gets the shadow output component
  61057. */
  61058. get shadow(): NodeMaterialConnectionPoint;
  61059. autoConfigure(material: NodeMaterial): void;
  61060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61061. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61063. private _injectVertexCode;
  61064. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61065. serialize(): any;
  61066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61067. }
  61068. }
  61069. declare module BABYLON {
  61070. /**
  61071. * Block used to read a reflection texture from a sampler
  61072. */
  61073. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61074. /**
  61075. * Create a new ReflectionTextureBlock
  61076. * @param name defines the block name
  61077. */
  61078. constructor(name: string);
  61079. /**
  61080. * Gets the current class name
  61081. * @returns the class name
  61082. */
  61083. getClassName(): string;
  61084. /**
  61085. * Gets the world position input component
  61086. */
  61087. get position(): NodeMaterialConnectionPoint;
  61088. /**
  61089. * Gets the world position input component
  61090. */
  61091. get worldPosition(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the world normal input component
  61094. */
  61095. get worldNormal(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Gets the world input component
  61098. */
  61099. get world(): NodeMaterialConnectionPoint;
  61100. /**
  61101. * Gets the camera (or eye) position component
  61102. */
  61103. get cameraPosition(): NodeMaterialConnectionPoint;
  61104. /**
  61105. * Gets the view input component
  61106. */
  61107. get view(): NodeMaterialConnectionPoint;
  61108. /**
  61109. * Gets the rgb output component
  61110. */
  61111. get rgb(): NodeMaterialConnectionPoint;
  61112. /**
  61113. * Gets the r output component
  61114. */
  61115. get r(): NodeMaterialConnectionPoint;
  61116. /**
  61117. * Gets the g output component
  61118. */
  61119. get g(): NodeMaterialConnectionPoint;
  61120. /**
  61121. * Gets the b output component
  61122. */
  61123. get b(): NodeMaterialConnectionPoint;
  61124. autoConfigure(material: NodeMaterial): void;
  61125. protected _buildBlock(state: NodeMaterialBuildState): this;
  61126. }
  61127. }
  61128. declare module BABYLON {
  61129. /**
  61130. * Block used to add 2 vectors
  61131. */
  61132. export class AddBlock extends NodeMaterialBlock {
  61133. /**
  61134. * Creates a new AddBlock
  61135. * @param name defines the block name
  61136. */
  61137. constructor(name: string);
  61138. /**
  61139. * Gets the current class name
  61140. * @returns the class name
  61141. */
  61142. getClassName(): string;
  61143. /**
  61144. * Gets the left operand input component
  61145. */
  61146. get left(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the right operand input component
  61149. */
  61150. get right(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the output component
  61153. */
  61154. get output(): NodeMaterialConnectionPoint;
  61155. protected _buildBlock(state: NodeMaterialBuildState): this;
  61156. }
  61157. }
  61158. declare module BABYLON {
  61159. /**
  61160. * Block used to scale a vector by a float
  61161. */
  61162. export class ScaleBlock extends NodeMaterialBlock {
  61163. /**
  61164. * Creates a new ScaleBlock
  61165. * @param name defines the block name
  61166. */
  61167. constructor(name: string);
  61168. /**
  61169. * Gets the current class name
  61170. * @returns the class name
  61171. */
  61172. getClassName(): string;
  61173. /**
  61174. * Gets the input component
  61175. */
  61176. get input(): NodeMaterialConnectionPoint;
  61177. /**
  61178. * Gets the factor input component
  61179. */
  61180. get factor(): NodeMaterialConnectionPoint;
  61181. /**
  61182. * Gets the output component
  61183. */
  61184. get output(): NodeMaterialConnectionPoint;
  61185. protected _buildBlock(state: NodeMaterialBuildState): this;
  61186. }
  61187. }
  61188. declare module BABYLON {
  61189. /**
  61190. * Block used to clamp a float
  61191. */
  61192. export class ClampBlock extends NodeMaterialBlock {
  61193. /** Gets or sets the minimum range */
  61194. minimum: number;
  61195. /** Gets or sets the maximum range */
  61196. maximum: number;
  61197. /**
  61198. * Creates a new ClampBlock
  61199. * @param name defines the block name
  61200. */
  61201. constructor(name: string);
  61202. /**
  61203. * Gets the current class name
  61204. * @returns the class name
  61205. */
  61206. getClassName(): string;
  61207. /**
  61208. * Gets the value input component
  61209. */
  61210. get value(): NodeMaterialConnectionPoint;
  61211. /**
  61212. * Gets the output component
  61213. */
  61214. get output(): NodeMaterialConnectionPoint;
  61215. protected _buildBlock(state: NodeMaterialBuildState): this;
  61216. protected _dumpPropertiesCode(): string;
  61217. serialize(): any;
  61218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61219. }
  61220. }
  61221. declare module BABYLON {
  61222. /**
  61223. * Block used to apply a cross product between 2 vectors
  61224. */
  61225. export class CrossBlock extends NodeMaterialBlock {
  61226. /**
  61227. * Creates a new CrossBlock
  61228. * @param name defines the block name
  61229. */
  61230. constructor(name: string);
  61231. /**
  61232. * Gets the current class name
  61233. * @returns the class name
  61234. */
  61235. getClassName(): string;
  61236. /**
  61237. * Gets the left operand input component
  61238. */
  61239. get left(): NodeMaterialConnectionPoint;
  61240. /**
  61241. * Gets the right operand input component
  61242. */
  61243. get right(): NodeMaterialConnectionPoint;
  61244. /**
  61245. * Gets the output component
  61246. */
  61247. get output(): NodeMaterialConnectionPoint;
  61248. protected _buildBlock(state: NodeMaterialBuildState): this;
  61249. }
  61250. }
  61251. declare module BABYLON {
  61252. /**
  61253. * Block used to apply a dot product between 2 vectors
  61254. */
  61255. export class DotBlock extends NodeMaterialBlock {
  61256. /**
  61257. * Creates a new DotBlock
  61258. * @param name defines the block name
  61259. */
  61260. constructor(name: string);
  61261. /**
  61262. * Gets the current class name
  61263. * @returns the class name
  61264. */
  61265. getClassName(): string;
  61266. /**
  61267. * Gets the left operand input component
  61268. */
  61269. get left(): NodeMaterialConnectionPoint;
  61270. /**
  61271. * Gets the right operand input component
  61272. */
  61273. get right(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the output component
  61276. */
  61277. get output(): NodeMaterialConnectionPoint;
  61278. protected _buildBlock(state: NodeMaterialBuildState): this;
  61279. }
  61280. }
  61281. declare module BABYLON {
  61282. /**
  61283. * Block used to normalize a vector
  61284. */
  61285. export class NormalizeBlock extends NodeMaterialBlock {
  61286. /**
  61287. * Creates a new NormalizeBlock
  61288. * @param name defines the block name
  61289. */
  61290. constructor(name: string);
  61291. /**
  61292. * Gets the current class name
  61293. * @returns the class name
  61294. */
  61295. getClassName(): string;
  61296. /**
  61297. * Gets the input component
  61298. */
  61299. get input(): NodeMaterialConnectionPoint;
  61300. /**
  61301. * Gets the output component
  61302. */
  61303. get output(): NodeMaterialConnectionPoint;
  61304. protected _buildBlock(state: NodeMaterialBuildState): this;
  61305. }
  61306. }
  61307. declare module BABYLON {
  61308. /**
  61309. * Operations supported by the Trigonometry block
  61310. */
  61311. export enum TrigonometryBlockOperations {
  61312. /** Cos */
  61313. Cos = 0,
  61314. /** Sin */
  61315. Sin = 1,
  61316. /** Abs */
  61317. Abs = 2,
  61318. /** Exp */
  61319. Exp = 3,
  61320. /** Exp2 */
  61321. Exp2 = 4,
  61322. /** Round */
  61323. Round = 5,
  61324. /** Floor */
  61325. Floor = 6,
  61326. /** Ceiling */
  61327. Ceiling = 7,
  61328. /** Square root */
  61329. Sqrt = 8,
  61330. /** Log */
  61331. Log = 9,
  61332. /** Tangent */
  61333. Tan = 10,
  61334. /** Arc tangent */
  61335. ArcTan = 11,
  61336. /** Arc cosinus */
  61337. ArcCos = 12,
  61338. /** Arc sinus */
  61339. ArcSin = 13,
  61340. /** Fraction */
  61341. Fract = 14,
  61342. /** Sign */
  61343. Sign = 15,
  61344. /** To radians (from degrees) */
  61345. Radians = 16,
  61346. /** To degrees (from radians) */
  61347. Degrees = 17
  61348. }
  61349. /**
  61350. * Block used to apply trigonometry operation to floats
  61351. */
  61352. export class TrigonometryBlock extends NodeMaterialBlock {
  61353. /**
  61354. * Gets or sets the operation applied by the block
  61355. */
  61356. operation: TrigonometryBlockOperations;
  61357. /**
  61358. * Creates a new TrigonometryBlock
  61359. * @param name defines the block name
  61360. */
  61361. constructor(name: string);
  61362. /**
  61363. * Gets the current class name
  61364. * @returns the class name
  61365. */
  61366. getClassName(): string;
  61367. /**
  61368. * Gets the input component
  61369. */
  61370. get input(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the output component
  61373. */
  61374. get output(): NodeMaterialConnectionPoint;
  61375. protected _buildBlock(state: NodeMaterialBuildState): this;
  61376. serialize(): any;
  61377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61378. protected _dumpPropertiesCode(): string;
  61379. }
  61380. }
  61381. declare module BABYLON {
  61382. /**
  61383. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61384. */
  61385. export class ColorMergerBlock extends NodeMaterialBlock {
  61386. /**
  61387. * Create a new ColorMergerBlock
  61388. * @param name defines the block name
  61389. */
  61390. constructor(name: string);
  61391. /**
  61392. * Gets the current class name
  61393. * @returns the class name
  61394. */
  61395. getClassName(): string;
  61396. /**
  61397. * Gets the rgb component (input)
  61398. */
  61399. get rgbIn(): NodeMaterialConnectionPoint;
  61400. /**
  61401. * Gets the r component (input)
  61402. */
  61403. get r(): NodeMaterialConnectionPoint;
  61404. /**
  61405. * Gets the g component (input)
  61406. */
  61407. get g(): NodeMaterialConnectionPoint;
  61408. /**
  61409. * Gets the b component (input)
  61410. */
  61411. get b(): NodeMaterialConnectionPoint;
  61412. /**
  61413. * Gets the a component (input)
  61414. */
  61415. get a(): NodeMaterialConnectionPoint;
  61416. /**
  61417. * Gets the rgba component (output)
  61418. */
  61419. get rgba(): NodeMaterialConnectionPoint;
  61420. /**
  61421. * Gets the rgb component (output)
  61422. */
  61423. get rgbOut(): NodeMaterialConnectionPoint;
  61424. /**
  61425. * Gets the rgb component (output)
  61426. * @deprecated Please use rgbOut instead.
  61427. */
  61428. get rgb(): NodeMaterialConnectionPoint;
  61429. protected _buildBlock(state: NodeMaterialBuildState): this;
  61430. }
  61431. }
  61432. declare module BABYLON {
  61433. /**
  61434. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61435. */
  61436. export class VectorSplitterBlock extends NodeMaterialBlock {
  61437. /**
  61438. * Create a new VectorSplitterBlock
  61439. * @param name defines the block name
  61440. */
  61441. constructor(name: string);
  61442. /**
  61443. * Gets the current class name
  61444. * @returns the class name
  61445. */
  61446. getClassName(): string;
  61447. /**
  61448. * Gets the xyzw component (input)
  61449. */
  61450. get xyzw(): NodeMaterialConnectionPoint;
  61451. /**
  61452. * Gets the xyz component (input)
  61453. */
  61454. get xyzIn(): NodeMaterialConnectionPoint;
  61455. /**
  61456. * Gets the xy component (input)
  61457. */
  61458. get xyIn(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the xyz component (output)
  61461. */
  61462. get xyzOut(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the xy component (output)
  61465. */
  61466. get xyOut(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the x component (output)
  61469. */
  61470. get x(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the y component (output)
  61473. */
  61474. get y(): NodeMaterialConnectionPoint;
  61475. /**
  61476. * Gets the z component (output)
  61477. */
  61478. get z(): NodeMaterialConnectionPoint;
  61479. /**
  61480. * Gets the w component (output)
  61481. */
  61482. get w(): NodeMaterialConnectionPoint;
  61483. protected _inputRename(name: string): string;
  61484. protected _outputRename(name: string): string;
  61485. protected _buildBlock(state: NodeMaterialBuildState): this;
  61486. }
  61487. }
  61488. declare module BABYLON {
  61489. /**
  61490. * Block used to lerp between 2 values
  61491. */
  61492. export class LerpBlock extends NodeMaterialBlock {
  61493. /**
  61494. * Creates a new LerpBlock
  61495. * @param name defines the block name
  61496. */
  61497. constructor(name: string);
  61498. /**
  61499. * Gets the current class name
  61500. * @returns the class name
  61501. */
  61502. getClassName(): string;
  61503. /**
  61504. * Gets the left operand input component
  61505. */
  61506. get left(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the right operand input component
  61509. */
  61510. get right(): NodeMaterialConnectionPoint;
  61511. /**
  61512. * Gets the gradient operand input component
  61513. */
  61514. get gradient(): NodeMaterialConnectionPoint;
  61515. /**
  61516. * Gets the output component
  61517. */
  61518. get output(): NodeMaterialConnectionPoint;
  61519. protected _buildBlock(state: NodeMaterialBuildState): this;
  61520. }
  61521. }
  61522. declare module BABYLON {
  61523. /**
  61524. * Block used to divide 2 vectors
  61525. */
  61526. export class DivideBlock extends NodeMaterialBlock {
  61527. /**
  61528. * Creates a new DivideBlock
  61529. * @param name defines the block name
  61530. */
  61531. constructor(name: string);
  61532. /**
  61533. * Gets the current class name
  61534. * @returns the class name
  61535. */
  61536. getClassName(): string;
  61537. /**
  61538. * Gets the left operand input component
  61539. */
  61540. get left(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Gets the right operand input component
  61543. */
  61544. get right(): NodeMaterialConnectionPoint;
  61545. /**
  61546. * Gets the output component
  61547. */
  61548. get output(): NodeMaterialConnectionPoint;
  61549. protected _buildBlock(state: NodeMaterialBuildState): this;
  61550. }
  61551. }
  61552. declare module BABYLON {
  61553. /**
  61554. * Block used to subtract 2 vectors
  61555. */
  61556. export class SubtractBlock extends NodeMaterialBlock {
  61557. /**
  61558. * Creates a new SubtractBlock
  61559. * @param name defines the block name
  61560. */
  61561. constructor(name: string);
  61562. /**
  61563. * Gets the current class name
  61564. * @returns the class name
  61565. */
  61566. getClassName(): string;
  61567. /**
  61568. * Gets the left operand input component
  61569. */
  61570. get left(): NodeMaterialConnectionPoint;
  61571. /**
  61572. * Gets the right operand input component
  61573. */
  61574. get right(): NodeMaterialConnectionPoint;
  61575. /**
  61576. * Gets the output component
  61577. */
  61578. get output(): NodeMaterialConnectionPoint;
  61579. protected _buildBlock(state: NodeMaterialBuildState): this;
  61580. }
  61581. }
  61582. declare module BABYLON {
  61583. /**
  61584. * Block used to step a value
  61585. */
  61586. export class StepBlock extends NodeMaterialBlock {
  61587. /**
  61588. * Creates a new StepBlock
  61589. * @param name defines the block name
  61590. */
  61591. constructor(name: string);
  61592. /**
  61593. * Gets the current class name
  61594. * @returns the class name
  61595. */
  61596. getClassName(): string;
  61597. /**
  61598. * Gets the value operand input component
  61599. */
  61600. get value(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the edge operand input component
  61603. */
  61604. get edge(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the output component
  61607. */
  61608. get output(): NodeMaterialConnectionPoint;
  61609. protected _buildBlock(state: NodeMaterialBuildState): this;
  61610. }
  61611. }
  61612. declare module BABYLON {
  61613. /**
  61614. * Block used to get the opposite (1 - x) of a value
  61615. */
  61616. export class OneMinusBlock extends NodeMaterialBlock {
  61617. /**
  61618. * Creates a new OneMinusBlock
  61619. * @param name defines the block name
  61620. */
  61621. constructor(name: string);
  61622. /**
  61623. * Gets the current class name
  61624. * @returns the class name
  61625. */
  61626. getClassName(): string;
  61627. /**
  61628. * Gets the input component
  61629. */
  61630. get input(): NodeMaterialConnectionPoint;
  61631. /**
  61632. * Gets the output component
  61633. */
  61634. get output(): NodeMaterialConnectionPoint;
  61635. protected _buildBlock(state: NodeMaterialBuildState): this;
  61636. }
  61637. }
  61638. declare module BABYLON {
  61639. /**
  61640. * Block used to get the view direction
  61641. */
  61642. export class ViewDirectionBlock extends NodeMaterialBlock {
  61643. /**
  61644. * Creates a new ViewDirectionBlock
  61645. * @param name defines the block name
  61646. */
  61647. constructor(name: string);
  61648. /**
  61649. * Gets the current class name
  61650. * @returns the class name
  61651. */
  61652. getClassName(): string;
  61653. /**
  61654. * Gets the world position component
  61655. */
  61656. get worldPosition(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the camera position component
  61659. */
  61660. get cameraPosition(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the output component
  61663. */
  61664. get output(): NodeMaterialConnectionPoint;
  61665. autoConfigure(material: NodeMaterial): void;
  61666. protected _buildBlock(state: NodeMaterialBuildState): this;
  61667. }
  61668. }
  61669. declare module BABYLON {
  61670. /**
  61671. * Block used to compute fresnel value
  61672. */
  61673. export class FresnelBlock extends NodeMaterialBlock {
  61674. /**
  61675. * Create a new FresnelBlock
  61676. * @param name defines the block name
  61677. */
  61678. constructor(name: string);
  61679. /**
  61680. * Gets the current class name
  61681. * @returns the class name
  61682. */
  61683. getClassName(): string;
  61684. /**
  61685. * Gets the world normal input component
  61686. */
  61687. get worldNormal(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the view direction input component
  61690. */
  61691. get viewDirection(): NodeMaterialConnectionPoint;
  61692. /**
  61693. * Gets the bias input component
  61694. */
  61695. get bias(): NodeMaterialConnectionPoint;
  61696. /**
  61697. * Gets the camera (or eye) position component
  61698. */
  61699. get power(): NodeMaterialConnectionPoint;
  61700. /**
  61701. * Gets the fresnel output component
  61702. */
  61703. get fresnel(): NodeMaterialConnectionPoint;
  61704. autoConfigure(material: NodeMaterial): void;
  61705. protected _buildBlock(state: NodeMaterialBuildState): this;
  61706. }
  61707. }
  61708. declare module BABYLON {
  61709. /**
  61710. * Block used to get the max of 2 values
  61711. */
  61712. export class MaxBlock extends NodeMaterialBlock {
  61713. /**
  61714. * Creates a new MaxBlock
  61715. * @param name defines the block name
  61716. */
  61717. constructor(name: string);
  61718. /**
  61719. * Gets the current class name
  61720. * @returns the class name
  61721. */
  61722. getClassName(): string;
  61723. /**
  61724. * Gets the left operand input component
  61725. */
  61726. get left(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the right operand input component
  61729. */
  61730. get right(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the output component
  61733. */
  61734. get output(): NodeMaterialConnectionPoint;
  61735. protected _buildBlock(state: NodeMaterialBuildState): this;
  61736. }
  61737. }
  61738. declare module BABYLON {
  61739. /**
  61740. * Block used to get the min of 2 values
  61741. */
  61742. export class MinBlock extends NodeMaterialBlock {
  61743. /**
  61744. * Creates a new MinBlock
  61745. * @param name defines the block name
  61746. */
  61747. constructor(name: string);
  61748. /**
  61749. * Gets the current class name
  61750. * @returns the class name
  61751. */
  61752. getClassName(): string;
  61753. /**
  61754. * Gets the left operand input component
  61755. */
  61756. get left(): NodeMaterialConnectionPoint;
  61757. /**
  61758. * Gets the right operand input component
  61759. */
  61760. get right(): NodeMaterialConnectionPoint;
  61761. /**
  61762. * Gets the output component
  61763. */
  61764. get output(): NodeMaterialConnectionPoint;
  61765. protected _buildBlock(state: NodeMaterialBuildState): this;
  61766. }
  61767. }
  61768. declare module BABYLON {
  61769. /**
  61770. * Block used to get the distance between 2 values
  61771. */
  61772. export class DistanceBlock extends NodeMaterialBlock {
  61773. /**
  61774. * Creates a new DistanceBlock
  61775. * @param name defines the block name
  61776. */
  61777. constructor(name: string);
  61778. /**
  61779. * Gets the current class name
  61780. * @returns the class name
  61781. */
  61782. getClassName(): string;
  61783. /**
  61784. * Gets the left operand input component
  61785. */
  61786. get left(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the right operand input component
  61789. */
  61790. get right(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the output component
  61793. */
  61794. get output(): NodeMaterialConnectionPoint;
  61795. protected _buildBlock(state: NodeMaterialBuildState): this;
  61796. }
  61797. }
  61798. declare module BABYLON {
  61799. /**
  61800. * Block used to get the length of a vector
  61801. */
  61802. export class LengthBlock extends NodeMaterialBlock {
  61803. /**
  61804. * Creates a new LengthBlock
  61805. * @param name defines the block name
  61806. */
  61807. constructor(name: string);
  61808. /**
  61809. * Gets the current class name
  61810. * @returns the class name
  61811. */
  61812. getClassName(): string;
  61813. /**
  61814. * Gets the value input component
  61815. */
  61816. get value(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the output component
  61819. */
  61820. get output(): NodeMaterialConnectionPoint;
  61821. protected _buildBlock(state: NodeMaterialBuildState): this;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Block used to get negative version of a value (i.e. x * -1)
  61827. */
  61828. export class NegateBlock extends NodeMaterialBlock {
  61829. /**
  61830. * Creates a new NegateBlock
  61831. * @param name defines the block name
  61832. */
  61833. constructor(name: string);
  61834. /**
  61835. * Gets the current class name
  61836. * @returns the class name
  61837. */
  61838. getClassName(): string;
  61839. /**
  61840. * Gets the value input component
  61841. */
  61842. get value(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the output component
  61845. */
  61846. get output(): NodeMaterialConnectionPoint;
  61847. protected _buildBlock(state: NodeMaterialBuildState): this;
  61848. }
  61849. }
  61850. declare module BABYLON {
  61851. /**
  61852. * Block used to get the value of the first parameter raised to the power of the second
  61853. */
  61854. export class PowBlock extends NodeMaterialBlock {
  61855. /**
  61856. * Creates a new PowBlock
  61857. * @param name defines the block name
  61858. */
  61859. constructor(name: string);
  61860. /**
  61861. * Gets the current class name
  61862. * @returns the class name
  61863. */
  61864. getClassName(): string;
  61865. /**
  61866. * Gets the value operand input component
  61867. */
  61868. get value(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the power operand input component
  61871. */
  61872. get power(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the output component
  61875. */
  61876. get output(): NodeMaterialConnectionPoint;
  61877. protected _buildBlock(state: NodeMaterialBuildState): this;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /**
  61882. * Block used to get a random number
  61883. */
  61884. export class RandomNumberBlock extends NodeMaterialBlock {
  61885. /**
  61886. * Creates a new RandomNumberBlock
  61887. * @param name defines the block name
  61888. */
  61889. constructor(name: string);
  61890. /**
  61891. * Gets the current class name
  61892. * @returns the class name
  61893. */
  61894. getClassName(): string;
  61895. /**
  61896. * Gets the seed input component
  61897. */
  61898. get seed(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the output component
  61901. */
  61902. get output(): NodeMaterialConnectionPoint;
  61903. protected _buildBlock(state: NodeMaterialBuildState): this;
  61904. }
  61905. }
  61906. declare module BABYLON {
  61907. /**
  61908. * Block used to compute arc tangent of 2 values
  61909. */
  61910. export class ArcTan2Block extends NodeMaterialBlock {
  61911. /**
  61912. * Creates a new ArcTan2Block
  61913. * @param name defines the block name
  61914. */
  61915. constructor(name: string);
  61916. /**
  61917. * Gets the current class name
  61918. * @returns the class name
  61919. */
  61920. getClassName(): string;
  61921. /**
  61922. * Gets the x operand input component
  61923. */
  61924. get x(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the y operand input component
  61927. */
  61928. get y(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the output component
  61931. */
  61932. get output(): NodeMaterialConnectionPoint;
  61933. protected _buildBlock(state: NodeMaterialBuildState): this;
  61934. }
  61935. }
  61936. declare module BABYLON {
  61937. /**
  61938. * Block used to smooth step a value
  61939. */
  61940. export class SmoothStepBlock extends NodeMaterialBlock {
  61941. /**
  61942. * Creates a new SmoothStepBlock
  61943. * @param name defines the block name
  61944. */
  61945. constructor(name: string);
  61946. /**
  61947. * Gets the current class name
  61948. * @returns the class name
  61949. */
  61950. getClassName(): string;
  61951. /**
  61952. * Gets the value operand input component
  61953. */
  61954. get value(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the first edge operand input component
  61957. */
  61958. get edge0(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the second edge operand input component
  61961. */
  61962. get edge1(): NodeMaterialConnectionPoint;
  61963. /**
  61964. * Gets the output component
  61965. */
  61966. get output(): NodeMaterialConnectionPoint;
  61967. protected _buildBlock(state: NodeMaterialBuildState): this;
  61968. }
  61969. }
  61970. declare module BABYLON {
  61971. /**
  61972. * Block used to get the reciprocal (1 / x) of a value
  61973. */
  61974. export class ReciprocalBlock extends NodeMaterialBlock {
  61975. /**
  61976. * Creates a new ReciprocalBlock
  61977. * @param name defines the block name
  61978. */
  61979. constructor(name: string);
  61980. /**
  61981. * Gets the current class name
  61982. * @returns the class name
  61983. */
  61984. getClassName(): string;
  61985. /**
  61986. * Gets the input component
  61987. */
  61988. get input(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the output component
  61991. */
  61992. get output(): NodeMaterialConnectionPoint;
  61993. protected _buildBlock(state: NodeMaterialBuildState): this;
  61994. }
  61995. }
  61996. declare module BABYLON {
  61997. /**
  61998. * Block used to replace a color by another one
  61999. */
  62000. export class ReplaceColorBlock extends NodeMaterialBlock {
  62001. /**
  62002. * Creates a new ReplaceColorBlock
  62003. * @param name defines the block name
  62004. */
  62005. constructor(name: string);
  62006. /**
  62007. * Gets the current class name
  62008. * @returns the class name
  62009. */
  62010. getClassName(): string;
  62011. /**
  62012. * Gets the value input component
  62013. */
  62014. get value(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the reference input component
  62017. */
  62018. get reference(): NodeMaterialConnectionPoint;
  62019. /**
  62020. * Gets the distance input component
  62021. */
  62022. get distance(): NodeMaterialConnectionPoint;
  62023. /**
  62024. * Gets the replacement input component
  62025. */
  62026. get replacement(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the output component
  62029. */
  62030. get output(): NodeMaterialConnectionPoint;
  62031. protected _buildBlock(state: NodeMaterialBuildState): this;
  62032. }
  62033. }
  62034. declare module BABYLON {
  62035. /**
  62036. * Block used to posterize a value
  62037. * @see https://en.wikipedia.org/wiki/Posterization
  62038. */
  62039. export class PosterizeBlock extends NodeMaterialBlock {
  62040. /**
  62041. * Creates a new PosterizeBlock
  62042. * @param name defines the block name
  62043. */
  62044. constructor(name: string);
  62045. /**
  62046. * Gets the current class name
  62047. * @returns the class name
  62048. */
  62049. getClassName(): string;
  62050. /**
  62051. * Gets the value input component
  62052. */
  62053. get value(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the steps input component
  62056. */
  62057. get steps(): NodeMaterialConnectionPoint;
  62058. /**
  62059. * Gets the output component
  62060. */
  62061. get output(): NodeMaterialConnectionPoint;
  62062. protected _buildBlock(state: NodeMaterialBuildState): this;
  62063. }
  62064. }
  62065. declare module BABYLON {
  62066. /**
  62067. * Operations supported by the Wave block
  62068. */
  62069. export enum WaveBlockKind {
  62070. /** SawTooth */
  62071. SawTooth = 0,
  62072. /** Square */
  62073. Square = 1,
  62074. /** Triangle */
  62075. Triangle = 2
  62076. }
  62077. /**
  62078. * Block used to apply wave operation to floats
  62079. */
  62080. export class WaveBlock extends NodeMaterialBlock {
  62081. /**
  62082. * Gets or sets the kibnd of wave to be applied by the block
  62083. */
  62084. kind: WaveBlockKind;
  62085. /**
  62086. * Creates a new WaveBlock
  62087. * @param name defines the block name
  62088. */
  62089. constructor(name: string);
  62090. /**
  62091. * Gets the current class name
  62092. * @returns the class name
  62093. */
  62094. getClassName(): string;
  62095. /**
  62096. * Gets the input component
  62097. */
  62098. get input(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the output component
  62101. */
  62102. get output(): NodeMaterialConnectionPoint;
  62103. protected _buildBlock(state: NodeMaterialBuildState): this;
  62104. serialize(): any;
  62105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62106. }
  62107. }
  62108. declare module BABYLON {
  62109. /**
  62110. * Class used to store a color step for the GradientBlock
  62111. */
  62112. export class GradientBlockColorStep {
  62113. /**
  62114. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62115. */
  62116. step: number;
  62117. /**
  62118. * Gets or sets the color associated with this step
  62119. */
  62120. color: Color3;
  62121. /**
  62122. * Creates a new GradientBlockColorStep
  62123. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62124. * @param color defines the color associated with this step
  62125. */
  62126. constructor(
  62127. /**
  62128. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62129. */
  62130. step: number,
  62131. /**
  62132. * Gets or sets the color associated with this step
  62133. */
  62134. color: Color3);
  62135. }
  62136. /**
  62137. * Block used to return a color from a gradient based on an input value between 0 and 1
  62138. */
  62139. export class GradientBlock extends NodeMaterialBlock {
  62140. /**
  62141. * Gets or sets the list of color steps
  62142. */
  62143. colorSteps: GradientBlockColorStep[];
  62144. /**
  62145. * Creates a new GradientBlock
  62146. * @param name defines the block name
  62147. */
  62148. constructor(name: string);
  62149. /**
  62150. * Gets the current class name
  62151. * @returns the class name
  62152. */
  62153. getClassName(): string;
  62154. /**
  62155. * Gets the gradient input component
  62156. */
  62157. get gradient(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the output component
  62160. */
  62161. get output(): NodeMaterialConnectionPoint;
  62162. private _writeColorConstant;
  62163. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62164. serialize(): any;
  62165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62166. protected _dumpPropertiesCode(): string;
  62167. }
  62168. }
  62169. declare module BABYLON {
  62170. /**
  62171. * Block used to normalize lerp between 2 values
  62172. */
  62173. export class NLerpBlock extends NodeMaterialBlock {
  62174. /**
  62175. * Creates a new NLerpBlock
  62176. * @param name defines the block name
  62177. */
  62178. constructor(name: string);
  62179. /**
  62180. * Gets the current class name
  62181. * @returns the class name
  62182. */
  62183. getClassName(): string;
  62184. /**
  62185. * Gets the left operand input component
  62186. */
  62187. get left(): NodeMaterialConnectionPoint;
  62188. /**
  62189. * Gets the right operand input component
  62190. */
  62191. get right(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the gradient operand input component
  62194. */
  62195. get gradient(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the output component
  62198. */
  62199. get output(): NodeMaterialConnectionPoint;
  62200. protected _buildBlock(state: NodeMaterialBuildState): this;
  62201. }
  62202. }
  62203. declare module BABYLON {
  62204. /**
  62205. * block used to Generate a Worley Noise 3D Noise Pattern
  62206. */
  62207. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62208. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62209. manhattanDistance: boolean;
  62210. /**
  62211. * Creates a new WorleyNoise3DBlock
  62212. * @param name defines the block name
  62213. */
  62214. constructor(name: string);
  62215. /**
  62216. * Gets the current class name
  62217. * @returns the class name
  62218. */
  62219. getClassName(): string;
  62220. /**
  62221. * Gets the seed input component
  62222. */
  62223. get seed(): NodeMaterialConnectionPoint;
  62224. /**
  62225. * Gets the jitter input component
  62226. */
  62227. get jitter(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the output component
  62230. */
  62231. get output(): NodeMaterialConnectionPoint;
  62232. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62233. /**
  62234. * Exposes the properties to the UI?
  62235. */
  62236. protected _dumpPropertiesCode(): string;
  62237. /**
  62238. * Exposes the properties to the Seralize?
  62239. */
  62240. serialize(): any;
  62241. /**
  62242. * Exposes the properties to the deseralize?
  62243. */
  62244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62245. }
  62246. }
  62247. declare module BABYLON {
  62248. /**
  62249. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62250. */
  62251. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62252. /**
  62253. * Creates a new SimplexPerlin3DBlock
  62254. * @param name defines the block name
  62255. */
  62256. constructor(name: string);
  62257. /**
  62258. * Gets the current class name
  62259. * @returns the class name
  62260. */
  62261. getClassName(): string;
  62262. /**
  62263. * Gets the seed operand input component
  62264. */
  62265. get seed(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the output component
  62268. */
  62269. get output(): NodeMaterialConnectionPoint;
  62270. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62271. }
  62272. }
  62273. declare module BABYLON {
  62274. /**
  62275. * Block used to blend normals
  62276. */
  62277. export class NormalBlendBlock extends NodeMaterialBlock {
  62278. /**
  62279. * Creates a new NormalBlendBlock
  62280. * @param name defines the block name
  62281. */
  62282. constructor(name: string);
  62283. /**
  62284. * Gets the current class name
  62285. * @returns the class name
  62286. */
  62287. getClassName(): string;
  62288. /**
  62289. * Gets the first input component
  62290. */
  62291. get normalMap0(): NodeMaterialConnectionPoint;
  62292. /**
  62293. * Gets the second input component
  62294. */
  62295. get normalMap1(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the output component
  62298. */
  62299. get output(): NodeMaterialConnectionPoint;
  62300. protected _buildBlock(state: NodeMaterialBuildState): this;
  62301. }
  62302. }
  62303. declare module BABYLON {
  62304. /**
  62305. * Block used to rotate a 2d vector by a given angle
  62306. */
  62307. export class Rotate2dBlock extends NodeMaterialBlock {
  62308. /**
  62309. * Creates a new Rotate2dBlock
  62310. * @param name defines the block name
  62311. */
  62312. constructor(name: string);
  62313. /**
  62314. * Gets the current class name
  62315. * @returns the class name
  62316. */
  62317. getClassName(): string;
  62318. /**
  62319. * Gets the input vector
  62320. */
  62321. get input(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the input angle
  62324. */
  62325. get angle(): NodeMaterialConnectionPoint;
  62326. /**
  62327. * Gets the output component
  62328. */
  62329. get output(): NodeMaterialConnectionPoint;
  62330. autoConfigure(material: NodeMaterial): void;
  62331. protected _buildBlock(state: NodeMaterialBuildState): this;
  62332. }
  62333. }
  62334. declare module BABYLON {
  62335. /**
  62336. * Block used to get the reflected vector from a direction and a normal
  62337. */
  62338. export class ReflectBlock extends NodeMaterialBlock {
  62339. /**
  62340. * Creates a new ReflectBlock
  62341. * @param name defines the block name
  62342. */
  62343. constructor(name: string);
  62344. /**
  62345. * Gets the current class name
  62346. * @returns the class name
  62347. */
  62348. getClassName(): string;
  62349. /**
  62350. * Gets the incident component
  62351. */
  62352. get incident(): NodeMaterialConnectionPoint;
  62353. /**
  62354. * Gets the normal component
  62355. */
  62356. get normal(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the output component
  62359. */
  62360. get output(): NodeMaterialConnectionPoint;
  62361. protected _buildBlock(state: NodeMaterialBuildState): this;
  62362. }
  62363. }
  62364. declare module BABYLON {
  62365. /**
  62366. * Block used to get the refracted vector from a direction and a normal
  62367. */
  62368. export class RefractBlock extends NodeMaterialBlock {
  62369. /**
  62370. * Creates a new RefractBlock
  62371. * @param name defines the block name
  62372. */
  62373. constructor(name: string);
  62374. /**
  62375. * Gets the current class name
  62376. * @returns the class name
  62377. */
  62378. getClassName(): string;
  62379. /**
  62380. * Gets the incident component
  62381. */
  62382. get incident(): NodeMaterialConnectionPoint;
  62383. /**
  62384. * Gets the normal component
  62385. */
  62386. get normal(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the index of refraction component
  62389. */
  62390. get ior(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the output component
  62393. */
  62394. get output(): NodeMaterialConnectionPoint;
  62395. protected _buildBlock(state: NodeMaterialBuildState): this;
  62396. }
  62397. }
  62398. declare module BABYLON {
  62399. /**
  62400. * Block used to desaturate a color
  62401. */
  62402. export class DesaturateBlock extends NodeMaterialBlock {
  62403. /**
  62404. * Creates a new DesaturateBlock
  62405. * @param name defines the block name
  62406. */
  62407. constructor(name: string);
  62408. /**
  62409. * Gets the current class name
  62410. * @returns the class name
  62411. */
  62412. getClassName(): string;
  62413. /**
  62414. * Gets the color operand input component
  62415. */
  62416. get color(): NodeMaterialConnectionPoint;
  62417. /**
  62418. * Gets the level operand input component
  62419. */
  62420. get level(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the output component
  62423. */
  62424. get output(): NodeMaterialConnectionPoint;
  62425. protected _buildBlock(state: NodeMaterialBuildState): this;
  62426. }
  62427. }
  62428. declare module BABYLON {
  62429. /**
  62430. * Block used to implement the ambient occlusion module of the PBR material
  62431. */
  62432. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62433. /**
  62434. * Create a new AmbientOcclusionBlock
  62435. * @param name defines the block name
  62436. */
  62437. constructor(name: string);
  62438. /**
  62439. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62440. */
  62441. useAmbientInGrayScale: boolean;
  62442. /**
  62443. * Initialize the block and prepare the context for build
  62444. * @param state defines the state that will be used for the build
  62445. */
  62446. initialize(state: NodeMaterialBuildState): void;
  62447. /**
  62448. * Gets the current class name
  62449. * @returns the class name
  62450. */
  62451. getClassName(): string;
  62452. /**
  62453. * Gets the texture input component
  62454. */
  62455. get texture(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the texture intensity component
  62458. */
  62459. get intensity(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the direct light intensity input component
  62462. */
  62463. get directLightIntensity(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the ambient occlusion object output component
  62466. */
  62467. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the main code of the block (fragment side)
  62470. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62471. * @returns the shader code
  62472. */
  62473. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62475. protected _buildBlock(state: NodeMaterialBuildState): this;
  62476. protected _dumpPropertiesCode(): string;
  62477. serialize(): any;
  62478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62479. }
  62480. }
  62481. declare module BABYLON {
  62482. /**
  62483. * Block used to implement the reflection module of the PBR material
  62484. */
  62485. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62486. /** @hidden */
  62487. _defineLODReflectionAlpha: string;
  62488. /** @hidden */
  62489. _defineLinearSpecularReflection: string;
  62490. private _vEnvironmentIrradianceName;
  62491. /** @hidden */
  62492. _vReflectionMicrosurfaceInfosName: string;
  62493. /** @hidden */
  62494. _vReflectionInfosName: string;
  62495. private _scene;
  62496. /**
  62497. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62498. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62499. * It's less burden on the user side in the editor part.
  62500. */
  62501. /** @hidden */
  62502. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62503. /** @hidden */
  62504. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62505. /** @hidden */
  62506. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62507. /**
  62508. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62509. * diffuse part of the IBL.
  62510. */
  62511. useSphericalHarmonics: boolean;
  62512. /**
  62513. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62514. */
  62515. forceIrradianceInFragment: boolean;
  62516. /**
  62517. * Create a new ReflectionBlock
  62518. * @param name defines the block name
  62519. */
  62520. constructor(name: string);
  62521. /**
  62522. * Gets the current class name
  62523. * @returns the class name
  62524. */
  62525. getClassName(): string;
  62526. /**
  62527. * Gets the position input component
  62528. */
  62529. get position(): NodeMaterialConnectionPoint;
  62530. /**
  62531. * Gets the world position input component
  62532. */
  62533. get worldPosition(): NodeMaterialConnectionPoint;
  62534. /**
  62535. * Gets the world normal input component
  62536. */
  62537. get worldNormal(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the world input component
  62540. */
  62541. get world(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the camera (or eye) position component
  62544. */
  62545. get cameraPosition(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the view input component
  62548. */
  62549. get view(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the color input component
  62552. */
  62553. get color(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the reflection object output component
  62556. */
  62557. get reflection(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62560. */
  62561. get hasTexture(): boolean;
  62562. /**
  62563. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62564. */
  62565. get reflectionColor(): string;
  62566. protected _getTexture(): Nullable<BaseTexture>;
  62567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62568. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62569. /**
  62570. * Gets the code to inject in the vertex shader
  62571. * @param state current state of the node material building
  62572. * @returns the shader code
  62573. */
  62574. handleVertexSide(state: NodeMaterialBuildState): string;
  62575. /**
  62576. * Gets the main code of the block (fragment side)
  62577. * @param state current state of the node material building
  62578. * @param normalVarName name of the existing variable corresponding to the normal
  62579. * @returns the shader code
  62580. */
  62581. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62582. protected _buildBlock(state: NodeMaterialBuildState): this;
  62583. protected _dumpPropertiesCode(): string;
  62584. serialize(): any;
  62585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62586. }
  62587. }
  62588. declare module BABYLON {
  62589. /**
  62590. * Block used to implement the sheen module of the PBR material
  62591. */
  62592. export class SheenBlock extends NodeMaterialBlock {
  62593. /**
  62594. * Create a new SheenBlock
  62595. * @param name defines the block name
  62596. */
  62597. constructor(name: string);
  62598. /**
  62599. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62600. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62601. * making it easier to setup and tweak the effect
  62602. */
  62603. albedoScaling: boolean;
  62604. /**
  62605. * Defines if the sheen is linked to the sheen color.
  62606. */
  62607. linkSheenWithAlbedo: boolean;
  62608. /**
  62609. * Initialize the block and prepare the context for build
  62610. * @param state defines the state that will be used for the build
  62611. */
  62612. initialize(state: NodeMaterialBuildState): void;
  62613. /**
  62614. * Gets the current class name
  62615. * @returns the class name
  62616. */
  62617. getClassName(): string;
  62618. /**
  62619. * Gets the intensity input component
  62620. */
  62621. get intensity(): NodeMaterialConnectionPoint;
  62622. /**
  62623. * Gets the color input component
  62624. */
  62625. get color(): NodeMaterialConnectionPoint;
  62626. /**
  62627. * Gets the roughness input component
  62628. */
  62629. get roughness(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the texture input component
  62632. */
  62633. get texture(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the sheen object output component
  62636. */
  62637. get sheen(): NodeMaterialConnectionPoint;
  62638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62639. /**
  62640. * Gets the main code of the block (fragment side)
  62641. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62642. * @returns the shader code
  62643. */
  62644. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62645. protected _buildBlock(state: NodeMaterialBuildState): this;
  62646. protected _dumpPropertiesCode(): string;
  62647. serialize(): any;
  62648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62649. }
  62650. }
  62651. declare module BABYLON {
  62652. /**
  62653. * Block used to implement the reflectivity module of the PBR material
  62654. */
  62655. export class ReflectivityBlock extends NodeMaterialBlock {
  62656. /**
  62657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62658. */
  62659. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62660. /**
  62661. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62662. */
  62663. useMetallnessFromMetallicTextureBlue: boolean;
  62664. /**
  62665. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62666. */
  62667. useRoughnessFromMetallicTextureAlpha: boolean;
  62668. /**
  62669. * Specifies if the metallic texture contains the roughness information in its green channel.
  62670. */
  62671. useRoughnessFromMetallicTextureGreen: boolean;
  62672. /**
  62673. * Create a new ReflectivityBlock
  62674. * @param name defines the block name
  62675. */
  62676. constructor(name: string);
  62677. /**
  62678. * Initialize the block and prepare the context for build
  62679. * @param state defines the state that will be used for the build
  62680. */
  62681. initialize(state: NodeMaterialBuildState): void;
  62682. /**
  62683. * Gets the current class name
  62684. * @returns the class name
  62685. */
  62686. getClassName(): string;
  62687. /**
  62688. * Gets the metallic input component
  62689. */
  62690. get metallic(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the roughness input component
  62693. */
  62694. get roughness(): NodeMaterialConnectionPoint;
  62695. /**
  62696. * Gets the texture input component
  62697. */
  62698. get texture(): NodeMaterialConnectionPoint;
  62699. /**
  62700. * Gets the reflectivity object output component
  62701. */
  62702. get reflectivity(): NodeMaterialConnectionPoint;
  62703. /**
  62704. * Gets the main code of the block (fragment side)
  62705. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62706. * @returns the shader code
  62707. */
  62708. getCode(aoIntensityVarName: string): string;
  62709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62710. protected _buildBlock(state: NodeMaterialBuildState): this;
  62711. protected _dumpPropertiesCode(): string;
  62712. serialize(): any;
  62713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62714. }
  62715. }
  62716. declare module BABYLON {
  62717. /**
  62718. * Block used to implement the anisotropy module of the PBR material
  62719. */
  62720. export class AnisotropyBlock extends NodeMaterialBlock {
  62721. /**
  62722. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62723. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62724. * It's less burden on the user side in the editor part.
  62725. */
  62726. /** @hidden */
  62727. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62728. /** @hidden */
  62729. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62730. /**
  62731. * Create a new AnisotropyBlock
  62732. * @param name defines the block name
  62733. */
  62734. constructor(name: string);
  62735. /**
  62736. * Initialize the block and prepare the context for build
  62737. * @param state defines the state that will be used for the build
  62738. */
  62739. initialize(state: NodeMaterialBuildState): void;
  62740. /**
  62741. * Gets the current class name
  62742. * @returns the class name
  62743. */
  62744. getClassName(): string;
  62745. /**
  62746. * Gets the intensity input component
  62747. */
  62748. get intensity(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the direction input component
  62751. */
  62752. get direction(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the texture input component
  62755. */
  62756. get texture(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the uv input component
  62759. */
  62760. get uv(): NodeMaterialConnectionPoint;
  62761. /**
  62762. * Gets the worldTangent input component
  62763. */
  62764. get worldTangent(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the anisotropy object output component
  62767. */
  62768. get anisotropy(): NodeMaterialConnectionPoint;
  62769. private _generateTBNSpace;
  62770. /**
  62771. * Gets the main code of the block (fragment side)
  62772. * @param state current state of the node material building
  62773. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62774. * @returns the shader code
  62775. */
  62776. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62778. protected _buildBlock(state: NodeMaterialBuildState): this;
  62779. }
  62780. }
  62781. declare module BABYLON {
  62782. /**
  62783. * Block used to implement the clear coat module of the PBR material
  62784. */
  62785. export class ClearCoatBlock extends NodeMaterialBlock {
  62786. private _scene;
  62787. /**
  62788. * Create a new ClearCoatBlock
  62789. * @param name defines the block name
  62790. */
  62791. constructor(name: string);
  62792. /**
  62793. * Initialize the block and prepare the context for build
  62794. * @param state defines the state that will be used for the build
  62795. */
  62796. initialize(state: NodeMaterialBuildState): void;
  62797. /**
  62798. * Gets the current class name
  62799. * @returns the class name
  62800. */
  62801. getClassName(): string;
  62802. /**
  62803. * Gets the intensity input component
  62804. */
  62805. get intensity(): NodeMaterialConnectionPoint;
  62806. /**
  62807. * Gets the roughness input component
  62808. */
  62809. get roughness(): NodeMaterialConnectionPoint;
  62810. /**
  62811. * Gets the ior input component
  62812. */
  62813. get ior(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the texture input component
  62816. */
  62817. get texture(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the bump texture input component
  62820. */
  62821. get bumpTexture(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the uv input component
  62824. */
  62825. get uv(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the tint color input component
  62828. */
  62829. get tintColor(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the tint "at distance" input component
  62832. */
  62833. get tintAtDistance(): NodeMaterialConnectionPoint;
  62834. /**
  62835. * Gets the tint thickness input component
  62836. */
  62837. get tintThickness(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the tint texture input component
  62840. */
  62841. get tintTexture(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the world tangent input component
  62844. */
  62845. get worldTangent(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the clear coat object output component
  62848. */
  62849. get clearcoat(): NodeMaterialConnectionPoint;
  62850. autoConfigure(material: NodeMaterial): void;
  62851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62853. private _generateTBNSpace;
  62854. /**
  62855. * Gets the main code of the block (fragment side)
  62856. * @param state current state of the node material building
  62857. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62858. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62859. * @param worldPosVarName name of the variable holding the world position
  62860. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62861. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62862. * @param worldNormalVarName name of the variable holding the world normal
  62863. * @returns the shader code
  62864. */
  62865. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62866. protected _buildBlock(state: NodeMaterialBuildState): this;
  62867. }
  62868. }
  62869. declare module BABYLON {
  62870. /**
  62871. * Block used to implement the sub surface module of the PBR material
  62872. */
  62873. export class SubSurfaceBlock extends NodeMaterialBlock {
  62874. /**
  62875. * Create a new SubSurfaceBlock
  62876. * @param name defines the block name
  62877. */
  62878. constructor(name: string);
  62879. /**
  62880. * Stores the intensity of the different subsurface effects in the thickness texture.
  62881. * * the green channel is the translucency intensity.
  62882. * * the blue channel is the scattering intensity.
  62883. * * the alpha channel is the refraction intensity.
  62884. */
  62885. useMaskFromThicknessTexture: boolean;
  62886. /**
  62887. * Initialize the block and prepare the context for build
  62888. * @param state defines the state that will be used for the build
  62889. */
  62890. initialize(state: NodeMaterialBuildState): void;
  62891. /**
  62892. * Gets the current class name
  62893. * @returns the class name
  62894. */
  62895. getClassName(): string;
  62896. /**
  62897. * Gets the min thickness input component
  62898. */
  62899. get minThickness(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the max thickness input component
  62902. */
  62903. get maxThickness(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the thickness texture component
  62906. */
  62907. get thicknessTexture(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the tint color input component
  62910. */
  62911. get tintColor(): NodeMaterialConnectionPoint;
  62912. /**
  62913. * Gets the translucency intensity input component
  62914. */
  62915. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62916. /**
  62917. * Gets the translucency diffusion distance input component
  62918. */
  62919. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62920. /**
  62921. * Gets the refraction object parameters
  62922. */
  62923. get refraction(): NodeMaterialConnectionPoint;
  62924. /**
  62925. * Gets the sub surface object output component
  62926. */
  62927. get subsurface(): NodeMaterialConnectionPoint;
  62928. autoConfigure(material: NodeMaterial): void;
  62929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62930. /**
  62931. * Gets the main code of the block (fragment side)
  62932. * @param state current state of the node material building
  62933. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62934. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62935. * @param worldPosVarName name of the variable holding the world position
  62936. * @returns the shader code
  62937. */
  62938. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62939. protected _buildBlock(state: NodeMaterialBuildState): this;
  62940. }
  62941. }
  62942. declare module BABYLON {
  62943. /**
  62944. * Block used to implement the PBR metallic/roughness model
  62945. */
  62946. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62947. /**
  62948. * Gets or sets the light associated with this block
  62949. */
  62950. light: Nullable<Light>;
  62951. private _lightId;
  62952. private _scene;
  62953. private _environmentBRDFTexture;
  62954. private _environmentBrdfSamplerName;
  62955. private _vNormalWName;
  62956. private _invertNormalName;
  62957. /**
  62958. * Create a new ReflectionBlock
  62959. * @param name defines the block name
  62960. */
  62961. constructor(name: string);
  62962. /**
  62963. * Intensity of the direct lights e.g. the four lights available in your scene.
  62964. * This impacts both the direct diffuse and specular highlights.
  62965. */
  62966. directIntensity: number;
  62967. /**
  62968. * Intensity of the environment e.g. how much the environment will light the object
  62969. * either through harmonics for rough material or through the refelction for shiny ones.
  62970. */
  62971. environmentIntensity: number;
  62972. /**
  62973. * This is a special control allowing the reduction of the specular highlights coming from the
  62974. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62975. */
  62976. specularIntensity: number;
  62977. /**
  62978. * Defines the falloff type used in this material.
  62979. * It by default is Physical.
  62980. */
  62981. lightFalloff: number;
  62982. /**
  62983. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62984. */
  62985. useAlphaFromAlbedoTexture: boolean;
  62986. /**
  62987. * Specifies that alpha test should be used
  62988. */
  62989. useAlphaTest: boolean;
  62990. /**
  62991. * Defines the alpha limits in alpha test mode.
  62992. */
  62993. alphaTestCutoff: number;
  62994. /**
  62995. * Specifies that alpha blending should be used
  62996. */
  62997. useAlphaBlending: boolean;
  62998. /**
  62999. * Defines if the alpha value should be determined via the rgb values.
  63000. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63001. */
  63002. opacityRGB: boolean;
  63003. /**
  63004. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63005. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63006. */
  63007. useRadianceOverAlpha: boolean;
  63008. /**
  63009. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63010. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63011. */
  63012. useSpecularOverAlpha: boolean;
  63013. /**
  63014. * Enables specular anti aliasing in the PBR shader.
  63015. * It will both interacts on the Geometry for analytical and IBL lighting.
  63016. * It also prefilter the roughness map based on the bump values.
  63017. */
  63018. enableSpecularAntiAliasing: boolean;
  63019. /**
  63020. * Defines if the material uses energy conservation.
  63021. */
  63022. useEnergyConservation: boolean;
  63023. /**
  63024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63025. * too much the area relying on ambient texture to define their ambient occlusion.
  63026. */
  63027. useRadianceOcclusion: boolean;
  63028. /**
  63029. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63030. * makes the reflect vector face the model (under horizon).
  63031. */
  63032. useHorizonOcclusion: boolean;
  63033. /**
  63034. * If set to true, no lighting calculations will be applied.
  63035. */
  63036. unlit: boolean;
  63037. /**
  63038. * Force normal to face away from face.
  63039. */
  63040. forceNormalForward: boolean;
  63041. /**
  63042. * Defines the material debug mode.
  63043. * It helps seeing only some components of the material while troubleshooting.
  63044. */
  63045. debugMode: number;
  63046. /**
  63047. * Specify from where on screen the debug mode should start.
  63048. * The value goes from -1 (full screen) to 1 (not visible)
  63049. * It helps with side by side comparison against the final render
  63050. * This defaults to 0
  63051. */
  63052. debugLimit: number;
  63053. /**
  63054. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63055. * You can use the factor to better multiply the final value.
  63056. */
  63057. debugFactor: number;
  63058. /**
  63059. * Initialize the block and prepare the context for build
  63060. * @param state defines the state that will be used for the build
  63061. */
  63062. initialize(state: NodeMaterialBuildState): void;
  63063. /**
  63064. * Gets the current class name
  63065. * @returns the class name
  63066. */
  63067. getClassName(): string;
  63068. /**
  63069. * Gets the world position input component
  63070. */
  63071. get worldPosition(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the world normal input component
  63074. */
  63075. get worldNormal(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the perturbed normal input component
  63078. */
  63079. get perturbedNormal(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the camera position input component
  63082. */
  63083. get cameraPosition(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the base color input component
  63086. */
  63087. get baseColor(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the base texture input component
  63090. */
  63091. get baseTexture(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the opacity texture input component
  63094. */
  63095. get opacityTexture(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the ambient color input component
  63098. */
  63099. get ambientColor(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the reflectivity object parameters
  63102. */
  63103. get reflectivity(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the ambient occlusion object parameters
  63106. */
  63107. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the reflection object parameters
  63110. */
  63111. get reflection(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the sheen object parameters
  63114. */
  63115. get sheen(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the clear coat object parameters
  63118. */
  63119. get clearcoat(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the sub surface object parameters
  63122. */
  63123. get subsurface(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the anisotropy object parameters
  63126. */
  63127. get anisotropy(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the ambient output component
  63130. */
  63131. get ambient(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the diffuse output component
  63134. */
  63135. get diffuse(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the specular output component
  63138. */
  63139. get specular(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the sheen output component
  63142. */
  63143. get sheenDir(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the clear coat output component
  63146. */
  63147. get clearcoatDir(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the indirect diffuse output component
  63150. */
  63151. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the indirect specular output component
  63154. */
  63155. get specularIndirect(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the indirect sheen output component
  63158. */
  63159. get sheenIndirect(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the indirect clear coat output component
  63162. */
  63163. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the refraction output component
  63166. */
  63167. get refraction(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the global lighting output component
  63170. */
  63171. get lighting(): NodeMaterialConnectionPoint;
  63172. /**
  63173. * Gets the shadow output component
  63174. */
  63175. get shadow(): NodeMaterialConnectionPoint;
  63176. /**
  63177. * Gets the alpha output component
  63178. */
  63179. get alpha(): NodeMaterialConnectionPoint;
  63180. autoConfigure(material: NodeMaterial): void;
  63181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63182. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63184. private _injectVertexCode;
  63185. /**
  63186. * Gets the code corresponding to the albedo/opacity module
  63187. * @returns the shader code
  63188. */
  63189. getAlbedoOpacityCode(): string;
  63190. protected _buildBlock(state: NodeMaterialBuildState): this;
  63191. protected _dumpPropertiesCode(): string;
  63192. serialize(): any;
  63193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63194. }
  63195. }
  63196. declare module BABYLON {
  63197. /**
  63198. * Block used to compute value of one parameter modulo another
  63199. */
  63200. export class ModBlock extends NodeMaterialBlock {
  63201. /**
  63202. * Creates a new ModBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the left operand input component
  63213. */
  63214. get left(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the right operand input component
  63217. */
  63218. get right(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the output component
  63221. */
  63222. get output(): NodeMaterialConnectionPoint;
  63223. protected _buildBlock(state: NodeMaterialBuildState): this;
  63224. }
  63225. }
  63226. declare module BABYLON {
  63227. /**
  63228. * Helper class to push actions to a pool of workers.
  63229. */
  63230. export class WorkerPool implements IDisposable {
  63231. private _workerInfos;
  63232. private _pendingActions;
  63233. /**
  63234. * Constructor
  63235. * @param workers Array of workers to use for actions
  63236. */
  63237. constructor(workers: Array<Worker>);
  63238. /**
  63239. * Terminates all workers and clears any pending actions.
  63240. */
  63241. dispose(): void;
  63242. /**
  63243. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63244. * pended until a worker has completed its action.
  63245. * @param action The action to perform. Call onComplete when the action is complete.
  63246. */
  63247. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63248. private _execute;
  63249. }
  63250. }
  63251. declare module BABYLON {
  63252. /**
  63253. * Configuration for Draco compression
  63254. */
  63255. export interface IDracoCompressionConfiguration {
  63256. /**
  63257. * Configuration for the decoder.
  63258. */
  63259. decoder: {
  63260. /**
  63261. * The url to the WebAssembly module.
  63262. */
  63263. wasmUrl?: string;
  63264. /**
  63265. * The url to the WebAssembly binary.
  63266. */
  63267. wasmBinaryUrl?: string;
  63268. /**
  63269. * The url to the fallback JavaScript module.
  63270. */
  63271. fallbackUrl?: string;
  63272. };
  63273. }
  63274. /**
  63275. * Draco compression (https://google.github.io/draco/)
  63276. *
  63277. * This class wraps the Draco module.
  63278. *
  63279. * **Encoder**
  63280. *
  63281. * The encoder is not currently implemented.
  63282. *
  63283. * **Decoder**
  63284. *
  63285. * 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.
  63286. *
  63287. * To update the configuration, use the following code:
  63288. * ```javascript
  63289. * DracoCompression.Configuration = {
  63290. * decoder: {
  63291. * wasmUrl: "<url to the WebAssembly library>",
  63292. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63293. * fallbackUrl: "<url to the fallback JavaScript library>",
  63294. * }
  63295. * };
  63296. * ```
  63297. *
  63298. * 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.
  63299. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63300. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63301. *
  63302. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63303. * ```javascript
  63304. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63305. * ```
  63306. *
  63307. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63308. */
  63309. export class DracoCompression implements IDisposable {
  63310. private _workerPoolPromise?;
  63311. private _decoderModulePromise?;
  63312. /**
  63313. * The configuration. Defaults to the following urls:
  63314. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63315. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63316. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63317. */
  63318. static Configuration: IDracoCompressionConfiguration;
  63319. /**
  63320. * Returns true if the decoder configuration is available.
  63321. */
  63322. static get DecoderAvailable(): boolean;
  63323. /**
  63324. * Default number of workers to create when creating the draco compression object.
  63325. */
  63326. static DefaultNumWorkers: number;
  63327. private static GetDefaultNumWorkers;
  63328. private static _Default;
  63329. /**
  63330. * Default instance for the draco compression object.
  63331. */
  63332. static get Default(): DracoCompression;
  63333. /**
  63334. * Constructor
  63335. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63336. */
  63337. constructor(numWorkers?: number);
  63338. /**
  63339. * Stop all async operations and release resources.
  63340. */
  63341. dispose(): void;
  63342. /**
  63343. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63344. * @returns a promise that resolves when ready
  63345. */
  63346. whenReadyAsync(): Promise<void>;
  63347. /**
  63348. * Decode Draco compressed mesh data to vertex data.
  63349. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63350. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63351. * @returns A promise that resolves with the decoded vertex data
  63352. */
  63353. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63354. [kind: string]: number;
  63355. }): Promise<VertexData>;
  63356. }
  63357. }
  63358. declare module BABYLON {
  63359. /**
  63360. * Class for building Constructive Solid Geometry
  63361. */
  63362. export class CSG {
  63363. private polygons;
  63364. /**
  63365. * The world matrix
  63366. */
  63367. matrix: Matrix;
  63368. /**
  63369. * Stores the position
  63370. */
  63371. position: Vector3;
  63372. /**
  63373. * Stores the rotation
  63374. */
  63375. rotation: Vector3;
  63376. /**
  63377. * Stores the rotation quaternion
  63378. */
  63379. rotationQuaternion: Nullable<Quaternion>;
  63380. /**
  63381. * Stores the scaling vector
  63382. */
  63383. scaling: Vector3;
  63384. /**
  63385. * Convert the Mesh to CSG
  63386. * @param mesh The Mesh to convert to CSG
  63387. * @returns A new CSG from the Mesh
  63388. */
  63389. static FromMesh(mesh: Mesh): CSG;
  63390. /**
  63391. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63392. * @param polygons Polygons used to construct a CSG solid
  63393. */
  63394. private static FromPolygons;
  63395. /**
  63396. * Clones, or makes a deep copy, of the CSG
  63397. * @returns A new CSG
  63398. */
  63399. clone(): CSG;
  63400. /**
  63401. * Unions this CSG with another CSG
  63402. * @param csg The CSG to union against this CSG
  63403. * @returns The unioned CSG
  63404. */
  63405. union(csg: CSG): CSG;
  63406. /**
  63407. * Unions this CSG with another CSG in place
  63408. * @param csg The CSG to union against this CSG
  63409. */
  63410. unionInPlace(csg: CSG): void;
  63411. /**
  63412. * Subtracts this CSG with another CSG
  63413. * @param csg The CSG to subtract against this CSG
  63414. * @returns A new CSG
  63415. */
  63416. subtract(csg: CSG): CSG;
  63417. /**
  63418. * Subtracts this CSG with another CSG in place
  63419. * @param csg The CSG to subtact against this CSG
  63420. */
  63421. subtractInPlace(csg: CSG): void;
  63422. /**
  63423. * Intersect this CSG with another CSG
  63424. * @param csg The CSG to intersect against this CSG
  63425. * @returns A new CSG
  63426. */
  63427. intersect(csg: CSG): CSG;
  63428. /**
  63429. * Intersects this CSG with another CSG in place
  63430. * @param csg The CSG to intersect against this CSG
  63431. */
  63432. intersectInPlace(csg: CSG): void;
  63433. /**
  63434. * Return a new CSG solid with solid and empty space switched. This solid is
  63435. * not modified.
  63436. * @returns A new CSG solid with solid and empty space switched
  63437. */
  63438. inverse(): CSG;
  63439. /**
  63440. * Inverses the CSG in place
  63441. */
  63442. inverseInPlace(): void;
  63443. /**
  63444. * This is used to keep meshes transformations so they can be restored
  63445. * when we build back a Babylon Mesh
  63446. * NB : All CSG operations are performed in world coordinates
  63447. * @param csg The CSG to copy the transform attributes from
  63448. * @returns This CSG
  63449. */
  63450. copyTransformAttributes(csg: CSG): CSG;
  63451. /**
  63452. * Build Raw mesh from CSG
  63453. * Coordinates here are in world space
  63454. * @param name The name of the mesh geometry
  63455. * @param scene The Scene
  63456. * @param keepSubMeshes Specifies if the submeshes should be kept
  63457. * @returns A new Mesh
  63458. */
  63459. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63460. /**
  63461. * Build Mesh from CSG taking material and transforms into account
  63462. * @param name The name of the Mesh
  63463. * @param material The material of the Mesh
  63464. * @param scene The Scene
  63465. * @param keepSubMeshes Specifies if submeshes should be kept
  63466. * @returns The new Mesh
  63467. */
  63468. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63469. }
  63470. }
  63471. declare module BABYLON {
  63472. /**
  63473. * Class used to create a trail following a mesh
  63474. */
  63475. export class TrailMesh extends Mesh {
  63476. private _generator;
  63477. private _autoStart;
  63478. private _running;
  63479. private _diameter;
  63480. private _length;
  63481. private _sectionPolygonPointsCount;
  63482. private _sectionVectors;
  63483. private _sectionNormalVectors;
  63484. private _beforeRenderObserver;
  63485. /**
  63486. * @constructor
  63487. * @param name The value used by scene.getMeshByName() to do a lookup.
  63488. * @param generator The mesh or transform node to generate a trail.
  63489. * @param scene The scene to add this mesh to.
  63490. * @param diameter Diameter of trailing mesh. Default is 1.
  63491. * @param length Length of trailing mesh. Default is 60.
  63492. * @param autoStart Automatically start trailing mesh. Default true.
  63493. */
  63494. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63495. /**
  63496. * "TrailMesh"
  63497. * @returns "TrailMesh"
  63498. */
  63499. getClassName(): string;
  63500. private _createMesh;
  63501. /**
  63502. * Start trailing mesh.
  63503. */
  63504. start(): void;
  63505. /**
  63506. * Stop trailing mesh.
  63507. */
  63508. stop(): void;
  63509. /**
  63510. * Update trailing mesh geometry.
  63511. */
  63512. update(): void;
  63513. /**
  63514. * Returns a new TrailMesh object.
  63515. * @param name is a string, the name given to the new mesh
  63516. * @param newGenerator use new generator object for cloned trail mesh
  63517. * @returns a new mesh
  63518. */
  63519. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63520. /**
  63521. * Serializes this trail mesh
  63522. * @param serializationObject object to write serialization to
  63523. */
  63524. serialize(serializationObject: any): void;
  63525. /**
  63526. * Parses a serialized trail mesh
  63527. * @param parsedMesh the serialized mesh
  63528. * @param scene the scene to create the trail mesh in
  63529. * @returns the created trail mesh
  63530. */
  63531. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63532. }
  63533. }
  63534. declare module BABYLON {
  63535. /**
  63536. * Class containing static functions to help procedurally build meshes
  63537. */
  63538. export class TiledBoxBuilder {
  63539. /**
  63540. * Creates a box mesh
  63541. * 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)
  63542. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63544. * * 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
  63545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63546. * @param name defines the name of the mesh
  63547. * @param options defines the options used to create the mesh
  63548. * @param scene defines the hosting scene
  63549. * @returns the box mesh
  63550. */
  63551. static CreateTiledBox(name: string, options: {
  63552. pattern?: number;
  63553. width?: number;
  63554. height?: number;
  63555. depth?: number;
  63556. tileSize?: number;
  63557. tileWidth?: number;
  63558. tileHeight?: number;
  63559. alignHorizontal?: number;
  63560. alignVertical?: number;
  63561. faceUV?: Vector4[];
  63562. faceColors?: Color4[];
  63563. sideOrientation?: number;
  63564. updatable?: boolean;
  63565. }, scene?: Nullable<Scene>): Mesh;
  63566. }
  63567. }
  63568. declare module BABYLON {
  63569. /**
  63570. * Class containing static functions to help procedurally build meshes
  63571. */
  63572. export class TorusKnotBuilder {
  63573. /**
  63574. * Creates a torus knot mesh
  63575. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63576. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63577. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63578. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63580. * * 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
  63581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63582. * @param name defines the name of the mesh
  63583. * @param options defines the options used to create the mesh
  63584. * @param scene defines the hosting scene
  63585. * @returns the torus knot mesh
  63586. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63587. */
  63588. static CreateTorusKnot(name: string, options: {
  63589. radius?: number;
  63590. tube?: number;
  63591. radialSegments?: number;
  63592. tubularSegments?: number;
  63593. p?: number;
  63594. q?: number;
  63595. updatable?: boolean;
  63596. sideOrientation?: number;
  63597. frontUVs?: Vector4;
  63598. backUVs?: Vector4;
  63599. }, scene: any): Mesh;
  63600. }
  63601. }
  63602. declare module BABYLON {
  63603. /**
  63604. * Polygon
  63605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63606. */
  63607. export class Polygon {
  63608. /**
  63609. * Creates a rectangle
  63610. * @param xmin bottom X coord
  63611. * @param ymin bottom Y coord
  63612. * @param xmax top X coord
  63613. * @param ymax top Y coord
  63614. * @returns points that make the resulting rectation
  63615. */
  63616. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63617. /**
  63618. * Creates a circle
  63619. * @param radius radius of circle
  63620. * @param cx scale in x
  63621. * @param cy scale in y
  63622. * @param numberOfSides number of sides that make up the circle
  63623. * @returns points that make the resulting circle
  63624. */
  63625. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63626. /**
  63627. * Creates a polygon from input string
  63628. * @param input Input polygon data
  63629. * @returns the parsed points
  63630. */
  63631. static Parse(input: string): Vector2[];
  63632. /**
  63633. * Starts building a polygon from x and y coordinates
  63634. * @param x x coordinate
  63635. * @param y y coordinate
  63636. * @returns the started path2
  63637. */
  63638. static StartingAt(x: number, y: number): Path2;
  63639. }
  63640. /**
  63641. * Builds a polygon
  63642. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63643. */
  63644. export class PolygonMeshBuilder {
  63645. private _points;
  63646. private _outlinepoints;
  63647. private _holes;
  63648. private _name;
  63649. private _scene;
  63650. private _epoints;
  63651. private _eholes;
  63652. private _addToepoint;
  63653. /**
  63654. * Babylon reference to the earcut plugin.
  63655. */
  63656. bjsEarcut: any;
  63657. /**
  63658. * Creates a PolygonMeshBuilder
  63659. * @param name name of the builder
  63660. * @param contours Path of the polygon
  63661. * @param scene scene to add to when creating the mesh
  63662. * @param earcutInjection can be used to inject your own earcut reference
  63663. */
  63664. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63665. /**
  63666. * Adds a whole within the polygon
  63667. * @param hole Array of points defining the hole
  63668. * @returns this
  63669. */
  63670. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63671. /**
  63672. * Creates the polygon
  63673. * @param updatable If the mesh should be updatable
  63674. * @param depth The depth of the mesh created
  63675. * @returns the created mesh
  63676. */
  63677. build(updatable?: boolean, depth?: number): Mesh;
  63678. /**
  63679. * Creates the polygon
  63680. * @param depth The depth of the mesh created
  63681. * @returns the created VertexData
  63682. */
  63683. buildVertexData(depth?: number): VertexData;
  63684. /**
  63685. * Adds a side to the polygon
  63686. * @param positions points that make the polygon
  63687. * @param normals normals of the polygon
  63688. * @param uvs uvs of the polygon
  63689. * @param indices indices of the polygon
  63690. * @param bounds bounds of the polygon
  63691. * @param points points of the polygon
  63692. * @param depth depth of the polygon
  63693. * @param flip flip of the polygon
  63694. */
  63695. private addSide;
  63696. }
  63697. }
  63698. declare module BABYLON {
  63699. /**
  63700. * Class containing static functions to help procedurally build meshes
  63701. */
  63702. export class PolygonBuilder {
  63703. /**
  63704. * Creates a polygon mesh
  63705. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63706. * * 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
  63707. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63709. * * 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)
  63710. * * Remember you can only change the shape positions, not their number when updating a polygon
  63711. * @param name defines the name of the mesh
  63712. * @param options defines the options used to create the mesh
  63713. * @param scene defines the hosting scene
  63714. * @param earcutInjection can be used to inject your own earcut reference
  63715. * @returns the polygon mesh
  63716. */
  63717. static CreatePolygon(name: string, options: {
  63718. shape: Vector3[];
  63719. holes?: Vector3[][];
  63720. depth?: number;
  63721. faceUV?: Vector4[];
  63722. faceColors?: Color4[];
  63723. updatable?: boolean;
  63724. sideOrientation?: number;
  63725. frontUVs?: Vector4;
  63726. backUVs?: Vector4;
  63727. wrap?: boolean;
  63728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63729. /**
  63730. * Creates an extruded polygon mesh, with depth in the Y direction.
  63731. * * 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)
  63732. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63733. * @param name defines the name of the mesh
  63734. * @param options defines the options used to create the mesh
  63735. * @param scene defines the hosting scene
  63736. * @param earcutInjection can be used to inject your own earcut reference
  63737. * @returns the polygon mesh
  63738. */
  63739. static ExtrudePolygon(name: string, options: {
  63740. shape: Vector3[];
  63741. holes?: Vector3[][];
  63742. depth?: number;
  63743. faceUV?: Vector4[];
  63744. faceColors?: Color4[];
  63745. updatable?: boolean;
  63746. sideOrientation?: number;
  63747. frontUVs?: Vector4;
  63748. backUVs?: Vector4;
  63749. wrap?: boolean;
  63750. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63751. }
  63752. }
  63753. declare module BABYLON {
  63754. /**
  63755. * Class containing static functions to help procedurally build meshes
  63756. */
  63757. export class LatheBuilder {
  63758. /**
  63759. * Creates lathe mesh.
  63760. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63761. * * 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
  63762. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63763. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63764. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63765. * * 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
  63766. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63767. * * 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
  63768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63769. * * 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
  63770. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63772. * @param name defines the name of the mesh
  63773. * @param options defines the options used to create the mesh
  63774. * @param scene defines the hosting scene
  63775. * @returns the lathe mesh
  63776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63777. */
  63778. static CreateLathe(name: string, options: {
  63779. shape: Vector3[];
  63780. radius?: number;
  63781. tessellation?: number;
  63782. clip?: number;
  63783. arc?: number;
  63784. closed?: boolean;
  63785. updatable?: boolean;
  63786. sideOrientation?: number;
  63787. frontUVs?: Vector4;
  63788. backUVs?: Vector4;
  63789. cap?: number;
  63790. invertUV?: boolean;
  63791. }, scene?: Nullable<Scene>): Mesh;
  63792. }
  63793. }
  63794. declare module BABYLON {
  63795. /**
  63796. * Class containing static functions to help procedurally build meshes
  63797. */
  63798. export class TiledPlaneBuilder {
  63799. /**
  63800. * Creates a tiled plane mesh
  63801. * * The parameter `pattern` will, depending on value, do nothing or
  63802. * * * flip (reflect about central vertical) alternate tiles across and up
  63803. * * * flip every tile on alternate rows
  63804. * * * rotate (180 degs) alternate tiles across and up
  63805. * * * rotate every tile on alternate rows
  63806. * * * flip and rotate alternate tiles across and up
  63807. * * * flip and rotate every tile on alternate rows
  63808. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63809. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63810. * * 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
  63811. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63812. * * 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)
  63813. * * 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)
  63814. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63815. * @param name defines the name of the mesh
  63816. * @param options defines the options used to create the mesh
  63817. * @param scene defines the hosting scene
  63818. * @returns the box mesh
  63819. */
  63820. static CreateTiledPlane(name: string, options: {
  63821. pattern?: number;
  63822. tileSize?: number;
  63823. tileWidth?: number;
  63824. tileHeight?: number;
  63825. size?: number;
  63826. width?: number;
  63827. height?: number;
  63828. alignHorizontal?: number;
  63829. alignVertical?: number;
  63830. sideOrientation?: number;
  63831. frontUVs?: Vector4;
  63832. backUVs?: Vector4;
  63833. updatable?: boolean;
  63834. }, scene?: Nullable<Scene>): Mesh;
  63835. }
  63836. }
  63837. declare module BABYLON {
  63838. /**
  63839. * Class containing static functions to help procedurally build meshes
  63840. */
  63841. export class TubeBuilder {
  63842. /**
  63843. * Creates a tube mesh.
  63844. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63845. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63846. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63847. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63848. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63849. * * 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)
  63850. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63851. * * 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
  63852. * * 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
  63853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63854. * * 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
  63855. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63857. * @param name defines the name of the mesh
  63858. * @param options defines the options used to create the mesh
  63859. * @param scene defines the hosting scene
  63860. * @returns the tube mesh
  63861. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63862. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63863. */
  63864. static CreateTube(name: string, options: {
  63865. path: Vector3[];
  63866. radius?: number;
  63867. tessellation?: number;
  63868. radiusFunction?: {
  63869. (i: number, distance: number): number;
  63870. };
  63871. cap?: number;
  63872. arc?: number;
  63873. updatable?: boolean;
  63874. sideOrientation?: number;
  63875. frontUVs?: Vector4;
  63876. backUVs?: Vector4;
  63877. instance?: Mesh;
  63878. invertUV?: boolean;
  63879. }, scene?: Nullable<Scene>): Mesh;
  63880. }
  63881. }
  63882. declare module BABYLON {
  63883. /**
  63884. * Class containing static functions to help procedurally build meshes
  63885. */
  63886. export class IcoSphereBuilder {
  63887. /**
  63888. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63889. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63890. * * 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`)
  63891. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63892. * * 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
  63893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63894. * * 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
  63895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63896. * @param name defines the name of the mesh
  63897. * @param options defines the options used to create the mesh
  63898. * @param scene defines the hosting scene
  63899. * @returns the icosahedron mesh
  63900. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63901. */
  63902. static CreateIcoSphere(name: string, options: {
  63903. radius?: number;
  63904. radiusX?: number;
  63905. radiusY?: number;
  63906. radiusZ?: number;
  63907. flat?: boolean;
  63908. subdivisions?: number;
  63909. sideOrientation?: number;
  63910. frontUVs?: Vector4;
  63911. backUVs?: Vector4;
  63912. updatable?: boolean;
  63913. }, scene?: Nullable<Scene>): Mesh;
  63914. }
  63915. }
  63916. declare module BABYLON {
  63917. /**
  63918. * Class containing static functions to help procedurally build meshes
  63919. */
  63920. export class DecalBuilder {
  63921. /**
  63922. * Creates a decal mesh.
  63923. * 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
  63924. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63925. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63926. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63927. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63928. * @param name defines the name of the mesh
  63929. * @param sourceMesh defines the mesh where the decal must be applied
  63930. * @param options defines the options used to create the mesh
  63931. * @param scene defines the hosting scene
  63932. * @returns the decal mesh
  63933. * @see https://doc.babylonjs.com/how_to/decals
  63934. */
  63935. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63936. position?: Vector3;
  63937. normal?: Vector3;
  63938. size?: Vector3;
  63939. angle?: number;
  63940. }): Mesh;
  63941. }
  63942. }
  63943. declare module BABYLON {
  63944. /**
  63945. * Class containing static functions to help procedurally build meshes
  63946. */
  63947. export class MeshBuilder {
  63948. /**
  63949. * Creates a box mesh
  63950. * * The parameter `size` sets the size (float) of each box side (default 1)
  63951. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63952. * * 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)
  63953. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63955. * * 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
  63956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63958. * @param name defines the name of the mesh
  63959. * @param options defines the options used to create the mesh
  63960. * @param scene defines the hosting scene
  63961. * @returns the box mesh
  63962. */
  63963. static CreateBox(name: string, options: {
  63964. size?: number;
  63965. width?: number;
  63966. height?: number;
  63967. depth?: number;
  63968. faceUV?: Vector4[];
  63969. faceColors?: Color4[];
  63970. sideOrientation?: number;
  63971. frontUVs?: Vector4;
  63972. backUVs?: Vector4;
  63973. wrap?: boolean;
  63974. topBaseAt?: number;
  63975. bottomBaseAt?: number;
  63976. updatable?: boolean;
  63977. }, scene?: Nullable<Scene>): Mesh;
  63978. /**
  63979. * Creates a tiled box mesh
  63980. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63982. * @param name defines the name of the mesh
  63983. * @param options defines the options used to create the mesh
  63984. * @param scene defines the hosting scene
  63985. * @returns the tiled box mesh
  63986. */
  63987. static CreateTiledBox(name: string, options: {
  63988. pattern?: number;
  63989. size?: number;
  63990. width?: number;
  63991. height?: number;
  63992. depth: number;
  63993. tileSize?: number;
  63994. tileWidth?: number;
  63995. tileHeight?: number;
  63996. faceUV?: Vector4[];
  63997. faceColors?: Color4[];
  63998. alignHorizontal?: number;
  63999. alignVertical?: number;
  64000. sideOrientation?: number;
  64001. updatable?: boolean;
  64002. }, scene?: Nullable<Scene>): Mesh;
  64003. /**
  64004. * Creates a sphere mesh
  64005. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64006. * * 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`)
  64007. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64008. * * 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
  64009. * * 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)
  64010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64011. * * 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
  64012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64013. * @param name defines the name of the mesh
  64014. * @param options defines the options used to create the mesh
  64015. * @param scene defines the hosting scene
  64016. * @returns the sphere mesh
  64017. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64018. */
  64019. static CreateSphere(name: string, options: {
  64020. segments?: number;
  64021. diameter?: number;
  64022. diameterX?: number;
  64023. diameterY?: number;
  64024. diameterZ?: number;
  64025. arc?: number;
  64026. slice?: number;
  64027. sideOrientation?: number;
  64028. frontUVs?: Vector4;
  64029. backUVs?: Vector4;
  64030. updatable?: boolean;
  64031. }, scene?: Nullable<Scene>): Mesh;
  64032. /**
  64033. * Creates a plane polygonal mesh. By default, this is a disc
  64034. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64035. * * 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
  64036. * * 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
  64037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64038. * * 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
  64039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64040. * @param name defines the name of the mesh
  64041. * @param options defines the options used to create the mesh
  64042. * @param scene defines the hosting scene
  64043. * @returns the plane polygonal mesh
  64044. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64045. */
  64046. static CreateDisc(name: string, options: {
  64047. radius?: number;
  64048. tessellation?: number;
  64049. arc?: number;
  64050. updatable?: boolean;
  64051. sideOrientation?: number;
  64052. frontUVs?: Vector4;
  64053. backUVs?: Vector4;
  64054. }, scene?: Nullable<Scene>): Mesh;
  64055. /**
  64056. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64057. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64058. * * 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`)
  64059. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64060. * * 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
  64061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64062. * * 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
  64063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64064. * @param name defines the name of the mesh
  64065. * @param options defines the options used to create the mesh
  64066. * @param scene defines the hosting scene
  64067. * @returns the icosahedron mesh
  64068. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64069. */
  64070. static CreateIcoSphere(name: string, options: {
  64071. radius?: number;
  64072. radiusX?: number;
  64073. radiusY?: number;
  64074. radiusZ?: number;
  64075. flat?: boolean;
  64076. subdivisions?: number;
  64077. sideOrientation?: number;
  64078. frontUVs?: Vector4;
  64079. backUVs?: Vector4;
  64080. updatable?: boolean;
  64081. }, scene?: Nullable<Scene>): Mesh;
  64082. /**
  64083. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64084. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64085. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64086. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64087. * * 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
  64088. * * 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
  64089. * * 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
  64090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64091. * * 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
  64092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64093. * * 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
  64094. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64095. * * 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
  64096. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64098. * @param name defines the name of the mesh
  64099. * @param options defines the options used to create the mesh
  64100. * @param scene defines the hosting scene
  64101. * @returns the ribbon mesh
  64102. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64103. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64104. */
  64105. static CreateRibbon(name: string, options: {
  64106. pathArray: Vector3[][];
  64107. closeArray?: boolean;
  64108. closePath?: boolean;
  64109. offset?: number;
  64110. updatable?: boolean;
  64111. sideOrientation?: number;
  64112. frontUVs?: Vector4;
  64113. backUVs?: Vector4;
  64114. instance?: Mesh;
  64115. invertUV?: boolean;
  64116. uvs?: Vector2[];
  64117. colors?: Color4[];
  64118. }, scene?: Nullable<Scene>): Mesh;
  64119. /**
  64120. * Creates a cylinder or a cone mesh
  64121. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64122. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64123. * * 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.
  64124. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64125. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64126. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64127. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64128. * * 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).
  64129. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64130. * * 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).
  64131. * * 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
  64132. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64133. * * 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
  64134. * * 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.
  64135. * * If `enclose` is false, a ring surface is one element.
  64136. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64137. * * 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
  64138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64139. * * 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
  64140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64141. * @param name defines the name of the mesh
  64142. * @param options defines the options used to create the mesh
  64143. * @param scene defines the hosting scene
  64144. * @returns the cylinder mesh
  64145. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64146. */
  64147. static CreateCylinder(name: string, options: {
  64148. height?: number;
  64149. diameterTop?: number;
  64150. diameterBottom?: number;
  64151. diameter?: number;
  64152. tessellation?: number;
  64153. subdivisions?: number;
  64154. arc?: number;
  64155. faceColors?: Color4[];
  64156. faceUV?: Vector4[];
  64157. updatable?: boolean;
  64158. hasRings?: boolean;
  64159. enclose?: boolean;
  64160. cap?: number;
  64161. sideOrientation?: number;
  64162. frontUVs?: Vector4;
  64163. backUVs?: Vector4;
  64164. }, scene?: Nullable<Scene>): Mesh;
  64165. /**
  64166. * Creates a torus mesh
  64167. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64168. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64169. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64171. * * 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
  64172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64173. * @param name defines the name of the mesh
  64174. * @param options defines the options used to create the mesh
  64175. * @param scene defines the hosting scene
  64176. * @returns the torus mesh
  64177. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64178. */
  64179. static CreateTorus(name: string, options: {
  64180. diameter?: number;
  64181. thickness?: number;
  64182. tessellation?: number;
  64183. updatable?: boolean;
  64184. sideOrientation?: number;
  64185. frontUVs?: Vector4;
  64186. backUVs?: Vector4;
  64187. }, scene?: Nullable<Scene>): Mesh;
  64188. /**
  64189. * Creates a torus knot mesh
  64190. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64191. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64192. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64193. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64195. * * 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
  64196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64197. * @param name defines the name of the mesh
  64198. * @param options defines the options used to create the mesh
  64199. * @param scene defines the hosting scene
  64200. * @returns the torus knot mesh
  64201. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64202. */
  64203. static CreateTorusKnot(name: string, options: {
  64204. radius?: number;
  64205. tube?: number;
  64206. radialSegments?: number;
  64207. tubularSegments?: number;
  64208. p?: number;
  64209. q?: number;
  64210. updatable?: boolean;
  64211. sideOrientation?: number;
  64212. frontUVs?: Vector4;
  64213. backUVs?: Vector4;
  64214. }, scene?: Nullable<Scene>): Mesh;
  64215. /**
  64216. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64217. * * 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
  64218. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64219. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64220. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64221. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64222. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64223. * * 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
  64224. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64227. * @param name defines the name of the new line system
  64228. * @param options defines the options used to create the line system
  64229. * @param scene defines the hosting scene
  64230. * @returns a new line system mesh
  64231. */
  64232. static CreateLineSystem(name: string, options: {
  64233. lines: Vector3[][];
  64234. updatable?: boolean;
  64235. instance?: Nullable<LinesMesh>;
  64236. colors?: Nullable<Color4[][]>;
  64237. useVertexAlpha?: boolean;
  64238. }, scene: Nullable<Scene>): LinesMesh;
  64239. /**
  64240. * Creates a line mesh
  64241. * 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
  64242. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64243. * * The parameter `points` is an array successive Vector3
  64244. * * 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
  64245. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64246. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64247. * * When updating an instance, remember that only point positions can change, not the number of points
  64248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64250. * @param name defines the name of the new line system
  64251. * @param options defines the options used to create the line system
  64252. * @param scene defines the hosting scene
  64253. * @returns a new line mesh
  64254. */
  64255. static CreateLines(name: string, options: {
  64256. points: Vector3[];
  64257. updatable?: boolean;
  64258. instance?: Nullable<LinesMesh>;
  64259. colors?: Color4[];
  64260. useVertexAlpha?: boolean;
  64261. }, scene?: Nullable<Scene>): LinesMesh;
  64262. /**
  64263. * Creates a dashed line mesh
  64264. * * 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
  64265. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64266. * * The parameter `points` is an array successive Vector3
  64267. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64268. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64269. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64270. * * 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
  64271. * * When updating an instance, remember that only point positions can change, not the number of points
  64272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64273. * @param name defines the name of the mesh
  64274. * @param options defines the options used to create the mesh
  64275. * @param scene defines the hosting scene
  64276. * @returns the dashed line mesh
  64277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64278. */
  64279. static CreateDashedLines(name: string, options: {
  64280. points: Vector3[];
  64281. dashSize?: number;
  64282. gapSize?: number;
  64283. dashNb?: number;
  64284. updatable?: boolean;
  64285. instance?: LinesMesh;
  64286. }, scene?: Nullable<Scene>): LinesMesh;
  64287. /**
  64288. * 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.
  64289. * * 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.
  64290. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64291. * * 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.
  64292. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64293. * * 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
  64294. * * 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
  64295. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64297. * * 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
  64298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64300. * @param name defines the name of the mesh
  64301. * @param options defines the options used to create the mesh
  64302. * @param scene defines the hosting scene
  64303. * @returns the extruded shape mesh
  64304. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64306. */
  64307. static ExtrudeShape(name: string, options: {
  64308. shape: Vector3[];
  64309. path: Vector3[];
  64310. scale?: number;
  64311. rotation?: number;
  64312. cap?: number;
  64313. updatable?: boolean;
  64314. sideOrientation?: number;
  64315. frontUVs?: Vector4;
  64316. backUVs?: Vector4;
  64317. instance?: Mesh;
  64318. invertUV?: boolean;
  64319. }, scene?: Nullable<Scene>): Mesh;
  64320. /**
  64321. * Creates an custom extruded shape mesh.
  64322. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64323. * * 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.
  64324. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64325. * * 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
  64326. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64327. * * 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
  64328. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64329. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64330. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64331. * * 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
  64332. * * 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
  64333. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64335. * * 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
  64336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64338. * @param name defines the name of the mesh
  64339. * @param options defines the options used to create the mesh
  64340. * @param scene defines the hosting scene
  64341. * @returns the custom extruded shape mesh
  64342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64345. */
  64346. static ExtrudeShapeCustom(name: string, options: {
  64347. shape: Vector3[];
  64348. path: Vector3[];
  64349. scaleFunction?: any;
  64350. rotationFunction?: any;
  64351. ribbonCloseArray?: boolean;
  64352. ribbonClosePath?: boolean;
  64353. cap?: number;
  64354. updatable?: boolean;
  64355. sideOrientation?: number;
  64356. frontUVs?: Vector4;
  64357. backUVs?: Vector4;
  64358. instance?: Mesh;
  64359. invertUV?: boolean;
  64360. }, scene?: Nullable<Scene>): Mesh;
  64361. /**
  64362. * Creates lathe mesh.
  64363. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64364. * * 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
  64365. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64366. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64367. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64368. * * 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
  64369. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64370. * * 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
  64371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64372. * * 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
  64373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64375. * @param name defines the name of the mesh
  64376. * @param options defines the options used to create the mesh
  64377. * @param scene defines the hosting scene
  64378. * @returns the lathe mesh
  64379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64380. */
  64381. static CreateLathe(name: string, options: {
  64382. shape: Vector3[];
  64383. radius?: number;
  64384. tessellation?: number;
  64385. clip?: number;
  64386. arc?: number;
  64387. closed?: boolean;
  64388. updatable?: boolean;
  64389. sideOrientation?: number;
  64390. frontUVs?: Vector4;
  64391. backUVs?: Vector4;
  64392. cap?: number;
  64393. invertUV?: boolean;
  64394. }, scene?: Nullable<Scene>): Mesh;
  64395. /**
  64396. * Creates a tiled plane mesh
  64397. * * You can set a limited pattern arrangement with the tiles
  64398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64399. * * 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
  64400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64401. * @param name defines the name of the mesh
  64402. * @param options defines the options used to create the mesh
  64403. * @param scene defines the hosting scene
  64404. * @returns the plane mesh
  64405. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64406. */
  64407. static CreateTiledPlane(name: string, options: {
  64408. pattern?: number;
  64409. tileSize?: number;
  64410. tileWidth?: number;
  64411. tileHeight?: number;
  64412. size?: number;
  64413. width?: number;
  64414. height?: number;
  64415. alignHorizontal?: number;
  64416. alignVertical?: number;
  64417. sideOrientation?: number;
  64418. frontUVs?: Vector4;
  64419. backUVs?: Vector4;
  64420. updatable?: boolean;
  64421. }, scene?: Nullable<Scene>): Mesh;
  64422. /**
  64423. * Creates a plane mesh
  64424. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64425. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64426. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64428. * * 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
  64429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64430. * @param name defines the name of the mesh
  64431. * @param options defines the options used to create the mesh
  64432. * @param scene defines the hosting scene
  64433. * @returns the plane mesh
  64434. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64435. */
  64436. static CreatePlane(name: string, options: {
  64437. size?: number;
  64438. width?: number;
  64439. height?: number;
  64440. sideOrientation?: number;
  64441. frontUVs?: Vector4;
  64442. backUVs?: Vector4;
  64443. updatable?: boolean;
  64444. sourcePlane?: Plane;
  64445. }, scene?: Nullable<Scene>): Mesh;
  64446. /**
  64447. * Creates a ground mesh
  64448. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64449. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64451. * @param name defines the name of the mesh
  64452. * @param options defines the options used to create the mesh
  64453. * @param scene defines the hosting scene
  64454. * @returns the ground mesh
  64455. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64456. */
  64457. static CreateGround(name: string, options: {
  64458. width?: number;
  64459. height?: number;
  64460. subdivisions?: number;
  64461. subdivisionsX?: number;
  64462. subdivisionsY?: number;
  64463. updatable?: boolean;
  64464. }, scene?: Nullable<Scene>): Mesh;
  64465. /**
  64466. * Creates a tiled ground mesh
  64467. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64468. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64469. * * 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
  64470. * * 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
  64471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64472. * @param name defines the name of the mesh
  64473. * @param options defines the options used to create the mesh
  64474. * @param scene defines the hosting scene
  64475. * @returns the tiled ground mesh
  64476. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64477. */
  64478. static CreateTiledGround(name: string, options: {
  64479. xmin: number;
  64480. zmin: number;
  64481. xmax: number;
  64482. zmax: number;
  64483. subdivisions?: {
  64484. w: number;
  64485. h: number;
  64486. };
  64487. precision?: {
  64488. w: number;
  64489. h: number;
  64490. };
  64491. updatable?: boolean;
  64492. }, scene?: Nullable<Scene>): Mesh;
  64493. /**
  64494. * Creates a ground mesh from a height map
  64495. * * The parameter `url` sets the URL of the height map image resource.
  64496. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64497. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64498. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64499. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64500. * * 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.
  64501. * * 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).
  64502. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64504. * @param name defines the name of the mesh
  64505. * @param url defines the url to the height map
  64506. * @param options defines the options used to create the mesh
  64507. * @param scene defines the hosting scene
  64508. * @returns the ground mesh
  64509. * @see https://doc.babylonjs.com/babylon101/height_map
  64510. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64511. */
  64512. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64513. width?: number;
  64514. height?: number;
  64515. subdivisions?: number;
  64516. minHeight?: number;
  64517. maxHeight?: number;
  64518. colorFilter?: Color3;
  64519. alphaFilter?: number;
  64520. updatable?: boolean;
  64521. onReady?: (mesh: GroundMesh) => void;
  64522. }, scene?: Nullable<Scene>): GroundMesh;
  64523. /**
  64524. * Creates a polygon mesh
  64525. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64526. * * 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
  64527. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64529. * * 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)
  64530. * * Remember you can only change the shape positions, not their number when updating a polygon
  64531. * @param name defines the name of the mesh
  64532. * @param options defines the options used to create the mesh
  64533. * @param scene defines the hosting scene
  64534. * @param earcutInjection can be used to inject your own earcut reference
  64535. * @returns the polygon mesh
  64536. */
  64537. static CreatePolygon(name: string, options: {
  64538. shape: Vector3[];
  64539. holes?: Vector3[][];
  64540. depth?: number;
  64541. faceUV?: Vector4[];
  64542. faceColors?: Color4[];
  64543. updatable?: boolean;
  64544. sideOrientation?: number;
  64545. frontUVs?: Vector4;
  64546. backUVs?: Vector4;
  64547. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64548. /**
  64549. * Creates an extruded polygon mesh, with depth in the Y direction.
  64550. * * 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)
  64551. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64552. * @param name defines the name of the mesh
  64553. * @param options defines the options used to create the mesh
  64554. * @param scene defines the hosting scene
  64555. * @param earcutInjection can be used to inject your own earcut reference
  64556. * @returns the polygon mesh
  64557. */
  64558. static ExtrudePolygon(name: string, options: {
  64559. shape: Vector3[];
  64560. holes?: Vector3[][];
  64561. depth?: number;
  64562. faceUV?: Vector4[];
  64563. faceColors?: Color4[];
  64564. updatable?: boolean;
  64565. sideOrientation?: number;
  64566. frontUVs?: Vector4;
  64567. backUVs?: Vector4;
  64568. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64569. /**
  64570. * Creates a tube mesh.
  64571. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64572. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64573. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64574. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64575. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64576. * * 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)
  64577. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64578. * * 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
  64579. * * 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
  64580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64581. * * 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
  64582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64584. * @param name defines the name of the mesh
  64585. * @param options defines the options used to create the mesh
  64586. * @param scene defines the hosting scene
  64587. * @returns the tube mesh
  64588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64589. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64590. */
  64591. static CreateTube(name: string, options: {
  64592. path: Vector3[];
  64593. radius?: number;
  64594. tessellation?: number;
  64595. radiusFunction?: {
  64596. (i: number, distance: number): number;
  64597. };
  64598. cap?: number;
  64599. arc?: number;
  64600. updatable?: boolean;
  64601. sideOrientation?: number;
  64602. frontUVs?: Vector4;
  64603. backUVs?: Vector4;
  64604. instance?: Mesh;
  64605. invertUV?: boolean;
  64606. }, scene?: Nullable<Scene>): Mesh;
  64607. /**
  64608. * Creates a polyhedron mesh
  64609. * * 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
  64610. * * The parameter `size` (positive float, default 1) sets the polygon size
  64611. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64612. * * 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`
  64613. * * 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
  64614. * * 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)`)
  64615. * * 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
  64616. * * 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
  64617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64618. * * 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
  64619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64620. * @param name defines the name of the mesh
  64621. * @param options defines the options used to create the mesh
  64622. * @param scene defines the hosting scene
  64623. * @returns the polyhedron mesh
  64624. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64625. */
  64626. static CreatePolyhedron(name: string, options: {
  64627. type?: number;
  64628. size?: number;
  64629. sizeX?: number;
  64630. sizeY?: number;
  64631. sizeZ?: number;
  64632. custom?: any;
  64633. faceUV?: Vector4[];
  64634. faceColors?: Color4[];
  64635. flat?: boolean;
  64636. updatable?: boolean;
  64637. sideOrientation?: number;
  64638. frontUVs?: Vector4;
  64639. backUVs?: Vector4;
  64640. }, scene?: Nullable<Scene>): Mesh;
  64641. /**
  64642. * Creates a decal mesh.
  64643. * 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
  64644. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64645. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64646. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64647. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64648. * @param name defines the name of the mesh
  64649. * @param sourceMesh defines the mesh where the decal must be applied
  64650. * @param options defines the options used to create the mesh
  64651. * @param scene defines the hosting scene
  64652. * @returns the decal mesh
  64653. * @see https://doc.babylonjs.com/how_to/decals
  64654. */
  64655. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64656. position?: Vector3;
  64657. normal?: Vector3;
  64658. size?: Vector3;
  64659. angle?: number;
  64660. }): Mesh;
  64661. }
  64662. }
  64663. declare module BABYLON {
  64664. /**
  64665. * A simplifier interface for future simplification implementations
  64666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64667. */
  64668. export interface ISimplifier {
  64669. /**
  64670. * Simplification of a given mesh according to the given settings.
  64671. * Since this requires computation, it is assumed that the function runs async.
  64672. * @param settings The settings of the simplification, including quality and distance
  64673. * @param successCallback A callback that will be called after the mesh was simplified.
  64674. * @param errorCallback in case of an error, this callback will be called. optional.
  64675. */
  64676. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64677. }
  64678. /**
  64679. * Expected simplification settings.
  64680. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64682. */
  64683. export interface ISimplificationSettings {
  64684. /**
  64685. * Gets or sets the expected quality
  64686. */
  64687. quality: number;
  64688. /**
  64689. * Gets or sets the distance when this optimized version should be used
  64690. */
  64691. distance: number;
  64692. /**
  64693. * Gets an already optimized mesh
  64694. */
  64695. optimizeMesh?: boolean;
  64696. }
  64697. /**
  64698. * Class used to specify simplification options
  64699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64700. */
  64701. export class SimplificationSettings implements ISimplificationSettings {
  64702. /** expected quality */
  64703. quality: number;
  64704. /** distance when this optimized version should be used */
  64705. distance: number;
  64706. /** already optimized mesh */
  64707. optimizeMesh?: boolean | undefined;
  64708. /**
  64709. * Creates a SimplificationSettings
  64710. * @param quality expected quality
  64711. * @param distance distance when this optimized version should be used
  64712. * @param optimizeMesh already optimized mesh
  64713. */
  64714. constructor(
  64715. /** expected quality */
  64716. quality: number,
  64717. /** distance when this optimized version should be used */
  64718. distance: number,
  64719. /** already optimized mesh */
  64720. optimizeMesh?: boolean | undefined);
  64721. }
  64722. /**
  64723. * Interface used to define a simplification task
  64724. */
  64725. export interface ISimplificationTask {
  64726. /**
  64727. * Array of settings
  64728. */
  64729. settings: Array<ISimplificationSettings>;
  64730. /**
  64731. * Simplification type
  64732. */
  64733. simplificationType: SimplificationType;
  64734. /**
  64735. * Mesh to simplify
  64736. */
  64737. mesh: Mesh;
  64738. /**
  64739. * Callback called on success
  64740. */
  64741. successCallback?: () => void;
  64742. /**
  64743. * Defines if parallel processing can be used
  64744. */
  64745. parallelProcessing: boolean;
  64746. }
  64747. /**
  64748. * Queue used to order the simplification tasks
  64749. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64750. */
  64751. export class SimplificationQueue {
  64752. private _simplificationArray;
  64753. /**
  64754. * Gets a boolean indicating that the process is still running
  64755. */
  64756. running: boolean;
  64757. /**
  64758. * Creates a new queue
  64759. */
  64760. constructor();
  64761. /**
  64762. * Adds a new simplification task
  64763. * @param task defines a task to add
  64764. */
  64765. addTask(task: ISimplificationTask): void;
  64766. /**
  64767. * Execute next task
  64768. */
  64769. executeNext(): void;
  64770. /**
  64771. * Execute a simplification task
  64772. * @param task defines the task to run
  64773. */
  64774. runSimplification(task: ISimplificationTask): void;
  64775. private getSimplifier;
  64776. }
  64777. /**
  64778. * The implemented types of simplification
  64779. * At the moment only Quadratic Error Decimation is implemented
  64780. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64781. */
  64782. export enum SimplificationType {
  64783. /** Quadratic error decimation */
  64784. QUADRATIC = 0
  64785. }
  64786. /**
  64787. * An implementation of the Quadratic Error simplification algorithm.
  64788. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64789. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64790. * @author RaananW
  64791. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64792. */
  64793. export class QuadraticErrorSimplification implements ISimplifier {
  64794. private _mesh;
  64795. private triangles;
  64796. private vertices;
  64797. private references;
  64798. private _reconstructedMesh;
  64799. /** Gets or sets the number pf sync interations */
  64800. syncIterations: number;
  64801. /** Gets or sets the aggressiveness of the simplifier */
  64802. aggressiveness: number;
  64803. /** Gets or sets the number of allowed iterations for decimation */
  64804. decimationIterations: number;
  64805. /** Gets or sets the espilon to use for bounding box computation */
  64806. boundingBoxEpsilon: number;
  64807. /**
  64808. * Creates a new QuadraticErrorSimplification
  64809. * @param _mesh defines the target mesh
  64810. */
  64811. constructor(_mesh: Mesh);
  64812. /**
  64813. * Simplification of a given mesh according to the given settings.
  64814. * Since this requires computation, it is assumed that the function runs async.
  64815. * @param settings The settings of the simplification, including quality and distance
  64816. * @param successCallback A callback that will be called after the mesh was simplified.
  64817. */
  64818. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64819. private runDecimation;
  64820. private initWithMesh;
  64821. private init;
  64822. private reconstructMesh;
  64823. private initDecimatedMesh;
  64824. private isFlipped;
  64825. private updateTriangles;
  64826. private identifyBorder;
  64827. private updateMesh;
  64828. private vertexError;
  64829. private calculateError;
  64830. }
  64831. }
  64832. declare module BABYLON {
  64833. interface Scene {
  64834. /** @hidden (Backing field) */
  64835. _simplificationQueue: SimplificationQueue;
  64836. /**
  64837. * Gets or sets the simplification queue attached to the scene
  64838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64839. */
  64840. simplificationQueue: SimplificationQueue;
  64841. }
  64842. interface Mesh {
  64843. /**
  64844. * Simplify the mesh according to the given array of settings.
  64845. * Function will return immediately and will simplify async
  64846. * @param settings a collection of simplification settings
  64847. * @param parallelProcessing should all levels calculate parallel or one after the other
  64848. * @param simplificationType the type of simplification to run
  64849. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64850. * @returns the current mesh
  64851. */
  64852. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64853. }
  64854. /**
  64855. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64856. * created in a scene
  64857. */
  64858. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64859. /**
  64860. * The component name helpfull to identify the component in the list of scene components.
  64861. */
  64862. readonly name: string;
  64863. /**
  64864. * The scene the component belongs to.
  64865. */
  64866. scene: Scene;
  64867. /**
  64868. * Creates a new instance of the component for the given scene
  64869. * @param scene Defines the scene to register the component in
  64870. */
  64871. constructor(scene: Scene);
  64872. /**
  64873. * Registers the component in a given scene
  64874. */
  64875. register(): void;
  64876. /**
  64877. * Rebuilds the elements related to this component in case of
  64878. * context lost for instance.
  64879. */
  64880. rebuild(): void;
  64881. /**
  64882. * Disposes the component and the associated ressources
  64883. */
  64884. dispose(): void;
  64885. private _beforeCameraUpdate;
  64886. }
  64887. }
  64888. declare module BABYLON {
  64889. /**
  64890. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64891. */
  64892. export interface INavigationEnginePlugin {
  64893. /**
  64894. * plugin name
  64895. */
  64896. name: string;
  64897. /**
  64898. * Creates a navigation mesh
  64899. * @param meshes array of all the geometry used to compute the navigatio mesh
  64900. * @param parameters bunch of parameters used to filter geometry
  64901. */
  64902. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64903. /**
  64904. * Create a navigation mesh debug mesh
  64905. * @param scene is where the mesh will be added
  64906. * @returns debug display mesh
  64907. */
  64908. createDebugNavMesh(scene: Scene): Mesh;
  64909. /**
  64910. * Get a navigation mesh constrained position, closest to the parameter position
  64911. * @param position world position
  64912. * @returns the closest point to position constrained by the navigation mesh
  64913. */
  64914. getClosestPoint(position: Vector3): Vector3;
  64915. /**
  64916. * Get a navigation mesh constrained position, closest to the parameter position
  64917. * @param position world position
  64918. * @param result output the closest point to position constrained by the navigation mesh
  64919. */
  64920. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64921. /**
  64922. * Get a navigation mesh constrained position, within a particular radius
  64923. * @param position world position
  64924. * @param maxRadius the maximum distance to the constrained world position
  64925. * @returns the closest point to position constrained by the navigation mesh
  64926. */
  64927. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64928. /**
  64929. * Get a navigation mesh constrained position, within a particular radius
  64930. * @param position world position
  64931. * @param maxRadius the maximum distance to the constrained world position
  64932. * @param result output the closest point to position constrained by the navigation mesh
  64933. */
  64934. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64935. /**
  64936. * Compute the final position from a segment made of destination-position
  64937. * @param position world position
  64938. * @param destination world position
  64939. * @returns the resulting point along the navmesh
  64940. */
  64941. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64942. /**
  64943. * Compute the final position from a segment made of destination-position
  64944. * @param position world position
  64945. * @param destination world position
  64946. * @param result output the resulting point along the navmesh
  64947. */
  64948. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64949. /**
  64950. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64951. * @param start world position
  64952. * @param end world position
  64953. * @returns array containing world position composing the path
  64954. */
  64955. computePath(start: Vector3, end: Vector3): Vector3[];
  64956. /**
  64957. * If this plugin is supported
  64958. * @returns true if plugin is supported
  64959. */
  64960. isSupported(): boolean;
  64961. /**
  64962. * Create a new Crowd so you can add agents
  64963. * @param maxAgents the maximum agent count in the crowd
  64964. * @param maxAgentRadius the maximum radius an agent can have
  64965. * @param scene to attach the crowd to
  64966. * @returns the crowd you can add agents to
  64967. */
  64968. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64969. /**
  64970. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64971. * The queries will try to find a solution within those bounds
  64972. * default is (1,1,1)
  64973. * @param extent x,y,z value that define the extent around the queries point of reference
  64974. */
  64975. setDefaultQueryExtent(extent: Vector3): void;
  64976. /**
  64977. * Get the Bounding box extent specified by setDefaultQueryExtent
  64978. * @returns the box extent values
  64979. */
  64980. getDefaultQueryExtent(): Vector3;
  64981. /**
  64982. * build the navmesh from a previously saved state using getNavmeshData
  64983. * @param data the Uint8Array returned by getNavmeshData
  64984. */
  64985. buildFromNavmeshData(data: Uint8Array): void;
  64986. /**
  64987. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64988. * @returns data the Uint8Array that can be saved and reused
  64989. */
  64990. getNavmeshData(): Uint8Array;
  64991. /**
  64992. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64993. * @param result output the box extent values
  64994. */
  64995. getDefaultQueryExtentToRef(result: Vector3): void;
  64996. /**
  64997. * Release all resources
  64998. */
  64999. dispose(): void;
  65000. }
  65001. /**
  65002. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65003. */
  65004. export interface ICrowd {
  65005. /**
  65006. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65007. * You can attach anything to that node. The node position is updated in the scene update tick.
  65008. * @param pos world position that will be constrained by the navigation mesh
  65009. * @param parameters agent parameters
  65010. * @param transform hooked to the agent that will be update by the scene
  65011. * @returns agent index
  65012. */
  65013. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65014. /**
  65015. * Returns the agent position in world space
  65016. * @param index agent index returned by addAgent
  65017. * @returns world space position
  65018. */
  65019. getAgentPosition(index: number): Vector3;
  65020. /**
  65021. * Gets the agent position result in world space
  65022. * @param index agent index returned by addAgent
  65023. * @param result output world space position
  65024. */
  65025. getAgentPositionToRef(index: number, result: Vector3): void;
  65026. /**
  65027. * Gets the agent velocity in world space
  65028. * @param index agent index returned by addAgent
  65029. * @returns world space velocity
  65030. */
  65031. getAgentVelocity(index: number): Vector3;
  65032. /**
  65033. * Gets the agent velocity result in world space
  65034. * @param index agent index returned by addAgent
  65035. * @param result output world space velocity
  65036. */
  65037. getAgentVelocityToRef(index: number, result: Vector3): void;
  65038. /**
  65039. * remove a particular agent previously created
  65040. * @param index agent index returned by addAgent
  65041. */
  65042. removeAgent(index: number): void;
  65043. /**
  65044. * get the list of all agents attached to this crowd
  65045. * @returns list of agent indices
  65046. */
  65047. getAgents(): number[];
  65048. /**
  65049. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65050. * @param deltaTime in seconds
  65051. */
  65052. update(deltaTime: number): void;
  65053. /**
  65054. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65055. * @param index agent index returned by addAgent
  65056. * @param destination targeted world position
  65057. */
  65058. agentGoto(index: number, destination: Vector3): void;
  65059. /**
  65060. * Teleport the agent to a new position
  65061. * @param index agent index returned by addAgent
  65062. * @param destination targeted world position
  65063. */
  65064. agentTeleport(index: number, destination: Vector3): void;
  65065. /**
  65066. * Update agent parameters
  65067. * @param index agent index returned by addAgent
  65068. * @param parameters agent parameters
  65069. */
  65070. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65071. /**
  65072. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65073. * The queries will try to find a solution within those bounds
  65074. * default is (1,1,1)
  65075. * @param extent x,y,z value that define the extent around the queries point of reference
  65076. */
  65077. setDefaultQueryExtent(extent: Vector3): void;
  65078. /**
  65079. * Get the Bounding box extent specified by setDefaultQueryExtent
  65080. * @returns the box extent values
  65081. */
  65082. getDefaultQueryExtent(): Vector3;
  65083. /**
  65084. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65085. * @param result output the box extent values
  65086. */
  65087. getDefaultQueryExtentToRef(result: Vector3): void;
  65088. /**
  65089. * Release all resources
  65090. */
  65091. dispose(): void;
  65092. }
  65093. /**
  65094. * Configures an agent
  65095. */
  65096. export interface IAgentParameters {
  65097. /**
  65098. * Agent radius. [Limit: >= 0]
  65099. */
  65100. radius: number;
  65101. /**
  65102. * Agent height. [Limit: > 0]
  65103. */
  65104. height: number;
  65105. /**
  65106. * Maximum allowed acceleration. [Limit: >= 0]
  65107. */
  65108. maxAcceleration: number;
  65109. /**
  65110. * Maximum allowed speed. [Limit: >= 0]
  65111. */
  65112. maxSpeed: number;
  65113. /**
  65114. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65115. */
  65116. collisionQueryRange: number;
  65117. /**
  65118. * The path visibility optimization range. [Limit: > 0]
  65119. */
  65120. pathOptimizationRange: number;
  65121. /**
  65122. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65123. */
  65124. separationWeight: number;
  65125. }
  65126. /**
  65127. * Configures the navigation mesh creation
  65128. */
  65129. export interface INavMeshParameters {
  65130. /**
  65131. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65132. */
  65133. cs: number;
  65134. /**
  65135. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65136. */
  65137. ch: number;
  65138. /**
  65139. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65140. */
  65141. walkableSlopeAngle: number;
  65142. /**
  65143. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65144. * be considered walkable. [Limit: >= 3] [Units: vx]
  65145. */
  65146. walkableHeight: number;
  65147. /**
  65148. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65149. */
  65150. walkableClimb: number;
  65151. /**
  65152. * The distance to erode/shrink the walkable area of the heightfield away from
  65153. * obstructions. [Limit: >=0] [Units: vx]
  65154. */
  65155. walkableRadius: number;
  65156. /**
  65157. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65158. */
  65159. maxEdgeLen: number;
  65160. /**
  65161. * The maximum distance a simplfied contour's border edges should deviate
  65162. * the original raw contour. [Limit: >=0] [Units: vx]
  65163. */
  65164. maxSimplificationError: number;
  65165. /**
  65166. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65167. */
  65168. minRegionArea: number;
  65169. /**
  65170. * Any regions with a span count smaller than this value will, if possible,
  65171. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65172. */
  65173. mergeRegionArea: number;
  65174. /**
  65175. * The maximum number of vertices allowed for polygons generated during the
  65176. * contour to polygon conversion process. [Limit: >= 3]
  65177. */
  65178. maxVertsPerPoly: number;
  65179. /**
  65180. * Sets the sampling distance to use when generating the detail mesh.
  65181. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65182. */
  65183. detailSampleDist: number;
  65184. /**
  65185. * The maximum distance the detail mesh surface should deviate from heightfield
  65186. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65187. */
  65188. detailSampleMaxError: number;
  65189. }
  65190. }
  65191. declare module BABYLON {
  65192. /**
  65193. * RecastJS navigation plugin
  65194. */
  65195. export class RecastJSPlugin implements INavigationEnginePlugin {
  65196. /**
  65197. * Reference to the Recast library
  65198. */
  65199. bjsRECAST: any;
  65200. /**
  65201. * plugin name
  65202. */
  65203. name: string;
  65204. /**
  65205. * the first navmesh created. We might extend this to support multiple navmeshes
  65206. */
  65207. navMesh: any;
  65208. /**
  65209. * Initializes the recastJS plugin
  65210. * @param recastInjection can be used to inject your own recast reference
  65211. */
  65212. constructor(recastInjection?: any);
  65213. /**
  65214. * Creates a navigation mesh
  65215. * @param meshes array of all the geometry used to compute the navigatio mesh
  65216. * @param parameters bunch of parameters used to filter geometry
  65217. */
  65218. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65219. /**
  65220. * Create a navigation mesh debug mesh
  65221. * @param scene is where the mesh will be added
  65222. * @returns debug display mesh
  65223. */
  65224. createDebugNavMesh(scene: Scene): Mesh;
  65225. /**
  65226. * Get a navigation mesh constrained position, closest to the parameter position
  65227. * @param position world position
  65228. * @returns the closest point to position constrained by the navigation mesh
  65229. */
  65230. getClosestPoint(position: Vector3): Vector3;
  65231. /**
  65232. * Get a navigation mesh constrained position, closest to the parameter position
  65233. * @param position world position
  65234. * @param result output the closest point to position constrained by the navigation mesh
  65235. */
  65236. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65237. /**
  65238. * Get a navigation mesh constrained position, within a particular radius
  65239. * @param position world position
  65240. * @param maxRadius the maximum distance to the constrained world position
  65241. * @returns the closest point to position constrained by the navigation mesh
  65242. */
  65243. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65244. /**
  65245. * Get a navigation mesh constrained position, within a particular radius
  65246. * @param position world position
  65247. * @param maxRadius the maximum distance to the constrained world position
  65248. * @param result output the closest point to position constrained by the navigation mesh
  65249. */
  65250. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65251. /**
  65252. * Compute the final position from a segment made of destination-position
  65253. * @param position world position
  65254. * @param destination world position
  65255. * @returns the resulting point along the navmesh
  65256. */
  65257. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65258. /**
  65259. * Compute the final position from a segment made of destination-position
  65260. * @param position world position
  65261. * @param destination world position
  65262. * @param result output the resulting point along the navmesh
  65263. */
  65264. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65265. /**
  65266. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65267. * @param start world position
  65268. * @param end world position
  65269. * @returns array containing world position composing the path
  65270. */
  65271. computePath(start: Vector3, end: Vector3): Vector3[];
  65272. /**
  65273. * Create a new Crowd so you can add agents
  65274. * @param maxAgents the maximum agent count in the crowd
  65275. * @param maxAgentRadius the maximum radius an agent can have
  65276. * @param scene to attach the crowd to
  65277. * @returns the crowd you can add agents to
  65278. */
  65279. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65280. /**
  65281. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65282. * The queries will try to find a solution within those bounds
  65283. * default is (1,1,1)
  65284. * @param extent x,y,z value that define the extent around the queries point of reference
  65285. */
  65286. setDefaultQueryExtent(extent: Vector3): void;
  65287. /**
  65288. * Get the Bounding box extent specified by setDefaultQueryExtent
  65289. * @returns the box extent values
  65290. */
  65291. getDefaultQueryExtent(): Vector3;
  65292. /**
  65293. * build the navmesh from a previously saved state using getNavmeshData
  65294. * @param data the Uint8Array returned by getNavmeshData
  65295. */
  65296. buildFromNavmeshData(data: Uint8Array): void;
  65297. /**
  65298. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65299. * @returns data the Uint8Array that can be saved and reused
  65300. */
  65301. getNavmeshData(): Uint8Array;
  65302. /**
  65303. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65304. * @param result output the box extent values
  65305. */
  65306. getDefaultQueryExtentToRef(result: Vector3): void;
  65307. /**
  65308. * Disposes
  65309. */
  65310. dispose(): void;
  65311. /**
  65312. * If this plugin is supported
  65313. * @returns true if plugin is supported
  65314. */
  65315. isSupported(): boolean;
  65316. }
  65317. /**
  65318. * Recast detour crowd implementation
  65319. */
  65320. export class RecastJSCrowd implements ICrowd {
  65321. /**
  65322. * Recast/detour plugin
  65323. */
  65324. bjsRECASTPlugin: RecastJSPlugin;
  65325. /**
  65326. * Link to the detour crowd
  65327. */
  65328. recastCrowd: any;
  65329. /**
  65330. * One transform per agent
  65331. */
  65332. transforms: TransformNode[];
  65333. /**
  65334. * All agents created
  65335. */
  65336. agents: number[];
  65337. /**
  65338. * Link to the scene is kept to unregister the crowd from the scene
  65339. */
  65340. private _scene;
  65341. /**
  65342. * Observer for crowd updates
  65343. */
  65344. private _onBeforeAnimationsObserver;
  65345. /**
  65346. * Constructor
  65347. * @param plugin recastJS plugin
  65348. * @param maxAgents the maximum agent count in the crowd
  65349. * @param maxAgentRadius the maximum radius an agent can have
  65350. * @param scene to attach the crowd to
  65351. * @returns the crowd you can add agents to
  65352. */
  65353. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65354. /**
  65355. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65356. * You can attach anything to that node. The node position is updated in the scene update tick.
  65357. * @param pos world position that will be constrained by the navigation mesh
  65358. * @param parameters agent parameters
  65359. * @param transform hooked to the agent that will be update by the scene
  65360. * @returns agent index
  65361. */
  65362. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65363. /**
  65364. * Returns the agent position in world space
  65365. * @param index agent index returned by addAgent
  65366. * @returns world space position
  65367. */
  65368. getAgentPosition(index: number): Vector3;
  65369. /**
  65370. * Returns the agent position result in world space
  65371. * @param index agent index returned by addAgent
  65372. * @param result output world space position
  65373. */
  65374. getAgentPositionToRef(index: number, result: Vector3): void;
  65375. /**
  65376. * Returns the agent velocity in world space
  65377. * @param index agent index returned by addAgent
  65378. * @returns world space velocity
  65379. */
  65380. getAgentVelocity(index: number): Vector3;
  65381. /**
  65382. * Returns the agent velocity result in world space
  65383. * @param index agent index returned by addAgent
  65384. * @param result output world space velocity
  65385. */
  65386. getAgentVelocityToRef(index: number, result: Vector3): void;
  65387. /**
  65388. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65389. * @param index agent index returned by addAgent
  65390. * @param destination targeted world position
  65391. */
  65392. agentGoto(index: number, destination: Vector3): void;
  65393. /**
  65394. * Teleport the agent to a new position
  65395. * @param index agent index returned by addAgent
  65396. * @param destination targeted world position
  65397. */
  65398. agentTeleport(index: number, destination: Vector3): void;
  65399. /**
  65400. * Update agent parameters
  65401. * @param index agent index returned by addAgent
  65402. * @param parameters agent parameters
  65403. */
  65404. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65405. /**
  65406. * remove a particular agent previously created
  65407. * @param index agent index returned by addAgent
  65408. */
  65409. removeAgent(index: number): void;
  65410. /**
  65411. * get the list of all agents attached to this crowd
  65412. * @returns list of agent indices
  65413. */
  65414. getAgents(): number[];
  65415. /**
  65416. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65417. * @param deltaTime in seconds
  65418. */
  65419. update(deltaTime: number): void;
  65420. /**
  65421. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65422. * The queries will try to find a solution within those bounds
  65423. * default is (1,1,1)
  65424. * @param extent x,y,z value that define the extent around the queries point of reference
  65425. */
  65426. setDefaultQueryExtent(extent: Vector3): void;
  65427. /**
  65428. * Get the Bounding box extent specified by setDefaultQueryExtent
  65429. * @returns the box extent values
  65430. */
  65431. getDefaultQueryExtent(): Vector3;
  65432. /**
  65433. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65434. * @param result output the box extent values
  65435. */
  65436. getDefaultQueryExtentToRef(result: Vector3): void;
  65437. /**
  65438. * Release all resources
  65439. */
  65440. dispose(): void;
  65441. }
  65442. }
  65443. declare module BABYLON {
  65444. /**
  65445. * Class used to enable access to IndexedDB
  65446. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65447. */
  65448. export class Database implements IOfflineProvider {
  65449. private _callbackManifestChecked;
  65450. private _currentSceneUrl;
  65451. private _db;
  65452. private _enableSceneOffline;
  65453. private _enableTexturesOffline;
  65454. private _manifestVersionFound;
  65455. private _mustUpdateRessources;
  65456. private _hasReachedQuota;
  65457. private _isSupported;
  65458. private _idbFactory;
  65459. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65460. private static IsUASupportingBlobStorage;
  65461. /**
  65462. * Gets a boolean indicating if Database storate is enabled (off by default)
  65463. */
  65464. static IDBStorageEnabled: boolean;
  65465. /**
  65466. * Gets a boolean indicating if scene must be saved in the database
  65467. */
  65468. get enableSceneOffline(): boolean;
  65469. /**
  65470. * Gets a boolean indicating if textures must be saved in the database
  65471. */
  65472. get enableTexturesOffline(): boolean;
  65473. /**
  65474. * Creates a new Database
  65475. * @param urlToScene defines the url to load the scene
  65476. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65477. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65478. */
  65479. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65480. private static _ParseURL;
  65481. private static _ReturnFullUrlLocation;
  65482. private _checkManifestFile;
  65483. /**
  65484. * Open the database and make it available
  65485. * @param successCallback defines the callback to call on success
  65486. * @param errorCallback defines the callback to call on error
  65487. */
  65488. open(successCallback: () => void, errorCallback: () => void): void;
  65489. /**
  65490. * Loads an image from the database
  65491. * @param url defines the url to load from
  65492. * @param image defines the target DOM image
  65493. */
  65494. loadImage(url: string, image: HTMLImageElement): void;
  65495. private _loadImageFromDBAsync;
  65496. private _saveImageIntoDBAsync;
  65497. private _checkVersionFromDB;
  65498. private _loadVersionFromDBAsync;
  65499. private _saveVersionIntoDBAsync;
  65500. /**
  65501. * Loads a file from database
  65502. * @param url defines the URL to load from
  65503. * @param sceneLoaded defines a callback to call on success
  65504. * @param progressCallBack defines a callback to call when progress changed
  65505. * @param errorCallback defines a callback to call on error
  65506. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65507. */
  65508. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65509. private _loadFileAsync;
  65510. private _saveFileAsync;
  65511. /**
  65512. * Validates if xhr data is correct
  65513. * @param xhr defines the request to validate
  65514. * @param dataType defines the expected data type
  65515. * @returns true if data is correct
  65516. */
  65517. private static _ValidateXHRData;
  65518. }
  65519. }
  65520. declare module BABYLON {
  65521. /** @hidden */
  65522. export var gpuUpdateParticlesPixelShader: {
  65523. name: string;
  65524. shader: string;
  65525. };
  65526. }
  65527. declare module BABYLON {
  65528. /** @hidden */
  65529. export var gpuUpdateParticlesVertexShader: {
  65530. name: string;
  65531. shader: string;
  65532. };
  65533. }
  65534. declare module BABYLON {
  65535. /** @hidden */
  65536. export var clipPlaneFragmentDeclaration2: {
  65537. name: string;
  65538. shader: string;
  65539. };
  65540. }
  65541. declare module BABYLON {
  65542. /** @hidden */
  65543. export var gpuRenderParticlesPixelShader: {
  65544. name: string;
  65545. shader: string;
  65546. };
  65547. }
  65548. declare module BABYLON {
  65549. /** @hidden */
  65550. export var clipPlaneVertexDeclaration2: {
  65551. name: string;
  65552. shader: string;
  65553. };
  65554. }
  65555. declare module BABYLON {
  65556. /** @hidden */
  65557. export var gpuRenderParticlesVertexShader: {
  65558. name: string;
  65559. shader: string;
  65560. };
  65561. }
  65562. declare module BABYLON {
  65563. /**
  65564. * This represents a GPU particle system in Babylon
  65565. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65566. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65567. */
  65568. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65569. /**
  65570. * The layer mask we are rendering the particles through.
  65571. */
  65572. layerMask: number;
  65573. private _capacity;
  65574. private _activeCount;
  65575. private _currentActiveCount;
  65576. private _accumulatedCount;
  65577. private _renderEffect;
  65578. private _updateEffect;
  65579. private _buffer0;
  65580. private _buffer1;
  65581. private _spriteBuffer;
  65582. private _updateVAO;
  65583. private _renderVAO;
  65584. private _targetIndex;
  65585. private _sourceBuffer;
  65586. private _targetBuffer;
  65587. private _engine;
  65588. private _currentRenderId;
  65589. private _started;
  65590. private _stopped;
  65591. private _timeDelta;
  65592. private _randomTexture;
  65593. private _randomTexture2;
  65594. private _attributesStrideSize;
  65595. private _updateEffectOptions;
  65596. private _randomTextureSize;
  65597. private _actualFrame;
  65598. private _customEffect;
  65599. private readonly _rawTextureWidth;
  65600. /**
  65601. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65602. */
  65603. static get IsSupported(): boolean;
  65604. /**
  65605. * An event triggered when the system is disposed.
  65606. */
  65607. onDisposeObservable: Observable<IParticleSystem>;
  65608. /**
  65609. * Gets the maximum number of particles active at the same time.
  65610. * @returns The max number of active particles.
  65611. */
  65612. getCapacity(): number;
  65613. /**
  65614. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65615. * to override the particles.
  65616. */
  65617. forceDepthWrite: boolean;
  65618. /**
  65619. * Gets or set the number of active particles
  65620. */
  65621. get activeParticleCount(): number;
  65622. set activeParticleCount(value: number);
  65623. private _preWarmDone;
  65624. /**
  65625. * Specifies if the particles are updated in emitter local space or world space.
  65626. */
  65627. isLocal: boolean;
  65628. /**
  65629. * Is this system ready to be used/rendered
  65630. * @return true if the system is ready
  65631. */
  65632. isReady(): boolean;
  65633. /**
  65634. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65635. * @returns True if it has been started, otherwise false.
  65636. */
  65637. isStarted(): boolean;
  65638. /**
  65639. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65640. * @returns True if it has been stopped, otherwise false.
  65641. */
  65642. isStopped(): boolean;
  65643. /**
  65644. * Gets a boolean indicating that the system is stopping
  65645. * @returns true if the system is currently stopping
  65646. */
  65647. isStopping(): boolean;
  65648. /**
  65649. * Gets the number of particles active at the same time.
  65650. * @returns The number of active particles.
  65651. */
  65652. getActiveCount(): number;
  65653. /**
  65654. * Starts the particle system and begins to emit
  65655. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65656. */
  65657. start(delay?: number): void;
  65658. /**
  65659. * Stops the particle system.
  65660. */
  65661. stop(): void;
  65662. /**
  65663. * Remove all active particles
  65664. */
  65665. reset(): void;
  65666. /**
  65667. * Returns the string "GPUParticleSystem"
  65668. * @returns a string containing the class name
  65669. */
  65670. getClassName(): string;
  65671. /**
  65672. * Gets the custom effect used to render the particles
  65673. * @param blendMode Blend mode for which the effect should be retrieved
  65674. * @returns The effect
  65675. */
  65676. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65677. /**
  65678. * Sets the custom effect used to render the particles
  65679. * @param effect The effect to set
  65680. * @param blendMode Blend mode for which the effect should be set
  65681. */
  65682. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65683. /** @hidden */
  65684. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65685. /**
  65686. * Observable that will be called just before the particles are drawn
  65687. */
  65688. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65689. /**
  65690. * Gets the name of the particle vertex shader
  65691. */
  65692. get vertexShaderName(): string;
  65693. private _colorGradientsTexture;
  65694. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65695. /**
  65696. * Adds a new color gradient
  65697. * @param gradient defines the gradient to use (between 0 and 1)
  65698. * @param color1 defines the color to affect to the specified gradient
  65699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65700. * @returns the current particle system
  65701. */
  65702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65703. private _refreshColorGradient;
  65704. /** Force the system to rebuild all gradients that need to be resync */
  65705. forceRefreshGradients(): void;
  65706. /**
  65707. * Remove a specific color gradient
  65708. * @param gradient defines the gradient to remove
  65709. * @returns the current particle system
  65710. */
  65711. removeColorGradient(gradient: number): GPUParticleSystem;
  65712. private _angularSpeedGradientsTexture;
  65713. private _sizeGradientsTexture;
  65714. private _velocityGradientsTexture;
  65715. private _limitVelocityGradientsTexture;
  65716. private _dragGradientsTexture;
  65717. private _addFactorGradient;
  65718. /**
  65719. * Adds a new size gradient
  65720. * @param gradient defines the gradient to use (between 0 and 1)
  65721. * @param factor defines the size factor to affect to the specified gradient
  65722. * @returns the current particle system
  65723. */
  65724. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65725. /**
  65726. * Remove a specific size gradient
  65727. * @param gradient defines the gradient to remove
  65728. * @returns the current particle system
  65729. */
  65730. removeSizeGradient(gradient: number): GPUParticleSystem;
  65731. private _refreshFactorGradient;
  65732. /**
  65733. * Adds a new angular speed gradient
  65734. * @param gradient defines the gradient to use (between 0 and 1)
  65735. * @param factor defines the angular speed to affect to the specified gradient
  65736. * @returns the current particle system
  65737. */
  65738. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65739. /**
  65740. * Remove a specific angular speed gradient
  65741. * @param gradient defines the gradient to remove
  65742. * @returns the current particle system
  65743. */
  65744. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65745. /**
  65746. * Adds a new velocity gradient
  65747. * @param gradient defines the gradient to use (between 0 and 1)
  65748. * @param factor defines the velocity to affect to the specified gradient
  65749. * @returns the current particle system
  65750. */
  65751. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65752. /**
  65753. * Remove a specific velocity gradient
  65754. * @param gradient defines the gradient to remove
  65755. * @returns the current particle system
  65756. */
  65757. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65758. /**
  65759. * Adds a new limit velocity gradient
  65760. * @param gradient defines the gradient to use (between 0 and 1)
  65761. * @param factor defines the limit velocity value to affect to the specified gradient
  65762. * @returns the current particle system
  65763. */
  65764. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65765. /**
  65766. * Remove a specific limit velocity gradient
  65767. * @param gradient defines the gradient to remove
  65768. * @returns the current particle system
  65769. */
  65770. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65771. /**
  65772. * Adds a new drag gradient
  65773. * @param gradient defines the gradient to use (between 0 and 1)
  65774. * @param factor defines the drag value to affect to the specified gradient
  65775. * @returns the current particle system
  65776. */
  65777. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65778. /**
  65779. * Remove a specific drag gradient
  65780. * @param gradient defines the gradient to remove
  65781. * @returns the current particle system
  65782. */
  65783. removeDragGradient(gradient: number): GPUParticleSystem;
  65784. /**
  65785. * Not supported by GPUParticleSystem
  65786. * @param gradient defines the gradient to use (between 0 and 1)
  65787. * @param factor defines the emit rate value to affect to the specified gradient
  65788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65789. * @returns the current particle system
  65790. */
  65791. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65792. /**
  65793. * Not supported by GPUParticleSystem
  65794. * @param gradient defines the gradient to remove
  65795. * @returns the current particle system
  65796. */
  65797. removeEmitRateGradient(gradient: number): IParticleSystem;
  65798. /**
  65799. * Not supported by GPUParticleSystem
  65800. * @param gradient defines the gradient to use (between 0 and 1)
  65801. * @param factor defines the start size value to affect to the specified gradient
  65802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65803. * @returns the current particle system
  65804. */
  65805. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65806. /**
  65807. * Not supported by GPUParticleSystem
  65808. * @param gradient defines the gradient to remove
  65809. * @returns the current particle system
  65810. */
  65811. removeStartSizeGradient(gradient: number): IParticleSystem;
  65812. /**
  65813. * Not supported by GPUParticleSystem
  65814. * @param gradient defines the gradient to use (between 0 and 1)
  65815. * @param min defines the color remap minimal range
  65816. * @param max defines the color remap maximal range
  65817. * @returns the current particle system
  65818. */
  65819. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65820. /**
  65821. * Not supported by GPUParticleSystem
  65822. * @param gradient defines the gradient to remove
  65823. * @returns the current particle system
  65824. */
  65825. removeColorRemapGradient(): IParticleSystem;
  65826. /**
  65827. * Not supported by GPUParticleSystem
  65828. * @param gradient defines the gradient to use (between 0 and 1)
  65829. * @param min defines the alpha remap minimal range
  65830. * @param max defines the alpha remap maximal range
  65831. * @returns the current particle system
  65832. */
  65833. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65834. /**
  65835. * Not supported by GPUParticleSystem
  65836. * @param gradient defines the gradient to remove
  65837. * @returns the current particle system
  65838. */
  65839. removeAlphaRemapGradient(): IParticleSystem;
  65840. /**
  65841. * Not supported by GPUParticleSystem
  65842. * @param gradient defines the gradient to use (between 0 and 1)
  65843. * @param color defines the color to affect to the specified gradient
  65844. * @returns the current particle system
  65845. */
  65846. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65847. /**
  65848. * Not supported by GPUParticleSystem
  65849. * @param gradient defines the gradient to remove
  65850. * @returns the current particle system
  65851. */
  65852. removeRampGradient(): IParticleSystem;
  65853. /**
  65854. * Not supported by GPUParticleSystem
  65855. * @returns the list of ramp gradients
  65856. */
  65857. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65858. /**
  65859. * Not supported by GPUParticleSystem
  65860. * Gets or sets a boolean indicating that ramp gradients must be used
  65861. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65862. */
  65863. get useRampGradients(): boolean;
  65864. set useRampGradients(value: boolean);
  65865. /**
  65866. * Not supported by GPUParticleSystem
  65867. * @param gradient defines the gradient to use (between 0 and 1)
  65868. * @param factor defines the life time factor to affect to the specified gradient
  65869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65870. * @returns the current particle system
  65871. */
  65872. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65873. /**
  65874. * Not supported by GPUParticleSystem
  65875. * @param gradient defines the gradient to remove
  65876. * @returns the current particle system
  65877. */
  65878. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65879. /**
  65880. * Instantiates a GPU particle system.
  65881. * 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.
  65882. * @param name The name of the particle system
  65883. * @param options The options used to create the system
  65884. * @param scene The scene the particle system belongs to
  65885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65886. * @param customEffect a custom effect used to change the way particles are rendered by default
  65887. */
  65888. constructor(name: string, options: Partial<{
  65889. capacity: number;
  65890. randomTextureSize: number;
  65891. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65892. protected _reset(): void;
  65893. private _createUpdateVAO;
  65894. private _createRenderVAO;
  65895. private _initialize;
  65896. /** @hidden */
  65897. _recreateUpdateEffect(): void;
  65898. private _getEffect;
  65899. /**
  65900. * Fill the defines array according to the current settings of the particle system
  65901. * @param defines Array to be updated
  65902. * @param blendMode blend mode to take into account when updating the array
  65903. */
  65904. fillDefines(defines: Array<string>, blendMode?: number): void;
  65905. /**
  65906. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65907. * @param uniforms Uniforms array to fill
  65908. * @param attributes Attributes array to fill
  65909. * @param samplers Samplers array to fill
  65910. */
  65911. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65912. /** @hidden */
  65913. _recreateRenderEffect(): Effect;
  65914. /**
  65915. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65916. * @param preWarm defines if we are in the pre-warmimg phase
  65917. */
  65918. animate(preWarm?: boolean): void;
  65919. private _createFactorGradientTexture;
  65920. private _createSizeGradientTexture;
  65921. private _createAngularSpeedGradientTexture;
  65922. private _createVelocityGradientTexture;
  65923. private _createLimitVelocityGradientTexture;
  65924. private _createDragGradientTexture;
  65925. private _createColorGradientTexture;
  65926. /**
  65927. * Renders the particle system in its current state
  65928. * @param preWarm defines if the system should only update the particles but not render them
  65929. * @returns the current number of particles
  65930. */
  65931. render(preWarm?: boolean): number;
  65932. /**
  65933. * Rebuilds the particle system
  65934. */
  65935. rebuild(): void;
  65936. private _releaseBuffers;
  65937. private _releaseVAOs;
  65938. /**
  65939. * Disposes the particle system and free the associated resources
  65940. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65941. */
  65942. dispose(disposeTexture?: boolean): void;
  65943. /**
  65944. * Clones the particle system.
  65945. * @param name The name of the cloned object
  65946. * @param newEmitter The new emitter to use
  65947. * @returns the cloned particle system
  65948. */
  65949. clone(name: string, newEmitter: any): GPUParticleSystem;
  65950. /**
  65951. * Serializes the particle system to a JSON object
  65952. * @param serializeTexture defines if the texture must be serialized as well
  65953. * @returns the JSON object
  65954. */
  65955. serialize(serializeTexture?: boolean): any;
  65956. /**
  65957. * Parses a JSON object to create a GPU particle system.
  65958. * @param parsedParticleSystem The JSON object to parse
  65959. * @param scene The scene to create the particle system in
  65960. * @param rootUrl The root url to use to load external dependencies like texture
  65961. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65962. * @returns the parsed GPU particle system
  65963. */
  65964. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65965. }
  65966. }
  65967. declare module BABYLON {
  65968. /**
  65969. * Represents a set of particle systems working together to create a specific effect
  65970. */
  65971. export class ParticleSystemSet implements IDisposable {
  65972. /**
  65973. * Gets or sets base Assets URL
  65974. */
  65975. static BaseAssetsUrl: string;
  65976. private _emitterCreationOptions;
  65977. private _emitterNode;
  65978. /**
  65979. * Gets the particle system list
  65980. */
  65981. systems: IParticleSystem[];
  65982. /**
  65983. * Gets the emitter node used with this set
  65984. */
  65985. get emitterNode(): Nullable<TransformNode>;
  65986. /**
  65987. * Creates a new emitter mesh as a sphere
  65988. * @param options defines the options used to create the sphere
  65989. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65990. * @param scene defines the hosting scene
  65991. */
  65992. setEmitterAsSphere(options: {
  65993. diameter: number;
  65994. segments: number;
  65995. color: Color3;
  65996. }, renderingGroupId: number, scene: Scene): void;
  65997. /**
  65998. * Starts all particle systems of the set
  65999. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66000. */
  66001. start(emitter?: AbstractMesh): void;
  66002. /**
  66003. * Release all associated resources
  66004. */
  66005. dispose(): void;
  66006. /**
  66007. * Serialize the set into a JSON compatible object
  66008. * @param serializeTexture defines if the texture must be serialized as well
  66009. * @returns a JSON compatible representation of the set
  66010. */
  66011. serialize(serializeTexture?: boolean): any;
  66012. /**
  66013. * Parse a new ParticleSystemSet from a serialized source
  66014. * @param data defines a JSON compatible representation of the set
  66015. * @param scene defines the hosting scene
  66016. * @param gpu defines if we want GPU particles or CPU particles
  66017. * @returns a new ParticleSystemSet
  66018. */
  66019. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66020. }
  66021. }
  66022. declare module BABYLON {
  66023. /**
  66024. * This class is made for on one-liner static method to help creating particle system set.
  66025. */
  66026. export class ParticleHelper {
  66027. /**
  66028. * Gets or sets base Assets URL
  66029. */
  66030. static BaseAssetsUrl: string;
  66031. /** Define the Url to load snippets */
  66032. static SnippetUrl: string;
  66033. /**
  66034. * Create a default particle system that you can tweak
  66035. * @param emitter defines the emitter to use
  66036. * @param capacity defines the system capacity (default is 500 particles)
  66037. * @param scene defines the hosting scene
  66038. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66039. * @returns the new Particle system
  66040. */
  66041. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66042. /**
  66043. * This is the main static method (one-liner) of this helper to create different particle systems
  66044. * @param type This string represents the type to the particle system to create
  66045. * @param scene The scene where the particle system should live
  66046. * @param gpu If the system will use gpu
  66047. * @returns the ParticleSystemSet created
  66048. */
  66049. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66050. /**
  66051. * Static function used to export a particle system to a ParticleSystemSet variable.
  66052. * Please note that the emitter shape is not exported
  66053. * @param systems defines the particle systems to export
  66054. * @returns the created particle system set
  66055. */
  66056. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66057. /**
  66058. * Creates a particle system from a snippet saved in a remote file
  66059. * @param name defines the name of the particle system to create
  66060. * @param url defines the url to load from
  66061. * @param scene defines the hosting scene
  66062. * @param gpu If the system will use gpu
  66063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66064. * @returns a promise that will resolve to the new particle system
  66065. */
  66066. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66067. /**
  66068. * Creates a particle system from a snippet saved by the particle system editor
  66069. * @param snippetId defines the snippet to load
  66070. * @param scene defines the hosting scene
  66071. * @param gpu If the system will use gpu
  66072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66073. * @returns a promise that will resolve to the new particle system
  66074. */
  66075. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66076. }
  66077. }
  66078. declare module BABYLON {
  66079. interface Engine {
  66080. /**
  66081. * Create an effect to use with particle systems.
  66082. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66083. * the particle system for which you want to create a custom effect in the last parameter
  66084. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66085. * @param uniformsNames defines a list of attribute names
  66086. * @param samplers defines an array of string used to represent textures
  66087. * @param defines defines the string containing the defines to use to compile the shaders
  66088. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66089. * @param onCompiled defines a function to call when the effect creation is successful
  66090. * @param onError defines a function to call when the effect creation has failed
  66091. * @param particleSystem the particle system you want to create the effect for
  66092. * @returns the new Effect
  66093. */
  66094. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66095. }
  66096. interface Mesh {
  66097. /**
  66098. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66099. * @returns an array of IParticleSystem
  66100. */
  66101. getEmittedParticleSystems(): IParticleSystem[];
  66102. /**
  66103. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66104. * @returns an array of IParticleSystem
  66105. */
  66106. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66107. }
  66108. /**
  66109. * @hidden
  66110. */
  66111. export var _IDoNeedToBeInTheBuild: number;
  66112. }
  66113. declare module BABYLON {
  66114. /** Defines the 4 color options */
  66115. export enum PointColor {
  66116. /** color value */
  66117. Color = 2,
  66118. /** uv value */
  66119. UV = 1,
  66120. /** random value */
  66121. Random = 0,
  66122. /** stated value */
  66123. Stated = 3
  66124. }
  66125. /**
  66126. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66127. * 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.
  66128. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66129. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66130. *
  66131. * Full documentation here : TO BE ENTERED
  66132. */
  66133. export class PointsCloudSystem implements IDisposable {
  66134. /**
  66135. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66136. * Example : var p = SPS.particles[i];
  66137. */
  66138. particles: CloudPoint[];
  66139. /**
  66140. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66141. */
  66142. nbParticles: number;
  66143. /**
  66144. * This a counter for your own usage. It's not set by any SPS functions.
  66145. */
  66146. counter: number;
  66147. /**
  66148. * The PCS name. This name is also given to the underlying mesh.
  66149. */
  66150. name: string;
  66151. /**
  66152. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66153. */
  66154. mesh: Mesh;
  66155. /**
  66156. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66157. * Please read :
  66158. */
  66159. vars: any;
  66160. /**
  66161. * @hidden
  66162. */
  66163. _size: number;
  66164. private _scene;
  66165. private _promises;
  66166. private _positions;
  66167. private _indices;
  66168. private _normals;
  66169. private _colors;
  66170. private _uvs;
  66171. private _indices32;
  66172. private _positions32;
  66173. private _colors32;
  66174. private _uvs32;
  66175. private _updatable;
  66176. private _isVisibilityBoxLocked;
  66177. private _alwaysVisible;
  66178. private _groups;
  66179. private _groupCounter;
  66180. private _computeParticleColor;
  66181. private _computeParticleTexture;
  66182. private _computeParticleRotation;
  66183. private _computeBoundingBox;
  66184. private _isReady;
  66185. /**
  66186. * Creates a PCS (Points Cloud System) object
  66187. * @param name (String) is the PCS name, this will be the underlying mesh name
  66188. * @param pointSize (number) is the size for each point
  66189. * @param scene (Scene) is the scene in which the PCS is added
  66190. * @param options defines the options of the PCS e.g.
  66191. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66192. */
  66193. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66194. updatable?: boolean;
  66195. });
  66196. /**
  66197. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66198. * If no points were added to the PCS, the returned mesh is just a single point.
  66199. * @returns a promise for the created mesh
  66200. */
  66201. buildMeshAsync(): Promise<Mesh>;
  66202. /**
  66203. * @hidden
  66204. */
  66205. private _buildMesh;
  66206. private _addParticle;
  66207. private _randomUnitVector;
  66208. private _getColorIndicesForCoord;
  66209. private _setPointsColorOrUV;
  66210. private _colorFromTexture;
  66211. private _calculateDensity;
  66212. /**
  66213. * Adds points to the PCS in random positions within a unit sphere
  66214. * @param nb (positive integer) the number of particles to be created from this model
  66215. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66216. * @returns the number of groups in the system
  66217. */
  66218. addPoints(nb: number, pointFunction?: any): number;
  66219. /**
  66220. * Adds points to the PCS from the surface of the model shape
  66221. * @param mesh is any Mesh object that will be used as a surface model for the points
  66222. * @param nb (positive integer) the number of particles to be created from this model
  66223. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66224. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66225. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66226. * @returns the number of groups in the system
  66227. */
  66228. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66229. /**
  66230. * Adds points to the PCS inside the model shape
  66231. * @param mesh is any Mesh object that will be used as a surface model for the points
  66232. * @param nb (positive integer) the number of particles to be created from this model
  66233. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66234. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66235. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66236. * @returns the number of groups in the system
  66237. */
  66238. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66239. /**
  66240. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66241. * This method calls `updateParticle()` for each particle of the SPS.
  66242. * For an animated SPS, it is usually called within the render loop.
  66243. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66244. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66245. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66246. * @returns the PCS.
  66247. */
  66248. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66249. /**
  66250. * Disposes the PCS.
  66251. */
  66252. dispose(): void;
  66253. /**
  66254. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66255. * doc :
  66256. * @returns the PCS.
  66257. */
  66258. refreshVisibleSize(): PointsCloudSystem;
  66259. /**
  66260. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66261. * @param size the size (float) of the visibility box
  66262. * note : this doesn't lock the PCS mesh bounding box.
  66263. * doc :
  66264. */
  66265. setVisibilityBox(size: number): void;
  66266. /**
  66267. * Gets whether the PCS is always visible or not
  66268. * doc :
  66269. */
  66270. get isAlwaysVisible(): boolean;
  66271. /**
  66272. * Sets the PCS as always visible or not
  66273. * doc :
  66274. */
  66275. set isAlwaysVisible(val: boolean);
  66276. /**
  66277. * Tells to `setParticles()` to compute the particle rotations or not
  66278. * Default value : false. The PCS is faster when it's set to false
  66279. * Note : particle rotations are only applied to parent particles
  66280. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66281. */
  66282. set computeParticleRotation(val: boolean);
  66283. /**
  66284. * Tells to `setParticles()` to compute the particle colors or not.
  66285. * Default value : true. The PCS is faster when it's set to false.
  66286. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66287. */
  66288. set computeParticleColor(val: boolean);
  66289. set computeParticleTexture(val: boolean);
  66290. /**
  66291. * Gets if `setParticles()` computes the particle colors or not.
  66292. * Default value : false. The PCS is faster when it's set to false.
  66293. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66294. */
  66295. get computeParticleColor(): boolean;
  66296. /**
  66297. * Gets if `setParticles()` computes the particle textures or not.
  66298. * Default value : false. The PCS is faster when it's set to false.
  66299. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66300. */
  66301. get computeParticleTexture(): boolean;
  66302. /**
  66303. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66304. */
  66305. set computeBoundingBox(val: boolean);
  66306. /**
  66307. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66308. */
  66309. get computeBoundingBox(): boolean;
  66310. /**
  66311. * This function does nothing. It may be overwritten to set all the particle first values.
  66312. * The PCS doesn't call this function, you may have to call it by your own.
  66313. * doc :
  66314. */
  66315. initParticles(): void;
  66316. /**
  66317. * This function does nothing. It may be overwritten to recycle a particle
  66318. * The PCS doesn't call this function, you can to call it
  66319. * doc :
  66320. * @param particle The particle to recycle
  66321. * @returns the recycled particle
  66322. */
  66323. recycleParticle(particle: CloudPoint): CloudPoint;
  66324. /**
  66325. * Updates a particle : this function should be overwritten by the user.
  66326. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66327. * doc :
  66328. * @example : just set a particle position or velocity and recycle conditions
  66329. * @param particle The particle to update
  66330. * @returns the updated particle
  66331. */
  66332. updateParticle(particle: CloudPoint): CloudPoint;
  66333. /**
  66334. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66335. * This does nothing and may be overwritten by the user.
  66336. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66337. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66338. * @param update the boolean update value actually passed to setParticles()
  66339. */
  66340. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66341. /**
  66342. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66343. * This will be passed three parameters.
  66344. * This does nothing and may be overwritten by the user.
  66345. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66346. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66347. * @param update the boolean update value actually passed to setParticles()
  66348. */
  66349. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66350. }
  66351. }
  66352. declare module BABYLON {
  66353. /**
  66354. * Represents one particle of a points cloud system.
  66355. */
  66356. export class CloudPoint {
  66357. /**
  66358. * particle global index
  66359. */
  66360. idx: number;
  66361. /**
  66362. * The color of the particle
  66363. */
  66364. color: Nullable<Color4>;
  66365. /**
  66366. * The world space position of the particle.
  66367. */
  66368. position: Vector3;
  66369. /**
  66370. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66371. */
  66372. rotation: Vector3;
  66373. /**
  66374. * The world space rotation quaternion of the particle.
  66375. */
  66376. rotationQuaternion: Nullable<Quaternion>;
  66377. /**
  66378. * The uv of the particle.
  66379. */
  66380. uv: Nullable<Vector2>;
  66381. /**
  66382. * The current speed of the particle.
  66383. */
  66384. velocity: Vector3;
  66385. /**
  66386. * The pivot point in the particle local space.
  66387. */
  66388. pivot: Vector3;
  66389. /**
  66390. * Must the particle be translated from its pivot point in its local space ?
  66391. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66392. * Default : false
  66393. */
  66394. translateFromPivot: boolean;
  66395. /**
  66396. * Index of this particle in the global "positions" array (Internal use)
  66397. * @hidden
  66398. */
  66399. _pos: number;
  66400. /**
  66401. * @hidden Index of this particle in the global "indices" array (Internal use)
  66402. */
  66403. _ind: number;
  66404. /**
  66405. * Group this particle belongs to
  66406. */
  66407. _group: PointsGroup;
  66408. /**
  66409. * Group id of this particle
  66410. */
  66411. groupId: number;
  66412. /**
  66413. * Index of the particle in its group id (Internal use)
  66414. */
  66415. idxInGroup: number;
  66416. /**
  66417. * @hidden Particle BoundingInfo object (Internal use)
  66418. */
  66419. _boundingInfo: BoundingInfo;
  66420. /**
  66421. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66422. */
  66423. _pcs: PointsCloudSystem;
  66424. /**
  66425. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66426. */
  66427. _stillInvisible: boolean;
  66428. /**
  66429. * @hidden Last computed particle rotation matrix
  66430. */
  66431. _rotationMatrix: number[];
  66432. /**
  66433. * Parent particle Id, if any.
  66434. * Default null.
  66435. */
  66436. parentId: Nullable<number>;
  66437. /**
  66438. * @hidden Internal global position in the PCS.
  66439. */
  66440. _globalPosition: Vector3;
  66441. /**
  66442. * Creates a Point Cloud object.
  66443. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66444. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66445. * @param group (PointsGroup) is the group the particle belongs to
  66446. * @param groupId (integer) is the group identifier in the PCS.
  66447. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66448. * @param pcs defines the PCS it is associated to
  66449. */
  66450. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66451. /**
  66452. * get point size
  66453. */
  66454. get size(): Vector3;
  66455. /**
  66456. * Set point size
  66457. */
  66458. set size(scale: Vector3);
  66459. /**
  66460. * Legacy support, changed quaternion to rotationQuaternion
  66461. */
  66462. get quaternion(): Nullable<Quaternion>;
  66463. /**
  66464. * Legacy support, changed quaternion to rotationQuaternion
  66465. */
  66466. set quaternion(q: Nullable<Quaternion>);
  66467. /**
  66468. * Returns a boolean. True if the particle intersects a mesh, else false
  66469. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66470. * @param target is the object (point or mesh) what the intersection is computed against
  66471. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66472. * @returns true if it intersects
  66473. */
  66474. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66475. /**
  66476. * get the rotation matrix of the particle
  66477. * @hidden
  66478. */
  66479. getRotationMatrix(m: Matrix): void;
  66480. }
  66481. /**
  66482. * Represents a group of points in a points cloud system
  66483. * * PCS internal tool, don't use it manually.
  66484. */
  66485. export class PointsGroup {
  66486. /**
  66487. * The group id
  66488. * @hidden
  66489. */
  66490. groupID: number;
  66491. /**
  66492. * image data for group (internal use)
  66493. * @hidden
  66494. */
  66495. _groupImageData: Nullable<ArrayBufferView>;
  66496. /**
  66497. * Image Width (internal use)
  66498. * @hidden
  66499. */
  66500. _groupImgWidth: number;
  66501. /**
  66502. * Image Height (internal use)
  66503. * @hidden
  66504. */
  66505. _groupImgHeight: number;
  66506. /**
  66507. * Custom position function (internal use)
  66508. * @hidden
  66509. */
  66510. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66511. /**
  66512. * density per facet for surface points
  66513. * @hidden
  66514. */
  66515. _groupDensity: number[];
  66516. /**
  66517. * Only when points are colored by texture carries pointer to texture list array
  66518. * @hidden
  66519. */
  66520. _textureNb: number;
  66521. /**
  66522. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66523. * PCS internal tool, don't use it manually.
  66524. * @hidden
  66525. */
  66526. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66527. }
  66528. }
  66529. declare module BABYLON {
  66530. interface Scene {
  66531. /** @hidden (Backing field) */
  66532. _physicsEngine: Nullable<IPhysicsEngine>;
  66533. /** @hidden */
  66534. _physicsTimeAccumulator: number;
  66535. /**
  66536. * Gets the current physics engine
  66537. * @returns a IPhysicsEngine or null if none attached
  66538. */
  66539. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66540. /**
  66541. * Enables physics to the current scene
  66542. * @param gravity defines the scene's gravity for the physics engine
  66543. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66544. * @return a boolean indicating if the physics engine was initialized
  66545. */
  66546. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66547. /**
  66548. * Disables and disposes the physics engine associated with the scene
  66549. */
  66550. disablePhysicsEngine(): void;
  66551. /**
  66552. * Gets a boolean indicating if there is an active physics engine
  66553. * @returns a boolean indicating if there is an active physics engine
  66554. */
  66555. isPhysicsEnabled(): boolean;
  66556. /**
  66557. * Deletes a physics compound impostor
  66558. * @param compound defines the compound to delete
  66559. */
  66560. deleteCompoundImpostor(compound: any): void;
  66561. /**
  66562. * An event triggered when physic simulation is about to be run
  66563. */
  66564. onBeforePhysicsObservable: Observable<Scene>;
  66565. /**
  66566. * An event triggered when physic simulation has been done
  66567. */
  66568. onAfterPhysicsObservable: Observable<Scene>;
  66569. }
  66570. interface AbstractMesh {
  66571. /** @hidden */
  66572. _physicsImpostor: Nullable<PhysicsImpostor>;
  66573. /**
  66574. * Gets or sets impostor used for physic simulation
  66575. * @see http://doc.babylonjs.com/features/physics_engine
  66576. */
  66577. physicsImpostor: Nullable<PhysicsImpostor>;
  66578. /**
  66579. * Gets the current physics impostor
  66580. * @see http://doc.babylonjs.com/features/physics_engine
  66581. * @returns a physics impostor or null
  66582. */
  66583. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66584. /** Apply a physic impulse to the mesh
  66585. * @param force defines the force to apply
  66586. * @param contactPoint defines where to apply the force
  66587. * @returns the current mesh
  66588. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66589. */
  66590. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66591. /**
  66592. * Creates a physic joint between two meshes
  66593. * @param otherMesh defines the other mesh to use
  66594. * @param pivot1 defines the pivot to use on this mesh
  66595. * @param pivot2 defines the pivot to use on the other mesh
  66596. * @param options defines additional options (can be plugin dependent)
  66597. * @returns the current mesh
  66598. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66599. */
  66600. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66601. /** @hidden */
  66602. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66603. }
  66604. /**
  66605. * Defines the physics engine scene component responsible to manage a physics engine
  66606. */
  66607. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66608. /**
  66609. * The component name helpful to identify the component in the list of scene components.
  66610. */
  66611. readonly name: string;
  66612. /**
  66613. * The scene the component belongs to.
  66614. */
  66615. scene: Scene;
  66616. /**
  66617. * Creates a new instance of the component for the given scene
  66618. * @param scene Defines the scene to register the component in
  66619. */
  66620. constructor(scene: Scene);
  66621. /**
  66622. * Registers the component in a given scene
  66623. */
  66624. register(): void;
  66625. /**
  66626. * Rebuilds the elements related to this component in case of
  66627. * context lost for instance.
  66628. */
  66629. rebuild(): void;
  66630. /**
  66631. * Disposes the component and the associated ressources
  66632. */
  66633. dispose(): void;
  66634. }
  66635. }
  66636. declare module BABYLON {
  66637. /**
  66638. * A helper for physics simulations
  66639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66640. */
  66641. export class PhysicsHelper {
  66642. private _scene;
  66643. private _physicsEngine;
  66644. /**
  66645. * Initializes the Physics helper
  66646. * @param scene Babylon.js scene
  66647. */
  66648. constructor(scene: Scene);
  66649. /**
  66650. * Applies a radial explosion impulse
  66651. * @param origin the origin of the explosion
  66652. * @param radiusOrEventOptions the radius or the options of radial explosion
  66653. * @param strength the explosion strength
  66654. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66655. * @returns A physics radial explosion event, or null
  66656. */
  66657. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66658. /**
  66659. * Applies a radial explosion force
  66660. * @param origin the origin of the explosion
  66661. * @param radiusOrEventOptions the radius or the options of radial explosion
  66662. * @param strength the explosion strength
  66663. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66664. * @returns A physics radial explosion event, or null
  66665. */
  66666. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66667. /**
  66668. * Creates a gravitational field
  66669. * @param origin the origin of the explosion
  66670. * @param radiusOrEventOptions the radius or the options of radial explosion
  66671. * @param strength the explosion strength
  66672. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66673. * @returns A physics gravitational field event, or null
  66674. */
  66675. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66676. /**
  66677. * Creates a physics updraft event
  66678. * @param origin the origin of the updraft
  66679. * @param radiusOrEventOptions the radius or the options of the updraft
  66680. * @param strength the strength of the updraft
  66681. * @param height the height of the updraft
  66682. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66683. * @returns A physics updraft event, or null
  66684. */
  66685. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66686. /**
  66687. * Creates a physics vortex event
  66688. * @param origin the of the vortex
  66689. * @param radiusOrEventOptions the radius or the options of the vortex
  66690. * @param strength the strength of the vortex
  66691. * @param height the height of the vortex
  66692. * @returns a Physics vortex event, or null
  66693. * A physics vortex event or null
  66694. */
  66695. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66696. }
  66697. /**
  66698. * Represents a physics radial explosion event
  66699. */
  66700. class PhysicsRadialExplosionEvent {
  66701. private _scene;
  66702. private _options;
  66703. private _sphere;
  66704. private _dataFetched;
  66705. /**
  66706. * Initializes a radial explosioin event
  66707. * @param _scene BabylonJS scene
  66708. * @param _options The options for the vortex event
  66709. */
  66710. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66711. /**
  66712. * Returns the data related to the radial explosion event (sphere).
  66713. * @returns The radial explosion event data
  66714. */
  66715. getData(): PhysicsRadialExplosionEventData;
  66716. /**
  66717. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66718. * @param impostor A physics imposter
  66719. * @param origin the origin of the explosion
  66720. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66721. */
  66722. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66723. /**
  66724. * Triggers affecterd impostors callbacks
  66725. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66726. */
  66727. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66728. /**
  66729. * Disposes the sphere.
  66730. * @param force Specifies if the sphere should be disposed by force
  66731. */
  66732. dispose(force?: boolean): void;
  66733. /*** Helpers ***/
  66734. private _prepareSphere;
  66735. private _intersectsWithSphere;
  66736. }
  66737. /**
  66738. * Represents a gravitational field event
  66739. */
  66740. class PhysicsGravitationalFieldEvent {
  66741. private _physicsHelper;
  66742. private _scene;
  66743. private _origin;
  66744. private _options;
  66745. private _tickCallback;
  66746. private _sphere;
  66747. private _dataFetched;
  66748. /**
  66749. * Initializes the physics gravitational field event
  66750. * @param _physicsHelper A physics helper
  66751. * @param _scene BabylonJS scene
  66752. * @param _origin The origin position of the gravitational field event
  66753. * @param _options The options for the vortex event
  66754. */
  66755. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66756. /**
  66757. * Returns the data related to the gravitational field event (sphere).
  66758. * @returns A gravitational field event
  66759. */
  66760. getData(): PhysicsGravitationalFieldEventData;
  66761. /**
  66762. * Enables the gravitational field.
  66763. */
  66764. enable(): void;
  66765. /**
  66766. * Disables the gravitational field.
  66767. */
  66768. disable(): void;
  66769. /**
  66770. * Disposes the sphere.
  66771. * @param force The force to dispose from the gravitational field event
  66772. */
  66773. dispose(force?: boolean): void;
  66774. private _tick;
  66775. }
  66776. /**
  66777. * Represents a physics updraft event
  66778. */
  66779. class PhysicsUpdraftEvent {
  66780. private _scene;
  66781. private _origin;
  66782. private _options;
  66783. private _physicsEngine;
  66784. private _originTop;
  66785. private _originDirection;
  66786. private _tickCallback;
  66787. private _cylinder;
  66788. private _cylinderPosition;
  66789. private _dataFetched;
  66790. /**
  66791. * Initializes the physics updraft event
  66792. * @param _scene BabylonJS scene
  66793. * @param _origin The origin position of the updraft
  66794. * @param _options The options for the updraft event
  66795. */
  66796. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66797. /**
  66798. * Returns the data related to the updraft event (cylinder).
  66799. * @returns A physics updraft event
  66800. */
  66801. getData(): PhysicsUpdraftEventData;
  66802. /**
  66803. * Enables the updraft.
  66804. */
  66805. enable(): void;
  66806. /**
  66807. * Disables the updraft.
  66808. */
  66809. disable(): void;
  66810. /**
  66811. * Disposes the cylinder.
  66812. * @param force Specifies if the updraft should be disposed by force
  66813. */
  66814. dispose(force?: boolean): void;
  66815. private getImpostorHitData;
  66816. private _tick;
  66817. /*** Helpers ***/
  66818. private _prepareCylinder;
  66819. private _intersectsWithCylinder;
  66820. }
  66821. /**
  66822. * Represents a physics vortex event
  66823. */
  66824. class PhysicsVortexEvent {
  66825. private _scene;
  66826. private _origin;
  66827. private _options;
  66828. private _physicsEngine;
  66829. private _originTop;
  66830. private _tickCallback;
  66831. private _cylinder;
  66832. private _cylinderPosition;
  66833. private _dataFetched;
  66834. /**
  66835. * Initializes the physics vortex event
  66836. * @param _scene The BabylonJS scene
  66837. * @param _origin The origin position of the vortex
  66838. * @param _options The options for the vortex event
  66839. */
  66840. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66841. /**
  66842. * Returns the data related to the vortex event (cylinder).
  66843. * @returns The physics vortex event data
  66844. */
  66845. getData(): PhysicsVortexEventData;
  66846. /**
  66847. * Enables the vortex.
  66848. */
  66849. enable(): void;
  66850. /**
  66851. * Disables the cortex.
  66852. */
  66853. disable(): void;
  66854. /**
  66855. * Disposes the sphere.
  66856. * @param force
  66857. */
  66858. dispose(force?: boolean): void;
  66859. private getImpostorHitData;
  66860. private _tick;
  66861. /*** Helpers ***/
  66862. private _prepareCylinder;
  66863. private _intersectsWithCylinder;
  66864. }
  66865. /**
  66866. * Options fot the radial explosion event
  66867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66868. */
  66869. export class PhysicsRadialExplosionEventOptions {
  66870. /**
  66871. * The radius of the sphere for the radial explosion.
  66872. */
  66873. radius: number;
  66874. /**
  66875. * The strenth of the explosion.
  66876. */
  66877. strength: number;
  66878. /**
  66879. * The strenght of the force in correspondence to the distance of the affected object
  66880. */
  66881. falloff: PhysicsRadialImpulseFalloff;
  66882. /**
  66883. * Sphere options for the radial explosion.
  66884. */
  66885. sphere: {
  66886. segments: number;
  66887. diameter: number;
  66888. };
  66889. /**
  66890. * Sphere options for the radial explosion.
  66891. */
  66892. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66893. }
  66894. /**
  66895. * Options fot the updraft event
  66896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66897. */
  66898. export class PhysicsUpdraftEventOptions {
  66899. /**
  66900. * The radius of the cylinder for the vortex
  66901. */
  66902. radius: number;
  66903. /**
  66904. * The strenth of the updraft.
  66905. */
  66906. strength: number;
  66907. /**
  66908. * The height of the cylinder for the updraft.
  66909. */
  66910. height: number;
  66911. /**
  66912. * The mode for the the updraft.
  66913. */
  66914. updraftMode: PhysicsUpdraftMode;
  66915. }
  66916. /**
  66917. * Options fot the vortex event
  66918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66919. */
  66920. export class PhysicsVortexEventOptions {
  66921. /**
  66922. * The radius of the cylinder for the vortex
  66923. */
  66924. radius: number;
  66925. /**
  66926. * The strenth of the vortex.
  66927. */
  66928. strength: number;
  66929. /**
  66930. * The height of the cylinder for the vortex.
  66931. */
  66932. height: number;
  66933. /**
  66934. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66935. */
  66936. centripetalForceThreshold: number;
  66937. /**
  66938. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66939. */
  66940. centripetalForceMultiplier: number;
  66941. /**
  66942. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66943. */
  66944. centrifugalForceMultiplier: number;
  66945. /**
  66946. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66947. */
  66948. updraftForceMultiplier: number;
  66949. }
  66950. /**
  66951. * The strenght of the force in correspondence to the distance of the affected object
  66952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66953. */
  66954. export enum PhysicsRadialImpulseFalloff {
  66955. /** Defines that impulse is constant in strength across it's whole radius */
  66956. Constant = 0,
  66957. /** Defines that impulse gets weaker if it's further from the origin */
  66958. Linear = 1
  66959. }
  66960. /**
  66961. * The strength of the force in correspondence to the distance of the affected object
  66962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66963. */
  66964. export enum PhysicsUpdraftMode {
  66965. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66966. Center = 0,
  66967. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66968. Perpendicular = 1
  66969. }
  66970. /**
  66971. * Interface for a physics hit data
  66972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66973. */
  66974. export interface PhysicsHitData {
  66975. /**
  66976. * The force applied at the contact point
  66977. */
  66978. force: Vector3;
  66979. /**
  66980. * The contact point
  66981. */
  66982. contactPoint: Vector3;
  66983. /**
  66984. * The distance from the origin to the contact point
  66985. */
  66986. distanceFromOrigin: number;
  66987. }
  66988. /**
  66989. * Interface for radial explosion event data
  66990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66991. */
  66992. export interface PhysicsRadialExplosionEventData {
  66993. /**
  66994. * A sphere used for the radial explosion event
  66995. */
  66996. sphere: Mesh;
  66997. }
  66998. /**
  66999. * Interface for gravitational field event data
  67000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67001. */
  67002. export interface PhysicsGravitationalFieldEventData {
  67003. /**
  67004. * A sphere mesh used for the gravitational field event
  67005. */
  67006. sphere: Mesh;
  67007. }
  67008. /**
  67009. * Interface for updraft event data
  67010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67011. */
  67012. export interface PhysicsUpdraftEventData {
  67013. /**
  67014. * A cylinder used for the updraft event
  67015. */
  67016. cylinder: Mesh;
  67017. }
  67018. /**
  67019. * Interface for vortex event data
  67020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67021. */
  67022. export interface PhysicsVortexEventData {
  67023. /**
  67024. * A cylinder used for the vortex event
  67025. */
  67026. cylinder: Mesh;
  67027. }
  67028. /**
  67029. * Interface for an affected physics impostor
  67030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67031. */
  67032. export interface PhysicsAffectedImpostorWithData {
  67033. /**
  67034. * The impostor affected by the effect
  67035. */
  67036. impostor: PhysicsImpostor;
  67037. /**
  67038. * The data about the hit/horce from the explosion
  67039. */
  67040. hitData: PhysicsHitData;
  67041. }
  67042. }
  67043. declare module BABYLON {
  67044. /** @hidden */
  67045. export var blackAndWhitePixelShader: {
  67046. name: string;
  67047. shader: string;
  67048. };
  67049. }
  67050. declare module BABYLON {
  67051. /**
  67052. * Post process used to render in black and white
  67053. */
  67054. export class BlackAndWhitePostProcess extends PostProcess {
  67055. /**
  67056. * Linear about to convert he result to black and white (default: 1)
  67057. */
  67058. degree: number;
  67059. /**
  67060. * Creates a black and white post process
  67061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67062. * @param name The name of the effect.
  67063. * @param options The required width/height ratio to downsize to before computing the render pass.
  67064. * @param camera The camera to apply the render pass to.
  67065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67066. * @param engine The engine which the post process will be applied. (default: current engine)
  67067. * @param reusable If the post process can be reused on the same frame. (default: false)
  67068. */
  67069. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67070. }
  67071. }
  67072. declare module BABYLON {
  67073. /**
  67074. * This represents a set of one or more post processes in Babylon.
  67075. * A post process can be used to apply a shader to a texture after it is rendered.
  67076. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67077. */
  67078. export class PostProcessRenderEffect {
  67079. private _postProcesses;
  67080. private _getPostProcesses;
  67081. private _singleInstance;
  67082. private _cameras;
  67083. private _indicesForCamera;
  67084. /**
  67085. * Name of the effect
  67086. * @hidden
  67087. */
  67088. _name: string;
  67089. /**
  67090. * Instantiates a post process render effect.
  67091. * A post process can be used to apply a shader to a texture after it is rendered.
  67092. * @param engine The engine the effect is tied to
  67093. * @param name The name of the effect
  67094. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67095. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67096. */
  67097. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67098. /**
  67099. * Checks if all the post processes in the effect are supported.
  67100. */
  67101. get isSupported(): boolean;
  67102. /**
  67103. * Updates the current state of the effect
  67104. * @hidden
  67105. */
  67106. _update(): void;
  67107. /**
  67108. * Attaches the effect on cameras
  67109. * @param cameras The camera to attach to.
  67110. * @hidden
  67111. */
  67112. _attachCameras(cameras: Camera): void;
  67113. /**
  67114. * Attaches the effect on cameras
  67115. * @param cameras The camera to attach to.
  67116. * @hidden
  67117. */
  67118. _attachCameras(cameras: Camera[]): void;
  67119. /**
  67120. * Detaches the effect on cameras
  67121. * @param cameras The camera to detatch from.
  67122. * @hidden
  67123. */
  67124. _detachCameras(cameras: Camera): void;
  67125. /**
  67126. * Detatches the effect on cameras
  67127. * @param cameras The camera to detatch from.
  67128. * @hidden
  67129. */
  67130. _detachCameras(cameras: Camera[]): void;
  67131. /**
  67132. * Enables the effect on given cameras
  67133. * @param cameras The camera to enable.
  67134. * @hidden
  67135. */
  67136. _enable(cameras: Camera): void;
  67137. /**
  67138. * Enables the effect on given cameras
  67139. * @param cameras The camera to enable.
  67140. * @hidden
  67141. */
  67142. _enable(cameras: Nullable<Camera[]>): void;
  67143. /**
  67144. * Disables the effect on the given cameras
  67145. * @param cameras The camera to disable.
  67146. * @hidden
  67147. */
  67148. _disable(cameras: Camera): void;
  67149. /**
  67150. * Disables the effect on the given cameras
  67151. * @param cameras The camera to disable.
  67152. * @hidden
  67153. */
  67154. _disable(cameras: Nullable<Camera[]>): void;
  67155. /**
  67156. * Gets a list of the post processes contained in the effect.
  67157. * @param camera The camera to get the post processes on.
  67158. * @returns The list of the post processes in the effect.
  67159. */
  67160. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67161. }
  67162. }
  67163. declare module BABYLON {
  67164. /** @hidden */
  67165. export var extractHighlightsPixelShader: {
  67166. name: string;
  67167. shader: string;
  67168. };
  67169. }
  67170. declare module BABYLON {
  67171. /**
  67172. * 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.
  67173. */
  67174. export class ExtractHighlightsPostProcess extends PostProcess {
  67175. /**
  67176. * The luminance threshold, pixels below this value will be set to black.
  67177. */
  67178. threshold: number;
  67179. /** @hidden */
  67180. _exposure: number;
  67181. /**
  67182. * Post process which has the input texture to be used when performing highlight extraction
  67183. * @hidden
  67184. */
  67185. _inputPostProcess: Nullable<PostProcess>;
  67186. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67187. }
  67188. }
  67189. declare module BABYLON {
  67190. /** @hidden */
  67191. export var bloomMergePixelShader: {
  67192. name: string;
  67193. shader: string;
  67194. };
  67195. }
  67196. declare module BABYLON {
  67197. /**
  67198. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67199. */
  67200. export class BloomMergePostProcess extends PostProcess {
  67201. /** Weight of the bloom to be added to the original input. */
  67202. weight: number;
  67203. /**
  67204. * Creates a new instance of @see BloomMergePostProcess
  67205. * @param name The name of the effect.
  67206. * @param originalFromInput Post process which's input will be used for the merge.
  67207. * @param blurred Blurred highlights post process which's output will be used.
  67208. * @param weight Weight of the bloom to be added to the original input.
  67209. * @param options The required width/height ratio to downsize to before computing the render pass.
  67210. * @param camera The camera to apply the render pass to.
  67211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67212. * @param engine The engine which the post process will be applied. (default: current engine)
  67213. * @param reusable If the post process can be reused on the same frame. (default: false)
  67214. * @param textureType Type of textures used when performing the post process. (default: 0)
  67215. * @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)
  67216. */
  67217. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67218. /** Weight of the bloom to be added to the original input. */
  67219. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67220. }
  67221. }
  67222. declare module BABYLON {
  67223. /**
  67224. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67225. */
  67226. export class BloomEffect extends PostProcessRenderEffect {
  67227. private bloomScale;
  67228. /**
  67229. * @hidden Internal
  67230. */
  67231. _effects: Array<PostProcess>;
  67232. /**
  67233. * @hidden Internal
  67234. */
  67235. _downscale: ExtractHighlightsPostProcess;
  67236. private _blurX;
  67237. private _blurY;
  67238. private _merge;
  67239. /**
  67240. * The luminance threshold to find bright areas of the image to bloom.
  67241. */
  67242. get threshold(): number;
  67243. set threshold(value: number);
  67244. /**
  67245. * The strength of the bloom.
  67246. */
  67247. get weight(): number;
  67248. set weight(value: number);
  67249. /**
  67250. * Specifies the size of the bloom blur kernel, relative to the final output size
  67251. */
  67252. get kernel(): number;
  67253. set kernel(value: number);
  67254. /**
  67255. * Creates a new instance of @see BloomEffect
  67256. * @param scene The scene the effect belongs to.
  67257. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67258. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67259. * @param bloomWeight The the strength of bloom.
  67260. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67261. * @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)
  67262. */
  67263. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67264. /**
  67265. * Disposes each of the internal effects for a given camera.
  67266. * @param camera The camera to dispose the effect on.
  67267. */
  67268. disposeEffects(camera: Camera): void;
  67269. /**
  67270. * @hidden Internal
  67271. */
  67272. _updateEffects(): void;
  67273. /**
  67274. * Internal
  67275. * @returns if all the contained post processes are ready.
  67276. * @hidden
  67277. */
  67278. _isReady(): boolean;
  67279. }
  67280. }
  67281. declare module BABYLON {
  67282. /** @hidden */
  67283. export var chromaticAberrationPixelShader: {
  67284. name: string;
  67285. shader: string;
  67286. };
  67287. }
  67288. declare module BABYLON {
  67289. /**
  67290. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67291. */
  67292. export class ChromaticAberrationPostProcess extends PostProcess {
  67293. /**
  67294. * The amount of seperation of rgb channels (default: 30)
  67295. */
  67296. aberrationAmount: number;
  67297. /**
  67298. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67299. */
  67300. radialIntensity: number;
  67301. /**
  67302. * 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))
  67303. */
  67304. direction: Vector2;
  67305. /**
  67306. * 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))
  67307. */
  67308. centerPosition: Vector2;
  67309. /**
  67310. * Creates a new instance ChromaticAberrationPostProcess
  67311. * @param name The name of the effect.
  67312. * @param screenWidth The width of the screen to apply the effect on.
  67313. * @param screenHeight The height of the screen to apply the effect on.
  67314. * @param options The required width/height ratio to downsize to before computing the render pass.
  67315. * @param camera The camera to apply the render pass to.
  67316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67317. * @param engine The engine which the post process will be applied. (default: current engine)
  67318. * @param reusable If the post process can be reused on the same frame. (default: false)
  67319. * @param textureType Type of textures used when performing the post process. (default: 0)
  67320. * @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)
  67321. */
  67322. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67323. }
  67324. }
  67325. declare module BABYLON {
  67326. /** @hidden */
  67327. export var circleOfConfusionPixelShader: {
  67328. name: string;
  67329. shader: string;
  67330. };
  67331. }
  67332. declare module BABYLON {
  67333. /**
  67334. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67335. */
  67336. export class CircleOfConfusionPostProcess extends PostProcess {
  67337. /**
  67338. * 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.
  67339. */
  67340. lensSize: number;
  67341. /**
  67342. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67343. */
  67344. fStop: number;
  67345. /**
  67346. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67347. */
  67348. focusDistance: number;
  67349. /**
  67350. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67351. */
  67352. focalLength: number;
  67353. private _depthTexture;
  67354. /**
  67355. * Creates a new instance CircleOfConfusionPostProcess
  67356. * @param name The name of the effect.
  67357. * @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.
  67358. * @param options The required width/height ratio to downsize to before computing the render pass.
  67359. * @param camera The camera to apply the render pass to.
  67360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67361. * @param engine The engine which the post process will be applied. (default: current engine)
  67362. * @param reusable If the post process can be reused on the same frame. (default: false)
  67363. * @param textureType Type of textures used when performing the post process. (default: 0)
  67364. * @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)
  67365. */
  67366. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67367. /**
  67368. * 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.
  67369. */
  67370. set depthTexture(value: RenderTargetTexture);
  67371. }
  67372. }
  67373. declare module BABYLON {
  67374. /** @hidden */
  67375. export var colorCorrectionPixelShader: {
  67376. name: string;
  67377. shader: string;
  67378. };
  67379. }
  67380. declare module BABYLON {
  67381. /**
  67382. *
  67383. * This post-process allows the modification of rendered colors by using
  67384. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67385. *
  67386. * The object needs to be provided an url to a texture containing the color
  67387. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67388. * Use an image editing software to tweak the LUT to match your needs.
  67389. *
  67390. * For an example of a color LUT, see here:
  67391. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67392. * For explanations on color grading, see here:
  67393. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67394. *
  67395. */
  67396. export class ColorCorrectionPostProcess extends PostProcess {
  67397. private _colorTableTexture;
  67398. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67399. }
  67400. }
  67401. declare module BABYLON {
  67402. /** @hidden */
  67403. export var convolutionPixelShader: {
  67404. name: string;
  67405. shader: string;
  67406. };
  67407. }
  67408. declare module BABYLON {
  67409. /**
  67410. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67411. * input texture to perform effects such as edge detection or sharpening
  67412. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67413. */
  67414. export class ConvolutionPostProcess extends PostProcess {
  67415. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67416. kernel: number[];
  67417. /**
  67418. * Creates a new instance ConvolutionPostProcess
  67419. * @param name The name of the effect.
  67420. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67421. * @param options The required width/height ratio to downsize to before computing the render pass.
  67422. * @param camera The camera to apply the render pass to.
  67423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67424. * @param engine The engine which the post process will be applied. (default: current engine)
  67425. * @param reusable If the post process can be reused on the same frame. (default: false)
  67426. * @param textureType Type of textures used when performing the post process. (default: 0)
  67427. */
  67428. constructor(name: string,
  67429. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67430. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67431. /**
  67432. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67433. */
  67434. static EdgeDetect0Kernel: number[];
  67435. /**
  67436. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67437. */
  67438. static EdgeDetect1Kernel: number[];
  67439. /**
  67440. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67441. */
  67442. static EdgeDetect2Kernel: number[];
  67443. /**
  67444. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67445. */
  67446. static SharpenKernel: number[];
  67447. /**
  67448. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67449. */
  67450. static EmbossKernel: number[];
  67451. /**
  67452. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67453. */
  67454. static GaussianKernel: number[];
  67455. }
  67456. }
  67457. declare module BABYLON {
  67458. /**
  67459. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67460. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67461. * based on samples that have a large difference in distance than the center pixel.
  67462. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67463. */
  67464. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67465. direction: Vector2;
  67466. /**
  67467. * Creates a new instance CircleOfConfusionPostProcess
  67468. * @param name The name of the effect.
  67469. * @param scene The scene the effect belongs to.
  67470. * @param direction The direction the blur should be applied.
  67471. * @param kernel The size of the kernel used to blur.
  67472. * @param options The required width/height ratio to downsize to before computing the render pass.
  67473. * @param camera The camera to apply the render pass to.
  67474. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67475. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67477. * @param engine The engine which the post process will be applied. (default: current engine)
  67478. * @param reusable If the post process can be reused on the same frame. (default: false)
  67479. * @param textureType Type of textures used when performing the post process. (default: 0)
  67480. * @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)
  67481. */
  67482. 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);
  67483. }
  67484. }
  67485. declare module BABYLON {
  67486. /** @hidden */
  67487. export var depthOfFieldMergePixelShader: {
  67488. name: string;
  67489. shader: string;
  67490. };
  67491. }
  67492. declare module BABYLON {
  67493. /**
  67494. * Options to be set when merging outputs from the default pipeline.
  67495. */
  67496. export class DepthOfFieldMergePostProcessOptions {
  67497. /**
  67498. * The original image to merge on top of
  67499. */
  67500. originalFromInput: PostProcess;
  67501. /**
  67502. * Parameters to perform the merge of the depth of field effect
  67503. */
  67504. depthOfField?: {
  67505. circleOfConfusion: PostProcess;
  67506. blurSteps: Array<PostProcess>;
  67507. };
  67508. /**
  67509. * Parameters to perform the merge of bloom effect
  67510. */
  67511. bloom?: {
  67512. blurred: PostProcess;
  67513. weight: number;
  67514. };
  67515. }
  67516. /**
  67517. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67518. */
  67519. export class DepthOfFieldMergePostProcess extends PostProcess {
  67520. private blurSteps;
  67521. /**
  67522. * Creates a new instance of DepthOfFieldMergePostProcess
  67523. * @param name The name of the effect.
  67524. * @param originalFromInput Post process which's input will be used for the merge.
  67525. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67526. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67527. * @param options The required width/height ratio to downsize to before computing the render pass.
  67528. * @param camera The camera to apply the render pass to.
  67529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67530. * @param engine The engine which the post process will be applied. (default: current engine)
  67531. * @param reusable If the post process can be reused on the same frame. (default: false)
  67532. * @param textureType Type of textures used when performing the post process. (default: 0)
  67533. * @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)
  67534. */
  67535. 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);
  67536. /**
  67537. * Updates the effect with the current post process compile time values and recompiles the shader.
  67538. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67539. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67540. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67541. * @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
  67542. * @param onCompiled Called when the shader has been compiled.
  67543. * @param onError Called if there is an error when compiling a shader.
  67544. */
  67545. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67546. }
  67547. }
  67548. declare module BABYLON {
  67549. /**
  67550. * Specifies the level of max blur that should be applied when using the depth of field effect
  67551. */
  67552. export enum DepthOfFieldEffectBlurLevel {
  67553. /**
  67554. * Subtle blur
  67555. */
  67556. Low = 0,
  67557. /**
  67558. * Medium blur
  67559. */
  67560. Medium = 1,
  67561. /**
  67562. * Large blur
  67563. */
  67564. High = 2
  67565. }
  67566. /**
  67567. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67568. */
  67569. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67570. private _circleOfConfusion;
  67571. /**
  67572. * @hidden Internal, blurs from high to low
  67573. */
  67574. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67575. private _depthOfFieldBlurY;
  67576. private _dofMerge;
  67577. /**
  67578. * @hidden Internal post processes in depth of field effect
  67579. */
  67580. _effects: Array<PostProcess>;
  67581. /**
  67582. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67583. */
  67584. set focalLength(value: number);
  67585. get focalLength(): number;
  67586. /**
  67587. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67588. */
  67589. set fStop(value: number);
  67590. get fStop(): number;
  67591. /**
  67592. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67593. */
  67594. set focusDistance(value: number);
  67595. get focusDistance(): number;
  67596. /**
  67597. * 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.
  67598. */
  67599. set lensSize(value: number);
  67600. get lensSize(): number;
  67601. /**
  67602. * Creates a new instance DepthOfFieldEffect
  67603. * @param scene The scene the effect belongs to.
  67604. * @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.
  67605. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67606. * @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)
  67607. */
  67608. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67609. /**
  67610. * Get the current class name of the current effet
  67611. * @returns "DepthOfFieldEffect"
  67612. */
  67613. getClassName(): string;
  67614. /**
  67615. * 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.
  67616. */
  67617. set depthTexture(value: RenderTargetTexture);
  67618. /**
  67619. * Disposes each of the internal effects for a given camera.
  67620. * @param camera The camera to dispose the effect on.
  67621. */
  67622. disposeEffects(camera: Camera): void;
  67623. /**
  67624. * @hidden Internal
  67625. */
  67626. _updateEffects(): void;
  67627. /**
  67628. * Internal
  67629. * @returns if all the contained post processes are ready.
  67630. * @hidden
  67631. */
  67632. _isReady(): boolean;
  67633. }
  67634. }
  67635. declare module BABYLON {
  67636. /** @hidden */
  67637. export var displayPassPixelShader: {
  67638. name: string;
  67639. shader: string;
  67640. };
  67641. }
  67642. declare module BABYLON {
  67643. /**
  67644. * DisplayPassPostProcess which produces an output the same as it's input
  67645. */
  67646. export class DisplayPassPostProcess extends PostProcess {
  67647. /**
  67648. * Creates the DisplayPassPostProcess
  67649. * @param name The name of the effect.
  67650. * @param options The required width/height ratio to downsize to before computing the render pass.
  67651. * @param camera The camera to apply the render pass to.
  67652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67653. * @param engine The engine which the post process will be applied. (default: current engine)
  67654. * @param reusable If the post process can be reused on the same frame. (default: false)
  67655. */
  67656. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67657. }
  67658. }
  67659. declare module BABYLON {
  67660. /** @hidden */
  67661. export var filterPixelShader: {
  67662. name: string;
  67663. shader: string;
  67664. };
  67665. }
  67666. declare module BABYLON {
  67667. /**
  67668. * Applies a kernel filter to the image
  67669. */
  67670. export class FilterPostProcess extends PostProcess {
  67671. /** The matrix to be applied to the image */
  67672. kernelMatrix: Matrix;
  67673. /**
  67674. *
  67675. * @param name The name of the effect.
  67676. * @param kernelMatrix The matrix to be applied to the image
  67677. * @param options The required width/height ratio to downsize to before computing the render pass.
  67678. * @param camera The camera to apply the render pass to.
  67679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67680. * @param engine The engine which the post process will be applied. (default: current engine)
  67681. * @param reusable If the post process can be reused on the same frame. (default: false)
  67682. */
  67683. constructor(name: string,
  67684. /** The matrix to be applied to the image */
  67685. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67686. }
  67687. }
  67688. declare module BABYLON {
  67689. /** @hidden */
  67690. export var fxaaPixelShader: {
  67691. name: string;
  67692. shader: string;
  67693. };
  67694. }
  67695. declare module BABYLON {
  67696. /** @hidden */
  67697. export var fxaaVertexShader: {
  67698. name: string;
  67699. shader: string;
  67700. };
  67701. }
  67702. declare module BABYLON {
  67703. /**
  67704. * Fxaa post process
  67705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67706. */
  67707. export class FxaaPostProcess extends PostProcess {
  67708. /** @hidden */
  67709. texelWidth: number;
  67710. /** @hidden */
  67711. texelHeight: number;
  67712. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67713. private _getDefines;
  67714. }
  67715. }
  67716. declare module BABYLON {
  67717. /** @hidden */
  67718. export var grainPixelShader: {
  67719. name: string;
  67720. shader: string;
  67721. };
  67722. }
  67723. declare module BABYLON {
  67724. /**
  67725. * The GrainPostProcess adds noise to the image at mid luminance levels
  67726. */
  67727. export class GrainPostProcess extends PostProcess {
  67728. /**
  67729. * The intensity of the grain added (default: 30)
  67730. */
  67731. intensity: number;
  67732. /**
  67733. * If the grain should be randomized on every frame
  67734. */
  67735. animated: boolean;
  67736. /**
  67737. * Creates a new instance of @see GrainPostProcess
  67738. * @param name The name of the effect.
  67739. * @param options The required width/height ratio to downsize to before computing the render pass.
  67740. * @param camera The camera to apply the render pass to.
  67741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67742. * @param engine The engine which the post process will be applied. (default: current engine)
  67743. * @param reusable If the post process can be reused on the same frame. (default: false)
  67744. * @param textureType Type of textures used when performing the post process. (default: 0)
  67745. * @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)
  67746. */
  67747. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67748. }
  67749. }
  67750. declare module BABYLON {
  67751. /** @hidden */
  67752. export var highlightsPixelShader: {
  67753. name: string;
  67754. shader: string;
  67755. };
  67756. }
  67757. declare module BABYLON {
  67758. /**
  67759. * Extracts highlights from the image
  67760. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67761. */
  67762. export class HighlightsPostProcess extends PostProcess {
  67763. /**
  67764. * Extracts highlights from the image
  67765. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67766. * @param name The name of the effect.
  67767. * @param options The required width/height ratio to downsize to before computing the render pass.
  67768. * @param camera The camera to apply the render pass to.
  67769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67770. * @param engine The engine which the post process will be applied. (default: current engine)
  67771. * @param reusable If the post process can be reused on the same frame. (default: false)
  67772. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67773. */
  67774. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67775. }
  67776. }
  67777. declare module BABYLON {
  67778. /** @hidden */
  67779. export var mrtFragmentDeclaration: {
  67780. name: string;
  67781. shader: string;
  67782. };
  67783. }
  67784. declare module BABYLON {
  67785. /** @hidden */
  67786. export var geometryPixelShader: {
  67787. name: string;
  67788. shader: string;
  67789. };
  67790. }
  67791. declare module BABYLON {
  67792. /** @hidden */
  67793. export var geometryVertexShader: {
  67794. name: string;
  67795. shader: string;
  67796. };
  67797. }
  67798. declare module BABYLON {
  67799. /** @hidden */
  67800. interface ISavedTransformationMatrix {
  67801. world: Matrix;
  67802. viewProjection: Matrix;
  67803. }
  67804. /**
  67805. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67806. */
  67807. export class GeometryBufferRenderer {
  67808. /**
  67809. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67810. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67811. */
  67812. static readonly POSITION_TEXTURE_TYPE: number;
  67813. /**
  67814. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67815. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67816. */
  67817. static readonly VELOCITY_TEXTURE_TYPE: number;
  67818. /**
  67819. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67820. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67821. */
  67822. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67823. /**
  67824. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67825. * in order to compute objects velocities when enableVelocity is set to "true"
  67826. * @hidden
  67827. */
  67828. _previousTransformationMatrices: {
  67829. [index: number]: ISavedTransformationMatrix;
  67830. };
  67831. /**
  67832. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67833. * in order to compute objects velocities when enableVelocity is set to "true"
  67834. * @hidden
  67835. */
  67836. _previousBonesTransformationMatrices: {
  67837. [index: number]: Float32Array;
  67838. };
  67839. /**
  67840. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67841. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67842. */
  67843. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67844. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67845. renderTransparentMeshes: boolean;
  67846. private _scene;
  67847. private _multiRenderTarget;
  67848. private _ratio;
  67849. private _enablePosition;
  67850. private _enableVelocity;
  67851. private _enableReflectivity;
  67852. private _positionIndex;
  67853. private _velocityIndex;
  67854. private _reflectivityIndex;
  67855. protected _effect: Effect;
  67856. protected _cachedDefines: string;
  67857. /**
  67858. * Set the render list (meshes to be rendered) used in the G buffer.
  67859. */
  67860. set renderList(meshes: Mesh[]);
  67861. /**
  67862. * Gets wether or not G buffer are supported by the running hardware.
  67863. * This requires draw buffer supports
  67864. */
  67865. get isSupported(): boolean;
  67866. /**
  67867. * Returns the index of the given texture type in the G-Buffer textures array
  67868. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67869. * @returns the index of the given texture type in the G-Buffer textures array
  67870. */
  67871. getTextureIndex(textureType: number): number;
  67872. /**
  67873. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67874. */
  67875. get enablePosition(): boolean;
  67876. /**
  67877. * Sets whether or not objects positions are enabled for the G buffer.
  67878. */
  67879. set enablePosition(enable: boolean);
  67880. /**
  67881. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67882. */
  67883. get enableVelocity(): boolean;
  67884. /**
  67885. * Sets wether or not objects velocities are enabled for the G buffer.
  67886. */
  67887. set enableVelocity(enable: boolean);
  67888. /**
  67889. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67890. */
  67891. get enableReflectivity(): boolean;
  67892. /**
  67893. * Sets wether or not objects roughness are enabled for the G buffer.
  67894. */
  67895. set enableReflectivity(enable: boolean);
  67896. /**
  67897. * Gets the scene associated with the buffer.
  67898. */
  67899. get scene(): Scene;
  67900. /**
  67901. * Gets the ratio used by the buffer during its creation.
  67902. * How big is the buffer related to the main canvas.
  67903. */
  67904. get ratio(): number;
  67905. /** @hidden */
  67906. static _SceneComponentInitialization: (scene: Scene) => void;
  67907. /**
  67908. * Creates a new G Buffer for the scene
  67909. * @param scene The scene the buffer belongs to
  67910. * @param ratio How big is the buffer related to the main canvas.
  67911. */
  67912. constructor(scene: Scene, ratio?: number);
  67913. /**
  67914. * Checks wether everything is ready to render a submesh to the G buffer.
  67915. * @param subMesh the submesh to check readiness for
  67916. * @param useInstances is the mesh drawn using instance or not
  67917. * @returns true if ready otherwise false
  67918. */
  67919. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67920. /**
  67921. * Gets the current underlying G Buffer.
  67922. * @returns the buffer
  67923. */
  67924. getGBuffer(): MultiRenderTarget;
  67925. /**
  67926. * Gets the number of samples used to render the buffer (anti aliasing).
  67927. */
  67928. get samples(): number;
  67929. /**
  67930. * Sets the number of samples used to render the buffer (anti aliasing).
  67931. */
  67932. set samples(value: number);
  67933. /**
  67934. * Disposes the renderer and frees up associated resources.
  67935. */
  67936. dispose(): void;
  67937. protected _createRenderTargets(): void;
  67938. private _copyBonesTransformationMatrices;
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. interface Scene {
  67943. /** @hidden (Backing field) */
  67944. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67945. /**
  67946. * Gets or Sets the current geometry buffer associated to the scene.
  67947. */
  67948. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67949. /**
  67950. * Enables a GeometryBufferRender and associates it with the scene
  67951. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67952. * @returns the GeometryBufferRenderer
  67953. */
  67954. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67955. /**
  67956. * Disables the GeometryBufferRender associated with the scene
  67957. */
  67958. disableGeometryBufferRenderer(): void;
  67959. }
  67960. /**
  67961. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67962. * in several rendering techniques.
  67963. */
  67964. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67965. /**
  67966. * The component name helpful to identify the component in the list of scene components.
  67967. */
  67968. readonly name: string;
  67969. /**
  67970. * The scene the component belongs to.
  67971. */
  67972. scene: Scene;
  67973. /**
  67974. * Creates a new instance of the component for the given scene
  67975. * @param scene Defines the scene to register the component in
  67976. */
  67977. constructor(scene: Scene);
  67978. /**
  67979. * Registers the component in a given scene
  67980. */
  67981. register(): void;
  67982. /**
  67983. * Rebuilds the elements related to this component in case of
  67984. * context lost for instance.
  67985. */
  67986. rebuild(): void;
  67987. /**
  67988. * Disposes the component and the associated ressources
  67989. */
  67990. dispose(): void;
  67991. private _gatherRenderTargets;
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /** @hidden */
  67996. export var motionBlurPixelShader: {
  67997. name: string;
  67998. shader: string;
  67999. };
  68000. }
  68001. declare module BABYLON {
  68002. /**
  68003. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68004. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68005. * As an example, all you have to do is to create the post-process:
  68006. * var mb = new BABYLON.MotionBlurPostProcess(
  68007. * 'mb', // The name of the effect.
  68008. * scene, // The scene containing the objects to blur according to their velocity.
  68009. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68010. * camera // The camera to apply the render pass to.
  68011. * );
  68012. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68013. */
  68014. export class MotionBlurPostProcess extends PostProcess {
  68015. /**
  68016. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68017. */
  68018. motionStrength: number;
  68019. /**
  68020. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68021. */
  68022. get motionBlurSamples(): number;
  68023. /**
  68024. * Sets the number of iterations to be used for motion blur quality
  68025. */
  68026. set motionBlurSamples(samples: number);
  68027. private _motionBlurSamples;
  68028. private _geometryBufferRenderer;
  68029. /**
  68030. * Creates a new instance MotionBlurPostProcess
  68031. * @param name The name of the effect.
  68032. * @param scene The scene containing the objects to blur according to their velocity.
  68033. * @param options The required width/height ratio to downsize to before computing the render pass.
  68034. * @param camera The camera to apply the render pass to.
  68035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68036. * @param engine The engine which the post process will be applied. (default: current engine)
  68037. * @param reusable If the post process can be reused on the same frame. (default: false)
  68038. * @param textureType Type of textures used when performing the post process. (default: 0)
  68039. * @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)
  68040. */
  68041. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68042. /**
  68043. * Excludes the given skinned mesh from computing bones velocities.
  68044. * 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.
  68045. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68046. */
  68047. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68048. /**
  68049. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68050. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68051. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68052. */
  68053. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68054. /**
  68055. * Disposes the post process.
  68056. * @param camera The camera to dispose the post process on.
  68057. */
  68058. dispose(camera?: Camera): void;
  68059. }
  68060. }
  68061. declare module BABYLON {
  68062. /** @hidden */
  68063. export var refractionPixelShader: {
  68064. name: string;
  68065. shader: string;
  68066. };
  68067. }
  68068. declare module BABYLON {
  68069. /**
  68070. * Post process which applies a refractin texture
  68071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68072. */
  68073. export class RefractionPostProcess extends PostProcess {
  68074. /** the base color of the refraction (used to taint the rendering) */
  68075. color: Color3;
  68076. /** simulated refraction depth */
  68077. depth: number;
  68078. /** the coefficient of the base color (0 to remove base color tainting) */
  68079. colorLevel: number;
  68080. private _refTexture;
  68081. private _ownRefractionTexture;
  68082. /**
  68083. * Gets or sets the refraction texture
  68084. * Please note that you are responsible for disposing the texture if you set it manually
  68085. */
  68086. get refractionTexture(): Texture;
  68087. set refractionTexture(value: Texture);
  68088. /**
  68089. * Initializes the RefractionPostProcess
  68090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68091. * @param name The name of the effect.
  68092. * @param refractionTextureUrl Url of the refraction texture to use
  68093. * @param color the base color of the refraction (used to taint the rendering)
  68094. * @param depth simulated refraction depth
  68095. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68096. * @param camera The camera to apply the render pass to.
  68097. * @param options The required width/height ratio to downsize to before computing the render pass.
  68098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68099. * @param engine The engine which the post process will be applied. (default: current engine)
  68100. * @param reusable If the post process can be reused on the same frame. (default: false)
  68101. */
  68102. constructor(name: string, refractionTextureUrl: string,
  68103. /** the base color of the refraction (used to taint the rendering) */
  68104. color: Color3,
  68105. /** simulated refraction depth */
  68106. depth: number,
  68107. /** the coefficient of the base color (0 to remove base color tainting) */
  68108. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68109. /**
  68110. * Disposes of the post process
  68111. * @param camera Camera to dispose post process on
  68112. */
  68113. dispose(camera: Camera): void;
  68114. }
  68115. }
  68116. declare module BABYLON {
  68117. /** @hidden */
  68118. export var sharpenPixelShader: {
  68119. name: string;
  68120. shader: string;
  68121. };
  68122. }
  68123. declare module BABYLON {
  68124. /**
  68125. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68126. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68127. */
  68128. export class SharpenPostProcess extends PostProcess {
  68129. /**
  68130. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68131. */
  68132. colorAmount: number;
  68133. /**
  68134. * How much sharpness should be applied (default: 0.3)
  68135. */
  68136. edgeAmount: number;
  68137. /**
  68138. * Creates a new instance ConvolutionPostProcess
  68139. * @param name The name of the effect.
  68140. * @param options The required width/height ratio to downsize to before computing the render pass.
  68141. * @param camera The camera to apply the render pass to.
  68142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68143. * @param engine The engine which the post process will be applied. (default: current engine)
  68144. * @param reusable If the post process can be reused on the same frame. (default: false)
  68145. * @param textureType Type of textures used when performing the post process. (default: 0)
  68146. * @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)
  68147. */
  68148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68149. }
  68150. }
  68151. declare module BABYLON {
  68152. /**
  68153. * PostProcessRenderPipeline
  68154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68155. */
  68156. export class PostProcessRenderPipeline {
  68157. private engine;
  68158. private _renderEffects;
  68159. private _renderEffectsForIsolatedPass;
  68160. /**
  68161. * List of inspectable custom properties (used by the Inspector)
  68162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68163. */
  68164. inspectableCustomProperties: IInspectable[];
  68165. /**
  68166. * @hidden
  68167. */
  68168. protected _cameras: Camera[];
  68169. /** @hidden */
  68170. _name: string;
  68171. /**
  68172. * Gets pipeline name
  68173. */
  68174. get name(): string;
  68175. /** Gets the list of attached cameras */
  68176. get cameras(): Camera[];
  68177. /**
  68178. * Initializes a PostProcessRenderPipeline
  68179. * @param engine engine to add the pipeline to
  68180. * @param name name of the pipeline
  68181. */
  68182. constructor(engine: Engine, name: string);
  68183. /**
  68184. * Gets the class name
  68185. * @returns "PostProcessRenderPipeline"
  68186. */
  68187. getClassName(): string;
  68188. /**
  68189. * If all the render effects in the pipeline are supported
  68190. */
  68191. get isSupported(): boolean;
  68192. /**
  68193. * Adds an effect to the pipeline
  68194. * @param renderEffect the effect to add
  68195. */
  68196. addEffect(renderEffect: PostProcessRenderEffect): void;
  68197. /** @hidden */
  68198. _rebuild(): void;
  68199. /** @hidden */
  68200. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68201. /** @hidden */
  68202. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68203. /** @hidden */
  68204. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68205. /** @hidden */
  68206. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68207. /** @hidden */
  68208. _attachCameras(cameras: Camera, unique: boolean): void;
  68209. /** @hidden */
  68210. _attachCameras(cameras: Camera[], unique: boolean): void;
  68211. /** @hidden */
  68212. _detachCameras(cameras: Camera): void;
  68213. /** @hidden */
  68214. _detachCameras(cameras: Nullable<Camera[]>): void;
  68215. /** @hidden */
  68216. _update(): void;
  68217. /** @hidden */
  68218. _reset(): void;
  68219. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68220. /**
  68221. * Disposes of the pipeline
  68222. */
  68223. dispose(): void;
  68224. }
  68225. }
  68226. declare module BABYLON {
  68227. /**
  68228. * PostProcessRenderPipelineManager class
  68229. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68230. */
  68231. export class PostProcessRenderPipelineManager {
  68232. private _renderPipelines;
  68233. /**
  68234. * Initializes a PostProcessRenderPipelineManager
  68235. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68236. */
  68237. constructor();
  68238. /**
  68239. * Gets the list of supported render pipelines
  68240. */
  68241. get supportedPipelines(): PostProcessRenderPipeline[];
  68242. /**
  68243. * Adds a pipeline to the manager
  68244. * @param renderPipeline The pipeline to add
  68245. */
  68246. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68247. /**
  68248. * Attaches a camera to the pipeline
  68249. * @param renderPipelineName The name of the pipeline to attach to
  68250. * @param cameras the camera to attach
  68251. * @param unique if the camera can be attached multiple times to the pipeline
  68252. */
  68253. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68254. /**
  68255. * Detaches a camera from the pipeline
  68256. * @param renderPipelineName The name of the pipeline to detach from
  68257. * @param cameras the camera to detach
  68258. */
  68259. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68260. /**
  68261. * Enables an effect by name on a pipeline
  68262. * @param renderPipelineName the name of the pipeline to enable the effect in
  68263. * @param renderEffectName the name of the effect to enable
  68264. * @param cameras the cameras that the effect should be enabled on
  68265. */
  68266. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68267. /**
  68268. * Disables an effect by name on a pipeline
  68269. * @param renderPipelineName the name of the pipeline to disable the effect in
  68270. * @param renderEffectName the name of the effect to disable
  68271. * @param cameras the cameras that the effect should be disabled on
  68272. */
  68273. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68274. /**
  68275. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68276. */
  68277. update(): void;
  68278. /** @hidden */
  68279. _rebuild(): void;
  68280. /**
  68281. * Disposes of the manager and pipelines
  68282. */
  68283. dispose(): void;
  68284. }
  68285. }
  68286. declare module BABYLON {
  68287. interface Scene {
  68288. /** @hidden (Backing field) */
  68289. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68290. /**
  68291. * Gets the postprocess render pipeline manager
  68292. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68293. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68294. */
  68295. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68296. }
  68297. /**
  68298. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68299. */
  68300. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68301. /**
  68302. * The component name helpfull to identify the component in the list of scene components.
  68303. */
  68304. readonly name: string;
  68305. /**
  68306. * The scene the component belongs to.
  68307. */
  68308. scene: Scene;
  68309. /**
  68310. * Creates a new instance of the component for the given scene
  68311. * @param scene Defines the scene to register the component in
  68312. */
  68313. constructor(scene: Scene);
  68314. /**
  68315. * Registers the component in a given scene
  68316. */
  68317. register(): void;
  68318. /**
  68319. * Rebuilds the elements related to this component in case of
  68320. * context lost for instance.
  68321. */
  68322. rebuild(): void;
  68323. /**
  68324. * Disposes the component and the associated ressources
  68325. */
  68326. dispose(): void;
  68327. private _gatherRenderTargets;
  68328. }
  68329. }
  68330. declare module BABYLON {
  68331. /**
  68332. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68333. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68334. */
  68335. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68336. private _scene;
  68337. private _camerasToBeAttached;
  68338. /**
  68339. * ID of the sharpen post process,
  68340. */
  68341. private readonly SharpenPostProcessId;
  68342. /**
  68343. * @ignore
  68344. * ID of the image processing post process;
  68345. */
  68346. readonly ImageProcessingPostProcessId: string;
  68347. /**
  68348. * @ignore
  68349. * ID of the Fast Approximate Anti-Aliasing post process;
  68350. */
  68351. readonly FxaaPostProcessId: string;
  68352. /**
  68353. * ID of the chromatic aberration post process,
  68354. */
  68355. private readonly ChromaticAberrationPostProcessId;
  68356. /**
  68357. * ID of the grain post process
  68358. */
  68359. private readonly GrainPostProcessId;
  68360. /**
  68361. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68362. */
  68363. sharpen: SharpenPostProcess;
  68364. private _sharpenEffect;
  68365. private bloom;
  68366. /**
  68367. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68368. */
  68369. depthOfField: DepthOfFieldEffect;
  68370. /**
  68371. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68372. */
  68373. fxaa: FxaaPostProcess;
  68374. /**
  68375. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68376. */
  68377. imageProcessing: ImageProcessingPostProcess;
  68378. /**
  68379. * Chromatic aberration post process which will shift rgb colors in the image
  68380. */
  68381. chromaticAberration: ChromaticAberrationPostProcess;
  68382. private _chromaticAberrationEffect;
  68383. /**
  68384. * Grain post process which add noise to the image
  68385. */
  68386. grain: GrainPostProcess;
  68387. private _grainEffect;
  68388. /**
  68389. * Glow post process which adds a glow to emissive areas of the image
  68390. */
  68391. private _glowLayer;
  68392. /**
  68393. * Animations which can be used to tweak settings over a period of time
  68394. */
  68395. animations: Animation[];
  68396. private _imageProcessingConfigurationObserver;
  68397. private _sharpenEnabled;
  68398. private _bloomEnabled;
  68399. private _depthOfFieldEnabled;
  68400. private _depthOfFieldBlurLevel;
  68401. private _fxaaEnabled;
  68402. private _imageProcessingEnabled;
  68403. private _defaultPipelineTextureType;
  68404. private _bloomScale;
  68405. private _chromaticAberrationEnabled;
  68406. private _grainEnabled;
  68407. private _buildAllowed;
  68408. /**
  68409. * Gets active scene
  68410. */
  68411. get scene(): Scene;
  68412. /**
  68413. * Enable or disable the sharpen process from the pipeline
  68414. */
  68415. set sharpenEnabled(enabled: boolean);
  68416. get sharpenEnabled(): boolean;
  68417. private _resizeObserver;
  68418. private _hardwareScaleLevel;
  68419. private _bloomKernel;
  68420. /**
  68421. * Specifies the size of the bloom blur kernel, relative to the final output size
  68422. */
  68423. get bloomKernel(): number;
  68424. set bloomKernel(value: number);
  68425. /**
  68426. * Specifies the weight of the bloom in the final rendering
  68427. */
  68428. private _bloomWeight;
  68429. /**
  68430. * Specifies the luma threshold for the area that will be blurred by the bloom
  68431. */
  68432. private _bloomThreshold;
  68433. private _hdr;
  68434. /**
  68435. * The strength of the bloom.
  68436. */
  68437. set bloomWeight(value: number);
  68438. get bloomWeight(): number;
  68439. /**
  68440. * The strength of the bloom.
  68441. */
  68442. set bloomThreshold(value: number);
  68443. get bloomThreshold(): number;
  68444. /**
  68445. * The scale of the bloom, lower value will provide better performance.
  68446. */
  68447. set bloomScale(value: number);
  68448. get bloomScale(): number;
  68449. /**
  68450. * Enable or disable the bloom from the pipeline
  68451. */
  68452. set bloomEnabled(enabled: boolean);
  68453. get bloomEnabled(): boolean;
  68454. private _rebuildBloom;
  68455. /**
  68456. * If the depth of field is enabled.
  68457. */
  68458. get depthOfFieldEnabled(): boolean;
  68459. set depthOfFieldEnabled(enabled: boolean);
  68460. /**
  68461. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68462. */
  68463. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68464. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68465. /**
  68466. * If the anti aliasing is enabled.
  68467. */
  68468. set fxaaEnabled(enabled: boolean);
  68469. get fxaaEnabled(): boolean;
  68470. private _samples;
  68471. /**
  68472. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68473. */
  68474. set samples(sampleCount: number);
  68475. get samples(): number;
  68476. /**
  68477. * If image processing is enabled.
  68478. */
  68479. set imageProcessingEnabled(enabled: boolean);
  68480. get imageProcessingEnabled(): boolean;
  68481. /**
  68482. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68483. */
  68484. set glowLayerEnabled(enabled: boolean);
  68485. get glowLayerEnabled(): boolean;
  68486. /**
  68487. * Gets the glow layer (or null if not defined)
  68488. */
  68489. get glowLayer(): Nullable<GlowLayer>;
  68490. /**
  68491. * Enable or disable the chromaticAberration process from the pipeline
  68492. */
  68493. set chromaticAberrationEnabled(enabled: boolean);
  68494. get chromaticAberrationEnabled(): boolean;
  68495. /**
  68496. * Enable or disable the grain process from the pipeline
  68497. */
  68498. set grainEnabled(enabled: boolean);
  68499. get grainEnabled(): boolean;
  68500. /**
  68501. * @constructor
  68502. * @param name - The rendering pipeline name (default: "")
  68503. * @param hdr - If high dynamic range textures should be used (default: true)
  68504. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68505. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68506. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68507. */
  68508. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68509. /**
  68510. * Get the class name
  68511. * @returns "DefaultRenderingPipeline"
  68512. */
  68513. getClassName(): string;
  68514. /**
  68515. * Force the compilation of the entire pipeline.
  68516. */
  68517. prepare(): void;
  68518. private _hasCleared;
  68519. private _prevPostProcess;
  68520. private _prevPrevPostProcess;
  68521. private _setAutoClearAndTextureSharing;
  68522. private _depthOfFieldSceneObserver;
  68523. private _buildPipeline;
  68524. private _disposePostProcesses;
  68525. /**
  68526. * Adds a camera to the pipeline
  68527. * @param camera the camera to be added
  68528. */
  68529. addCamera(camera: Camera): void;
  68530. /**
  68531. * Removes a camera from the pipeline
  68532. * @param camera the camera to remove
  68533. */
  68534. removeCamera(camera: Camera): void;
  68535. /**
  68536. * Dispose of the pipeline and stop all post processes
  68537. */
  68538. dispose(): void;
  68539. /**
  68540. * Serialize the rendering pipeline (Used when exporting)
  68541. * @returns the serialized object
  68542. */
  68543. serialize(): any;
  68544. /**
  68545. * Parse the serialized pipeline
  68546. * @param source Source pipeline.
  68547. * @param scene The scene to load the pipeline to.
  68548. * @param rootUrl The URL of the serialized pipeline.
  68549. * @returns An instantiated pipeline from the serialized object.
  68550. */
  68551. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68552. }
  68553. }
  68554. declare module BABYLON {
  68555. /** @hidden */
  68556. export var lensHighlightsPixelShader: {
  68557. name: string;
  68558. shader: string;
  68559. };
  68560. }
  68561. declare module BABYLON {
  68562. /** @hidden */
  68563. export var depthOfFieldPixelShader: {
  68564. name: string;
  68565. shader: string;
  68566. };
  68567. }
  68568. declare module BABYLON {
  68569. /**
  68570. * BABYLON.JS Chromatic Aberration GLSL Shader
  68571. * Author: Olivier Guyot
  68572. * Separates very slightly R, G and B colors on the edges of the screen
  68573. * Inspired by Francois Tarlier & Martins Upitis
  68574. */
  68575. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68576. /**
  68577. * @ignore
  68578. * The chromatic aberration PostProcess id in the pipeline
  68579. */
  68580. LensChromaticAberrationEffect: string;
  68581. /**
  68582. * @ignore
  68583. * The highlights enhancing PostProcess id in the pipeline
  68584. */
  68585. HighlightsEnhancingEffect: string;
  68586. /**
  68587. * @ignore
  68588. * The depth-of-field PostProcess id in the pipeline
  68589. */
  68590. LensDepthOfFieldEffect: string;
  68591. private _scene;
  68592. private _depthTexture;
  68593. private _grainTexture;
  68594. private _chromaticAberrationPostProcess;
  68595. private _highlightsPostProcess;
  68596. private _depthOfFieldPostProcess;
  68597. private _edgeBlur;
  68598. private _grainAmount;
  68599. private _chromaticAberration;
  68600. private _distortion;
  68601. private _highlightsGain;
  68602. private _highlightsThreshold;
  68603. private _dofDistance;
  68604. private _dofAperture;
  68605. private _dofDarken;
  68606. private _dofPentagon;
  68607. private _blurNoise;
  68608. /**
  68609. * @constructor
  68610. *
  68611. * Effect parameters are as follow:
  68612. * {
  68613. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68614. * edge_blur: number; // from 0 to x (1 for realism)
  68615. * distortion: number; // from 0 to x (1 for realism)
  68616. * grain_amount: number; // from 0 to 1
  68617. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68618. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68619. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68620. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68621. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68622. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68623. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68624. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68625. * }
  68626. * Note: if an effect parameter is unset, effect is disabled
  68627. *
  68628. * @param name The rendering pipeline name
  68629. * @param parameters - An object containing all parameters (see above)
  68630. * @param scene The scene linked to this pipeline
  68631. * @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)
  68632. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68633. */
  68634. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68635. /**
  68636. * Get the class name
  68637. * @returns "LensRenderingPipeline"
  68638. */
  68639. getClassName(): string;
  68640. /**
  68641. * Gets associated scene
  68642. */
  68643. get scene(): Scene;
  68644. /**
  68645. * Gets or sets the edge blur
  68646. */
  68647. get edgeBlur(): number;
  68648. set edgeBlur(value: number);
  68649. /**
  68650. * Gets or sets the grain amount
  68651. */
  68652. get grainAmount(): number;
  68653. set grainAmount(value: number);
  68654. /**
  68655. * Gets or sets the chromatic aberration amount
  68656. */
  68657. get chromaticAberration(): number;
  68658. set chromaticAberration(value: number);
  68659. /**
  68660. * Gets or sets the depth of field aperture
  68661. */
  68662. get dofAperture(): number;
  68663. set dofAperture(value: number);
  68664. /**
  68665. * Gets or sets the edge distortion
  68666. */
  68667. get edgeDistortion(): number;
  68668. set edgeDistortion(value: number);
  68669. /**
  68670. * Gets or sets the depth of field distortion
  68671. */
  68672. get dofDistortion(): number;
  68673. set dofDistortion(value: number);
  68674. /**
  68675. * Gets or sets the darken out of focus amount
  68676. */
  68677. get darkenOutOfFocus(): number;
  68678. set darkenOutOfFocus(value: number);
  68679. /**
  68680. * Gets or sets a boolean indicating if blur noise is enabled
  68681. */
  68682. get blurNoise(): boolean;
  68683. set blurNoise(value: boolean);
  68684. /**
  68685. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68686. */
  68687. get pentagonBokeh(): boolean;
  68688. set pentagonBokeh(value: boolean);
  68689. /**
  68690. * Gets or sets the highlight grain amount
  68691. */
  68692. get highlightsGain(): number;
  68693. set highlightsGain(value: number);
  68694. /**
  68695. * Gets or sets the highlight threshold
  68696. */
  68697. get highlightsThreshold(): number;
  68698. set highlightsThreshold(value: number);
  68699. /**
  68700. * Sets the amount of blur at the edges
  68701. * @param amount blur amount
  68702. */
  68703. setEdgeBlur(amount: number): void;
  68704. /**
  68705. * Sets edge blur to 0
  68706. */
  68707. disableEdgeBlur(): void;
  68708. /**
  68709. * Sets the amout of grain
  68710. * @param amount Amount of grain
  68711. */
  68712. setGrainAmount(amount: number): void;
  68713. /**
  68714. * Set grain amount to 0
  68715. */
  68716. disableGrain(): void;
  68717. /**
  68718. * Sets the chromatic aberration amount
  68719. * @param amount amount of chromatic aberration
  68720. */
  68721. setChromaticAberration(amount: number): void;
  68722. /**
  68723. * Sets chromatic aberration amount to 0
  68724. */
  68725. disableChromaticAberration(): void;
  68726. /**
  68727. * Sets the EdgeDistortion amount
  68728. * @param amount amount of EdgeDistortion
  68729. */
  68730. setEdgeDistortion(amount: number): void;
  68731. /**
  68732. * Sets edge distortion to 0
  68733. */
  68734. disableEdgeDistortion(): void;
  68735. /**
  68736. * Sets the FocusDistance amount
  68737. * @param amount amount of FocusDistance
  68738. */
  68739. setFocusDistance(amount: number): void;
  68740. /**
  68741. * Disables depth of field
  68742. */
  68743. disableDepthOfField(): void;
  68744. /**
  68745. * Sets the Aperture amount
  68746. * @param amount amount of Aperture
  68747. */
  68748. setAperture(amount: number): void;
  68749. /**
  68750. * Sets the DarkenOutOfFocus amount
  68751. * @param amount amount of DarkenOutOfFocus
  68752. */
  68753. setDarkenOutOfFocus(amount: number): void;
  68754. private _pentagonBokehIsEnabled;
  68755. /**
  68756. * Creates a pentagon bokeh effect
  68757. */
  68758. enablePentagonBokeh(): void;
  68759. /**
  68760. * Disables the pentagon bokeh effect
  68761. */
  68762. disablePentagonBokeh(): void;
  68763. /**
  68764. * Enables noise blur
  68765. */
  68766. enableNoiseBlur(): void;
  68767. /**
  68768. * Disables noise blur
  68769. */
  68770. disableNoiseBlur(): void;
  68771. /**
  68772. * Sets the HighlightsGain amount
  68773. * @param amount amount of HighlightsGain
  68774. */
  68775. setHighlightsGain(amount: number): void;
  68776. /**
  68777. * Sets the HighlightsThreshold amount
  68778. * @param amount amount of HighlightsThreshold
  68779. */
  68780. setHighlightsThreshold(amount: number): void;
  68781. /**
  68782. * Disables highlights
  68783. */
  68784. disableHighlights(): void;
  68785. /**
  68786. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68787. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68788. */
  68789. dispose(disableDepthRender?: boolean): void;
  68790. private _createChromaticAberrationPostProcess;
  68791. private _createHighlightsPostProcess;
  68792. private _createDepthOfFieldPostProcess;
  68793. private _createGrainTexture;
  68794. }
  68795. }
  68796. declare module BABYLON {
  68797. /** @hidden */
  68798. export var ssao2PixelShader: {
  68799. name: string;
  68800. shader: string;
  68801. };
  68802. }
  68803. declare module BABYLON {
  68804. /** @hidden */
  68805. export var ssaoCombinePixelShader: {
  68806. name: string;
  68807. shader: string;
  68808. };
  68809. }
  68810. declare module BABYLON {
  68811. /**
  68812. * Render pipeline to produce ssao effect
  68813. */
  68814. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68815. /**
  68816. * @ignore
  68817. * The PassPostProcess id in the pipeline that contains the original scene color
  68818. */
  68819. SSAOOriginalSceneColorEffect: string;
  68820. /**
  68821. * @ignore
  68822. * The SSAO PostProcess id in the pipeline
  68823. */
  68824. SSAORenderEffect: string;
  68825. /**
  68826. * @ignore
  68827. * The horizontal blur PostProcess id in the pipeline
  68828. */
  68829. SSAOBlurHRenderEffect: string;
  68830. /**
  68831. * @ignore
  68832. * The vertical blur PostProcess id in the pipeline
  68833. */
  68834. SSAOBlurVRenderEffect: string;
  68835. /**
  68836. * @ignore
  68837. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68838. */
  68839. SSAOCombineRenderEffect: string;
  68840. /**
  68841. * The output strength of the SSAO post-process. Default value is 1.0.
  68842. */
  68843. totalStrength: number;
  68844. /**
  68845. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68846. */
  68847. maxZ: number;
  68848. /**
  68849. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68850. */
  68851. minZAspect: number;
  68852. private _samples;
  68853. /**
  68854. * Number of samples used for the SSAO calculations. Default value is 8
  68855. */
  68856. set samples(n: number);
  68857. get samples(): number;
  68858. private _textureSamples;
  68859. /**
  68860. * Number of samples to use for antialiasing
  68861. */
  68862. set textureSamples(n: number);
  68863. get textureSamples(): number;
  68864. /**
  68865. * Ratio object used for SSAO ratio and blur ratio
  68866. */
  68867. private _ratio;
  68868. /**
  68869. * Dynamically generated sphere sampler.
  68870. */
  68871. private _sampleSphere;
  68872. /**
  68873. * Blur filter offsets
  68874. */
  68875. private _samplerOffsets;
  68876. private _expensiveBlur;
  68877. /**
  68878. * If bilateral blur should be used
  68879. */
  68880. set expensiveBlur(b: boolean);
  68881. get expensiveBlur(): boolean;
  68882. /**
  68883. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68884. */
  68885. radius: number;
  68886. /**
  68887. * The base color of the SSAO post-process
  68888. * The final result is "base + ssao" between [0, 1]
  68889. */
  68890. base: number;
  68891. /**
  68892. * Support test.
  68893. */
  68894. static get IsSupported(): boolean;
  68895. private _scene;
  68896. private _depthTexture;
  68897. private _normalTexture;
  68898. private _randomTexture;
  68899. private _originalColorPostProcess;
  68900. private _ssaoPostProcess;
  68901. private _blurHPostProcess;
  68902. private _blurVPostProcess;
  68903. private _ssaoCombinePostProcess;
  68904. /**
  68905. * Gets active scene
  68906. */
  68907. get scene(): Scene;
  68908. /**
  68909. * @constructor
  68910. * @param name The rendering pipeline name
  68911. * @param scene The scene linked to this pipeline
  68912. * @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 }
  68913. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68914. */
  68915. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68916. /**
  68917. * Get the class name
  68918. * @returns "SSAO2RenderingPipeline"
  68919. */
  68920. getClassName(): string;
  68921. /**
  68922. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68923. */
  68924. dispose(disableGeometryBufferRenderer?: boolean): void;
  68925. private _createBlurPostProcess;
  68926. /** @hidden */
  68927. _rebuild(): void;
  68928. private _bits;
  68929. private _radicalInverse_VdC;
  68930. private _hammersley;
  68931. private _hemisphereSample_uniform;
  68932. private _generateHemisphere;
  68933. private _createSSAOPostProcess;
  68934. private _createSSAOCombinePostProcess;
  68935. private _createRandomTexture;
  68936. /**
  68937. * Serialize the rendering pipeline (Used when exporting)
  68938. * @returns the serialized object
  68939. */
  68940. serialize(): any;
  68941. /**
  68942. * Parse the serialized pipeline
  68943. * @param source Source pipeline.
  68944. * @param scene The scene to load the pipeline to.
  68945. * @param rootUrl The URL of the serialized pipeline.
  68946. * @returns An instantiated pipeline from the serialized object.
  68947. */
  68948. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68949. }
  68950. }
  68951. declare module BABYLON {
  68952. /** @hidden */
  68953. export var ssaoPixelShader: {
  68954. name: string;
  68955. shader: string;
  68956. };
  68957. }
  68958. declare module BABYLON {
  68959. /**
  68960. * Render pipeline to produce ssao effect
  68961. */
  68962. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68963. /**
  68964. * @ignore
  68965. * The PassPostProcess id in the pipeline that contains the original scene color
  68966. */
  68967. SSAOOriginalSceneColorEffect: string;
  68968. /**
  68969. * @ignore
  68970. * The SSAO PostProcess id in the pipeline
  68971. */
  68972. SSAORenderEffect: string;
  68973. /**
  68974. * @ignore
  68975. * The horizontal blur PostProcess id in the pipeline
  68976. */
  68977. SSAOBlurHRenderEffect: string;
  68978. /**
  68979. * @ignore
  68980. * The vertical blur PostProcess id in the pipeline
  68981. */
  68982. SSAOBlurVRenderEffect: string;
  68983. /**
  68984. * @ignore
  68985. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68986. */
  68987. SSAOCombineRenderEffect: string;
  68988. /**
  68989. * The output strength of the SSAO post-process. Default value is 1.0.
  68990. */
  68991. totalStrength: number;
  68992. /**
  68993. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68994. */
  68995. radius: number;
  68996. /**
  68997. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68998. * Must not be equal to fallOff and superior to fallOff.
  68999. * Default value is 0.0075
  69000. */
  69001. area: number;
  69002. /**
  69003. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69004. * Must not be equal to area and inferior to area.
  69005. * Default value is 0.000001
  69006. */
  69007. fallOff: number;
  69008. /**
  69009. * The base color of the SSAO post-process
  69010. * The final result is "base + ssao" between [0, 1]
  69011. */
  69012. base: number;
  69013. private _scene;
  69014. private _depthTexture;
  69015. private _randomTexture;
  69016. private _originalColorPostProcess;
  69017. private _ssaoPostProcess;
  69018. private _blurHPostProcess;
  69019. private _blurVPostProcess;
  69020. private _ssaoCombinePostProcess;
  69021. private _firstUpdate;
  69022. /**
  69023. * Gets active scene
  69024. */
  69025. get scene(): Scene;
  69026. /**
  69027. * @constructor
  69028. * @param name - The rendering pipeline name
  69029. * @param scene - The scene linked to this pipeline
  69030. * @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 }
  69031. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69032. */
  69033. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69034. /**
  69035. * Get the class name
  69036. * @returns "SSAORenderingPipeline"
  69037. */
  69038. getClassName(): string;
  69039. /**
  69040. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69041. */
  69042. dispose(disableDepthRender?: boolean): void;
  69043. private _createBlurPostProcess;
  69044. /** @hidden */
  69045. _rebuild(): void;
  69046. private _createSSAOPostProcess;
  69047. private _createSSAOCombinePostProcess;
  69048. private _createRandomTexture;
  69049. }
  69050. }
  69051. declare module BABYLON {
  69052. /** @hidden */
  69053. export var screenSpaceReflectionPixelShader: {
  69054. name: string;
  69055. shader: string;
  69056. };
  69057. }
  69058. declare module BABYLON {
  69059. /**
  69060. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69061. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69062. */
  69063. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69064. /**
  69065. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69066. */
  69067. threshold: number;
  69068. /**
  69069. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69070. */
  69071. strength: number;
  69072. /**
  69073. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69074. */
  69075. reflectionSpecularFalloffExponent: number;
  69076. /**
  69077. * 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]
  69078. */
  69079. step: number;
  69080. /**
  69081. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69082. */
  69083. roughnessFactor: number;
  69084. private _geometryBufferRenderer;
  69085. private _enableSmoothReflections;
  69086. private _reflectionSamples;
  69087. private _smoothSteps;
  69088. /**
  69089. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69090. * @param name The name of the effect.
  69091. * @param scene The scene containing the objects to calculate reflections.
  69092. * @param options The required width/height ratio to downsize to before computing the render pass.
  69093. * @param camera The camera to apply the render pass to.
  69094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69095. * @param engine The engine which the post process will be applied. (default: current engine)
  69096. * @param reusable If the post process can be reused on the same frame. (default: false)
  69097. * @param textureType Type of textures used when performing the post process. (default: 0)
  69098. * @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)
  69099. */
  69100. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69101. /**
  69102. * Gets wether or not smoothing reflections is enabled.
  69103. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69104. */
  69105. get enableSmoothReflections(): boolean;
  69106. /**
  69107. * Sets wether or not smoothing reflections is enabled.
  69108. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69109. */
  69110. set enableSmoothReflections(enabled: boolean);
  69111. /**
  69112. * Gets the number of samples taken while computing reflections. More samples count is high,
  69113. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69114. */
  69115. get reflectionSamples(): number;
  69116. /**
  69117. * Sets the number of samples taken while computing reflections. More samples count is high,
  69118. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69119. */
  69120. set reflectionSamples(samples: number);
  69121. /**
  69122. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69123. * more the post-process will require GPU power and can generate a drop in FPS.
  69124. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69125. */
  69126. get smoothSteps(): number;
  69127. set smoothSteps(steps: number);
  69128. private _updateEffectDefines;
  69129. }
  69130. }
  69131. declare module BABYLON {
  69132. /** @hidden */
  69133. export var standardPixelShader: {
  69134. name: string;
  69135. shader: string;
  69136. };
  69137. }
  69138. declare module BABYLON {
  69139. /**
  69140. * Standard rendering pipeline
  69141. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69142. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69143. */
  69144. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69145. /**
  69146. * Public members
  69147. */
  69148. /**
  69149. * Post-process which contains the original scene color before the pipeline applies all the effects
  69150. */
  69151. originalPostProcess: Nullable<PostProcess>;
  69152. /**
  69153. * Post-process used to down scale an image x4
  69154. */
  69155. downSampleX4PostProcess: Nullable<PostProcess>;
  69156. /**
  69157. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69158. */
  69159. brightPassPostProcess: Nullable<PostProcess>;
  69160. /**
  69161. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69162. */
  69163. blurHPostProcesses: PostProcess[];
  69164. /**
  69165. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69166. */
  69167. blurVPostProcesses: PostProcess[];
  69168. /**
  69169. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69170. */
  69171. textureAdderPostProcess: Nullable<PostProcess>;
  69172. /**
  69173. * Post-process used to create volumetric lighting effect
  69174. */
  69175. volumetricLightPostProcess: Nullable<PostProcess>;
  69176. /**
  69177. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69178. */
  69179. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69180. /**
  69181. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69182. */
  69183. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69184. /**
  69185. * Post-process used to merge the volumetric light effect and the real scene color
  69186. */
  69187. volumetricLightMergePostProces: Nullable<PostProcess>;
  69188. /**
  69189. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69190. */
  69191. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69192. /**
  69193. * Base post-process used to calculate the average luminance of the final image for HDR
  69194. */
  69195. luminancePostProcess: Nullable<PostProcess>;
  69196. /**
  69197. * Post-processes used to create down sample post-processes in order to get
  69198. * the average luminance of the final image for HDR
  69199. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69200. */
  69201. luminanceDownSamplePostProcesses: PostProcess[];
  69202. /**
  69203. * Post-process used to create a HDR effect (light adaptation)
  69204. */
  69205. hdrPostProcess: Nullable<PostProcess>;
  69206. /**
  69207. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69208. */
  69209. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69210. /**
  69211. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69212. */
  69213. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69214. /**
  69215. * Post-process used to merge the final HDR post-process and the real scene color
  69216. */
  69217. hdrFinalPostProcess: Nullable<PostProcess>;
  69218. /**
  69219. * Post-process used to create a lens flare effect
  69220. */
  69221. lensFlarePostProcess: Nullable<PostProcess>;
  69222. /**
  69223. * Post-process that merges the result of the lens flare post-process and the real scene color
  69224. */
  69225. lensFlareComposePostProcess: Nullable<PostProcess>;
  69226. /**
  69227. * Post-process used to create a motion blur effect
  69228. */
  69229. motionBlurPostProcess: Nullable<PostProcess>;
  69230. /**
  69231. * Post-process used to create a depth of field effect
  69232. */
  69233. depthOfFieldPostProcess: Nullable<PostProcess>;
  69234. /**
  69235. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69236. */
  69237. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69238. /**
  69239. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69240. */
  69241. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69242. /**
  69243. * Represents the brightness threshold in order to configure the illuminated surfaces
  69244. */
  69245. brightThreshold: number;
  69246. /**
  69247. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69248. */
  69249. blurWidth: number;
  69250. /**
  69251. * Sets if the blur for highlighted surfaces must be only horizontal
  69252. */
  69253. horizontalBlur: boolean;
  69254. /**
  69255. * Gets the overall exposure used by the pipeline
  69256. */
  69257. get exposure(): number;
  69258. /**
  69259. * Sets the overall exposure used by the pipeline
  69260. */
  69261. set exposure(value: number);
  69262. /**
  69263. * Texture used typically to simulate "dirty" on camera lens
  69264. */
  69265. lensTexture: Nullable<Texture>;
  69266. /**
  69267. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69268. */
  69269. volumetricLightCoefficient: number;
  69270. /**
  69271. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69272. */
  69273. volumetricLightPower: number;
  69274. /**
  69275. * Used the set the blur intensity to smooth the volumetric lights
  69276. */
  69277. volumetricLightBlurScale: number;
  69278. /**
  69279. * Light (spot or directional) used to generate the volumetric lights rays
  69280. * The source light must have a shadow generate so the pipeline can get its
  69281. * depth map
  69282. */
  69283. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69284. /**
  69285. * For eye adaptation, represents the minimum luminance the eye can see
  69286. */
  69287. hdrMinimumLuminance: number;
  69288. /**
  69289. * For eye adaptation, represents the decrease luminance speed
  69290. */
  69291. hdrDecreaseRate: number;
  69292. /**
  69293. * For eye adaptation, represents the increase luminance speed
  69294. */
  69295. hdrIncreaseRate: number;
  69296. /**
  69297. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69298. */
  69299. get hdrAutoExposure(): boolean;
  69300. /**
  69301. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69302. */
  69303. set hdrAutoExposure(value: boolean);
  69304. /**
  69305. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69306. */
  69307. lensColorTexture: Nullable<Texture>;
  69308. /**
  69309. * The overall strengh for the lens flare effect
  69310. */
  69311. lensFlareStrength: number;
  69312. /**
  69313. * Dispersion coefficient for lens flare ghosts
  69314. */
  69315. lensFlareGhostDispersal: number;
  69316. /**
  69317. * Main lens flare halo width
  69318. */
  69319. lensFlareHaloWidth: number;
  69320. /**
  69321. * Based on the lens distortion effect, defines how much the lens flare result
  69322. * is distorted
  69323. */
  69324. lensFlareDistortionStrength: number;
  69325. /**
  69326. * Configures the blur intensity used for for lens flare (halo)
  69327. */
  69328. lensFlareBlurWidth: number;
  69329. /**
  69330. * Lens star texture must be used to simulate rays on the flares and is available
  69331. * in the documentation
  69332. */
  69333. lensStarTexture: Nullable<Texture>;
  69334. /**
  69335. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69336. * flare effect by taking account of the dirt texture
  69337. */
  69338. lensFlareDirtTexture: Nullable<Texture>;
  69339. /**
  69340. * Represents the focal length for the depth of field effect
  69341. */
  69342. depthOfFieldDistance: number;
  69343. /**
  69344. * Represents the blur intensity for the blurred part of the depth of field effect
  69345. */
  69346. depthOfFieldBlurWidth: number;
  69347. /**
  69348. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69349. */
  69350. get motionStrength(): number;
  69351. /**
  69352. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69353. */
  69354. set motionStrength(strength: number);
  69355. /**
  69356. * Gets wether or not the motion blur post-process is object based or screen based.
  69357. */
  69358. get objectBasedMotionBlur(): boolean;
  69359. /**
  69360. * Sets wether or not the motion blur post-process should be object based or screen based
  69361. */
  69362. set objectBasedMotionBlur(value: boolean);
  69363. /**
  69364. * List of animations for the pipeline (IAnimatable implementation)
  69365. */
  69366. animations: Animation[];
  69367. /**
  69368. * Private members
  69369. */
  69370. private _scene;
  69371. private _currentDepthOfFieldSource;
  69372. private _basePostProcess;
  69373. private _fixedExposure;
  69374. private _currentExposure;
  69375. private _hdrAutoExposure;
  69376. private _hdrCurrentLuminance;
  69377. private _motionStrength;
  69378. private _isObjectBasedMotionBlur;
  69379. private _floatTextureType;
  69380. private _camerasToBeAttached;
  69381. private _ratio;
  69382. private _bloomEnabled;
  69383. private _depthOfFieldEnabled;
  69384. private _vlsEnabled;
  69385. private _lensFlareEnabled;
  69386. private _hdrEnabled;
  69387. private _motionBlurEnabled;
  69388. private _fxaaEnabled;
  69389. private _screenSpaceReflectionsEnabled;
  69390. private _motionBlurSamples;
  69391. private _volumetricLightStepsCount;
  69392. private _samples;
  69393. /**
  69394. * @ignore
  69395. * Specifies if the bloom pipeline is enabled
  69396. */
  69397. get BloomEnabled(): boolean;
  69398. set BloomEnabled(enabled: boolean);
  69399. /**
  69400. * @ignore
  69401. * Specifies if the depth of field pipeline is enabed
  69402. */
  69403. get DepthOfFieldEnabled(): boolean;
  69404. set DepthOfFieldEnabled(enabled: boolean);
  69405. /**
  69406. * @ignore
  69407. * Specifies if the lens flare pipeline is enabed
  69408. */
  69409. get LensFlareEnabled(): boolean;
  69410. set LensFlareEnabled(enabled: boolean);
  69411. /**
  69412. * @ignore
  69413. * Specifies if the HDR pipeline is enabled
  69414. */
  69415. get HDREnabled(): boolean;
  69416. set HDREnabled(enabled: boolean);
  69417. /**
  69418. * @ignore
  69419. * Specifies if the volumetric lights scattering effect is enabled
  69420. */
  69421. get VLSEnabled(): boolean;
  69422. set VLSEnabled(enabled: boolean);
  69423. /**
  69424. * @ignore
  69425. * Specifies if the motion blur effect is enabled
  69426. */
  69427. get MotionBlurEnabled(): boolean;
  69428. set MotionBlurEnabled(enabled: boolean);
  69429. /**
  69430. * Specifies if anti-aliasing is enabled
  69431. */
  69432. get fxaaEnabled(): boolean;
  69433. set fxaaEnabled(enabled: boolean);
  69434. /**
  69435. * Specifies if screen space reflections are enabled.
  69436. */
  69437. get screenSpaceReflectionsEnabled(): boolean;
  69438. set screenSpaceReflectionsEnabled(enabled: boolean);
  69439. /**
  69440. * Specifies the number of steps used to calculate the volumetric lights
  69441. * Typically in interval [50, 200]
  69442. */
  69443. get volumetricLightStepsCount(): number;
  69444. set volumetricLightStepsCount(count: number);
  69445. /**
  69446. * Specifies the number of samples used for the motion blur effect
  69447. * Typically in interval [16, 64]
  69448. */
  69449. get motionBlurSamples(): number;
  69450. set motionBlurSamples(samples: number);
  69451. /**
  69452. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69453. */
  69454. get samples(): number;
  69455. set samples(sampleCount: number);
  69456. /**
  69457. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69458. * @constructor
  69459. * @param name The rendering pipeline name
  69460. * @param scene The scene linked to this pipeline
  69461. * @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)
  69462. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69463. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69464. */
  69465. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69466. private _buildPipeline;
  69467. private _createDownSampleX4PostProcess;
  69468. private _createBrightPassPostProcess;
  69469. private _createBlurPostProcesses;
  69470. private _createTextureAdderPostProcess;
  69471. private _createVolumetricLightPostProcess;
  69472. private _createLuminancePostProcesses;
  69473. private _createHdrPostProcess;
  69474. private _createLensFlarePostProcess;
  69475. private _createDepthOfFieldPostProcess;
  69476. private _createMotionBlurPostProcess;
  69477. private _getDepthTexture;
  69478. private _disposePostProcesses;
  69479. /**
  69480. * Dispose of the pipeline and stop all post processes
  69481. */
  69482. dispose(): void;
  69483. /**
  69484. * Serialize the rendering pipeline (Used when exporting)
  69485. * @returns the serialized object
  69486. */
  69487. serialize(): any;
  69488. /**
  69489. * Parse the serialized pipeline
  69490. * @param source Source pipeline.
  69491. * @param scene The scene to load the pipeline to.
  69492. * @param rootUrl The URL of the serialized pipeline.
  69493. * @returns An instantiated pipeline from the serialized object.
  69494. */
  69495. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69496. /**
  69497. * Luminance steps
  69498. */
  69499. static LuminanceSteps: number;
  69500. }
  69501. }
  69502. declare module BABYLON {
  69503. /** @hidden */
  69504. export var stereoscopicInterlacePixelShader: {
  69505. name: string;
  69506. shader: string;
  69507. };
  69508. }
  69509. declare module BABYLON {
  69510. /**
  69511. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69512. */
  69513. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69514. private _stepSize;
  69515. private _passedProcess;
  69516. /**
  69517. * Initializes a StereoscopicInterlacePostProcessI
  69518. * @param name The name of the effect.
  69519. * @param rigCameras The rig cameras to be appled to the post process
  69520. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69521. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69523. * @param engine The engine which the post process will be applied. (default: current engine)
  69524. * @param reusable If the post process can be reused on the same frame. (default: false)
  69525. */
  69526. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69527. }
  69528. /**
  69529. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69530. */
  69531. export class StereoscopicInterlacePostProcess extends PostProcess {
  69532. private _stepSize;
  69533. private _passedProcess;
  69534. /**
  69535. * Initializes a StereoscopicInterlacePostProcess
  69536. * @param name The name of the effect.
  69537. * @param rigCameras The rig cameras to be appled to the post process
  69538. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69540. * @param engine The engine which the post process will be applied. (default: current engine)
  69541. * @param reusable If the post process can be reused on the same frame. (default: false)
  69542. */
  69543. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69544. }
  69545. }
  69546. declare module BABYLON {
  69547. /** @hidden */
  69548. export var tonemapPixelShader: {
  69549. name: string;
  69550. shader: string;
  69551. };
  69552. }
  69553. declare module BABYLON {
  69554. /** Defines operator used for tonemapping */
  69555. export enum TonemappingOperator {
  69556. /** Hable */
  69557. Hable = 0,
  69558. /** Reinhard */
  69559. Reinhard = 1,
  69560. /** HejiDawson */
  69561. HejiDawson = 2,
  69562. /** Photographic */
  69563. Photographic = 3
  69564. }
  69565. /**
  69566. * Defines a post process to apply tone mapping
  69567. */
  69568. export class TonemapPostProcess extends PostProcess {
  69569. private _operator;
  69570. /** Defines the required exposure adjustement */
  69571. exposureAdjustment: number;
  69572. /**
  69573. * Creates a new TonemapPostProcess
  69574. * @param name defines the name of the postprocess
  69575. * @param _operator defines the operator to use
  69576. * @param exposureAdjustment defines the required exposure adjustement
  69577. * @param camera defines the camera to use (can be null)
  69578. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69579. * @param engine defines the hosting engine (can be ignore if camera is set)
  69580. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69581. */
  69582. constructor(name: string, _operator: TonemappingOperator,
  69583. /** Defines the required exposure adjustement */
  69584. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69585. }
  69586. }
  69587. declare module BABYLON {
  69588. /** @hidden */
  69589. export var volumetricLightScatteringPixelShader: {
  69590. name: string;
  69591. shader: string;
  69592. };
  69593. }
  69594. declare module BABYLON {
  69595. /** @hidden */
  69596. export var volumetricLightScatteringPassVertexShader: {
  69597. name: string;
  69598. shader: string;
  69599. };
  69600. }
  69601. declare module BABYLON {
  69602. /** @hidden */
  69603. export var volumetricLightScatteringPassPixelShader: {
  69604. name: string;
  69605. shader: string;
  69606. };
  69607. }
  69608. declare module BABYLON {
  69609. /**
  69610. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69611. */
  69612. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69613. private _volumetricLightScatteringPass;
  69614. private _volumetricLightScatteringRTT;
  69615. private _viewPort;
  69616. private _screenCoordinates;
  69617. private _cachedDefines;
  69618. /**
  69619. * If not undefined, the mesh position is computed from the attached node position
  69620. */
  69621. attachedNode: {
  69622. position: Vector3;
  69623. };
  69624. /**
  69625. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69626. */
  69627. customMeshPosition: Vector3;
  69628. /**
  69629. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69630. */
  69631. useCustomMeshPosition: boolean;
  69632. /**
  69633. * If the post-process should inverse the light scattering direction
  69634. */
  69635. invert: boolean;
  69636. /**
  69637. * The internal mesh used by the post-process
  69638. */
  69639. mesh: Mesh;
  69640. /**
  69641. * @hidden
  69642. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69643. */
  69644. get useDiffuseColor(): boolean;
  69645. set useDiffuseColor(useDiffuseColor: boolean);
  69646. /**
  69647. * Array containing the excluded meshes not rendered in the internal pass
  69648. */
  69649. excludedMeshes: AbstractMesh[];
  69650. /**
  69651. * Controls the overall intensity of the post-process
  69652. */
  69653. exposure: number;
  69654. /**
  69655. * Dissipates each sample's contribution in range [0, 1]
  69656. */
  69657. decay: number;
  69658. /**
  69659. * Controls the overall intensity of each sample
  69660. */
  69661. weight: number;
  69662. /**
  69663. * Controls the density of each sample
  69664. */
  69665. density: number;
  69666. /**
  69667. * @constructor
  69668. * @param name The post-process name
  69669. * @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)
  69670. * @param camera The camera that the post-process will be attached to
  69671. * @param mesh The mesh used to create the light scattering
  69672. * @param samples The post-process quality, default 100
  69673. * @param samplingModeThe post-process filtering mode
  69674. * @param engine The babylon engine
  69675. * @param reusable If the post-process is reusable
  69676. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69677. */
  69678. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69679. /**
  69680. * Returns the string "VolumetricLightScatteringPostProcess"
  69681. * @returns "VolumetricLightScatteringPostProcess"
  69682. */
  69683. getClassName(): string;
  69684. private _isReady;
  69685. /**
  69686. * Sets the new light position for light scattering effect
  69687. * @param position The new custom light position
  69688. */
  69689. setCustomMeshPosition(position: Vector3): void;
  69690. /**
  69691. * Returns the light position for light scattering effect
  69692. * @return Vector3 The custom light position
  69693. */
  69694. getCustomMeshPosition(): Vector3;
  69695. /**
  69696. * Disposes the internal assets and detaches the post-process from the camera
  69697. */
  69698. dispose(camera: Camera): void;
  69699. /**
  69700. * Returns the render target texture used by the post-process
  69701. * @return the render target texture used by the post-process
  69702. */
  69703. getPass(): RenderTargetTexture;
  69704. private _meshExcluded;
  69705. private _createPass;
  69706. private _updateMeshScreenCoordinates;
  69707. /**
  69708. * Creates a default mesh for the Volumeric Light Scattering post-process
  69709. * @param name The mesh name
  69710. * @param scene The scene where to create the mesh
  69711. * @return the default mesh
  69712. */
  69713. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69714. }
  69715. }
  69716. declare module BABYLON {
  69717. interface Scene {
  69718. /** @hidden (Backing field) */
  69719. _boundingBoxRenderer: BoundingBoxRenderer;
  69720. /** @hidden (Backing field) */
  69721. _forceShowBoundingBoxes: boolean;
  69722. /**
  69723. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69724. */
  69725. forceShowBoundingBoxes: boolean;
  69726. /**
  69727. * Gets the bounding box renderer associated with the scene
  69728. * @returns a BoundingBoxRenderer
  69729. */
  69730. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69731. }
  69732. interface AbstractMesh {
  69733. /** @hidden (Backing field) */
  69734. _showBoundingBox: boolean;
  69735. /**
  69736. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69737. */
  69738. showBoundingBox: boolean;
  69739. }
  69740. /**
  69741. * Component responsible of rendering the bounding box of the meshes in a scene.
  69742. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69743. */
  69744. export class BoundingBoxRenderer implements ISceneComponent {
  69745. /**
  69746. * The component name helpfull to identify the component in the list of scene components.
  69747. */
  69748. readonly name: string;
  69749. /**
  69750. * The scene the component belongs to.
  69751. */
  69752. scene: Scene;
  69753. /**
  69754. * Color of the bounding box lines placed in front of an object
  69755. */
  69756. frontColor: Color3;
  69757. /**
  69758. * Color of the bounding box lines placed behind an object
  69759. */
  69760. backColor: Color3;
  69761. /**
  69762. * Defines if the renderer should show the back lines or not
  69763. */
  69764. showBackLines: boolean;
  69765. /**
  69766. * Observable raised before rendering a bounding box
  69767. */
  69768. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69769. /**
  69770. * Observable raised after rendering a bounding box
  69771. */
  69772. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69773. /**
  69774. * @hidden
  69775. */
  69776. renderList: SmartArray<BoundingBox>;
  69777. private _colorShader;
  69778. private _vertexBuffers;
  69779. private _indexBuffer;
  69780. private _fillIndexBuffer;
  69781. private _fillIndexData;
  69782. /**
  69783. * Instantiates a new bounding box renderer in a scene.
  69784. * @param scene the scene the renderer renders in
  69785. */
  69786. constructor(scene: Scene);
  69787. /**
  69788. * Registers the component in a given scene
  69789. */
  69790. register(): void;
  69791. private _evaluateSubMesh;
  69792. private _activeMesh;
  69793. private _prepareRessources;
  69794. private _createIndexBuffer;
  69795. /**
  69796. * Rebuilds the elements related to this component in case of
  69797. * context lost for instance.
  69798. */
  69799. rebuild(): void;
  69800. /**
  69801. * @hidden
  69802. */
  69803. reset(): void;
  69804. /**
  69805. * Render the bounding boxes of a specific rendering group
  69806. * @param renderingGroupId defines the rendering group to render
  69807. */
  69808. render(renderingGroupId: number): void;
  69809. /**
  69810. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69811. * @param mesh Define the mesh to render the occlusion bounding box for
  69812. */
  69813. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69814. /**
  69815. * Dispose and release the resources attached to this renderer.
  69816. */
  69817. dispose(): void;
  69818. }
  69819. }
  69820. declare module BABYLON {
  69821. interface Scene {
  69822. /** @hidden (Backing field) */
  69823. _depthRenderer: {
  69824. [id: string]: DepthRenderer;
  69825. };
  69826. /**
  69827. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69828. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69829. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69830. * @returns the created depth renderer
  69831. */
  69832. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69833. /**
  69834. * Disables a depth renderer for a given camera
  69835. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69836. */
  69837. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69838. }
  69839. /**
  69840. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69841. * in several rendering techniques.
  69842. */
  69843. export class DepthRendererSceneComponent implements ISceneComponent {
  69844. /**
  69845. * The component name helpfull to identify the component in the list of scene components.
  69846. */
  69847. readonly name: string;
  69848. /**
  69849. * The scene the component belongs to.
  69850. */
  69851. scene: Scene;
  69852. /**
  69853. * Creates a new instance of the component for the given scene
  69854. * @param scene Defines the scene to register the component in
  69855. */
  69856. constructor(scene: Scene);
  69857. /**
  69858. * Registers the component in a given scene
  69859. */
  69860. register(): void;
  69861. /**
  69862. * Rebuilds the elements related to this component in case of
  69863. * context lost for instance.
  69864. */
  69865. rebuild(): void;
  69866. /**
  69867. * Disposes the component and the associated ressources
  69868. */
  69869. dispose(): void;
  69870. private _gatherRenderTargets;
  69871. private _gatherActiveCameraRenderTargets;
  69872. }
  69873. }
  69874. declare module BABYLON {
  69875. /** @hidden */
  69876. export var outlinePixelShader: {
  69877. name: string;
  69878. shader: string;
  69879. };
  69880. }
  69881. declare module BABYLON {
  69882. /** @hidden */
  69883. export var outlineVertexShader: {
  69884. name: string;
  69885. shader: string;
  69886. };
  69887. }
  69888. declare module BABYLON {
  69889. interface Scene {
  69890. /** @hidden */
  69891. _outlineRenderer: OutlineRenderer;
  69892. /**
  69893. * Gets the outline renderer associated with the scene
  69894. * @returns a OutlineRenderer
  69895. */
  69896. getOutlineRenderer(): OutlineRenderer;
  69897. }
  69898. interface AbstractMesh {
  69899. /** @hidden (Backing field) */
  69900. _renderOutline: boolean;
  69901. /**
  69902. * Gets or sets a boolean indicating if the outline must be rendered as well
  69903. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69904. */
  69905. renderOutline: boolean;
  69906. /** @hidden (Backing field) */
  69907. _renderOverlay: boolean;
  69908. /**
  69909. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69910. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69911. */
  69912. renderOverlay: boolean;
  69913. }
  69914. /**
  69915. * This class is responsible to draw bothe outline/overlay of meshes.
  69916. * It should not be used directly but through the available method on mesh.
  69917. */
  69918. export class OutlineRenderer implements ISceneComponent {
  69919. /**
  69920. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69921. */
  69922. private static _StencilReference;
  69923. /**
  69924. * The name of the component. Each component must have a unique name.
  69925. */
  69926. name: string;
  69927. /**
  69928. * The scene the component belongs to.
  69929. */
  69930. scene: Scene;
  69931. /**
  69932. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69933. */
  69934. zOffset: number;
  69935. private _engine;
  69936. private _effect;
  69937. private _cachedDefines;
  69938. private _savedDepthWrite;
  69939. /**
  69940. * Instantiates a new outline renderer. (There could be only one per scene).
  69941. * @param scene Defines the scene it belongs to
  69942. */
  69943. constructor(scene: Scene);
  69944. /**
  69945. * Register the component to one instance of a scene.
  69946. */
  69947. register(): void;
  69948. /**
  69949. * Rebuilds the elements related to this component in case of
  69950. * context lost for instance.
  69951. */
  69952. rebuild(): void;
  69953. /**
  69954. * Disposes the component and the associated ressources.
  69955. */
  69956. dispose(): void;
  69957. /**
  69958. * Renders the outline in the canvas.
  69959. * @param subMesh Defines the sumesh to render
  69960. * @param batch Defines the batch of meshes in case of instances
  69961. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69962. */
  69963. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69964. /**
  69965. * Returns whether or not the outline renderer is ready for a given submesh.
  69966. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69967. * @param subMesh Defines the submesh to check readyness for
  69968. * @param useInstances Defines wheter wee are trying to render instances or not
  69969. * @returns true if ready otherwise false
  69970. */
  69971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69972. private _beforeRenderingMesh;
  69973. private _afterRenderingMesh;
  69974. }
  69975. }
  69976. declare module BABYLON {
  69977. /**
  69978. * Defines the basic options interface of a Sprite Frame Source Size.
  69979. */
  69980. export interface ISpriteJSONSpriteSourceSize {
  69981. /**
  69982. * number of the original width of the Frame
  69983. */
  69984. w: number;
  69985. /**
  69986. * number of the original height of the Frame
  69987. */
  69988. h: number;
  69989. }
  69990. /**
  69991. * Defines the basic options interface of a Sprite Frame Data.
  69992. */
  69993. export interface ISpriteJSONSpriteFrameData {
  69994. /**
  69995. * number of the x offset of the Frame
  69996. */
  69997. x: number;
  69998. /**
  69999. * number of the y offset of the Frame
  70000. */
  70001. y: number;
  70002. /**
  70003. * number of the width of the Frame
  70004. */
  70005. w: number;
  70006. /**
  70007. * number of the height of the Frame
  70008. */
  70009. h: number;
  70010. }
  70011. /**
  70012. * Defines the basic options interface of a JSON Sprite.
  70013. */
  70014. export interface ISpriteJSONSprite {
  70015. /**
  70016. * string name of the Frame
  70017. */
  70018. filename: string;
  70019. /**
  70020. * ISpriteJSONSpriteFrame basic object of the frame data
  70021. */
  70022. frame: ISpriteJSONSpriteFrameData;
  70023. /**
  70024. * boolean to flag is the frame was rotated.
  70025. */
  70026. rotated: boolean;
  70027. /**
  70028. * boolean to flag is the frame was trimmed.
  70029. */
  70030. trimmed: boolean;
  70031. /**
  70032. * ISpriteJSONSpriteFrame basic object of the source data
  70033. */
  70034. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70035. /**
  70036. * ISpriteJSONSpriteFrame basic object of the source data
  70037. */
  70038. sourceSize: ISpriteJSONSpriteSourceSize;
  70039. }
  70040. /**
  70041. * Defines the basic options interface of a JSON atlas.
  70042. */
  70043. export interface ISpriteJSONAtlas {
  70044. /**
  70045. * Array of objects that contain the frame data.
  70046. */
  70047. frames: Array<ISpriteJSONSprite>;
  70048. /**
  70049. * object basic object containing the sprite meta data.
  70050. */
  70051. meta?: object;
  70052. }
  70053. }
  70054. declare module BABYLON {
  70055. /** @hidden */
  70056. export var spriteMapPixelShader: {
  70057. name: string;
  70058. shader: string;
  70059. };
  70060. }
  70061. declare module BABYLON {
  70062. /** @hidden */
  70063. export var spriteMapVertexShader: {
  70064. name: string;
  70065. shader: string;
  70066. };
  70067. }
  70068. declare module BABYLON {
  70069. /**
  70070. * Defines the basic options interface of a SpriteMap
  70071. */
  70072. export interface ISpriteMapOptions {
  70073. /**
  70074. * Vector2 of the number of cells in the grid.
  70075. */
  70076. stageSize?: Vector2;
  70077. /**
  70078. * Vector2 of the size of the output plane in World Units.
  70079. */
  70080. outputSize?: Vector2;
  70081. /**
  70082. * Vector3 of the position of the output plane in World Units.
  70083. */
  70084. outputPosition?: Vector3;
  70085. /**
  70086. * Vector3 of the rotation of the output plane.
  70087. */
  70088. outputRotation?: Vector3;
  70089. /**
  70090. * number of layers that the system will reserve in resources.
  70091. */
  70092. layerCount?: number;
  70093. /**
  70094. * number of max animation frames a single cell will reserve in resources.
  70095. */
  70096. maxAnimationFrames?: number;
  70097. /**
  70098. * number cell index of the base tile when the system compiles.
  70099. */
  70100. baseTile?: number;
  70101. /**
  70102. * boolean flip the sprite after its been repositioned by the framing data.
  70103. */
  70104. flipU?: boolean;
  70105. /**
  70106. * Vector3 scalar of the global RGB values of the SpriteMap.
  70107. */
  70108. colorMultiply?: Vector3;
  70109. }
  70110. /**
  70111. * Defines the IDisposable interface in order to be cleanable from resources.
  70112. */
  70113. export interface ISpriteMap extends IDisposable {
  70114. /**
  70115. * String name of the SpriteMap.
  70116. */
  70117. name: string;
  70118. /**
  70119. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70120. */
  70121. atlasJSON: ISpriteJSONAtlas;
  70122. /**
  70123. * Texture of the SpriteMap.
  70124. */
  70125. spriteSheet: Texture;
  70126. /**
  70127. * The parameters to initialize the SpriteMap with.
  70128. */
  70129. options: ISpriteMapOptions;
  70130. }
  70131. /**
  70132. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70133. */
  70134. export class SpriteMap implements ISpriteMap {
  70135. /** The Name of the spriteMap */
  70136. name: string;
  70137. /** The JSON file with the frame and meta data */
  70138. atlasJSON: ISpriteJSONAtlas;
  70139. /** The systems Sprite Sheet Texture */
  70140. spriteSheet: Texture;
  70141. /** Arguments passed with the Constructor */
  70142. options: ISpriteMapOptions;
  70143. /** Public Sprite Storage array, parsed from atlasJSON */
  70144. sprites: Array<ISpriteJSONSprite>;
  70145. /** Returns the Number of Sprites in the System */
  70146. get spriteCount(): number;
  70147. /** Returns the Position of Output Plane*/
  70148. get position(): Vector3;
  70149. /** Returns the Position of Output Plane*/
  70150. set position(v: Vector3);
  70151. /** Returns the Rotation of Output Plane*/
  70152. get rotation(): Vector3;
  70153. /** Returns the Rotation of Output Plane*/
  70154. set rotation(v: Vector3);
  70155. /** Sets the AnimationMap*/
  70156. get animationMap(): RawTexture;
  70157. /** Sets the AnimationMap*/
  70158. set animationMap(v: RawTexture);
  70159. /** Scene that the SpriteMap was created in */
  70160. private _scene;
  70161. /** Texture Buffer of Float32 that holds tile frame data*/
  70162. private _frameMap;
  70163. /** Texture Buffers of Float32 that holds tileMap data*/
  70164. private _tileMaps;
  70165. /** Texture Buffer of Float32 that holds Animation Data*/
  70166. private _animationMap;
  70167. /** Custom ShaderMaterial Central to the System*/
  70168. private _material;
  70169. /** Custom ShaderMaterial Central to the System*/
  70170. private _output;
  70171. /** Systems Time Ticker*/
  70172. private _time;
  70173. /**
  70174. * Creates a new SpriteMap
  70175. * @param name defines the SpriteMaps Name
  70176. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70177. * @param spriteSheet is the Texture that the Sprites are on.
  70178. * @param options a basic deployment configuration
  70179. * @param scene The Scene that the map is deployed on
  70180. */
  70181. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70182. /**
  70183. * Returns tileID location
  70184. * @returns Vector2 the cell position ID
  70185. */
  70186. getTileID(): Vector2;
  70187. /**
  70188. * Gets the UV location of the mouse over the SpriteMap.
  70189. * @returns Vector2 the UV position of the mouse interaction
  70190. */
  70191. getMousePosition(): Vector2;
  70192. /**
  70193. * Creates the "frame" texture Buffer
  70194. * -------------------------------------
  70195. * Structure of frames
  70196. * "filename": "Falling-Water-2.png",
  70197. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70198. * "rotated": true,
  70199. * "trimmed": true,
  70200. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70201. * "sourceSize": {"w":32,"h":32}
  70202. * @returns RawTexture of the frameMap
  70203. */
  70204. private _createFrameBuffer;
  70205. /**
  70206. * Creates the tileMap texture Buffer
  70207. * @param buffer normally and array of numbers, or a false to generate from scratch
  70208. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70209. * @returns RawTexture of the tileMap
  70210. */
  70211. private _createTileBuffer;
  70212. /**
  70213. * Modifies the data of the tileMaps
  70214. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70215. * @param pos is the iVector2 Coordinates of the Tile
  70216. * @param tile The SpriteIndex of the new Tile
  70217. */
  70218. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70219. /**
  70220. * Creates the animationMap texture Buffer
  70221. * @param buffer normally and array of numbers, or a false to generate from scratch
  70222. * @returns RawTexture of the animationMap
  70223. */
  70224. private _createTileAnimationBuffer;
  70225. /**
  70226. * Modifies the data of the animationMap
  70227. * @param cellID is the Index of the Sprite
  70228. * @param _frame is the target Animation frame
  70229. * @param toCell is the Target Index of the next frame of the animation
  70230. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70231. * @param speed is a global scalar of the time variable on the map.
  70232. */
  70233. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70234. /**
  70235. * Exports the .tilemaps file
  70236. */
  70237. saveTileMaps(): void;
  70238. /**
  70239. * Imports the .tilemaps file
  70240. * @param url of the .tilemaps file
  70241. */
  70242. loadTileMaps(url: string): void;
  70243. /**
  70244. * Release associated resources
  70245. */
  70246. dispose(): void;
  70247. }
  70248. }
  70249. declare module BABYLON {
  70250. /**
  70251. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70252. * @see http://doc.babylonjs.com/babylon101/sprites
  70253. */
  70254. export class SpritePackedManager extends SpriteManager {
  70255. /** defines the packed manager's name */
  70256. name: string;
  70257. /**
  70258. * Creates a new sprite manager from a packed sprite sheet
  70259. * @param name defines the manager's name
  70260. * @param imgUrl defines the sprite sheet url
  70261. * @param capacity defines the maximum allowed number of sprites
  70262. * @param scene defines the hosting scene
  70263. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70264. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70265. * @param samplingMode defines the smapling mode to use with spritesheet
  70266. * @param fromPacked set to true; do not alter
  70267. */
  70268. constructor(
  70269. /** defines the packed manager's name */
  70270. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70271. }
  70272. }
  70273. declare module BABYLON {
  70274. /**
  70275. * Defines the list of states available for a task inside a AssetsManager
  70276. */
  70277. export enum AssetTaskState {
  70278. /**
  70279. * Initialization
  70280. */
  70281. INIT = 0,
  70282. /**
  70283. * Running
  70284. */
  70285. RUNNING = 1,
  70286. /**
  70287. * Done
  70288. */
  70289. DONE = 2,
  70290. /**
  70291. * Error
  70292. */
  70293. ERROR = 3
  70294. }
  70295. /**
  70296. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70297. */
  70298. export abstract class AbstractAssetTask {
  70299. /**
  70300. * Task name
  70301. */ name: string;
  70302. /**
  70303. * Callback called when the task is successful
  70304. */
  70305. onSuccess: (task: any) => void;
  70306. /**
  70307. * Callback called when the task is not successful
  70308. */
  70309. onError: (task: any, message?: string, exception?: any) => void;
  70310. /**
  70311. * Creates a new AssetsManager
  70312. * @param name defines the name of the task
  70313. */
  70314. constructor(
  70315. /**
  70316. * Task name
  70317. */ name: string);
  70318. private _isCompleted;
  70319. private _taskState;
  70320. private _errorObject;
  70321. /**
  70322. * Get if the task is completed
  70323. */
  70324. get isCompleted(): boolean;
  70325. /**
  70326. * Gets the current state of the task
  70327. */
  70328. get taskState(): AssetTaskState;
  70329. /**
  70330. * Gets the current error object (if task is in error)
  70331. */
  70332. get errorObject(): {
  70333. message?: string;
  70334. exception?: any;
  70335. };
  70336. /**
  70337. * Internal only
  70338. * @hidden
  70339. */
  70340. _setErrorObject(message?: string, exception?: any): void;
  70341. /**
  70342. * Execute the current task
  70343. * @param scene defines the scene where you want your assets to be loaded
  70344. * @param onSuccess is a callback called when the task is successfully executed
  70345. * @param onError is a callback called if an error occurs
  70346. */
  70347. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70348. /**
  70349. * Execute the current task
  70350. * @param scene defines the scene where you want your assets to be loaded
  70351. * @param onSuccess is a callback called when the task is successfully executed
  70352. * @param onError is a callback called if an error occurs
  70353. */
  70354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70355. /**
  70356. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70357. * This can be used with failed tasks that have the reason for failure fixed.
  70358. */
  70359. reset(): void;
  70360. private onErrorCallback;
  70361. private onDoneCallback;
  70362. }
  70363. /**
  70364. * Define the interface used by progress events raised during assets loading
  70365. */
  70366. export interface IAssetsProgressEvent {
  70367. /**
  70368. * Defines the number of remaining tasks to process
  70369. */
  70370. remainingCount: number;
  70371. /**
  70372. * Defines the total number of tasks
  70373. */
  70374. totalCount: number;
  70375. /**
  70376. * Defines the task that was just processed
  70377. */
  70378. task: AbstractAssetTask;
  70379. }
  70380. /**
  70381. * Class used to share progress information about assets loading
  70382. */
  70383. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70384. /**
  70385. * Defines the number of remaining tasks to process
  70386. */
  70387. remainingCount: number;
  70388. /**
  70389. * Defines the total number of tasks
  70390. */
  70391. totalCount: number;
  70392. /**
  70393. * Defines the task that was just processed
  70394. */
  70395. task: AbstractAssetTask;
  70396. /**
  70397. * Creates a AssetsProgressEvent
  70398. * @param remainingCount defines the number of remaining tasks to process
  70399. * @param totalCount defines the total number of tasks
  70400. * @param task defines the task that was just processed
  70401. */
  70402. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70403. }
  70404. /**
  70405. * Define a task used by AssetsManager to load meshes
  70406. */
  70407. export class MeshAssetTask extends AbstractAssetTask {
  70408. /**
  70409. * Defines the name of the task
  70410. */
  70411. name: string;
  70412. /**
  70413. * Defines the list of mesh's names you want to load
  70414. */
  70415. meshesNames: any;
  70416. /**
  70417. * Defines the root url to use as a base to load your meshes and associated resources
  70418. */
  70419. rootUrl: string;
  70420. /**
  70421. * Defines the filename or File of the scene to load from
  70422. */
  70423. sceneFilename: string | File;
  70424. /**
  70425. * Gets the list of loaded meshes
  70426. */
  70427. loadedMeshes: Array<AbstractMesh>;
  70428. /**
  70429. * Gets the list of loaded particle systems
  70430. */
  70431. loadedParticleSystems: Array<IParticleSystem>;
  70432. /**
  70433. * Gets the list of loaded skeletons
  70434. */
  70435. loadedSkeletons: Array<Skeleton>;
  70436. /**
  70437. * Gets the list of loaded animation groups
  70438. */
  70439. loadedAnimationGroups: Array<AnimationGroup>;
  70440. /**
  70441. * Callback called when the task is successful
  70442. */
  70443. onSuccess: (task: MeshAssetTask) => void;
  70444. /**
  70445. * Callback called when the task is successful
  70446. */
  70447. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70448. /**
  70449. * Creates a new MeshAssetTask
  70450. * @param name defines the name of the task
  70451. * @param meshesNames defines the list of mesh's names you want to load
  70452. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70453. * @param sceneFilename defines the filename or File of the scene to load from
  70454. */
  70455. constructor(
  70456. /**
  70457. * Defines the name of the task
  70458. */
  70459. name: string,
  70460. /**
  70461. * Defines the list of mesh's names you want to load
  70462. */
  70463. meshesNames: any,
  70464. /**
  70465. * Defines the root url to use as a base to load your meshes and associated resources
  70466. */
  70467. rootUrl: string,
  70468. /**
  70469. * Defines the filename or File of the scene to load from
  70470. */
  70471. sceneFilename: string | File);
  70472. /**
  70473. * Execute the current task
  70474. * @param scene defines the scene where you want your assets to be loaded
  70475. * @param onSuccess is a callback called when the task is successfully executed
  70476. * @param onError is a callback called if an error occurs
  70477. */
  70478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70479. }
  70480. /**
  70481. * Define a task used by AssetsManager to load text content
  70482. */
  70483. export class TextFileAssetTask extends AbstractAssetTask {
  70484. /**
  70485. * Defines the name of the task
  70486. */
  70487. name: string;
  70488. /**
  70489. * Defines the location of the file to load
  70490. */
  70491. url: string;
  70492. /**
  70493. * Gets the loaded text string
  70494. */
  70495. text: string;
  70496. /**
  70497. * Callback called when the task is successful
  70498. */
  70499. onSuccess: (task: TextFileAssetTask) => void;
  70500. /**
  70501. * Callback called when the task is successful
  70502. */
  70503. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70504. /**
  70505. * Creates a new TextFileAssetTask object
  70506. * @param name defines the name of the task
  70507. * @param url defines the location of the file to load
  70508. */
  70509. constructor(
  70510. /**
  70511. * Defines the name of the task
  70512. */
  70513. name: string,
  70514. /**
  70515. * Defines the location of the file to load
  70516. */
  70517. url: string);
  70518. /**
  70519. * Execute the current task
  70520. * @param scene defines the scene where you want your assets to be loaded
  70521. * @param onSuccess is a callback called when the task is successfully executed
  70522. * @param onError is a callback called if an error occurs
  70523. */
  70524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70525. }
  70526. /**
  70527. * Define a task used by AssetsManager to load binary data
  70528. */
  70529. export class BinaryFileAssetTask extends AbstractAssetTask {
  70530. /**
  70531. * Defines the name of the task
  70532. */
  70533. name: string;
  70534. /**
  70535. * Defines the location of the file to load
  70536. */
  70537. url: string;
  70538. /**
  70539. * Gets the lodaded data (as an array buffer)
  70540. */
  70541. data: ArrayBuffer;
  70542. /**
  70543. * Callback called when the task is successful
  70544. */
  70545. onSuccess: (task: BinaryFileAssetTask) => void;
  70546. /**
  70547. * Callback called when the task is successful
  70548. */
  70549. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70550. /**
  70551. * Creates a new BinaryFileAssetTask object
  70552. * @param name defines the name of the new task
  70553. * @param url defines the location of the file to load
  70554. */
  70555. constructor(
  70556. /**
  70557. * Defines the name of the task
  70558. */
  70559. name: string,
  70560. /**
  70561. * Defines the location of the file to load
  70562. */
  70563. url: string);
  70564. /**
  70565. * Execute the current task
  70566. * @param scene defines the scene where you want your assets to be loaded
  70567. * @param onSuccess is a callback called when the task is successfully executed
  70568. * @param onError is a callback called if an error occurs
  70569. */
  70570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70571. }
  70572. /**
  70573. * Define a task used by AssetsManager to load images
  70574. */
  70575. export class ImageAssetTask extends AbstractAssetTask {
  70576. /**
  70577. * Defines the name of the task
  70578. */
  70579. name: string;
  70580. /**
  70581. * Defines the location of the image to load
  70582. */
  70583. url: string;
  70584. /**
  70585. * Gets the loaded images
  70586. */
  70587. image: HTMLImageElement;
  70588. /**
  70589. * Callback called when the task is successful
  70590. */
  70591. onSuccess: (task: ImageAssetTask) => void;
  70592. /**
  70593. * Callback called when the task is successful
  70594. */
  70595. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70596. /**
  70597. * Creates a new ImageAssetTask
  70598. * @param name defines the name of the task
  70599. * @param url defines the location of the image to load
  70600. */
  70601. constructor(
  70602. /**
  70603. * Defines the name of the task
  70604. */
  70605. name: string,
  70606. /**
  70607. * Defines the location of the image to load
  70608. */
  70609. url: string);
  70610. /**
  70611. * Execute the current task
  70612. * @param scene defines the scene where you want your assets to be loaded
  70613. * @param onSuccess is a callback called when the task is successfully executed
  70614. * @param onError is a callback called if an error occurs
  70615. */
  70616. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70617. }
  70618. /**
  70619. * Defines the interface used by texture loading tasks
  70620. */
  70621. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70622. /**
  70623. * Gets the loaded texture
  70624. */
  70625. texture: TEX;
  70626. }
  70627. /**
  70628. * Define a task used by AssetsManager to load 2D textures
  70629. */
  70630. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70631. /**
  70632. * Defines the name of the task
  70633. */
  70634. name: string;
  70635. /**
  70636. * Defines the location of the file to load
  70637. */
  70638. url: string;
  70639. /**
  70640. * Defines if mipmap should not be generated (default is false)
  70641. */
  70642. noMipmap?: boolean | undefined;
  70643. /**
  70644. * Defines if texture must be inverted on Y axis (default is true)
  70645. */
  70646. invertY: boolean;
  70647. /**
  70648. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70649. */
  70650. samplingMode: number;
  70651. /**
  70652. * Gets the loaded texture
  70653. */
  70654. texture: Texture;
  70655. /**
  70656. * Callback called when the task is successful
  70657. */
  70658. onSuccess: (task: TextureAssetTask) => void;
  70659. /**
  70660. * Callback called when the task is successful
  70661. */
  70662. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70663. /**
  70664. * Creates a new TextureAssetTask object
  70665. * @param name defines the name of the task
  70666. * @param url defines the location of the file to load
  70667. * @param noMipmap defines if mipmap should not be generated (default is false)
  70668. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70669. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70670. */
  70671. constructor(
  70672. /**
  70673. * Defines the name of the task
  70674. */
  70675. name: string,
  70676. /**
  70677. * Defines the location of the file to load
  70678. */
  70679. url: string,
  70680. /**
  70681. * Defines if mipmap should not be generated (default is false)
  70682. */
  70683. noMipmap?: boolean | undefined,
  70684. /**
  70685. * Defines if texture must be inverted on Y axis (default is true)
  70686. */
  70687. invertY?: boolean,
  70688. /**
  70689. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70690. */
  70691. samplingMode?: number);
  70692. /**
  70693. * Execute the current task
  70694. * @param scene defines the scene where you want your assets to be loaded
  70695. * @param onSuccess is a callback called when the task is successfully executed
  70696. * @param onError is a callback called if an error occurs
  70697. */
  70698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70699. }
  70700. /**
  70701. * Define a task used by AssetsManager to load cube textures
  70702. */
  70703. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70704. /**
  70705. * Defines the name of the task
  70706. */
  70707. name: string;
  70708. /**
  70709. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70710. */
  70711. url: string;
  70712. /**
  70713. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70714. */
  70715. extensions?: string[] | undefined;
  70716. /**
  70717. * Defines if mipmaps should not be generated (default is false)
  70718. */
  70719. noMipmap?: boolean | undefined;
  70720. /**
  70721. * Defines the explicit list of files (undefined by default)
  70722. */
  70723. files?: string[] | undefined;
  70724. /**
  70725. * Gets the loaded texture
  70726. */
  70727. texture: CubeTexture;
  70728. /**
  70729. * Callback called when the task is successful
  70730. */
  70731. onSuccess: (task: CubeTextureAssetTask) => void;
  70732. /**
  70733. * Callback called when the task is successful
  70734. */
  70735. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70736. /**
  70737. * Creates a new CubeTextureAssetTask
  70738. * @param name defines the name of the task
  70739. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70740. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70741. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70742. * @param files defines the explicit list of files (undefined by default)
  70743. */
  70744. constructor(
  70745. /**
  70746. * Defines the name of the task
  70747. */
  70748. name: string,
  70749. /**
  70750. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70751. */
  70752. url: string,
  70753. /**
  70754. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70755. */
  70756. extensions?: string[] | undefined,
  70757. /**
  70758. * Defines if mipmaps should not be generated (default is false)
  70759. */
  70760. noMipmap?: boolean | undefined,
  70761. /**
  70762. * Defines the explicit list of files (undefined by default)
  70763. */
  70764. files?: string[] | undefined);
  70765. /**
  70766. * Execute the current task
  70767. * @param scene defines the scene where you want your assets to be loaded
  70768. * @param onSuccess is a callback called when the task is successfully executed
  70769. * @param onError is a callback called if an error occurs
  70770. */
  70771. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70772. }
  70773. /**
  70774. * Define a task used by AssetsManager to load HDR cube textures
  70775. */
  70776. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70777. /**
  70778. * Defines the name of the task
  70779. */
  70780. name: string;
  70781. /**
  70782. * Defines the location of the file to load
  70783. */
  70784. url: string;
  70785. /**
  70786. * Defines the desired size (the more it increases the longer the generation will be)
  70787. */
  70788. size: number;
  70789. /**
  70790. * Defines if mipmaps should not be generated (default is false)
  70791. */
  70792. noMipmap: boolean;
  70793. /**
  70794. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70795. */
  70796. generateHarmonics: boolean;
  70797. /**
  70798. * 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)
  70799. */
  70800. gammaSpace: boolean;
  70801. /**
  70802. * Internal Use Only
  70803. */
  70804. reserved: boolean;
  70805. /**
  70806. * Gets the loaded texture
  70807. */
  70808. texture: HDRCubeTexture;
  70809. /**
  70810. * Callback called when the task is successful
  70811. */
  70812. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70813. /**
  70814. * Callback called when the task is successful
  70815. */
  70816. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70817. /**
  70818. * Creates a new HDRCubeTextureAssetTask object
  70819. * @param name defines the name of the task
  70820. * @param url defines the location of the file to load
  70821. * @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.
  70822. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70823. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70824. * @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)
  70825. * @param reserved Internal use only
  70826. */
  70827. constructor(
  70828. /**
  70829. * Defines the name of the task
  70830. */
  70831. name: string,
  70832. /**
  70833. * Defines the location of the file to load
  70834. */
  70835. url: string,
  70836. /**
  70837. * Defines the desired size (the more it increases the longer the generation will be)
  70838. */
  70839. size: number,
  70840. /**
  70841. * Defines if mipmaps should not be generated (default is false)
  70842. */
  70843. noMipmap?: boolean,
  70844. /**
  70845. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70846. */
  70847. generateHarmonics?: boolean,
  70848. /**
  70849. * 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)
  70850. */
  70851. gammaSpace?: boolean,
  70852. /**
  70853. * Internal Use Only
  70854. */
  70855. reserved?: boolean);
  70856. /**
  70857. * Execute the current task
  70858. * @param scene defines the scene where you want your assets to be loaded
  70859. * @param onSuccess is a callback called when the task is successfully executed
  70860. * @param onError is a callback called if an error occurs
  70861. */
  70862. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70863. }
  70864. /**
  70865. * Define a task used by AssetsManager to load Equirectangular cube textures
  70866. */
  70867. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70868. /**
  70869. * Defines the name of the task
  70870. */
  70871. name: string;
  70872. /**
  70873. * Defines the location of the file to load
  70874. */
  70875. url: string;
  70876. /**
  70877. * Defines the desired size (the more it increases the longer the generation will be)
  70878. */
  70879. size: number;
  70880. /**
  70881. * Defines if mipmaps should not be generated (default is false)
  70882. */
  70883. noMipmap: boolean;
  70884. /**
  70885. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70886. * but the standard material would require them in Gamma space) (default is true)
  70887. */
  70888. gammaSpace: boolean;
  70889. /**
  70890. * Gets the loaded texture
  70891. */
  70892. texture: EquiRectangularCubeTexture;
  70893. /**
  70894. * Callback called when the task is successful
  70895. */
  70896. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70897. /**
  70898. * Callback called when the task is successful
  70899. */
  70900. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70901. /**
  70902. * Creates a new EquiRectangularCubeTextureAssetTask object
  70903. * @param name defines the name of the task
  70904. * @param url defines the location of the file to load
  70905. * @param size defines the desired size (the more it increases the longer the generation will be)
  70906. * If the size is omitted this implies you are using a preprocessed cubemap.
  70907. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70908. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70909. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70910. * (default is true)
  70911. */
  70912. constructor(
  70913. /**
  70914. * Defines the name of the task
  70915. */
  70916. name: string,
  70917. /**
  70918. * Defines the location of the file to load
  70919. */
  70920. url: string,
  70921. /**
  70922. * Defines the desired size (the more it increases the longer the generation will be)
  70923. */
  70924. size: number,
  70925. /**
  70926. * Defines if mipmaps should not be generated (default is false)
  70927. */
  70928. noMipmap?: boolean,
  70929. /**
  70930. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70931. * but the standard material would require them in Gamma space) (default is true)
  70932. */
  70933. gammaSpace?: boolean);
  70934. /**
  70935. * Execute the current task
  70936. * @param scene defines the scene where you want your assets to be loaded
  70937. * @param onSuccess is a callback called when the task is successfully executed
  70938. * @param onError is a callback called if an error occurs
  70939. */
  70940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70941. }
  70942. /**
  70943. * This class can be used to easily import assets into a scene
  70944. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70945. */
  70946. export class AssetsManager {
  70947. private _scene;
  70948. private _isLoading;
  70949. protected _tasks: AbstractAssetTask[];
  70950. protected _waitingTasksCount: number;
  70951. protected _totalTasksCount: number;
  70952. /**
  70953. * Callback called when all tasks are processed
  70954. */
  70955. onFinish: (tasks: AbstractAssetTask[]) => void;
  70956. /**
  70957. * Callback called when a task is successful
  70958. */
  70959. onTaskSuccess: (task: AbstractAssetTask) => void;
  70960. /**
  70961. * Callback called when a task had an error
  70962. */
  70963. onTaskError: (task: AbstractAssetTask) => void;
  70964. /**
  70965. * Callback called when a task is done (whatever the result is)
  70966. */
  70967. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70968. /**
  70969. * Observable called when all tasks are processed
  70970. */
  70971. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70972. /**
  70973. * Observable called when a task had an error
  70974. */
  70975. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70976. /**
  70977. * Observable called when all tasks were executed
  70978. */
  70979. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70980. /**
  70981. * Observable called when a task is done (whatever the result is)
  70982. */
  70983. onProgressObservable: Observable<IAssetsProgressEvent>;
  70984. /**
  70985. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70987. */
  70988. useDefaultLoadingScreen: boolean;
  70989. /**
  70990. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70991. * when all assets have been downloaded.
  70992. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70993. */
  70994. autoHideLoadingUI: boolean;
  70995. /**
  70996. * Creates a new AssetsManager
  70997. * @param scene defines the scene to work on
  70998. */
  70999. constructor(scene: Scene);
  71000. /**
  71001. * Add a MeshAssetTask to the list of active tasks
  71002. * @param taskName defines the name of the new task
  71003. * @param meshesNames defines the name of meshes to load
  71004. * @param rootUrl defines the root url to use to locate files
  71005. * @param sceneFilename defines the filename of the scene file
  71006. * @returns a new MeshAssetTask object
  71007. */
  71008. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71009. /**
  71010. * Add a TextFileAssetTask to the list of active tasks
  71011. * @param taskName defines the name of the new task
  71012. * @param url defines the url of the file to load
  71013. * @returns a new TextFileAssetTask object
  71014. */
  71015. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71016. /**
  71017. * Add a BinaryFileAssetTask to the list of active tasks
  71018. * @param taskName defines the name of the new task
  71019. * @param url defines the url of the file to load
  71020. * @returns a new BinaryFileAssetTask object
  71021. */
  71022. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71023. /**
  71024. * Add a ImageAssetTask to the list of active tasks
  71025. * @param taskName defines the name of the new task
  71026. * @param url defines the url of the file to load
  71027. * @returns a new ImageAssetTask object
  71028. */
  71029. addImageTask(taskName: string, url: string): ImageAssetTask;
  71030. /**
  71031. * Add a TextureAssetTask to the list of active tasks
  71032. * @param taskName defines the name of the new task
  71033. * @param url defines the url of the file to load
  71034. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71035. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71036. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71037. * @returns a new TextureAssetTask object
  71038. */
  71039. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71040. /**
  71041. * Add a CubeTextureAssetTask to the list of active tasks
  71042. * @param taskName defines the name of the new task
  71043. * @param url defines the url of the file to load
  71044. * @param extensions defines the extension to use to load the cube map (can be null)
  71045. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71046. * @param files defines the list of files to load (can be null)
  71047. * @returns a new CubeTextureAssetTask object
  71048. */
  71049. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71050. /**
  71051. *
  71052. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71053. * @param taskName defines the name of the new task
  71054. * @param url defines the url of the file to load
  71055. * @param size defines the size you want for the cubemap (can be null)
  71056. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71057. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71058. * @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)
  71059. * @param reserved Internal use only
  71060. * @returns a new HDRCubeTextureAssetTask object
  71061. */
  71062. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71063. /**
  71064. *
  71065. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71066. * @param taskName defines the name of the new task
  71067. * @param url defines the url of the file to load
  71068. * @param size defines the size you want for the cubemap (can be null)
  71069. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71070. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71071. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71072. * @returns a new EquiRectangularCubeTextureAssetTask object
  71073. */
  71074. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71075. /**
  71076. * Remove a task from the assets manager.
  71077. * @param task the task to remove
  71078. */
  71079. removeTask(task: AbstractAssetTask): void;
  71080. private _decreaseWaitingTasksCount;
  71081. private _runTask;
  71082. /**
  71083. * Reset the AssetsManager and remove all tasks
  71084. * @return the current instance of the AssetsManager
  71085. */
  71086. reset(): AssetsManager;
  71087. /**
  71088. * Start the loading process
  71089. * @return the current instance of the AssetsManager
  71090. */
  71091. load(): AssetsManager;
  71092. /**
  71093. * Start the loading process as an async operation
  71094. * @return a promise returning the list of failed tasks
  71095. */
  71096. loadAsync(): Promise<void>;
  71097. }
  71098. }
  71099. declare module BABYLON {
  71100. /**
  71101. * Wrapper class for promise with external resolve and reject.
  71102. */
  71103. export class Deferred<T> {
  71104. /**
  71105. * The promise associated with this deferred object.
  71106. */
  71107. readonly promise: Promise<T>;
  71108. private _resolve;
  71109. private _reject;
  71110. /**
  71111. * The resolve method of the promise associated with this deferred object.
  71112. */
  71113. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71114. /**
  71115. * The reject method of the promise associated with this deferred object.
  71116. */
  71117. get reject(): (reason?: any) => void;
  71118. /**
  71119. * Constructor for this deferred object.
  71120. */
  71121. constructor();
  71122. }
  71123. }
  71124. declare module BABYLON {
  71125. /**
  71126. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71127. */
  71128. export class MeshExploder {
  71129. private _centerMesh;
  71130. private _meshes;
  71131. private _meshesOrigins;
  71132. private _toCenterVectors;
  71133. private _scaledDirection;
  71134. private _newPosition;
  71135. private _centerPosition;
  71136. /**
  71137. * Explodes meshes from a center mesh.
  71138. * @param meshes The meshes to explode.
  71139. * @param centerMesh The mesh to be center of explosion.
  71140. */
  71141. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71142. private _setCenterMesh;
  71143. /**
  71144. * Get class name
  71145. * @returns "MeshExploder"
  71146. */
  71147. getClassName(): string;
  71148. /**
  71149. * "Exploded meshes"
  71150. * @returns Array of meshes with the centerMesh at index 0.
  71151. */
  71152. getMeshes(): Array<Mesh>;
  71153. /**
  71154. * Explodes meshes giving a specific direction
  71155. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71156. */
  71157. explode(direction?: number): void;
  71158. }
  71159. }
  71160. declare module BABYLON {
  71161. /**
  71162. * Class used to help managing file picking and drag'n'drop
  71163. */
  71164. export class FilesInput {
  71165. /**
  71166. * List of files ready to be loaded
  71167. */
  71168. static get FilesToLoad(): {
  71169. [key: string]: File;
  71170. };
  71171. /**
  71172. * Callback called when a file is processed
  71173. */
  71174. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71175. private _engine;
  71176. private _currentScene;
  71177. private _sceneLoadedCallback;
  71178. private _progressCallback;
  71179. private _additionalRenderLoopLogicCallback;
  71180. private _textureLoadingCallback;
  71181. private _startingProcessingFilesCallback;
  71182. private _onReloadCallback;
  71183. private _errorCallback;
  71184. private _elementToMonitor;
  71185. private _sceneFileToLoad;
  71186. private _filesToLoad;
  71187. /**
  71188. * Creates a new FilesInput
  71189. * @param engine defines the rendering engine
  71190. * @param scene defines the hosting scene
  71191. * @param sceneLoadedCallback callback called when scene is loaded
  71192. * @param progressCallback callback called to track progress
  71193. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71194. * @param textureLoadingCallback callback called when a texture is loading
  71195. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71196. * @param onReloadCallback callback called when a reload is requested
  71197. * @param errorCallback callback call if an error occurs
  71198. */
  71199. 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);
  71200. private _dragEnterHandler;
  71201. private _dragOverHandler;
  71202. private _dropHandler;
  71203. /**
  71204. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71205. * @param elementToMonitor defines the DOM element to track
  71206. */
  71207. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71208. /**
  71209. * Release all associated resources
  71210. */
  71211. dispose(): void;
  71212. private renderFunction;
  71213. private drag;
  71214. private drop;
  71215. private _traverseFolder;
  71216. private _processFiles;
  71217. /**
  71218. * Load files from a drop event
  71219. * @param event defines the drop event to use as source
  71220. */
  71221. loadFiles(event: any): void;
  71222. private _processReload;
  71223. /**
  71224. * Reload the current scene from the loaded files
  71225. */
  71226. reload(): void;
  71227. }
  71228. }
  71229. declare module BABYLON {
  71230. /**
  71231. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71232. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71233. */
  71234. export class SceneOptimization {
  71235. /**
  71236. * Defines the priority of this optimization (0 by default which means first in the list)
  71237. */
  71238. priority: number;
  71239. /**
  71240. * Gets a string describing the action executed by the current optimization
  71241. * @returns description string
  71242. */
  71243. getDescription(): string;
  71244. /**
  71245. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71246. * @param scene defines the current scene where to apply this optimization
  71247. * @param optimizer defines the current optimizer
  71248. * @returns true if everything that can be done was applied
  71249. */
  71250. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71251. /**
  71252. * Creates the SceneOptimization object
  71253. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71254. * @param desc defines the description associated with the optimization
  71255. */
  71256. constructor(
  71257. /**
  71258. * Defines the priority of this optimization (0 by default which means first in the list)
  71259. */
  71260. priority?: number);
  71261. }
  71262. /**
  71263. * Defines an optimization used to reduce the size of render target textures
  71264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71265. */
  71266. export class TextureOptimization extends SceneOptimization {
  71267. /**
  71268. * Defines the priority of this optimization (0 by default which means first in the list)
  71269. */
  71270. priority: number;
  71271. /**
  71272. * 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
  71273. */
  71274. maximumSize: number;
  71275. /**
  71276. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71277. */
  71278. step: number;
  71279. /**
  71280. * Gets a string describing the action executed by the current optimization
  71281. * @returns description string
  71282. */
  71283. getDescription(): string;
  71284. /**
  71285. * Creates the TextureOptimization object
  71286. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71287. * @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
  71288. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71289. */
  71290. constructor(
  71291. /**
  71292. * Defines the priority of this optimization (0 by default which means first in the list)
  71293. */
  71294. priority?: number,
  71295. /**
  71296. * 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
  71297. */
  71298. maximumSize?: number,
  71299. /**
  71300. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71301. */
  71302. step?: number);
  71303. /**
  71304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71305. * @param scene defines the current scene where to apply this optimization
  71306. * @param optimizer defines the current optimizer
  71307. * @returns true if everything that can be done was applied
  71308. */
  71309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71310. }
  71311. /**
  71312. * Defines an optimization used to increase or decrease the rendering resolution
  71313. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71314. */
  71315. export class HardwareScalingOptimization extends SceneOptimization {
  71316. /**
  71317. * Defines the priority of this optimization (0 by default which means first in the list)
  71318. */
  71319. priority: number;
  71320. /**
  71321. * Defines the maximum scale to use (2 by default)
  71322. */
  71323. maximumScale: number;
  71324. /**
  71325. * Defines the step to use between two passes (0.5 by default)
  71326. */
  71327. step: number;
  71328. private _currentScale;
  71329. private _directionOffset;
  71330. /**
  71331. * Gets a string describing the action executed by the current optimization
  71332. * @return description string
  71333. */
  71334. getDescription(): string;
  71335. /**
  71336. * Creates the HardwareScalingOptimization object
  71337. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71338. * @param maximumScale defines the maximum scale to use (2 by default)
  71339. * @param step defines the step to use between two passes (0.5 by default)
  71340. */
  71341. constructor(
  71342. /**
  71343. * Defines the priority of this optimization (0 by default which means first in the list)
  71344. */
  71345. priority?: number,
  71346. /**
  71347. * Defines the maximum scale to use (2 by default)
  71348. */
  71349. maximumScale?: number,
  71350. /**
  71351. * Defines the step to use between two passes (0.5 by default)
  71352. */
  71353. step?: number);
  71354. /**
  71355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71356. * @param scene defines the current scene where to apply this optimization
  71357. * @param optimizer defines the current optimizer
  71358. * @returns true if everything that can be done was applied
  71359. */
  71360. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71361. }
  71362. /**
  71363. * Defines an optimization used to remove shadows
  71364. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71365. */
  71366. export class ShadowsOptimization extends SceneOptimization {
  71367. /**
  71368. * Gets a string describing the action executed by the current optimization
  71369. * @return description string
  71370. */
  71371. getDescription(): string;
  71372. /**
  71373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71374. * @param scene defines the current scene where to apply this optimization
  71375. * @param optimizer defines the current optimizer
  71376. * @returns true if everything that can be done was applied
  71377. */
  71378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71379. }
  71380. /**
  71381. * Defines an optimization used to turn post-processes off
  71382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71383. */
  71384. export class PostProcessesOptimization extends SceneOptimization {
  71385. /**
  71386. * Gets a string describing the action executed by the current optimization
  71387. * @return description string
  71388. */
  71389. getDescription(): string;
  71390. /**
  71391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71392. * @param scene defines the current scene where to apply this optimization
  71393. * @param optimizer defines the current optimizer
  71394. * @returns true if everything that can be done was applied
  71395. */
  71396. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71397. }
  71398. /**
  71399. * Defines an optimization used to turn lens flares off
  71400. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71401. */
  71402. export class LensFlaresOptimization extends SceneOptimization {
  71403. /**
  71404. * Gets a string describing the action executed by the current optimization
  71405. * @return description string
  71406. */
  71407. getDescription(): string;
  71408. /**
  71409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71410. * @param scene defines the current scene where to apply this optimization
  71411. * @param optimizer defines the current optimizer
  71412. * @returns true if everything that can be done was applied
  71413. */
  71414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71415. }
  71416. /**
  71417. * Defines an optimization based on user defined callback.
  71418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71419. */
  71420. export class CustomOptimization extends SceneOptimization {
  71421. /**
  71422. * Callback called to apply the custom optimization.
  71423. */
  71424. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71425. /**
  71426. * Callback called to get custom description
  71427. */
  71428. onGetDescription: () => string;
  71429. /**
  71430. * Gets a string describing the action executed by the current optimization
  71431. * @returns description string
  71432. */
  71433. getDescription(): string;
  71434. /**
  71435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71436. * @param scene defines the current scene where to apply this optimization
  71437. * @param optimizer defines the current optimizer
  71438. * @returns true if everything that can be done was applied
  71439. */
  71440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71441. }
  71442. /**
  71443. * Defines an optimization used to turn particles off
  71444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71445. */
  71446. export class ParticlesOptimization extends SceneOptimization {
  71447. /**
  71448. * Gets a string describing the action executed by the current optimization
  71449. * @return description string
  71450. */
  71451. getDescription(): string;
  71452. /**
  71453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71454. * @param scene defines the current scene where to apply this optimization
  71455. * @param optimizer defines the current optimizer
  71456. * @returns true if everything that can be done was applied
  71457. */
  71458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71459. }
  71460. /**
  71461. * Defines an optimization used to turn render targets off
  71462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71463. */
  71464. export class RenderTargetsOptimization extends SceneOptimization {
  71465. /**
  71466. * Gets a string describing the action executed by the current optimization
  71467. * @return description string
  71468. */
  71469. getDescription(): string;
  71470. /**
  71471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71472. * @param scene defines the current scene where to apply this optimization
  71473. * @param optimizer defines the current optimizer
  71474. * @returns true if everything that can be done was applied
  71475. */
  71476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71477. }
  71478. /**
  71479. * Defines an optimization used to merge meshes with compatible materials
  71480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71481. */
  71482. export class MergeMeshesOptimization extends SceneOptimization {
  71483. private static _UpdateSelectionTree;
  71484. /**
  71485. * Gets or sets a boolean which defines if optimization octree has to be updated
  71486. */
  71487. static get UpdateSelectionTree(): boolean;
  71488. /**
  71489. * Gets or sets a boolean which defines if optimization octree has to be updated
  71490. */
  71491. static set UpdateSelectionTree(value: boolean);
  71492. /**
  71493. * Gets a string describing the action executed by the current optimization
  71494. * @return description string
  71495. */
  71496. getDescription(): string;
  71497. private _canBeMerged;
  71498. /**
  71499. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71500. * @param scene defines the current scene where to apply this optimization
  71501. * @param optimizer defines the current optimizer
  71502. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71503. * @returns true if everything that can be done was applied
  71504. */
  71505. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71506. }
  71507. /**
  71508. * Defines a list of options used by SceneOptimizer
  71509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71510. */
  71511. export class SceneOptimizerOptions {
  71512. /**
  71513. * Defines the target frame rate to reach (60 by default)
  71514. */
  71515. targetFrameRate: number;
  71516. /**
  71517. * Defines the interval between two checkes (2000ms by default)
  71518. */
  71519. trackerDuration: number;
  71520. /**
  71521. * Gets the list of optimizations to apply
  71522. */
  71523. optimizations: SceneOptimization[];
  71524. /**
  71525. * Creates a new list of options used by SceneOptimizer
  71526. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71527. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71528. */
  71529. constructor(
  71530. /**
  71531. * Defines the target frame rate to reach (60 by default)
  71532. */
  71533. targetFrameRate?: number,
  71534. /**
  71535. * Defines the interval between two checkes (2000ms by default)
  71536. */
  71537. trackerDuration?: number);
  71538. /**
  71539. * Add a new optimization
  71540. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71541. * @returns the current SceneOptimizerOptions
  71542. */
  71543. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71544. /**
  71545. * Add a new custom optimization
  71546. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71547. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71548. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71549. * @returns the current SceneOptimizerOptions
  71550. */
  71551. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71552. /**
  71553. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71554. * @param targetFrameRate defines the target frame rate (60 by default)
  71555. * @returns a SceneOptimizerOptions object
  71556. */
  71557. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71558. /**
  71559. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71560. * @param targetFrameRate defines the target frame rate (60 by default)
  71561. * @returns a SceneOptimizerOptions object
  71562. */
  71563. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71564. /**
  71565. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71566. * @param targetFrameRate defines the target frame rate (60 by default)
  71567. * @returns a SceneOptimizerOptions object
  71568. */
  71569. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71570. }
  71571. /**
  71572. * Class used to run optimizations in order to reach a target frame rate
  71573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71574. */
  71575. export class SceneOptimizer implements IDisposable {
  71576. private _isRunning;
  71577. private _options;
  71578. private _scene;
  71579. private _currentPriorityLevel;
  71580. private _targetFrameRate;
  71581. private _trackerDuration;
  71582. private _currentFrameRate;
  71583. private _sceneDisposeObserver;
  71584. private _improvementMode;
  71585. /**
  71586. * Defines an observable called when the optimizer reaches the target frame rate
  71587. */
  71588. onSuccessObservable: Observable<SceneOptimizer>;
  71589. /**
  71590. * Defines an observable called when the optimizer enables an optimization
  71591. */
  71592. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71593. /**
  71594. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71595. */
  71596. onFailureObservable: Observable<SceneOptimizer>;
  71597. /**
  71598. * Gets a boolean indicating if the optimizer is in improvement mode
  71599. */
  71600. get isInImprovementMode(): boolean;
  71601. /**
  71602. * Gets the current priority level (0 at start)
  71603. */
  71604. get currentPriorityLevel(): number;
  71605. /**
  71606. * Gets the current frame rate checked by the SceneOptimizer
  71607. */
  71608. get currentFrameRate(): number;
  71609. /**
  71610. * Gets or sets the current target frame rate (60 by default)
  71611. */
  71612. get targetFrameRate(): number;
  71613. /**
  71614. * Gets or sets the current target frame rate (60 by default)
  71615. */
  71616. set targetFrameRate(value: number);
  71617. /**
  71618. * Gets or sets the current interval between two checks (every 2000ms by default)
  71619. */
  71620. get trackerDuration(): number;
  71621. /**
  71622. * Gets or sets the current interval between two checks (every 2000ms by default)
  71623. */
  71624. set trackerDuration(value: number);
  71625. /**
  71626. * Gets the list of active optimizations
  71627. */
  71628. get optimizations(): SceneOptimization[];
  71629. /**
  71630. * Creates a new SceneOptimizer
  71631. * @param scene defines the scene to work on
  71632. * @param options defines the options to use with the SceneOptimizer
  71633. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71634. * @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)
  71635. */
  71636. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71637. /**
  71638. * Stops the current optimizer
  71639. */
  71640. stop(): void;
  71641. /**
  71642. * Reset the optimizer to initial step (current priority level = 0)
  71643. */
  71644. reset(): void;
  71645. /**
  71646. * Start the optimizer. By default it will try to reach a specific framerate
  71647. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71648. */
  71649. start(): void;
  71650. private _checkCurrentState;
  71651. /**
  71652. * Release all resources
  71653. */
  71654. dispose(): void;
  71655. /**
  71656. * Helper function to create a SceneOptimizer with one single line of code
  71657. * @param scene defines the scene to work on
  71658. * @param options defines the options to use with the SceneOptimizer
  71659. * @param onSuccess defines a callback to call on success
  71660. * @param onFailure defines a callback to call on failure
  71661. * @returns the new SceneOptimizer object
  71662. */
  71663. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71664. }
  71665. }
  71666. declare module BABYLON {
  71667. /**
  71668. * Class used to serialize a scene into a string
  71669. */
  71670. export class SceneSerializer {
  71671. /**
  71672. * Clear cache used by a previous serialization
  71673. */
  71674. static ClearCache(): void;
  71675. /**
  71676. * Serialize a scene into a JSON compatible object
  71677. * @param scene defines the scene to serialize
  71678. * @returns a JSON compatible object
  71679. */
  71680. static Serialize(scene: Scene): any;
  71681. /**
  71682. * Serialize a mesh into a JSON compatible object
  71683. * @param toSerialize defines the mesh to serialize
  71684. * @param withParents defines if parents must be serialized as well
  71685. * @param withChildren defines if children must be serialized as well
  71686. * @returns a JSON compatible object
  71687. */
  71688. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71689. }
  71690. }
  71691. declare module BABYLON {
  71692. /**
  71693. * Class used to host texture specific utilities
  71694. */
  71695. export class TextureTools {
  71696. /**
  71697. * Uses the GPU to create a copy texture rescaled at a given size
  71698. * @param texture Texture to copy from
  71699. * @param width defines the desired width
  71700. * @param height defines the desired height
  71701. * @param useBilinearMode defines if bilinear mode has to be used
  71702. * @return the generated texture
  71703. */
  71704. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71705. }
  71706. }
  71707. declare module BABYLON {
  71708. /**
  71709. * This represents the different options available for the video capture.
  71710. */
  71711. export interface VideoRecorderOptions {
  71712. /** Defines the mime type of the video. */
  71713. mimeType: string;
  71714. /** Defines the FPS the video should be recorded at. */
  71715. fps: number;
  71716. /** Defines the chunk size for the recording data. */
  71717. recordChunckSize: number;
  71718. /** The audio tracks to attach to the recording. */
  71719. audioTracks?: MediaStreamTrack[];
  71720. }
  71721. /**
  71722. * This can help with recording videos from BabylonJS.
  71723. * This is based on the available WebRTC functionalities of the browser.
  71724. *
  71725. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71726. */
  71727. export class VideoRecorder {
  71728. private static readonly _defaultOptions;
  71729. /**
  71730. * Returns whether or not the VideoRecorder is available in your browser.
  71731. * @param engine Defines the Babylon Engine.
  71732. * @returns true if supported otherwise false.
  71733. */
  71734. static IsSupported(engine: Engine): boolean;
  71735. private readonly _options;
  71736. private _canvas;
  71737. private _mediaRecorder;
  71738. private _recordedChunks;
  71739. private _fileName;
  71740. private _resolve;
  71741. private _reject;
  71742. /**
  71743. * True when a recording is already in progress.
  71744. */
  71745. get isRecording(): boolean;
  71746. /**
  71747. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71748. * @param engine Defines the BabylonJS Engine you wish to record.
  71749. * @param options Defines options that can be used to customize the capture.
  71750. */
  71751. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71752. /**
  71753. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71754. */
  71755. stopRecording(): void;
  71756. /**
  71757. * Starts recording the canvas for a max duration specified in parameters.
  71758. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71759. * If null no automatic download will start and you can rely on the promise to get the data back.
  71760. * @param maxDuration Defines the maximum recording time in seconds.
  71761. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71762. * @return A promise callback at the end of the recording with the video data in Blob.
  71763. */
  71764. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71765. /**
  71766. * Releases internal resources used during the recording.
  71767. */
  71768. dispose(): void;
  71769. private _handleDataAvailable;
  71770. private _handleError;
  71771. private _handleStop;
  71772. }
  71773. }
  71774. declare module BABYLON {
  71775. /**
  71776. * Class containing a set of static utilities functions for screenshots
  71777. */
  71778. export class ScreenshotTools {
  71779. /**
  71780. * Captures a screenshot of the current rendering
  71781. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71782. * @param engine defines the rendering engine
  71783. * @param camera defines the source camera
  71784. * @param size This parameter can be set to a single number or to an object with the
  71785. * following (optional) properties: precision, width, height. If a single number is passed,
  71786. * it will be used for both width and height. If an object is passed, the screenshot size
  71787. * will be derived from the parameters. The precision property is a multiplier allowing
  71788. * rendering at a higher or lower resolution
  71789. * @param successCallback defines the callback receives a single parameter which contains the
  71790. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71791. * src parameter of an <img> to display it
  71792. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71793. * Check your browser for supported MIME types
  71794. */
  71795. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71796. /**
  71797. * Captures a screenshot of the current rendering
  71798. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71799. * @param engine defines the rendering engine
  71800. * @param camera defines the source camera
  71801. * @param size This parameter can be set to a single number or to an object with the
  71802. * following (optional) properties: precision, width, height. If a single number is passed,
  71803. * it will be used for both width and height. If an object is passed, the screenshot size
  71804. * will be derived from the parameters. The precision property is a multiplier allowing
  71805. * rendering at a higher or lower resolution
  71806. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71807. * Check your browser for supported MIME types
  71808. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71809. * to the src parameter of an <img> to display it
  71810. */
  71811. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71812. /**
  71813. * Generates an image screenshot from the specified camera.
  71814. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71815. * @param engine The engine to use for rendering
  71816. * @param camera The camera to use for rendering
  71817. * @param size This parameter can be set to a single number or to an object with the
  71818. * following (optional) properties: precision, width, height. If a single number is passed,
  71819. * it will be used for both width and height. If an object is passed, the screenshot size
  71820. * will be derived from the parameters. The precision property is a multiplier allowing
  71821. * rendering at a higher or lower resolution
  71822. * @param successCallback The callback receives a single parameter which contains the
  71823. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71824. * src parameter of an <img> to display it
  71825. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71826. * Check your browser for supported MIME types
  71827. * @param samples Texture samples (default: 1)
  71828. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71829. * @param fileName A name for for the downloaded file.
  71830. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71831. */
  71832. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71833. /**
  71834. * Generates an image screenshot from the specified camera.
  71835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71836. * @param engine The engine to use for rendering
  71837. * @param camera The camera to use for rendering
  71838. * @param size This parameter can be set to a single number or to an object with the
  71839. * following (optional) properties: precision, width, height. If a single number is passed,
  71840. * it will be used for both width and height. If an object is passed, the screenshot size
  71841. * will be derived from the parameters. The precision property is a multiplier allowing
  71842. * rendering at a higher or lower resolution
  71843. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71844. * Check your browser for supported MIME types
  71845. * @param samples Texture samples (default: 1)
  71846. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71847. * @param fileName A name for for the downloaded file.
  71848. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71849. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71850. * to the src parameter of an <img> to display it
  71851. */
  71852. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71853. /**
  71854. * Gets height and width for screenshot size
  71855. * @private
  71856. */
  71857. private static _getScreenshotSize;
  71858. }
  71859. }
  71860. declare module BABYLON {
  71861. /**
  71862. * Interface for a data buffer
  71863. */
  71864. export interface IDataBuffer {
  71865. /**
  71866. * Reads bytes from the data buffer.
  71867. * @param byteOffset The byte offset to read
  71868. * @param byteLength The byte length to read
  71869. * @returns A promise that resolves when the bytes are read
  71870. */
  71871. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71872. /**
  71873. * The byte length of the buffer.
  71874. */
  71875. readonly byteLength: number;
  71876. }
  71877. /**
  71878. * Utility class for reading from a data buffer
  71879. */
  71880. export class DataReader {
  71881. /**
  71882. * The data buffer associated with this data reader.
  71883. */
  71884. readonly buffer: IDataBuffer;
  71885. /**
  71886. * The current byte offset from the beginning of the data buffer.
  71887. */
  71888. byteOffset: number;
  71889. private _dataView;
  71890. private _dataByteOffset;
  71891. /**
  71892. * Constructor
  71893. * @param buffer The buffer to read
  71894. */
  71895. constructor(buffer: IDataBuffer);
  71896. /**
  71897. * Loads the given byte length.
  71898. * @param byteLength The byte length to load
  71899. * @returns A promise that resolves when the load is complete
  71900. */
  71901. loadAsync(byteLength: number): Promise<void>;
  71902. /**
  71903. * Read a unsigned 32-bit integer from the currently loaded data range.
  71904. * @returns The 32-bit integer read
  71905. */
  71906. readUint32(): number;
  71907. /**
  71908. * Read a byte array from the currently loaded data range.
  71909. * @param byteLength The byte length to read
  71910. * @returns The byte array read
  71911. */
  71912. readUint8Array(byteLength: number): Uint8Array;
  71913. /**
  71914. * Read a string from the currently loaded data range.
  71915. * @param byteLength The byte length to read
  71916. * @returns The string read
  71917. */
  71918. readString(byteLength: number): string;
  71919. /**
  71920. * Skips the given byte length the currently loaded data range.
  71921. * @param byteLength The byte length to skip
  71922. */
  71923. skipBytes(byteLength: number): void;
  71924. }
  71925. }
  71926. declare module BABYLON {
  71927. /**
  71928. * Class for storing data to local storage if available or in-memory storage otherwise
  71929. */
  71930. export class DataStorage {
  71931. private static _Storage;
  71932. private static _GetStorage;
  71933. /**
  71934. * Reads a string from the data storage
  71935. * @param key The key to read
  71936. * @param defaultValue The value if the key doesn't exist
  71937. * @returns The string value
  71938. */
  71939. static ReadString(key: string, defaultValue: string): string;
  71940. /**
  71941. * Writes a string to the data storage
  71942. * @param key The key to write
  71943. * @param value The value to write
  71944. */
  71945. static WriteString(key: string, value: string): void;
  71946. /**
  71947. * Reads a boolean from the data storage
  71948. * @param key The key to read
  71949. * @param defaultValue The value if the key doesn't exist
  71950. * @returns The boolean value
  71951. */
  71952. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71953. /**
  71954. * Writes a boolean to the data storage
  71955. * @param key The key to write
  71956. * @param value The value to write
  71957. */
  71958. static WriteBoolean(key: string, value: boolean): void;
  71959. /**
  71960. * Reads a number from the data storage
  71961. * @param key The key to read
  71962. * @param defaultValue The value if the key doesn't exist
  71963. * @returns The number value
  71964. */
  71965. static ReadNumber(key: string, defaultValue: number): number;
  71966. /**
  71967. * Writes a number to the data storage
  71968. * @param key The key to write
  71969. * @param value The value to write
  71970. */
  71971. static WriteNumber(key: string, value: number): void;
  71972. }
  71973. }
  71974. declare module BABYLON {
  71975. /**
  71976. * Options used for hit testing
  71977. */
  71978. export interface IWebXRLegacyHitTestOptions {
  71979. /**
  71980. * Only test when user interacted with the scene. Default - hit test every frame
  71981. */
  71982. testOnPointerDownOnly?: boolean;
  71983. /**
  71984. * The node to use to transform the local results to world coordinates
  71985. */
  71986. worldParentNode?: TransformNode;
  71987. }
  71988. /**
  71989. * Interface defining the babylon result of raycasting/hit-test
  71990. */
  71991. export interface IWebXRLegacyHitResult {
  71992. /**
  71993. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71994. */
  71995. transformationMatrix: Matrix;
  71996. /**
  71997. * The native hit test result
  71998. */
  71999. xrHitResult: XRHitResult | XRHitTestResult;
  72000. }
  72001. /**
  72002. * The currently-working hit-test module.
  72003. * Hit test (or Ray-casting) is used to interact with the real world.
  72004. * For further information read here - https://github.com/immersive-web/hit-test
  72005. */
  72006. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72007. /**
  72008. * options to use when constructing this feature
  72009. */
  72010. readonly options: IWebXRLegacyHitTestOptions;
  72011. private _direction;
  72012. private _mat;
  72013. private _onSelectEnabled;
  72014. private _origin;
  72015. /**
  72016. * The module's name
  72017. */
  72018. static readonly Name: string;
  72019. /**
  72020. * The (Babylon) version of this module.
  72021. * This is an integer representing the implementation version.
  72022. * This number does not correspond to the WebXR specs version
  72023. */
  72024. static readonly Version: number;
  72025. /**
  72026. * Populated with the last native XR Hit Results
  72027. */
  72028. lastNativeXRHitResults: XRHitResult[];
  72029. /**
  72030. * Triggered when new babylon (transformed) hit test results are available
  72031. */
  72032. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72033. /**
  72034. * Creates a new instance of the (legacy version) hit test feature
  72035. * @param _xrSessionManager an instance of WebXRSessionManager
  72036. * @param options options to use when constructing this feature
  72037. */
  72038. constructor(_xrSessionManager: WebXRSessionManager,
  72039. /**
  72040. * options to use when constructing this feature
  72041. */
  72042. options?: IWebXRLegacyHitTestOptions);
  72043. /**
  72044. * execute a hit test with an XR Ray
  72045. *
  72046. * @param xrSession a native xrSession that will execute this hit test
  72047. * @param xrRay the ray (position and direction) to use for ray-casting
  72048. * @param referenceSpace native XR reference space to use for the hit-test
  72049. * @param filter filter function that will filter the results
  72050. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72051. */
  72052. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72053. /**
  72054. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72055. * @param event the (select) event to use to select with
  72056. * @param referenceSpace the reference space to use for this hit test
  72057. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72058. */
  72059. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72060. /**
  72061. * attach this feature
  72062. * Will usually be called by the features manager
  72063. *
  72064. * @returns true if successful.
  72065. */
  72066. attach(): boolean;
  72067. /**
  72068. * detach this feature.
  72069. * Will usually be called by the features manager
  72070. *
  72071. * @returns true if successful.
  72072. */
  72073. detach(): boolean;
  72074. /**
  72075. * Dispose this feature and all of the resources attached
  72076. */
  72077. dispose(): void;
  72078. protected _onXRFrame(frame: XRFrame): void;
  72079. private _onHitTestResults;
  72080. private _onSelect;
  72081. }
  72082. }
  72083. declare module BABYLON {
  72084. /**
  72085. * Options used in the plane detector module
  72086. */
  72087. export interface IWebXRPlaneDetectorOptions {
  72088. /**
  72089. * The node to use to transform the local results to world coordinates
  72090. */
  72091. worldParentNode?: TransformNode;
  72092. }
  72093. /**
  72094. * A babylon interface for a WebXR plane.
  72095. * A Plane is actually a polygon, built from N points in space
  72096. *
  72097. * Supported in chrome 79, not supported in canary 81 ATM
  72098. */
  72099. export interface IWebXRPlane {
  72100. /**
  72101. * a babylon-assigned ID for this polygon
  72102. */
  72103. id: number;
  72104. /**
  72105. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72106. */
  72107. polygonDefinition: Array<Vector3>;
  72108. /**
  72109. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72110. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72111. */
  72112. transformationMatrix: Matrix;
  72113. /**
  72114. * the native xr-plane object
  72115. */
  72116. xrPlane: XRPlane;
  72117. }
  72118. /**
  72119. * The plane detector is used to detect planes in the real world when in AR
  72120. * For more information see https://github.com/immersive-web/real-world-geometry/
  72121. */
  72122. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72123. private _options;
  72124. private _detectedPlanes;
  72125. private _enabled;
  72126. private _lastFrameDetected;
  72127. /**
  72128. * The module's name
  72129. */
  72130. static readonly Name: string;
  72131. /**
  72132. * The (Babylon) version of this module.
  72133. * This is an integer representing the implementation version.
  72134. * This number does not correspond to the WebXR specs version
  72135. */
  72136. static readonly Version: number;
  72137. /**
  72138. * Observers registered here will be executed when a new plane was added to the session
  72139. */
  72140. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72141. /**
  72142. * Observers registered here will be executed when a plane is no longer detected in the session
  72143. */
  72144. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72145. /**
  72146. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72147. * This can execute N times every frame
  72148. */
  72149. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72150. /**
  72151. * construct a new Plane Detector
  72152. * @param _xrSessionManager an instance of xr Session manager
  72153. * @param _options configuration to use when constructing this feature
  72154. */
  72155. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72156. /**
  72157. * Dispose this feature and all of the resources attached
  72158. */
  72159. dispose(): void;
  72160. protected _onXRFrame(frame: XRFrame): void;
  72161. private _init;
  72162. private _updatePlaneWithXRPlane;
  72163. /**
  72164. * avoiding using Array.find for global support.
  72165. * @param xrPlane the plane to find in the array
  72166. */
  72167. private findIndexInPlaneArray;
  72168. }
  72169. }
  72170. declare module BABYLON {
  72171. /**
  72172. * Configuration options of the anchor system
  72173. */
  72174. export interface IWebXRAnchorSystemOptions {
  72175. /**
  72176. * Should a new anchor be added every time a select event is triggered
  72177. */
  72178. addAnchorOnSelect?: boolean;
  72179. /**
  72180. * should the anchor system use plane detection.
  72181. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72182. */
  72183. usePlaneDetection?: boolean;
  72184. /**
  72185. * a node that will be used to convert local to world coordinates
  72186. */
  72187. worldParentNode?: TransformNode;
  72188. }
  72189. /**
  72190. * A babylon container for an XR Anchor
  72191. */
  72192. export interface IWebXRAnchor {
  72193. /**
  72194. * A babylon-assigned ID for this anchor
  72195. */
  72196. id: number;
  72197. /**
  72198. * Transformation matrix to apply to an object attached to this anchor
  72199. */
  72200. transformationMatrix: Matrix;
  72201. /**
  72202. * The native anchor object
  72203. */
  72204. xrAnchor: XRAnchor;
  72205. }
  72206. /**
  72207. * An implementation of the anchor system of WebXR.
  72208. * Note that the current documented implementation is not available in any browser. Future implementations
  72209. * will use the frame to create an anchor and not the session or a detected plane
  72210. * For further information see https://github.com/immersive-web/anchors/
  72211. */
  72212. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72213. private _options;
  72214. private _enabled;
  72215. private _hitTestModule;
  72216. private _lastFrameDetected;
  72217. private _onSelect;
  72218. private _planeDetector;
  72219. private _trackedAnchors;
  72220. /**
  72221. * The module's name
  72222. */
  72223. static readonly Name: string;
  72224. /**
  72225. * The (Babylon) version of this module.
  72226. * This is an integer representing the implementation version.
  72227. * This number does not correspond to the WebXR specs version
  72228. */
  72229. static readonly Version: number;
  72230. /**
  72231. * Observers registered here will be executed when a new anchor was added to the session
  72232. */
  72233. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72234. /**
  72235. * Observers registered here will be executed when an anchor was removed from the session
  72236. */
  72237. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72238. /**
  72239. * Observers registered here will be executed when an existing anchor updates
  72240. * This can execute N times every frame
  72241. */
  72242. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72243. /**
  72244. * constructs a new anchor system
  72245. * @param _xrSessionManager an instance of WebXRSessionManager
  72246. * @param _options configuration object for this feature
  72247. */
  72248. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72249. /**
  72250. * Add anchor at a specific XR point.
  72251. *
  72252. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72253. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72254. * @returns a promise the fulfills when the anchor was created
  72255. */
  72256. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72257. /**
  72258. * attach this feature
  72259. * Will usually be called by the features manager
  72260. *
  72261. * @returns true if successful.
  72262. */
  72263. attach(): boolean;
  72264. /**
  72265. * detach this feature.
  72266. * Will usually be called by the features manager
  72267. *
  72268. * @returns true if successful.
  72269. */
  72270. detach(): boolean;
  72271. /**
  72272. * Dispose this feature and all of the resources attached
  72273. */
  72274. dispose(): void;
  72275. /**
  72276. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72277. * @param hitTestModule the hit-test module to use.
  72278. */
  72279. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72280. /**
  72281. * set the plane detector to use in order to create anchors from frames
  72282. * @param planeDetector the plane-detector module to use
  72283. * @param enable enable plane-anchors. default is true
  72284. */
  72285. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72286. protected _onXRFrame(frame: XRFrame): void;
  72287. /**
  72288. * avoiding using Array.find for global support.
  72289. * @param xrAnchor the plane to find in the array
  72290. */
  72291. private _findIndexInAnchorArray;
  72292. private _updateAnchorWithXRFrame;
  72293. }
  72294. }
  72295. declare module BABYLON {
  72296. /**
  72297. * Options interface for the background remover plugin
  72298. */
  72299. export interface IWebXRBackgroundRemoverOptions {
  72300. /**
  72301. * Further background meshes to disable when entering AR
  72302. */
  72303. backgroundMeshes?: AbstractMesh[];
  72304. /**
  72305. * flags to configure the removal of the environment helper.
  72306. * If not set, the entire background will be removed. If set, flags should be set as well.
  72307. */
  72308. environmentHelperRemovalFlags?: {
  72309. /**
  72310. * Should the skybox be removed (default false)
  72311. */
  72312. skyBox?: boolean;
  72313. /**
  72314. * Should the ground be removed (default false)
  72315. */
  72316. ground?: boolean;
  72317. };
  72318. /**
  72319. * don't disable the environment helper
  72320. */
  72321. ignoreEnvironmentHelper?: boolean;
  72322. }
  72323. /**
  72324. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72325. */
  72326. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72327. /**
  72328. * read-only options to be used in this module
  72329. */
  72330. readonly options: IWebXRBackgroundRemoverOptions;
  72331. /**
  72332. * The module's name
  72333. */
  72334. static readonly Name: string;
  72335. /**
  72336. * The (Babylon) version of this module.
  72337. * This is an integer representing the implementation version.
  72338. * This number does not correspond to the WebXR specs version
  72339. */
  72340. static readonly Version: number;
  72341. /**
  72342. * registered observers will be triggered when the background state changes
  72343. */
  72344. onBackgroundStateChangedObservable: Observable<boolean>;
  72345. /**
  72346. * constructs a new background remover module
  72347. * @param _xrSessionManager the session manager for this module
  72348. * @param options read-only options to be used in this module
  72349. */
  72350. constructor(_xrSessionManager: WebXRSessionManager,
  72351. /**
  72352. * read-only options to be used in this module
  72353. */
  72354. options?: IWebXRBackgroundRemoverOptions);
  72355. /**
  72356. * attach this feature
  72357. * Will usually be called by the features manager
  72358. *
  72359. * @returns true if successful.
  72360. */
  72361. attach(): boolean;
  72362. /**
  72363. * detach this feature.
  72364. * Will usually be called by the features manager
  72365. *
  72366. * @returns true if successful.
  72367. */
  72368. detach(): boolean;
  72369. /**
  72370. * Dispose this feature and all of the resources attached
  72371. */
  72372. dispose(): void;
  72373. protected _onXRFrame(_xrFrame: XRFrame): void;
  72374. private _setBackgroundState;
  72375. }
  72376. }
  72377. declare module BABYLON {
  72378. /**
  72379. * Options for the controller physics feature
  72380. */
  72381. export class IWebXRControllerPhysicsOptions {
  72382. /**
  72383. * Should the headset get its own impostor
  72384. */
  72385. enableHeadsetImpostor?: boolean;
  72386. /**
  72387. * Optional parameters for the headset impostor
  72388. */
  72389. headsetImpostorParams?: {
  72390. /**
  72391. * The type of impostor to create. Default is sphere
  72392. */
  72393. impostorType: number;
  72394. /**
  72395. * the size of the impostor. Defaults to 10cm
  72396. */
  72397. impostorSize?: number | {
  72398. width: number;
  72399. height: number;
  72400. depth: number;
  72401. };
  72402. /**
  72403. * Friction definitions
  72404. */
  72405. friction?: number;
  72406. /**
  72407. * Restitution
  72408. */
  72409. restitution?: number;
  72410. };
  72411. /**
  72412. * The physics properties of the future impostors
  72413. */
  72414. physicsProperties?: {
  72415. /**
  72416. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72417. * Note that this requires a physics engine that supports mesh impostors!
  72418. */
  72419. useControllerMesh?: boolean;
  72420. /**
  72421. * The type of impostor to create. Default is sphere
  72422. */
  72423. impostorType?: number;
  72424. /**
  72425. * the size of the impostor. Defaults to 10cm
  72426. */
  72427. impostorSize?: number | {
  72428. width: number;
  72429. height: number;
  72430. depth: number;
  72431. };
  72432. /**
  72433. * Friction definitions
  72434. */
  72435. friction?: number;
  72436. /**
  72437. * Restitution
  72438. */
  72439. restitution?: number;
  72440. };
  72441. /**
  72442. * the xr input to use with this pointer selection
  72443. */
  72444. xrInput: WebXRInput;
  72445. }
  72446. /**
  72447. * Add physics impostor to your webxr controllers,
  72448. * including naive calculation of their linear and angular velocity
  72449. */
  72450. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72451. private readonly _options;
  72452. private _attachController;
  72453. private _controllers;
  72454. private _debugMode;
  72455. private _delta;
  72456. private _headsetImpostor?;
  72457. private _headsetMesh?;
  72458. private _lastTimestamp;
  72459. private _tmpQuaternion;
  72460. private _tmpVector;
  72461. /**
  72462. * The module's name
  72463. */
  72464. static readonly Name: string;
  72465. /**
  72466. * The (Babylon) version of this module.
  72467. * This is an integer representing the implementation version.
  72468. * This number does not correspond to the webxr specs version
  72469. */
  72470. static readonly Version: number;
  72471. /**
  72472. * Construct a new Controller Physics Feature
  72473. * @param _xrSessionManager the corresponding xr session manager
  72474. * @param _options options to create this feature with
  72475. */
  72476. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72477. /**
  72478. * @hidden
  72479. * enable debugging - will show console outputs and the impostor mesh
  72480. */
  72481. _enablePhysicsDebug(): void;
  72482. /**
  72483. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72484. * @param xrController the controller to add
  72485. */
  72486. addController(xrController: WebXRInputSource): void;
  72487. /**
  72488. * attach this feature
  72489. * Will usually be called by the features manager
  72490. *
  72491. * @returns true if successful.
  72492. */
  72493. attach(): boolean;
  72494. /**
  72495. * detach this feature.
  72496. * Will usually be called by the features manager
  72497. *
  72498. * @returns true if successful.
  72499. */
  72500. detach(): boolean;
  72501. /**
  72502. * Get the headset impostor, if enabled
  72503. * @returns the impostor
  72504. */
  72505. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72506. /**
  72507. * Get the physics impostor of a specific controller.
  72508. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72509. * @param controller the controller or the controller id of which to get the impostor
  72510. * @returns the impostor or null
  72511. */
  72512. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72513. /**
  72514. * Update the physics properties provided in the constructor
  72515. * @param newProperties the new properties object
  72516. */
  72517. setPhysicsProperties(newProperties: {
  72518. impostorType?: number;
  72519. impostorSize?: number | {
  72520. width: number;
  72521. height: number;
  72522. depth: number;
  72523. };
  72524. friction?: number;
  72525. restitution?: number;
  72526. }): void;
  72527. protected _onXRFrame(_xrFrame: any): void;
  72528. private _detachController;
  72529. }
  72530. }
  72531. declare module BABYLON {
  72532. /**
  72533. * Options used for hit testing (version 2)
  72534. */
  72535. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72536. /**
  72537. * Do not create a permanent hit test. Will usually be used when only
  72538. * transient inputs are needed.
  72539. */
  72540. disablePermanentHitTest?: boolean;
  72541. /**
  72542. * Enable transient (for example touch-based) hit test inspections
  72543. */
  72544. enableTransientHitTest?: boolean;
  72545. /**
  72546. * Offset ray for the permanent hit test
  72547. */
  72548. offsetRay?: Vector3;
  72549. /**
  72550. * Offset ray for the transient hit test
  72551. */
  72552. transientOffsetRay?: Vector3;
  72553. /**
  72554. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72555. */
  72556. useReferenceSpace?: boolean;
  72557. }
  72558. /**
  72559. * Interface defining the babylon result of hit-test
  72560. */
  72561. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72562. /**
  72563. * The input source that generated this hit test (if transient)
  72564. */
  72565. inputSource?: XRInputSource;
  72566. /**
  72567. * Is this a transient hit test
  72568. */
  72569. isTransient?: boolean;
  72570. /**
  72571. * Position of the hit test result
  72572. */
  72573. position: Vector3;
  72574. /**
  72575. * Rotation of the hit test result
  72576. */
  72577. rotationQuaternion: Quaternion;
  72578. }
  72579. /**
  72580. * The currently-working hit-test module.
  72581. * Hit test (or Ray-casting) is used to interact with the real world.
  72582. * For further information read here - https://github.com/immersive-web/hit-test
  72583. *
  72584. * Tested on chrome (mobile) 80.
  72585. */
  72586. export class WebXRHitTest extends WebXRAbstractFeature {
  72587. /**
  72588. * options to use when constructing this feature
  72589. */
  72590. readonly options: IWebXRHitTestOptions;
  72591. private _tmpMat;
  72592. private _tmpPos;
  72593. private _tmpQuat;
  72594. private _transientXrHitTestSource;
  72595. private _xrHitTestSource;
  72596. private initHitTestSource;
  72597. /**
  72598. * The module's name
  72599. */
  72600. static readonly Name: string;
  72601. /**
  72602. * The (Babylon) version of this module.
  72603. * This is an integer representing the implementation version.
  72604. * This number does not correspond to the WebXR specs version
  72605. */
  72606. static readonly Version: number;
  72607. /**
  72608. * When set to true, each hit test will have its own position/rotation objects
  72609. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72610. * the developers will clone them or copy them as they see fit.
  72611. */
  72612. autoCloneTransformation: boolean;
  72613. /**
  72614. * Populated with the last native XR Hit Results
  72615. */
  72616. lastNativeXRHitResults: XRHitResult[];
  72617. /**
  72618. * Triggered when new babylon (transformed) hit test results are available
  72619. */
  72620. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72621. /**
  72622. * Use this to temporarily pause hit test checks.
  72623. */
  72624. paused: boolean;
  72625. /**
  72626. * Creates a new instance of the hit test feature
  72627. * @param _xrSessionManager an instance of WebXRSessionManager
  72628. * @param options options to use when constructing this feature
  72629. */
  72630. constructor(_xrSessionManager: WebXRSessionManager,
  72631. /**
  72632. * options to use when constructing this feature
  72633. */
  72634. options?: IWebXRHitTestOptions);
  72635. /**
  72636. * attach this feature
  72637. * Will usually be called by the features manager
  72638. *
  72639. * @returns true if successful.
  72640. */
  72641. attach(): boolean;
  72642. /**
  72643. * detach this feature.
  72644. * Will usually be called by the features manager
  72645. *
  72646. * @returns true if successful.
  72647. */
  72648. detach(): boolean;
  72649. /**
  72650. * Dispose this feature and all of the resources attached
  72651. */
  72652. dispose(): void;
  72653. protected _onXRFrame(frame: XRFrame): void;
  72654. private _processWebXRHitTestResult;
  72655. }
  72656. }
  72657. declare module BABYLON {
  72658. /**
  72659. * The motion controller class for all microsoft mixed reality controllers
  72660. */
  72661. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72662. protected readonly _mapping: {
  72663. defaultButton: {
  72664. valueNodeName: string;
  72665. unpressedNodeName: string;
  72666. pressedNodeName: string;
  72667. };
  72668. defaultAxis: {
  72669. valueNodeName: string;
  72670. minNodeName: string;
  72671. maxNodeName: string;
  72672. };
  72673. buttons: {
  72674. "xr-standard-trigger": {
  72675. rootNodeName: string;
  72676. componentProperty: string;
  72677. states: string[];
  72678. };
  72679. "xr-standard-squeeze": {
  72680. rootNodeName: string;
  72681. componentProperty: string;
  72682. states: string[];
  72683. };
  72684. "xr-standard-touchpad": {
  72685. rootNodeName: string;
  72686. labelAnchorNodeName: string;
  72687. touchPointNodeName: string;
  72688. };
  72689. "xr-standard-thumbstick": {
  72690. rootNodeName: string;
  72691. componentProperty: string;
  72692. states: string[];
  72693. };
  72694. };
  72695. axes: {
  72696. "xr-standard-touchpad": {
  72697. "x-axis": {
  72698. rootNodeName: string;
  72699. };
  72700. "y-axis": {
  72701. rootNodeName: string;
  72702. };
  72703. };
  72704. "xr-standard-thumbstick": {
  72705. "x-axis": {
  72706. rootNodeName: string;
  72707. };
  72708. "y-axis": {
  72709. rootNodeName: string;
  72710. };
  72711. };
  72712. };
  72713. };
  72714. /**
  72715. * The base url used to load the left and right controller models
  72716. */
  72717. static MODEL_BASE_URL: string;
  72718. /**
  72719. * The name of the left controller model file
  72720. */
  72721. static MODEL_LEFT_FILENAME: string;
  72722. /**
  72723. * The name of the right controller model file
  72724. */
  72725. static MODEL_RIGHT_FILENAME: string;
  72726. profileId: string;
  72727. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72728. protected _getFilenameAndPath(): {
  72729. filename: string;
  72730. path: string;
  72731. };
  72732. protected _getModelLoadingConstraints(): boolean;
  72733. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72734. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72735. protected _updateModel(): void;
  72736. }
  72737. }
  72738. declare module BABYLON {
  72739. /**
  72740. * The motion controller class for oculus touch (quest, rift).
  72741. * This class supports legacy mapping as well the standard xr mapping
  72742. */
  72743. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72744. private _forceLegacyControllers;
  72745. private _modelRootNode;
  72746. /**
  72747. * The base url used to load the left and right controller models
  72748. */
  72749. static MODEL_BASE_URL: string;
  72750. /**
  72751. * The name of the left controller model file
  72752. */
  72753. static MODEL_LEFT_FILENAME: string;
  72754. /**
  72755. * The name of the right controller model file
  72756. */
  72757. static MODEL_RIGHT_FILENAME: string;
  72758. /**
  72759. * Base Url for the Quest controller model.
  72760. */
  72761. static QUEST_MODEL_BASE_URL: string;
  72762. profileId: string;
  72763. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72764. protected _getFilenameAndPath(): {
  72765. filename: string;
  72766. path: string;
  72767. };
  72768. protected _getModelLoadingConstraints(): boolean;
  72769. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72770. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72771. protected _updateModel(): void;
  72772. /**
  72773. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72774. * between the touch and touch 2.
  72775. */
  72776. private _isQuest;
  72777. }
  72778. }
  72779. declare module BABYLON {
  72780. /**
  72781. * The motion controller class for the standard HTC-Vive controllers
  72782. */
  72783. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72784. private _modelRootNode;
  72785. /**
  72786. * The base url used to load the left and right controller models
  72787. */
  72788. static MODEL_BASE_URL: string;
  72789. /**
  72790. * File name for the controller model.
  72791. */
  72792. static MODEL_FILENAME: string;
  72793. profileId: string;
  72794. /**
  72795. * Create a new Vive motion controller object
  72796. * @param scene the scene to use to create this controller
  72797. * @param gamepadObject the corresponding gamepad object
  72798. * @param handedness the handedness of the controller
  72799. */
  72800. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72801. protected _getFilenameAndPath(): {
  72802. filename: string;
  72803. path: string;
  72804. };
  72805. protected _getModelLoadingConstraints(): boolean;
  72806. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72807. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72808. protected _updateModel(): void;
  72809. }
  72810. }
  72811. declare module BABYLON {
  72812. /**
  72813. * A cursor which tracks a point on a path
  72814. */
  72815. export class PathCursor {
  72816. private path;
  72817. /**
  72818. * Stores path cursor callbacks for when an onchange event is triggered
  72819. */
  72820. private _onchange;
  72821. /**
  72822. * The value of the path cursor
  72823. */
  72824. value: number;
  72825. /**
  72826. * The animation array of the path cursor
  72827. */
  72828. animations: Animation[];
  72829. /**
  72830. * Initializes the path cursor
  72831. * @param path The path to track
  72832. */
  72833. constructor(path: Path2);
  72834. /**
  72835. * Gets the cursor point on the path
  72836. * @returns A point on the path cursor at the cursor location
  72837. */
  72838. getPoint(): Vector3;
  72839. /**
  72840. * Moves the cursor ahead by the step amount
  72841. * @param step The amount to move the cursor forward
  72842. * @returns This path cursor
  72843. */
  72844. moveAhead(step?: number): PathCursor;
  72845. /**
  72846. * Moves the cursor behind by the step amount
  72847. * @param step The amount to move the cursor back
  72848. * @returns This path cursor
  72849. */
  72850. moveBack(step?: number): PathCursor;
  72851. /**
  72852. * Moves the cursor by the step amount
  72853. * If the step amount is greater than one, an exception is thrown
  72854. * @param step The amount to move the cursor
  72855. * @returns This path cursor
  72856. */
  72857. move(step: number): PathCursor;
  72858. /**
  72859. * Ensures that the value is limited between zero and one
  72860. * @returns This path cursor
  72861. */
  72862. private ensureLimits;
  72863. /**
  72864. * Runs onchange callbacks on change (used by the animation engine)
  72865. * @returns This path cursor
  72866. */
  72867. private raiseOnChange;
  72868. /**
  72869. * Executes a function on change
  72870. * @param f A path cursor onchange callback
  72871. * @returns This path cursor
  72872. */
  72873. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72874. }
  72875. }
  72876. declare module BABYLON {
  72877. /** @hidden */
  72878. export var blurPixelShader: {
  72879. name: string;
  72880. shader: string;
  72881. };
  72882. }
  72883. declare module BABYLON {
  72884. /** @hidden */
  72885. export var pointCloudVertexDeclaration: {
  72886. name: string;
  72887. shader: string;
  72888. };
  72889. }
  72890. // Mixins
  72891. interface Window {
  72892. mozIndexedDB: IDBFactory;
  72893. webkitIndexedDB: IDBFactory;
  72894. msIndexedDB: IDBFactory;
  72895. webkitURL: typeof URL;
  72896. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72897. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72898. WebGLRenderingContext: WebGLRenderingContext;
  72899. MSGesture: MSGesture;
  72900. CANNON: any;
  72901. AudioContext: AudioContext;
  72902. webkitAudioContext: AudioContext;
  72903. PointerEvent: any;
  72904. Math: Math;
  72905. Uint8Array: Uint8ArrayConstructor;
  72906. Float32Array: Float32ArrayConstructor;
  72907. mozURL: typeof URL;
  72908. msURL: typeof URL;
  72909. VRFrameData: any; // WebVR, from specs 1.1
  72910. DracoDecoderModule: any;
  72911. setImmediate(handler: (...args: any[]) => void): number;
  72912. }
  72913. interface HTMLCanvasElement {
  72914. requestPointerLock(): void;
  72915. msRequestPointerLock?(): void;
  72916. mozRequestPointerLock?(): void;
  72917. webkitRequestPointerLock?(): void;
  72918. /** Track wether a record is in progress */
  72919. isRecording: boolean;
  72920. /** Capture Stream method defined by some browsers */
  72921. captureStream(fps?: number): MediaStream;
  72922. }
  72923. interface CanvasRenderingContext2D {
  72924. msImageSmoothingEnabled: boolean;
  72925. }
  72926. interface MouseEvent {
  72927. mozMovementX: number;
  72928. mozMovementY: number;
  72929. webkitMovementX: number;
  72930. webkitMovementY: number;
  72931. msMovementX: number;
  72932. msMovementY: number;
  72933. }
  72934. interface Navigator {
  72935. mozGetVRDevices: (any: any) => any;
  72936. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72937. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72938. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72939. webkitGetGamepads(): Gamepad[];
  72940. msGetGamepads(): Gamepad[];
  72941. webkitGamepads(): Gamepad[];
  72942. }
  72943. interface HTMLVideoElement {
  72944. mozSrcObject: any;
  72945. }
  72946. interface Math {
  72947. fround(x: number): number;
  72948. imul(a: number, b: number): number;
  72949. }
  72950. interface WebGLRenderingContext {
  72951. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72952. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72953. vertexAttribDivisor(index: number, divisor: number): void;
  72954. createVertexArray(): any;
  72955. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72956. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72957. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72958. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72959. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72960. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72961. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72962. // Queries
  72963. createQuery(): WebGLQuery;
  72964. deleteQuery(query: WebGLQuery): void;
  72965. beginQuery(target: number, query: WebGLQuery): void;
  72966. endQuery(target: number): void;
  72967. getQueryParameter(query: WebGLQuery, pname: number): any;
  72968. getQuery(target: number, pname: number): any;
  72969. MAX_SAMPLES: number;
  72970. RGBA8: number;
  72971. READ_FRAMEBUFFER: number;
  72972. DRAW_FRAMEBUFFER: number;
  72973. UNIFORM_BUFFER: number;
  72974. HALF_FLOAT_OES: number;
  72975. RGBA16F: number;
  72976. RGBA32F: number;
  72977. R32F: number;
  72978. RG32F: number;
  72979. RGB32F: number;
  72980. R16F: number;
  72981. RG16F: number;
  72982. RGB16F: number;
  72983. RED: number;
  72984. RG: number;
  72985. R8: number;
  72986. RG8: number;
  72987. UNSIGNED_INT_24_8: number;
  72988. DEPTH24_STENCIL8: number;
  72989. MIN: number;
  72990. MAX: number;
  72991. /* Multiple Render Targets */
  72992. drawBuffers(buffers: number[]): void;
  72993. readBuffer(src: number): void;
  72994. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72995. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72996. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72997. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72998. // Occlusion Query
  72999. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73000. ANY_SAMPLES_PASSED: number;
  73001. QUERY_RESULT_AVAILABLE: number;
  73002. QUERY_RESULT: number;
  73003. }
  73004. interface WebGLProgram {
  73005. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73006. }
  73007. interface EXT_disjoint_timer_query {
  73008. QUERY_COUNTER_BITS_EXT: number;
  73009. TIME_ELAPSED_EXT: number;
  73010. TIMESTAMP_EXT: number;
  73011. GPU_DISJOINT_EXT: number;
  73012. QUERY_RESULT_EXT: number;
  73013. QUERY_RESULT_AVAILABLE_EXT: number;
  73014. queryCounterEXT(query: WebGLQuery, target: number): void;
  73015. createQueryEXT(): WebGLQuery;
  73016. beginQueryEXT(target: number, query: WebGLQuery): void;
  73017. endQueryEXT(target: number): void;
  73018. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73019. deleteQueryEXT(query: WebGLQuery): void;
  73020. }
  73021. interface WebGLUniformLocation {
  73022. _currentState: any;
  73023. }
  73024. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73025. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73026. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73027. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73028. interface WebGLRenderingContext {
  73029. readonly RASTERIZER_DISCARD: number;
  73030. readonly DEPTH_COMPONENT24: number;
  73031. readonly TEXTURE_3D: number;
  73032. readonly TEXTURE_2D_ARRAY: number;
  73033. readonly TEXTURE_COMPARE_FUNC: number;
  73034. readonly TEXTURE_COMPARE_MODE: number;
  73035. readonly COMPARE_REF_TO_TEXTURE: number;
  73036. readonly TEXTURE_WRAP_R: number;
  73037. readonly HALF_FLOAT: number;
  73038. readonly RGB8: number;
  73039. readonly RED_INTEGER: number;
  73040. readonly RG_INTEGER: number;
  73041. readonly RGB_INTEGER: number;
  73042. readonly RGBA_INTEGER: number;
  73043. readonly R8_SNORM: number;
  73044. readonly RG8_SNORM: number;
  73045. readonly RGB8_SNORM: number;
  73046. readonly RGBA8_SNORM: number;
  73047. readonly R8I: number;
  73048. readonly RG8I: number;
  73049. readonly RGB8I: number;
  73050. readonly RGBA8I: number;
  73051. readonly R8UI: number;
  73052. readonly RG8UI: number;
  73053. readonly RGB8UI: number;
  73054. readonly RGBA8UI: number;
  73055. readonly R16I: number;
  73056. readonly RG16I: number;
  73057. readonly RGB16I: number;
  73058. readonly RGBA16I: number;
  73059. readonly R16UI: number;
  73060. readonly RG16UI: number;
  73061. readonly RGB16UI: number;
  73062. readonly RGBA16UI: number;
  73063. readonly R32I: number;
  73064. readonly RG32I: number;
  73065. readonly RGB32I: number;
  73066. readonly RGBA32I: number;
  73067. readonly R32UI: number;
  73068. readonly RG32UI: number;
  73069. readonly RGB32UI: number;
  73070. readonly RGBA32UI: number;
  73071. readonly RGB10_A2UI: number;
  73072. readonly R11F_G11F_B10F: number;
  73073. readonly RGB9_E5: number;
  73074. readonly RGB10_A2: number;
  73075. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73076. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73077. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73078. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73079. readonly DEPTH_COMPONENT32F: number;
  73080. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73081. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73082. 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;
  73083. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73084. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73085. readonly TRANSFORM_FEEDBACK: number;
  73086. readonly INTERLEAVED_ATTRIBS: number;
  73087. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73088. createTransformFeedback(): WebGLTransformFeedback;
  73089. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73090. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73091. beginTransformFeedback(primitiveMode: number): void;
  73092. endTransformFeedback(): void;
  73093. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73094. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73095. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73096. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73097. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73098. }
  73099. interface ImageBitmap {
  73100. readonly width: number;
  73101. readonly height: number;
  73102. close(): void;
  73103. }
  73104. interface WebGLQuery extends WebGLObject {
  73105. }
  73106. declare var WebGLQuery: {
  73107. prototype: WebGLQuery;
  73108. new(): WebGLQuery;
  73109. };
  73110. interface WebGLSampler extends WebGLObject {
  73111. }
  73112. declare var WebGLSampler: {
  73113. prototype: WebGLSampler;
  73114. new(): WebGLSampler;
  73115. };
  73116. interface WebGLSync extends WebGLObject {
  73117. }
  73118. declare var WebGLSync: {
  73119. prototype: WebGLSync;
  73120. new(): WebGLSync;
  73121. };
  73122. interface WebGLTransformFeedback extends WebGLObject {
  73123. }
  73124. declare var WebGLTransformFeedback: {
  73125. prototype: WebGLTransformFeedback;
  73126. new(): WebGLTransformFeedback;
  73127. };
  73128. interface WebGLVertexArrayObject extends WebGLObject {
  73129. }
  73130. declare var WebGLVertexArrayObject: {
  73131. prototype: WebGLVertexArrayObject;
  73132. new(): WebGLVertexArrayObject;
  73133. };
  73134. // Type definitions for WebVR API
  73135. // Project: https://w3c.github.io/webvr/
  73136. // Definitions by: six a <https://github.com/lostfictions>
  73137. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73138. interface VRDisplay extends EventTarget {
  73139. /**
  73140. * Dictionary of capabilities describing the VRDisplay.
  73141. */
  73142. readonly capabilities: VRDisplayCapabilities;
  73143. /**
  73144. * z-depth defining the far plane of the eye view frustum
  73145. * enables mapping of values in the render target depth
  73146. * attachment to scene coordinates. Initially set to 10000.0.
  73147. */
  73148. depthFar: number;
  73149. /**
  73150. * z-depth defining the near plane of the eye view frustum
  73151. * enables mapping of values in the render target depth
  73152. * attachment to scene coordinates. Initially set to 0.01.
  73153. */
  73154. depthNear: number;
  73155. /**
  73156. * An identifier for this distinct VRDisplay. Used as an
  73157. * association point in the Gamepad API.
  73158. */
  73159. readonly displayId: number;
  73160. /**
  73161. * A display name, a user-readable name identifying it.
  73162. */
  73163. readonly displayName: string;
  73164. readonly isConnected: boolean;
  73165. readonly isPresenting: boolean;
  73166. /**
  73167. * If this VRDisplay supports room-scale experiences, the optional
  73168. * stage attribute contains details on the room-scale parameters.
  73169. */
  73170. readonly stageParameters: VRStageParameters | null;
  73171. /**
  73172. * Passing the value returned by `requestAnimationFrame` to
  73173. * `cancelAnimationFrame` will unregister the callback.
  73174. * @param handle Define the hanle of the request to cancel
  73175. */
  73176. cancelAnimationFrame(handle: number): void;
  73177. /**
  73178. * Stops presenting to the VRDisplay.
  73179. * @returns a promise to know when it stopped
  73180. */
  73181. exitPresent(): Promise<void>;
  73182. /**
  73183. * Return the current VREyeParameters for the given eye.
  73184. * @param whichEye Define the eye we want the parameter for
  73185. * @returns the eye parameters
  73186. */
  73187. getEyeParameters(whichEye: string): VREyeParameters;
  73188. /**
  73189. * Populates the passed VRFrameData with the information required to render
  73190. * the current frame.
  73191. * @param frameData Define the data structure to populate
  73192. * @returns true if ok otherwise false
  73193. */
  73194. getFrameData(frameData: VRFrameData): boolean;
  73195. /**
  73196. * Get the layers currently being presented.
  73197. * @returns the list of VR layers
  73198. */
  73199. getLayers(): VRLayer[];
  73200. /**
  73201. * Return a VRPose containing the future predicted pose of the VRDisplay
  73202. * when the current frame will be presented. The value returned will not
  73203. * change until JavaScript has returned control to the browser.
  73204. *
  73205. * The VRPose will contain the position, orientation, velocity,
  73206. * and acceleration of each of these properties.
  73207. * @returns the pose object
  73208. */
  73209. getPose(): VRPose;
  73210. /**
  73211. * Return the current instantaneous pose of the VRDisplay, with no
  73212. * prediction applied.
  73213. * @returns the current instantaneous pose
  73214. */
  73215. getImmediatePose(): VRPose;
  73216. /**
  73217. * The callback passed to `requestAnimationFrame` will be called
  73218. * any time a new frame should be rendered. When the VRDisplay is
  73219. * presenting the callback will be called at the native refresh
  73220. * rate of the HMD. When not presenting this function acts
  73221. * identically to how window.requestAnimationFrame acts. Content should
  73222. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73223. * asynchronously from other displays and at differing refresh rates.
  73224. * @param callback Define the eaction to run next frame
  73225. * @returns the request handle it
  73226. */
  73227. requestAnimationFrame(callback: FrameRequestCallback): number;
  73228. /**
  73229. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73230. * Repeat calls while already presenting will update the VRLayers being displayed.
  73231. * @param layers Define the list of layer to present
  73232. * @returns a promise to know when the request has been fulfilled
  73233. */
  73234. requestPresent(layers: VRLayer[]): Promise<void>;
  73235. /**
  73236. * Reset the pose for this display, treating its current position and
  73237. * orientation as the "origin/zero" values. VRPose.position,
  73238. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73239. * updated when calling resetPose(). This should be called in only
  73240. * sitting-space experiences.
  73241. */
  73242. resetPose(): void;
  73243. /**
  73244. * The VRLayer provided to the VRDisplay will be captured and presented
  73245. * in the HMD. Calling this function has the same effect on the source
  73246. * canvas as any other operation that uses its source image, and canvases
  73247. * created without preserveDrawingBuffer set to true will be cleared.
  73248. * @param pose Define the pose to submit
  73249. */
  73250. submitFrame(pose?: VRPose): void;
  73251. }
  73252. declare var VRDisplay: {
  73253. prototype: VRDisplay;
  73254. new(): VRDisplay;
  73255. };
  73256. interface VRLayer {
  73257. leftBounds?: number[] | Float32Array | null;
  73258. rightBounds?: number[] | Float32Array | null;
  73259. source?: HTMLCanvasElement | null;
  73260. }
  73261. interface VRDisplayCapabilities {
  73262. readonly canPresent: boolean;
  73263. readonly hasExternalDisplay: boolean;
  73264. readonly hasOrientation: boolean;
  73265. readonly hasPosition: boolean;
  73266. readonly maxLayers: number;
  73267. }
  73268. interface VREyeParameters {
  73269. /** @deprecated */
  73270. readonly fieldOfView: VRFieldOfView;
  73271. readonly offset: Float32Array;
  73272. readonly renderHeight: number;
  73273. readonly renderWidth: number;
  73274. }
  73275. interface VRFieldOfView {
  73276. readonly downDegrees: number;
  73277. readonly leftDegrees: number;
  73278. readonly rightDegrees: number;
  73279. readonly upDegrees: number;
  73280. }
  73281. interface VRFrameData {
  73282. readonly leftProjectionMatrix: Float32Array;
  73283. readonly leftViewMatrix: Float32Array;
  73284. readonly pose: VRPose;
  73285. readonly rightProjectionMatrix: Float32Array;
  73286. readonly rightViewMatrix: Float32Array;
  73287. readonly timestamp: number;
  73288. }
  73289. interface VRPose {
  73290. readonly angularAcceleration: Float32Array | null;
  73291. readonly angularVelocity: Float32Array | null;
  73292. readonly linearAcceleration: Float32Array | null;
  73293. readonly linearVelocity: Float32Array | null;
  73294. readonly orientation: Float32Array | null;
  73295. readonly position: Float32Array | null;
  73296. readonly timestamp: number;
  73297. }
  73298. interface VRStageParameters {
  73299. sittingToStandingTransform?: Float32Array;
  73300. sizeX?: number;
  73301. sizeY?: number;
  73302. }
  73303. interface Navigator {
  73304. getVRDisplays(): Promise<VRDisplay[]>;
  73305. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73306. }
  73307. interface Window {
  73308. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73309. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73310. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73311. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73312. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73313. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73314. }
  73315. interface Gamepad {
  73316. readonly displayId: number;
  73317. }
  73318. type XRSessionMode =
  73319. | "inline"
  73320. | "immersive-vr"
  73321. | "immersive-ar";
  73322. type XRReferenceSpaceType =
  73323. | "viewer"
  73324. | "local"
  73325. | "local-floor"
  73326. | "bounded-floor"
  73327. | "unbounded";
  73328. type XREnvironmentBlendMode =
  73329. | "opaque"
  73330. | "additive"
  73331. | "alpha-blend";
  73332. type XRVisibilityState =
  73333. | "visible"
  73334. | "visible-blurred"
  73335. | "hidden";
  73336. type XRHandedness =
  73337. | "none"
  73338. | "left"
  73339. | "right";
  73340. type XRTargetRayMode =
  73341. | "gaze"
  73342. | "tracked-pointer"
  73343. | "screen";
  73344. type XREye =
  73345. | "none"
  73346. | "left"
  73347. | "right";
  73348. type XREventType =
  73349. | "devicechange"
  73350. | "visibilitychange"
  73351. | "end"
  73352. | "inputsourceschange"
  73353. | "select"
  73354. | "selectstart"
  73355. | "selectend"
  73356. | "squeeze"
  73357. | "squeezestart"
  73358. | "squeezeend"
  73359. | "reset";
  73360. interface XRSpace extends EventTarget {
  73361. }
  73362. interface XRRenderState {
  73363. depthNear?: number;
  73364. depthFar?: number;
  73365. inlineVerticalFieldOfView?: number;
  73366. baseLayer?: XRWebGLLayer;
  73367. }
  73368. interface XRInputSource {
  73369. handedness: XRHandedness;
  73370. targetRayMode: XRTargetRayMode;
  73371. targetRaySpace: XRSpace;
  73372. gripSpace: XRSpace | undefined;
  73373. gamepad: Gamepad | undefined;
  73374. profiles: Array<string>;
  73375. }
  73376. interface XRSessionInit {
  73377. optionalFeatures?: string[];
  73378. requiredFeatures?: string[];
  73379. }
  73380. interface XRSession extends XRAnchorCreator {
  73381. addEventListener: Function;
  73382. removeEventListener: Function;
  73383. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73384. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73385. requestAnimationFrame: Function;
  73386. end(): Promise<void>;
  73387. renderState: XRRenderState;
  73388. inputSources: Array<XRInputSource>;
  73389. // hit test
  73390. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73391. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73392. // legacy AR hit test
  73393. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73394. // legacy plane detection
  73395. updateWorldTrackingState(options: {
  73396. planeDetectionState?: { enabled: boolean; }
  73397. }): void;
  73398. }
  73399. interface XRReferenceSpace extends XRSpace {
  73400. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73401. onreset: any;
  73402. }
  73403. type XRPlaneSet = Set<XRPlane>;
  73404. type XRAnchorSet = Set<XRAnchor>;
  73405. interface XRFrame {
  73406. session: XRSession;
  73407. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73408. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73409. // AR
  73410. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73411. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73412. // Anchors
  73413. trackedAnchors?: XRAnchorSet;
  73414. // Planes
  73415. worldInformation: {
  73416. detectedPlanes?: XRPlaneSet;
  73417. };
  73418. }
  73419. interface XRViewerPose extends XRPose {
  73420. views: Array<XRView>;
  73421. }
  73422. interface XRPose {
  73423. transform: XRRigidTransform;
  73424. emulatedPosition: boolean;
  73425. }
  73426. interface XRWebGLLayerOptions {
  73427. antialias?: boolean;
  73428. depth?: boolean;
  73429. stencil?: boolean;
  73430. alpha?: boolean;
  73431. multiview?: boolean;
  73432. framebufferScaleFactor?: number;
  73433. }
  73434. declare var XRWebGLLayer: {
  73435. prototype: XRWebGLLayer;
  73436. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73437. };
  73438. interface XRWebGLLayer {
  73439. framebuffer: WebGLFramebuffer;
  73440. framebufferWidth: number;
  73441. framebufferHeight: number;
  73442. getViewport: Function;
  73443. }
  73444. declare class XRRigidTransform {
  73445. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73446. position: DOMPointReadOnly;
  73447. orientation: DOMPointReadOnly;
  73448. matrix: Float32Array;
  73449. inverse: XRRigidTransform;
  73450. }
  73451. interface XRView {
  73452. eye: XREye;
  73453. projectionMatrix: Float32Array;
  73454. transform: XRRigidTransform;
  73455. }
  73456. interface XRInputSourceChangeEvent {
  73457. session: XRSession;
  73458. removed: Array<XRInputSource>;
  73459. added: Array<XRInputSource>;
  73460. }
  73461. interface XRInputSourceEvent extends Event {
  73462. readonly frame: XRFrame;
  73463. readonly inputSource: XRInputSource;
  73464. }
  73465. // Experimental(er) features
  73466. declare class XRRay {
  73467. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73468. origin: DOMPointReadOnly;
  73469. direction: DOMPointReadOnly;
  73470. matrix: Float32Array;
  73471. }
  73472. declare enum XRHitTestTrackableType {
  73473. "point",
  73474. "plane"
  73475. }
  73476. interface XRHitResult {
  73477. hitMatrix: Float32Array;
  73478. }
  73479. interface XRTransientInputHitTestResult {
  73480. readonly inputSource: XRInputSource;
  73481. readonly results: Array<XRHitTestResult>;
  73482. }
  73483. interface XRHitTestResult {
  73484. getPose(baseSpace: XRSpace): XRPose | undefined;
  73485. }
  73486. interface XRHitTestSource {
  73487. cancel(): void;
  73488. }
  73489. interface XRTransientInputHitTestSource {
  73490. cancel(): void;
  73491. }
  73492. interface XRHitTestOptionsInit {
  73493. space: XRSpace;
  73494. entityTypes?: Array<XRHitTestTrackableType>;
  73495. offsetRay?: XRRay;
  73496. }
  73497. interface XRTransientInputHitTestOptionsInit {
  73498. profile: string;
  73499. entityTypes?: Array<XRHitTestTrackableType>;
  73500. offsetRay?: XRRay;
  73501. }
  73502. interface XRAnchor {
  73503. // remove?
  73504. id?: string;
  73505. anchorSpace: XRSpace;
  73506. lastChangedTime: number;
  73507. detach(): void;
  73508. }
  73509. interface XRPlane extends XRAnchorCreator {
  73510. orientation: "Horizontal" | "Vertical";
  73511. planeSpace: XRSpace;
  73512. polygon: Array<DOMPointReadOnly>;
  73513. lastChangedTime: number;
  73514. }
  73515. interface XRAnchorCreator {
  73516. // AR Anchors
  73517. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73518. }
  73519. /**
  73520. * @ignore
  73521. */
  73522. declare module BABYLON.GLTF2.Exporter {
  73523. }
  73524. /**
  73525. * @ignore
  73526. */
  73527. declare module BABYLON.GLTF1 {
  73528. }
  73529. declare module BABYLON.GUI {
  73530. /**
  73531. * Class used to specific a value and its associated unit
  73532. */
  73533. export class ValueAndUnit {
  73534. /** defines the unit to store */
  73535. unit: number;
  73536. /** defines a boolean indicating if the value can be negative */
  73537. negativeValueAllowed: boolean;
  73538. private _value;
  73539. private _originalUnit;
  73540. /**
  73541. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73542. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73543. */
  73544. ignoreAdaptiveScaling: boolean;
  73545. /**
  73546. * Creates a new ValueAndUnit
  73547. * @param value defines the value to store
  73548. * @param unit defines the unit to store
  73549. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73550. */
  73551. constructor(value: number,
  73552. /** defines the unit to store */
  73553. unit?: number,
  73554. /** defines a boolean indicating if the value can be negative */
  73555. negativeValueAllowed?: boolean);
  73556. /** Gets a boolean indicating if the value is a percentage */
  73557. get isPercentage(): boolean;
  73558. /** Gets a boolean indicating if the value is store as pixel */
  73559. get isPixel(): boolean;
  73560. /** Gets direct internal value */
  73561. get internalValue(): number;
  73562. /**
  73563. * Gets value as pixel
  73564. * @param host defines the root host
  73565. * @param refValue defines the reference value for percentages
  73566. * @returns the value as pixel
  73567. */
  73568. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73569. /**
  73570. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73571. * @param value defines the value to store
  73572. * @param unit defines the unit to store
  73573. * @returns the current ValueAndUnit
  73574. */
  73575. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73576. /**
  73577. * Gets the value accordingly to its unit
  73578. * @param host defines the root host
  73579. * @returns the value
  73580. */
  73581. getValue(host: AdvancedDynamicTexture): number;
  73582. /**
  73583. * Gets a string representation of the value
  73584. * @param host defines the root host
  73585. * @param decimals defines an optional number of decimals to display
  73586. * @returns a string
  73587. */
  73588. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73589. /**
  73590. * Store a value parsed from a string
  73591. * @param source defines the source string
  73592. * @returns true if the value was successfully parsed
  73593. */
  73594. fromString(source: string | number): boolean;
  73595. private static _Regex;
  73596. private static _UNITMODE_PERCENTAGE;
  73597. private static _UNITMODE_PIXEL;
  73598. /** UNITMODE_PERCENTAGE */
  73599. static get UNITMODE_PERCENTAGE(): number;
  73600. /** UNITMODE_PIXEL */
  73601. static get UNITMODE_PIXEL(): number;
  73602. }
  73603. }
  73604. declare module BABYLON.GUI {
  73605. /**
  73606. * Define a style used by control to automatically setup properties based on a template.
  73607. * Only support font related properties so far
  73608. */
  73609. export class Style implements BABYLON.IDisposable {
  73610. private _fontFamily;
  73611. private _fontStyle;
  73612. private _fontWeight;
  73613. /** @hidden */
  73614. _host: AdvancedDynamicTexture;
  73615. /** @hidden */
  73616. _fontSize: ValueAndUnit;
  73617. /**
  73618. * BABYLON.Observable raised when the style values are changed
  73619. */
  73620. onChangedObservable: BABYLON.Observable<Style>;
  73621. /**
  73622. * Creates a new style object
  73623. * @param host defines the AdvancedDynamicTexture which hosts this style
  73624. */
  73625. constructor(host: AdvancedDynamicTexture);
  73626. /**
  73627. * Gets or sets the font size
  73628. */
  73629. get fontSize(): string | number;
  73630. set fontSize(value: string | number);
  73631. /**
  73632. * Gets or sets the font family
  73633. */
  73634. get fontFamily(): string;
  73635. set fontFamily(value: string);
  73636. /**
  73637. * Gets or sets the font style
  73638. */
  73639. get fontStyle(): string;
  73640. set fontStyle(value: string);
  73641. /** Gets or sets font weight */
  73642. get fontWeight(): string;
  73643. set fontWeight(value: string);
  73644. /** Dispose all associated resources */
  73645. dispose(): void;
  73646. }
  73647. }
  73648. declare module BABYLON.GUI {
  73649. /**
  73650. * Class used to transport BABYLON.Vector2 information for pointer events
  73651. */
  73652. export class Vector2WithInfo extends BABYLON.Vector2 {
  73653. /** defines the current mouse button index */
  73654. buttonIndex: number;
  73655. /**
  73656. * Creates a new Vector2WithInfo
  73657. * @param source defines the vector2 data to transport
  73658. * @param buttonIndex defines the current mouse button index
  73659. */
  73660. constructor(source: BABYLON.Vector2,
  73661. /** defines the current mouse button index */
  73662. buttonIndex?: number);
  73663. }
  73664. /** Class used to provide 2D matrix features */
  73665. export class Matrix2D {
  73666. /** Gets the internal array of 6 floats used to store matrix data */
  73667. m: Float32Array;
  73668. /**
  73669. * Creates a new matrix
  73670. * @param m00 defines value for (0, 0)
  73671. * @param m01 defines value for (0, 1)
  73672. * @param m10 defines value for (1, 0)
  73673. * @param m11 defines value for (1, 1)
  73674. * @param m20 defines value for (2, 0)
  73675. * @param m21 defines value for (2, 1)
  73676. */
  73677. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73678. /**
  73679. * Fills the matrix from direct values
  73680. * @param m00 defines value for (0, 0)
  73681. * @param m01 defines value for (0, 1)
  73682. * @param m10 defines value for (1, 0)
  73683. * @param m11 defines value for (1, 1)
  73684. * @param m20 defines value for (2, 0)
  73685. * @param m21 defines value for (2, 1)
  73686. * @returns the current modified matrix
  73687. */
  73688. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73689. /**
  73690. * Gets matrix determinant
  73691. * @returns the determinant
  73692. */
  73693. determinant(): number;
  73694. /**
  73695. * Inverses the matrix and stores it in a target matrix
  73696. * @param result defines the target matrix
  73697. * @returns the current matrix
  73698. */
  73699. invertToRef(result: Matrix2D): Matrix2D;
  73700. /**
  73701. * Multiplies the current matrix with another one
  73702. * @param other defines the second operand
  73703. * @param result defines the target matrix
  73704. * @returns the current matrix
  73705. */
  73706. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73707. /**
  73708. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73709. * @param x defines the x coordinate to transform
  73710. * @param y defines the x coordinate to transform
  73711. * @param result defines the target vector2
  73712. * @returns the current matrix
  73713. */
  73714. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73715. /**
  73716. * Creates an identity matrix
  73717. * @returns a new matrix
  73718. */
  73719. static Identity(): Matrix2D;
  73720. /**
  73721. * Creates a translation matrix and stores it in a target matrix
  73722. * @param x defines the x coordinate of the translation
  73723. * @param y defines the y coordinate of the translation
  73724. * @param result defines the target matrix
  73725. */
  73726. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73727. /**
  73728. * Creates a scaling matrix and stores it in a target matrix
  73729. * @param x defines the x coordinate of the scaling
  73730. * @param y defines the y coordinate of the scaling
  73731. * @param result defines the target matrix
  73732. */
  73733. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73734. /**
  73735. * Creates a rotation matrix and stores it in a target matrix
  73736. * @param angle defines the rotation angle
  73737. * @param result defines the target matrix
  73738. */
  73739. static RotationToRef(angle: number, result: Matrix2D): void;
  73740. private static _TempPreTranslationMatrix;
  73741. private static _TempPostTranslationMatrix;
  73742. private static _TempRotationMatrix;
  73743. private static _TempScalingMatrix;
  73744. private static _TempCompose0;
  73745. private static _TempCompose1;
  73746. private static _TempCompose2;
  73747. /**
  73748. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73749. * @param tx defines the x coordinate of the translation
  73750. * @param ty defines the y coordinate of the translation
  73751. * @param angle defines the rotation angle
  73752. * @param scaleX defines the x coordinate of the scaling
  73753. * @param scaleY defines the y coordinate of the scaling
  73754. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73755. * @param result defines the target matrix
  73756. */
  73757. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73758. }
  73759. }
  73760. declare module BABYLON.GUI {
  73761. /**
  73762. * Class used to store 2D control sizes
  73763. */
  73764. export class Measure {
  73765. /** defines left coordinate */
  73766. left: number;
  73767. /** defines top coordinate */
  73768. top: number;
  73769. /** defines width dimension */
  73770. width: number;
  73771. /** defines height dimension */
  73772. height: number;
  73773. /**
  73774. * Creates a new measure
  73775. * @param left defines left coordinate
  73776. * @param top defines top coordinate
  73777. * @param width defines width dimension
  73778. * @param height defines height dimension
  73779. */
  73780. constructor(
  73781. /** defines left coordinate */
  73782. left: number,
  73783. /** defines top coordinate */
  73784. top: number,
  73785. /** defines width dimension */
  73786. width: number,
  73787. /** defines height dimension */
  73788. height: number);
  73789. /**
  73790. * Copy from another measure
  73791. * @param other defines the other measure to copy from
  73792. */
  73793. copyFrom(other: Measure): void;
  73794. /**
  73795. * Copy from a group of 4 floats
  73796. * @param left defines left coordinate
  73797. * @param top defines top coordinate
  73798. * @param width defines width dimension
  73799. * @param height defines height dimension
  73800. */
  73801. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73802. /**
  73803. * Computes the axis aligned bounding box measure for two given measures
  73804. * @param a Input measure
  73805. * @param b Input measure
  73806. * @param result the resulting bounding measure
  73807. */
  73808. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73809. /**
  73810. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73811. * @param transform the matrix to transform the measure before computing the AABB
  73812. * @param result the resulting AABB
  73813. */
  73814. transformToRef(transform: Matrix2D, result: Measure): void;
  73815. /**
  73816. * Check equality between this measure and another one
  73817. * @param other defines the other measures
  73818. * @returns true if both measures are equals
  73819. */
  73820. isEqualsTo(other: Measure): boolean;
  73821. /**
  73822. * Creates an empty measure
  73823. * @returns a new measure
  73824. */
  73825. static Empty(): Measure;
  73826. }
  73827. }
  73828. declare module BABYLON.GUI {
  73829. /**
  73830. * Interface used to define a control that can receive focus
  73831. */
  73832. export interface IFocusableControl {
  73833. /**
  73834. * Function called when the control receives the focus
  73835. */
  73836. onFocus(): void;
  73837. /**
  73838. * Function called when the control loses the focus
  73839. */
  73840. onBlur(): void;
  73841. /**
  73842. * Function called to let the control handle keyboard events
  73843. * @param evt defines the current keyboard event
  73844. */
  73845. processKeyboard(evt: KeyboardEvent): void;
  73846. /**
  73847. * Function called to get the list of controls that should not steal the focus from this control
  73848. * @returns an array of controls
  73849. */
  73850. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73851. }
  73852. /**
  73853. * Class used to create texture to support 2D GUI elements
  73854. * @see http://doc.babylonjs.com/how_to/gui
  73855. */
  73856. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73857. private _isDirty;
  73858. private _renderObserver;
  73859. private _resizeObserver;
  73860. private _preKeyboardObserver;
  73861. private _pointerMoveObserver;
  73862. private _pointerObserver;
  73863. private _canvasPointerOutObserver;
  73864. private _background;
  73865. /** @hidden */
  73866. _rootContainer: Container;
  73867. /** @hidden */
  73868. _lastPickedControl: Control;
  73869. /** @hidden */
  73870. _lastControlOver: {
  73871. [pointerId: number]: Control;
  73872. };
  73873. /** @hidden */
  73874. _lastControlDown: {
  73875. [pointerId: number]: Control;
  73876. };
  73877. /** @hidden */
  73878. _capturingControl: {
  73879. [pointerId: number]: Control;
  73880. };
  73881. /** @hidden */
  73882. _shouldBlockPointer: boolean;
  73883. /** @hidden */
  73884. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  73885. /** @hidden */
  73886. _linkedControls: Control[];
  73887. private _isFullscreen;
  73888. private _fullscreenViewport;
  73889. private _idealWidth;
  73890. private _idealHeight;
  73891. private _useSmallestIdeal;
  73892. private _renderAtIdealSize;
  73893. private _focusedControl;
  73894. private _blockNextFocusCheck;
  73895. private _renderScale;
  73896. private _rootElement;
  73897. private _cursorChanged;
  73898. private _defaultMousePointerId;
  73899. /** @hidden */
  73900. _numLayoutCalls: number;
  73901. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73902. get numLayoutCalls(): number;
  73903. /** @hidden */
  73904. _numRenderCalls: number;
  73905. /** Gets the number of render calls made the last time the ADT has been rendered */
  73906. get numRenderCalls(): number;
  73907. /**
  73908. * Define type to string to ensure compatibility across browsers
  73909. * Safari doesn't support DataTransfer constructor
  73910. */
  73911. private _clipboardData;
  73912. /**
  73913. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73914. */
  73915. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73916. /**
  73917. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73918. */
  73919. onControlPickedObservable: BABYLON.Observable<Control>;
  73920. /**
  73921. * BABYLON.Observable event triggered before layout is evaluated
  73922. */
  73923. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73924. /**
  73925. * BABYLON.Observable event triggered after the layout was evaluated
  73926. */
  73927. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73928. /**
  73929. * BABYLON.Observable event triggered before the texture is rendered
  73930. */
  73931. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73932. /**
  73933. * BABYLON.Observable event triggered after the texture was rendered
  73934. */
  73935. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73936. /**
  73937. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73938. */
  73939. premulAlpha: boolean;
  73940. /**
  73941. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73942. * Useful when you want more antialiasing
  73943. */
  73944. get renderScale(): number;
  73945. set renderScale(value: number);
  73946. /** Gets or sets the background color */
  73947. get background(): string;
  73948. set background(value: string);
  73949. /**
  73950. * Gets or sets the ideal width used to design controls.
  73951. * The GUI will then rescale everything accordingly
  73952. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73953. */
  73954. get idealWidth(): number;
  73955. set idealWidth(value: number);
  73956. /**
  73957. * Gets or sets the ideal height used to design controls.
  73958. * The GUI will then rescale everything accordingly
  73959. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73960. */
  73961. get idealHeight(): number;
  73962. set idealHeight(value: number);
  73963. /**
  73964. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73965. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73966. */
  73967. get useSmallestIdeal(): boolean;
  73968. set useSmallestIdeal(value: boolean);
  73969. /**
  73970. * Gets or sets a boolean indicating if adaptive scaling must be used
  73971. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73972. */
  73973. get renderAtIdealSize(): boolean;
  73974. set renderAtIdealSize(value: boolean);
  73975. /**
  73976. * Gets the ratio used when in "ideal mode"
  73977. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73978. * */
  73979. get idealRatio(): number;
  73980. /**
  73981. * Gets the underlying layer used to render the texture when in fullscreen mode
  73982. */
  73983. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73984. /**
  73985. * Gets the root container control
  73986. */
  73987. get rootContainer(): Container;
  73988. /**
  73989. * Returns an array containing the root container.
  73990. * This is mostly used to let the Inspector introspects the ADT
  73991. * @returns an array containing the rootContainer
  73992. */
  73993. getChildren(): Array<Container>;
  73994. /**
  73995. * Will return all controls that are inside this texture
  73996. * @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
  73997. * @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
  73998. * @return all child controls
  73999. */
  74000. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74001. /**
  74002. * Gets or sets the current focused control
  74003. */
  74004. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74005. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74006. /**
  74007. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74008. */
  74009. get isForeground(): boolean;
  74010. set isForeground(value: boolean);
  74011. /**
  74012. * Gets or set information about clipboardData
  74013. */
  74014. get clipboardData(): string;
  74015. set clipboardData(value: string);
  74016. /**
  74017. * Creates a new AdvancedDynamicTexture
  74018. * @param name defines the name of the texture
  74019. * @param width defines the width of the texture
  74020. * @param height defines the height of the texture
  74021. * @param scene defines the hosting scene
  74022. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74023. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74024. */
  74025. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74026. /**
  74027. * Get the current class name of the texture useful for serialization or dynamic coding.
  74028. * @returns "AdvancedDynamicTexture"
  74029. */
  74030. getClassName(): string;
  74031. /**
  74032. * Function used to execute a function on all controls
  74033. * @param func defines the function to execute
  74034. * @param container defines the container where controls belong. If null the root container will be used
  74035. */
  74036. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74037. private _useInvalidateRectOptimization;
  74038. /**
  74039. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74040. */
  74041. get useInvalidateRectOptimization(): boolean;
  74042. set useInvalidateRectOptimization(value: boolean);
  74043. private _invalidatedRectangle;
  74044. /**
  74045. * Invalidates a rectangle area on the gui texture
  74046. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74047. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74048. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74049. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74050. */
  74051. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74052. /**
  74053. * Marks the texture as dirty forcing a complete update
  74054. */
  74055. markAsDirty(): void;
  74056. /**
  74057. * Helper function used to create a new style
  74058. * @returns a new style
  74059. * @see http://doc.babylonjs.com/how_to/gui#styles
  74060. */
  74061. createStyle(): Style;
  74062. /**
  74063. * Adds a new control to the root container
  74064. * @param control defines the control to add
  74065. * @returns the current texture
  74066. */
  74067. addControl(control: Control): AdvancedDynamicTexture;
  74068. /**
  74069. * Removes a control from the root container
  74070. * @param control defines the control to remove
  74071. * @returns the current texture
  74072. */
  74073. removeControl(control: Control): AdvancedDynamicTexture;
  74074. /**
  74075. * Release all resources
  74076. */
  74077. dispose(): void;
  74078. private _onResize;
  74079. /** @hidden */
  74080. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74081. /**
  74082. * Get screen coordinates for a vector3
  74083. * @param position defines the position to project
  74084. * @param worldMatrix defines the world matrix to use
  74085. * @returns the projected position
  74086. */
  74087. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74088. private _checkUpdate;
  74089. private _clearMeasure;
  74090. private _render;
  74091. /** @hidden */
  74092. _changeCursor(cursor: string): void;
  74093. /** @hidden */
  74094. _registerLastControlDown(control: Control, pointerId: number): void;
  74095. private _doPicking;
  74096. /** @hidden */
  74097. _cleanControlAfterRemovalFromList(list: {
  74098. [pointerId: number]: Control;
  74099. }, control: Control): void;
  74100. /** @hidden */
  74101. _cleanControlAfterRemoval(control: Control): void;
  74102. /** Attach to all scene events required to support pointer events */
  74103. attach(): void;
  74104. /** @hidden */
  74105. private onClipboardCopy;
  74106. /** @hidden */
  74107. private onClipboardCut;
  74108. /** @hidden */
  74109. private onClipboardPaste;
  74110. /**
  74111. * Register the clipboard Events onto the canvas
  74112. */
  74113. registerClipboardEvents(): void;
  74114. /**
  74115. * Unregister the clipboard Events from the canvas
  74116. */
  74117. unRegisterClipboardEvents(): void;
  74118. /**
  74119. * Connect the texture to a hosting mesh to enable interactions
  74120. * @param mesh defines the mesh to attach to
  74121. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74122. */
  74123. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74124. /**
  74125. * Move the focus to a specific control
  74126. * @param control defines the control which will receive the focus
  74127. */
  74128. moveFocusToControl(control: IFocusableControl): void;
  74129. private _manageFocus;
  74130. private _attachToOnPointerOut;
  74131. /**
  74132. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74133. * @param mesh defines the mesh which will receive the texture
  74134. * @param width defines the texture width (1024 by default)
  74135. * @param height defines the texture height (1024 by default)
  74136. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74137. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74138. * @returns a new AdvancedDynamicTexture
  74139. */
  74140. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74141. /**
  74142. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74143. * In this mode the texture will rely on a layer for its rendering.
  74144. * This allows it to be treated like any other layer.
  74145. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74146. * LayerMask is set through advancedTexture.layer.layerMask
  74147. * @param name defines name for the texture
  74148. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74149. * @param scene defines the hsoting scene
  74150. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74151. * @returns a new AdvancedDynamicTexture
  74152. */
  74153. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74154. }
  74155. }
  74156. declare module BABYLON.GUI {
  74157. /**
  74158. * Root class used for all 2D controls
  74159. * @see http://doc.babylonjs.com/how_to/gui#controls
  74160. */
  74161. export class Control {
  74162. /** defines the name of the control */
  74163. name?: string | undefined;
  74164. /**
  74165. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74166. */
  74167. static AllowAlphaInheritance: boolean;
  74168. private _alpha;
  74169. private _alphaSet;
  74170. private _zIndex;
  74171. /** @hidden */
  74172. _host: AdvancedDynamicTexture;
  74173. /** Gets or sets the control parent */
  74174. parent: BABYLON.Nullable<Container>;
  74175. /** @hidden */
  74176. _currentMeasure: Measure;
  74177. private _fontFamily;
  74178. private _fontStyle;
  74179. private _fontWeight;
  74180. private _fontSize;
  74181. private _font;
  74182. /** @hidden */
  74183. _width: ValueAndUnit;
  74184. /** @hidden */
  74185. _height: ValueAndUnit;
  74186. /** @hidden */
  74187. protected _fontOffset: {
  74188. ascent: number;
  74189. height: number;
  74190. descent: number;
  74191. };
  74192. private _color;
  74193. private _style;
  74194. private _styleObserver;
  74195. /** @hidden */
  74196. protected _horizontalAlignment: number;
  74197. /** @hidden */
  74198. protected _verticalAlignment: number;
  74199. /** @hidden */
  74200. protected _isDirty: boolean;
  74201. /** @hidden */
  74202. protected _wasDirty: boolean;
  74203. /** @hidden */
  74204. _tempParentMeasure: Measure;
  74205. /** @hidden */
  74206. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74207. /** @hidden */
  74208. protected _cachedParentMeasure: Measure;
  74209. private _paddingLeft;
  74210. private _paddingRight;
  74211. private _paddingTop;
  74212. private _paddingBottom;
  74213. /** @hidden */
  74214. _left: ValueAndUnit;
  74215. /** @hidden */
  74216. _top: ValueAndUnit;
  74217. private _scaleX;
  74218. private _scaleY;
  74219. private _rotation;
  74220. private _transformCenterX;
  74221. private _transformCenterY;
  74222. /** @hidden */
  74223. _transformMatrix: Matrix2D;
  74224. /** @hidden */
  74225. protected _invertTransformMatrix: Matrix2D;
  74226. /** @hidden */
  74227. protected _transformedPosition: BABYLON.Vector2;
  74228. private _isMatrixDirty;
  74229. private _cachedOffsetX;
  74230. private _cachedOffsetY;
  74231. private _isVisible;
  74232. private _isHighlighted;
  74233. /** @hidden */
  74234. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74235. private _fontSet;
  74236. private _dummyVector2;
  74237. private _downCount;
  74238. private _enterCount;
  74239. private _doNotRender;
  74240. private _downPointerIds;
  74241. protected _isEnabled: boolean;
  74242. protected _disabledColor: string;
  74243. protected _disabledColorItem: string;
  74244. /** @hidden */
  74245. protected _rebuildLayout: boolean;
  74246. /** @hidden */
  74247. _customData: any;
  74248. /** @hidden */
  74249. _isClipped: boolean;
  74250. /** @hidden */
  74251. _automaticSize: boolean;
  74252. /** @hidden */
  74253. _tag: any;
  74254. /**
  74255. * 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
  74256. */
  74257. uniqueId: number;
  74258. /**
  74259. * Gets or sets an object used to store user defined information for the node
  74260. */
  74261. metadata: any;
  74262. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74263. isHitTestVisible: boolean;
  74264. /** Gets or sets a boolean indicating if the control can block pointer events */
  74265. isPointerBlocker: boolean;
  74266. /** Gets or sets a boolean indicating if the control can be focusable */
  74267. isFocusInvisible: boolean;
  74268. /**
  74269. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74270. * 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
  74271. */
  74272. clipChildren: boolean;
  74273. /**
  74274. * Gets or sets a boolean indicating that control content must be clipped
  74275. * 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
  74276. */
  74277. clipContent: boolean;
  74278. /**
  74279. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74280. */
  74281. useBitmapCache: boolean;
  74282. private _cacheData;
  74283. private _shadowOffsetX;
  74284. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74285. get shadowOffsetX(): number;
  74286. set shadowOffsetX(value: number);
  74287. private _shadowOffsetY;
  74288. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74289. get shadowOffsetY(): number;
  74290. set shadowOffsetY(value: number);
  74291. private _shadowBlur;
  74292. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74293. get shadowBlur(): number;
  74294. set shadowBlur(value: number);
  74295. private _shadowColor;
  74296. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74297. get shadowColor(): string;
  74298. set shadowColor(value: string);
  74299. /** Gets or sets the cursor to use when the control is hovered */
  74300. hoverCursor: string;
  74301. /** @hidden */
  74302. protected _linkOffsetX: ValueAndUnit;
  74303. /** @hidden */
  74304. protected _linkOffsetY: ValueAndUnit;
  74305. /** Gets the control type name */
  74306. get typeName(): string;
  74307. /**
  74308. * Get the current class name of the control.
  74309. * @returns current class name
  74310. */
  74311. getClassName(): string;
  74312. /**
  74313. * An event triggered when pointer wheel is scrolled
  74314. */
  74315. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74316. /**
  74317. * An event triggered when the pointer move over the control.
  74318. */
  74319. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74320. /**
  74321. * An event triggered when the pointer move out of the control.
  74322. */
  74323. onPointerOutObservable: BABYLON.Observable<Control>;
  74324. /**
  74325. * An event triggered when the pointer taps the control
  74326. */
  74327. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74328. /**
  74329. * An event triggered when pointer up
  74330. */
  74331. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74332. /**
  74333. * An event triggered when a control is clicked on
  74334. */
  74335. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74336. /**
  74337. * An event triggered when pointer enters the control
  74338. */
  74339. onPointerEnterObservable: BABYLON.Observable<Control>;
  74340. /**
  74341. * An event triggered when the control is marked as dirty
  74342. */
  74343. onDirtyObservable: BABYLON.Observable<Control>;
  74344. /**
  74345. * An event triggered before drawing the control
  74346. */
  74347. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74348. /**
  74349. * An event triggered after the control was drawn
  74350. */
  74351. onAfterDrawObservable: BABYLON.Observable<Control>;
  74352. /**
  74353. * An event triggered when the control has been disposed
  74354. */
  74355. onDisposeObservable: BABYLON.Observable<Control>;
  74356. /**
  74357. * Get the hosting AdvancedDynamicTexture
  74358. */
  74359. get host(): AdvancedDynamicTexture;
  74360. /** Gets or set information about font offsets (used to render and align text) */
  74361. get fontOffset(): {
  74362. ascent: number;
  74363. height: number;
  74364. descent: number;
  74365. };
  74366. set fontOffset(offset: {
  74367. ascent: number;
  74368. height: number;
  74369. descent: number;
  74370. });
  74371. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74372. get alpha(): number;
  74373. set alpha(value: number);
  74374. /**
  74375. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74376. */
  74377. get isHighlighted(): boolean;
  74378. set isHighlighted(value: boolean);
  74379. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74380. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74381. */
  74382. get scaleX(): number;
  74383. set scaleX(value: number);
  74384. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74385. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74386. */
  74387. get scaleY(): number;
  74388. set scaleY(value: number);
  74389. /** Gets or sets the rotation angle (0 by default)
  74390. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74391. */
  74392. get rotation(): number;
  74393. set rotation(value: number);
  74394. /** Gets or sets the transformation center on Y axis (0 by default)
  74395. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74396. */
  74397. get transformCenterY(): number;
  74398. set transformCenterY(value: number);
  74399. /** Gets or sets the transformation center on X axis (0 by default)
  74400. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74401. */
  74402. get transformCenterX(): number;
  74403. set transformCenterX(value: number);
  74404. /**
  74405. * Gets or sets the horizontal alignment
  74406. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74407. */
  74408. get horizontalAlignment(): number;
  74409. set horizontalAlignment(value: number);
  74410. /**
  74411. * Gets or sets the vertical alignment
  74412. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74413. */
  74414. get verticalAlignment(): number;
  74415. set verticalAlignment(value: number);
  74416. /**
  74417. * Gets or sets control width
  74418. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74419. */
  74420. get width(): string | number;
  74421. set width(value: string | number);
  74422. /**
  74423. * Gets or sets the control width in pixel
  74424. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74425. */
  74426. get widthInPixels(): number;
  74427. set widthInPixels(value: number);
  74428. /**
  74429. * Gets or sets control height
  74430. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74431. */
  74432. get height(): string | number;
  74433. set height(value: string | number);
  74434. /**
  74435. * Gets or sets control height in pixel
  74436. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74437. */
  74438. get heightInPixels(): number;
  74439. set heightInPixels(value: number);
  74440. /** Gets or set font family */
  74441. get fontFamily(): string;
  74442. set fontFamily(value: string);
  74443. /** Gets or sets font style */
  74444. get fontStyle(): string;
  74445. set fontStyle(value: string);
  74446. /** Gets or sets font weight */
  74447. get fontWeight(): string;
  74448. set fontWeight(value: string);
  74449. /**
  74450. * Gets or sets style
  74451. * @see http://doc.babylonjs.com/how_to/gui#styles
  74452. */
  74453. get style(): BABYLON.Nullable<Style>;
  74454. set style(value: BABYLON.Nullable<Style>);
  74455. /** @hidden */
  74456. get _isFontSizeInPercentage(): boolean;
  74457. /** Gets or sets font size in pixels */
  74458. get fontSizeInPixels(): number;
  74459. set fontSizeInPixels(value: number);
  74460. /** Gets or sets font size */
  74461. get fontSize(): string | number;
  74462. set fontSize(value: string | number);
  74463. /** Gets or sets foreground color */
  74464. get color(): string;
  74465. set color(value: string);
  74466. /** Gets or sets z index which is used to reorder controls on the z axis */
  74467. get zIndex(): number;
  74468. set zIndex(value: number);
  74469. /** Gets or sets a boolean indicating if the control can be rendered */
  74470. get notRenderable(): boolean;
  74471. set notRenderable(value: boolean);
  74472. /** Gets or sets a boolean indicating if the control is visible */
  74473. get isVisible(): boolean;
  74474. set isVisible(value: boolean);
  74475. /** Gets a boolean indicating that the control needs to update its rendering */
  74476. get isDirty(): boolean;
  74477. /**
  74478. * Gets the current linked mesh (or null if none)
  74479. */
  74480. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74481. /**
  74482. * Gets or sets a value indicating the padding to use on the left of the control
  74483. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74484. */
  74485. get paddingLeft(): string | number;
  74486. set paddingLeft(value: string | number);
  74487. /**
  74488. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74489. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74490. */
  74491. get paddingLeftInPixels(): number;
  74492. set paddingLeftInPixels(value: number);
  74493. /**
  74494. * Gets or sets a value indicating the padding to use on the right of the control
  74495. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74496. */
  74497. get paddingRight(): string | number;
  74498. set paddingRight(value: string | number);
  74499. /**
  74500. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74501. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74502. */
  74503. get paddingRightInPixels(): number;
  74504. set paddingRightInPixels(value: number);
  74505. /**
  74506. * Gets or sets a value indicating the padding to use on the top of the control
  74507. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74508. */
  74509. get paddingTop(): string | number;
  74510. set paddingTop(value: string | number);
  74511. /**
  74512. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74513. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74514. */
  74515. get paddingTopInPixels(): number;
  74516. set paddingTopInPixels(value: number);
  74517. /**
  74518. * Gets or sets a value indicating the padding to use on the bottom of the control
  74519. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74520. */
  74521. get paddingBottom(): string | number;
  74522. set paddingBottom(value: string | number);
  74523. /**
  74524. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74525. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74526. */
  74527. get paddingBottomInPixels(): number;
  74528. set paddingBottomInPixels(value: number);
  74529. /**
  74530. * Gets or sets a value indicating the left coordinate of the control
  74531. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74532. */
  74533. get left(): string | number;
  74534. set left(value: string | number);
  74535. /**
  74536. * Gets or sets a value indicating the left coordinate in pixels of the control
  74537. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74538. */
  74539. get leftInPixels(): number;
  74540. set leftInPixels(value: number);
  74541. /**
  74542. * Gets or sets a value indicating the top coordinate of the control
  74543. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74544. */
  74545. get top(): string | number;
  74546. set top(value: string | number);
  74547. /**
  74548. * Gets or sets a value indicating the top coordinate in pixels of the control
  74549. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74550. */
  74551. get topInPixels(): number;
  74552. set topInPixels(value: number);
  74553. /**
  74554. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74555. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74556. */
  74557. get linkOffsetX(): string | number;
  74558. set linkOffsetX(value: string | number);
  74559. /**
  74560. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74561. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74562. */
  74563. get linkOffsetXInPixels(): number;
  74564. set linkOffsetXInPixels(value: number);
  74565. /**
  74566. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74567. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74568. */
  74569. get linkOffsetY(): string | number;
  74570. set linkOffsetY(value: string | number);
  74571. /**
  74572. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74573. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74574. */
  74575. get linkOffsetYInPixels(): number;
  74576. set linkOffsetYInPixels(value: number);
  74577. /** Gets the center coordinate on X axis */
  74578. get centerX(): number;
  74579. /** Gets the center coordinate on Y axis */
  74580. get centerY(): number;
  74581. /** Gets or sets if control is Enabled*/
  74582. get isEnabled(): boolean;
  74583. set isEnabled(value: boolean);
  74584. /** Gets or sets background color of control if it's disabled*/
  74585. get disabledColor(): string;
  74586. set disabledColor(value: string);
  74587. /** Gets or sets front color of control if it's disabled*/
  74588. get disabledColorItem(): string;
  74589. set disabledColorItem(value: string);
  74590. /**
  74591. * Creates a new control
  74592. * @param name defines the name of the control
  74593. */
  74594. constructor(
  74595. /** defines the name of the control */
  74596. name?: string | undefined);
  74597. /** @hidden */
  74598. protected _getTypeName(): string;
  74599. /**
  74600. * Gets the first ascendant in the hierarchy of the given type
  74601. * @param className defines the required type
  74602. * @returns the ascendant or null if not found
  74603. */
  74604. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74605. /** @hidden */
  74606. _resetFontCache(): void;
  74607. /**
  74608. * Determines if a container is an ascendant of the current control
  74609. * @param container defines the container to look for
  74610. * @returns true if the container is one of the ascendant of the control
  74611. */
  74612. isAscendant(container: Control): boolean;
  74613. /**
  74614. * Gets coordinates in local control space
  74615. * @param globalCoordinates defines the coordinates to transform
  74616. * @returns the new coordinates in local space
  74617. */
  74618. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74619. /**
  74620. * Gets coordinates in local control space
  74621. * @param globalCoordinates defines the coordinates to transform
  74622. * @param result defines the target vector2 where to store the result
  74623. * @returns the current control
  74624. */
  74625. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74626. /**
  74627. * Gets coordinates in parent local control space
  74628. * @param globalCoordinates defines the coordinates to transform
  74629. * @returns the new coordinates in parent local space
  74630. */
  74631. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74632. /**
  74633. * Move the current control to a vector3 position projected onto the screen.
  74634. * @param position defines the target position
  74635. * @param scene defines the hosting scene
  74636. */
  74637. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74638. /**
  74639. * Will store all controls that have this control as ascendant in a given array
  74640. * @param results defines the array where to store the descendants
  74641. * @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
  74642. * @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
  74643. */
  74644. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74645. /**
  74646. * Will return all controls that have this control as ascendant
  74647. * @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
  74648. * @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
  74649. * @return all child controls
  74650. */
  74651. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74652. /**
  74653. * Link current control with a target mesh
  74654. * @param mesh defines the mesh to link with
  74655. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74656. */
  74657. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74658. /** @hidden */
  74659. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74660. /** @hidden */
  74661. _offsetLeft(offset: number): void;
  74662. /** @hidden */
  74663. _offsetTop(offset: number): void;
  74664. /** @hidden */
  74665. _markMatrixAsDirty(): void;
  74666. /** @hidden */
  74667. _flagDescendantsAsMatrixDirty(): void;
  74668. /** @hidden */
  74669. _intersectsRect(rect: Measure): boolean;
  74670. /** @hidden */
  74671. protected invalidateRect(): void;
  74672. /** @hidden */
  74673. _markAsDirty(force?: boolean): void;
  74674. /** @hidden */
  74675. _markAllAsDirty(): void;
  74676. /** @hidden */
  74677. _link(host: AdvancedDynamicTexture): void;
  74678. /** @hidden */
  74679. protected _transform(context?: CanvasRenderingContext2D): void;
  74680. /** @hidden */
  74681. _renderHighlight(context: CanvasRenderingContext2D): void;
  74682. /** @hidden */
  74683. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74684. /** @hidden */
  74685. protected _applyStates(context: CanvasRenderingContext2D): void;
  74686. /** @hidden */
  74687. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74688. /** @hidden */
  74689. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74690. protected _evaluateClippingState(parentMeasure: Measure): void;
  74691. /** @hidden */
  74692. _measure(): void;
  74693. /** @hidden */
  74694. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74695. /** @hidden */
  74696. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74697. /** @hidden */
  74698. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74699. /** @hidden */
  74700. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74701. private static _ClipMeasure;
  74702. private _tmpMeasureA;
  74703. private _clip;
  74704. /** @hidden */
  74705. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74706. /** @hidden */
  74707. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74708. /**
  74709. * Tests if a given coordinates belong to the current control
  74710. * @param x defines x coordinate to test
  74711. * @param y defines y coordinate to test
  74712. * @returns true if the coordinates are inside the control
  74713. */
  74714. contains(x: number, y: number): boolean;
  74715. /** @hidden */
  74716. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74717. /** @hidden */
  74718. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74719. /** @hidden */
  74720. _onPointerEnter(target: Control): boolean;
  74721. /** @hidden */
  74722. _onPointerOut(target: Control, force?: boolean): void;
  74723. /** @hidden */
  74724. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74725. /** @hidden */
  74726. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74727. /** @hidden */
  74728. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74729. /** @hidden */
  74730. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74731. /** @hidden */
  74732. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74733. private _prepareFont;
  74734. /** Releases associated resources */
  74735. dispose(): void;
  74736. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74737. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74738. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74739. private static _VERTICAL_ALIGNMENT_TOP;
  74740. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74741. private static _VERTICAL_ALIGNMENT_CENTER;
  74742. /** HORIZONTAL_ALIGNMENT_LEFT */
  74743. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74744. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74745. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74746. /** HORIZONTAL_ALIGNMENT_CENTER */
  74747. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74748. /** VERTICAL_ALIGNMENT_TOP */
  74749. static get VERTICAL_ALIGNMENT_TOP(): number;
  74750. /** VERTICAL_ALIGNMENT_BOTTOM */
  74751. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74752. /** VERTICAL_ALIGNMENT_CENTER */
  74753. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74754. private static _FontHeightSizes;
  74755. /** @hidden */
  74756. static _GetFontOffset(font: string): {
  74757. ascent: number;
  74758. height: number;
  74759. descent: number;
  74760. };
  74761. /**
  74762. * Creates a stack panel that can be used to render headers
  74763. * @param control defines the control to associate with the header
  74764. * @param text defines the text of the header
  74765. * @param size defines the size of the header
  74766. * @param options defines options used to configure the header
  74767. * @returns a new StackPanel
  74768. * @ignore
  74769. * @hidden
  74770. */
  74771. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74772. isHorizontal: boolean;
  74773. controlFirst: boolean;
  74774. }) => any;
  74775. /** @hidden */
  74776. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74777. }
  74778. }
  74779. declare module BABYLON.GUI {
  74780. /**
  74781. * Root class for 2D containers
  74782. * @see http://doc.babylonjs.com/how_to/gui#containers
  74783. */
  74784. export class Container extends Control {
  74785. name?: string | undefined;
  74786. /** @hidden */
  74787. _children: Control[];
  74788. /** @hidden */
  74789. protected _measureForChildren: Measure;
  74790. /** @hidden */
  74791. protected _background: string;
  74792. /** @hidden */
  74793. protected _adaptWidthToChildren: boolean;
  74794. /** @hidden */
  74795. protected _adaptHeightToChildren: boolean;
  74796. /**
  74797. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74798. */
  74799. logLayoutCycleErrors: boolean;
  74800. /**
  74801. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74802. */
  74803. maxLayoutCycle: number;
  74804. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74805. get adaptHeightToChildren(): boolean;
  74806. set adaptHeightToChildren(value: boolean);
  74807. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74808. get adaptWidthToChildren(): boolean;
  74809. set adaptWidthToChildren(value: boolean);
  74810. /** Gets or sets background color */
  74811. get background(): string;
  74812. set background(value: string);
  74813. /** Gets the list of children */
  74814. get children(): Control[];
  74815. /**
  74816. * Creates a new Container
  74817. * @param name defines the name of the container
  74818. */
  74819. constructor(name?: string | undefined);
  74820. protected _getTypeName(): string;
  74821. _flagDescendantsAsMatrixDirty(): void;
  74822. /**
  74823. * Gets a child using its name
  74824. * @param name defines the child name to look for
  74825. * @returns the child control if found
  74826. */
  74827. getChildByName(name: string): BABYLON.Nullable<Control>;
  74828. /**
  74829. * Gets a child using its type and its name
  74830. * @param name defines the child name to look for
  74831. * @param type defines the child type to look for
  74832. * @returns the child control if found
  74833. */
  74834. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74835. /**
  74836. * Search for a specific control in children
  74837. * @param control defines the control to look for
  74838. * @returns true if the control is in child list
  74839. */
  74840. containsControl(control: Control): boolean;
  74841. /**
  74842. * Adds a new control to the current container
  74843. * @param control defines the control to add
  74844. * @returns the current container
  74845. */
  74846. addControl(control: BABYLON.Nullable<Control>): Container;
  74847. /**
  74848. * Removes all controls from the current container
  74849. * @returns the current container
  74850. */
  74851. clearControls(): Container;
  74852. /**
  74853. * Removes a control from the current container
  74854. * @param control defines the control to remove
  74855. * @returns the current container
  74856. */
  74857. removeControl(control: Control): Container;
  74858. /** @hidden */
  74859. _reOrderControl(control: Control): void;
  74860. /** @hidden */
  74861. _offsetLeft(offset: number): void;
  74862. /** @hidden */
  74863. _offsetTop(offset: number): void;
  74864. /** @hidden */
  74865. _markAllAsDirty(): void;
  74866. /** @hidden */
  74867. protected _localDraw(context: CanvasRenderingContext2D): void;
  74868. /** @hidden */
  74869. _link(host: AdvancedDynamicTexture): void;
  74870. /** @hidden */
  74871. protected _beforeLayout(): void;
  74872. /** @hidden */
  74873. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74874. /** @hidden */
  74875. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74876. protected _postMeasure(): void;
  74877. /** @hidden */
  74878. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74879. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74880. /** @hidden */
  74881. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74882. /** @hidden */
  74883. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74884. /** Releases associated resources */
  74885. dispose(): void;
  74886. }
  74887. }
  74888. declare module BABYLON.GUI {
  74889. /** Class used to create rectangle container */
  74890. export class Rectangle extends Container {
  74891. name?: string | undefined;
  74892. private _thickness;
  74893. private _cornerRadius;
  74894. /** Gets or sets border thickness */
  74895. get thickness(): number;
  74896. set thickness(value: number);
  74897. /** Gets or sets the corner radius angle */
  74898. get cornerRadius(): number;
  74899. set cornerRadius(value: number);
  74900. /**
  74901. * Creates a new Rectangle
  74902. * @param name defines the control name
  74903. */
  74904. constructor(name?: string | undefined);
  74905. protected _getTypeName(): string;
  74906. protected _localDraw(context: CanvasRenderingContext2D): void;
  74907. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74908. private _drawRoundedRect;
  74909. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74910. }
  74911. }
  74912. declare module BABYLON.GUI {
  74913. /**
  74914. * Enum that determines the text-wrapping mode to use.
  74915. */
  74916. export enum TextWrapping {
  74917. /**
  74918. * Clip the text when it's larger than Control.width; this is the default mode.
  74919. */
  74920. Clip = 0,
  74921. /**
  74922. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74923. */
  74924. WordWrap = 1,
  74925. /**
  74926. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74927. */
  74928. Ellipsis = 2
  74929. }
  74930. /**
  74931. * Class used to create text block control
  74932. */
  74933. export class TextBlock extends Control {
  74934. /**
  74935. * Defines the name of the control
  74936. */
  74937. name?: string | undefined;
  74938. private _text;
  74939. private _textWrapping;
  74940. private _textHorizontalAlignment;
  74941. private _textVerticalAlignment;
  74942. private _lines;
  74943. private _resizeToFit;
  74944. private _lineSpacing;
  74945. private _outlineWidth;
  74946. private _outlineColor;
  74947. /**
  74948. * An event triggered after the text is changed
  74949. */
  74950. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74951. /**
  74952. * An event triggered after the text was broken up into lines
  74953. */
  74954. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74955. /**
  74956. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74957. */
  74958. get lines(): any[];
  74959. /**
  74960. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74961. */
  74962. get resizeToFit(): boolean;
  74963. /**
  74964. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74965. */
  74966. set resizeToFit(value: boolean);
  74967. /**
  74968. * Gets or sets a boolean indicating if text must be wrapped
  74969. */
  74970. get textWrapping(): TextWrapping | boolean;
  74971. /**
  74972. * Gets or sets a boolean indicating if text must be wrapped
  74973. */
  74974. set textWrapping(value: TextWrapping | boolean);
  74975. /**
  74976. * Gets or sets text to display
  74977. */
  74978. get text(): string;
  74979. /**
  74980. * Gets or sets text to display
  74981. */
  74982. set text(value: string);
  74983. /**
  74984. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74985. */
  74986. get textHorizontalAlignment(): number;
  74987. /**
  74988. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74989. */
  74990. set textHorizontalAlignment(value: number);
  74991. /**
  74992. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74993. */
  74994. get textVerticalAlignment(): number;
  74995. /**
  74996. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74997. */
  74998. set textVerticalAlignment(value: number);
  74999. /**
  75000. * Gets or sets line spacing value
  75001. */
  75002. set lineSpacing(value: string | number);
  75003. /**
  75004. * Gets or sets line spacing value
  75005. */
  75006. get lineSpacing(): string | number;
  75007. /**
  75008. * Gets or sets outlineWidth of the text to display
  75009. */
  75010. get outlineWidth(): number;
  75011. /**
  75012. * Gets or sets outlineWidth of the text to display
  75013. */
  75014. set outlineWidth(value: number);
  75015. /**
  75016. * Gets or sets outlineColor of the text to display
  75017. */
  75018. get outlineColor(): string;
  75019. /**
  75020. * Gets or sets outlineColor of the text to display
  75021. */
  75022. set outlineColor(value: string);
  75023. /**
  75024. * Creates a new TextBlock object
  75025. * @param name defines the name of the control
  75026. * @param text defines the text to display (emptry string by default)
  75027. */
  75028. constructor(
  75029. /**
  75030. * Defines the name of the control
  75031. */
  75032. name?: string | undefined, text?: string);
  75033. protected _getTypeName(): string;
  75034. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75035. private _drawText;
  75036. /** @hidden */
  75037. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75038. protected _applyStates(context: CanvasRenderingContext2D): void;
  75039. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75040. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75041. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75042. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75043. protected _renderLines(context: CanvasRenderingContext2D): void;
  75044. /**
  75045. * Given a width constraint applied on the text block, find the expected height
  75046. * @returns expected height
  75047. */
  75048. computeExpectedHeight(): number;
  75049. dispose(): void;
  75050. }
  75051. }
  75052. declare module BABYLON.GUI {
  75053. /**
  75054. * Class used to create 2D images
  75055. */
  75056. export class Image extends Control {
  75057. name?: string | undefined;
  75058. private _workingCanvas;
  75059. private _domImage;
  75060. private _imageWidth;
  75061. private _imageHeight;
  75062. private _loaded;
  75063. private _stretch;
  75064. private _source;
  75065. private _autoScale;
  75066. private _sourceLeft;
  75067. private _sourceTop;
  75068. private _sourceWidth;
  75069. private _sourceHeight;
  75070. private _svgAttributesComputationCompleted;
  75071. private _isSVG;
  75072. private _cellWidth;
  75073. private _cellHeight;
  75074. private _cellId;
  75075. private _populateNinePatchSlicesFromImage;
  75076. private _sliceLeft;
  75077. private _sliceRight;
  75078. private _sliceTop;
  75079. private _sliceBottom;
  75080. private _detectPointerOnOpaqueOnly;
  75081. /**
  75082. * BABYLON.Observable notified when the content is loaded
  75083. */
  75084. onImageLoadedObservable: BABYLON.Observable<Image>;
  75085. /**
  75086. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75087. */
  75088. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75089. /**
  75090. * Gets a boolean indicating that the content is loaded
  75091. */
  75092. get isLoaded(): boolean;
  75093. /**
  75094. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75095. */
  75096. get populateNinePatchSlicesFromImage(): boolean;
  75097. set populateNinePatchSlicesFromImage(value: boolean);
  75098. /**
  75099. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75100. * Beware using this as this will comsume more memory as the image has to be stored twice
  75101. */
  75102. get detectPointerOnOpaqueOnly(): boolean;
  75103. set detectPointerOnOpaqueOnly(value: boolean);
  75104. /**
  75105. * Gets or sets the left value for slicing (9-patch)
  75106. */
  75107. get sliceLeft(): number;
  75108. set sliceLeft(value: number);
  75109. /**
  75110. * Gets or sets the right value for slicing (9-patch)
  75111. */
  75112. get sliceRight(): number;
  75113. set sliceRight(value: number);
  75114. /**
  75115. * Gets or sets the top value for slicing (9-patch)
  75116. */
  75117. get sliceTop(): number;
  75118. set sliceTop(value: number);
  75119. /**
  75120. * Gets or sets the bottom value for slicing (9-patch)
  75121. */
  75122. get sliceBottom(): number;
  75123. set sliceBottom(value: number);
  75124. /**
  75125. * Gets or sets the left coordinate in the source image
  75126. */
  75127. get sourceLeft(): number;
  75128. set sourceLeft(value: number);
  75129. /**
  75130. * Gets or sets the top coordinate in the source image
  75131. */
  75132. get sourceTop(): number;
  75133. set sourceTop(value: number);
  75134. /**
  75135. * Gets or sets the width to capture in the source image
  75136. */
  75137. get sourceWidth(): number;
  75138. set sourceWidth(value: number);
  75139. /**
  75140. * Gets or sets the height to capture in the source image
  75141. */
  75142. get sourceHeight(): number;
  75143. set sourceHeight(value: number);
  75144. /** Indicates if the format of the image is SVG */
  75145. get isSVG(): boolean;
  75146. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75147. get svgAttributesComputationCompleted(): boolean;
  75148. /**
  75149. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75150. * @see http://doc.babylonjs.com/how_to/gui#image
  75151. */
  75152. get autoScale(): boolean;
  75153. set autoScale(value: boolean);
  75154. /** Gets or sets the streching mode used by the image */
  75155. get stretch(): number;
  75156. set stretch(value: number);
  75157. /** @hidden */
  75158. _rotate90(n: number, preserveProperties?: boolean): Image;
  75159. private _handleRotationForSVGImage;
  75160. private _rotate90SourceProperties;
  75161. /**
  75162. * Gets or sets the internal DOM image used to render the control
  75163. */
  75164. set domImage(value: HTMLImageElement);
  75165. get domImage(): HTMLImageElement;
  75166. private _onImageLoaded;
  75167. private _extractNinePatchSliceDataFromImage;
  75168. /**
  75169. * Gets or sets image source url
  75170. */
  75171. set source(value: BABYLON.Nullable<string>);
  75172. /**
  75173. * Checks for svg document with icon id present
  75174. */
  75175. private _svgCheck;
  75176. /**
  75177. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75178. * given external svg file and icon id
  75179. */
  75180. private _getSVGAttribs;
  75181. /**
  75182. * Gets or sets the cell width to use when animation sheet is enabled
  75183. * @see http://doc.babylonjs.com/how_to/gui#image
  75184. */
  75185. get cellWidth(): number;
  75186. set cellWidth(value: number);
  75187. /**
  75188. * Gets or sets the cell height to use when animation sheet is enabled
  75189. * @see http://doc.babylonjs.com/how_to/gui#image
  75190. */
  75191. get cellHeight(): number;
  75192. set cellHeight(value: number);
  75193. /**
  75194. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75195. * @see http://doc.babylonjs.com/how_to/gui#image
  75196. */
  75197. get cellId(): number;
  75198. set cellId(value: number);
  75199. /**
  75200. * Creates a new Image
  75201. * @param name defines the control name
  75202. * @param url defines the image url
  75203. */
  75204. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75205. /**
  75206. * Tests if a given coordinates belong to the current control
  75207. * @param x defines x coordinate to test
  75208. * @param y defines y coordinate to test
  75209. * @returns true if the coordinates are inside the control
  75210. */
  75211. contains(x: number, y: number): boolean;
  75212. protected _getTypeName(): string;
  75213. /** Force the control to synchronize with its content */
  75214. synchronizeSizeWithContent(): void;
  75215. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75216. private _prepareWorkingCanvasForOpaqueDetection;
  75217. private _drawImage;
  75218. _draw(context: CanvasRenderingContext2D): void;
  75219. private _renderCornerPatch;
  75220. private _renderNinePatch;
  75221. dispose(): void;
  75222. /** STRETCH_NONE */
  75223. static readonly STRETCH_NONE: number;
  75224. /** STRETCH_FILL */
  75225. static readonly STRETCH_FILL: number;
  75226. /** STRETCH_UNIFORM */
  75227. static readonly STRETCH_UNIFORM: number;
  75228. /** STRETCH_EXTEND */
  75229. static readonly STRETCH_EXTEND: number;
  75230. /** NINE_PATCH */
  75231. static readonly STRETCH_NINE_PATCH: number;
  75232. }
  75233. }
  75234. declare module BABYLON.GUI {
  75235. /**
  75236. * Class used to create 2D buttons
  75237. */
  75238. export class Button extends Rectangle {
  75239. name?: string | undefined;
  75240. /**
  75241. * Function called to generate a pointer enter animation
  75242. */
  75243. pointerEnterAnimation: () => void;
  75244. /**
  75245. * Function called to generate a pointer out animation
  75246. */
  75247. pointerOutAnimation: () => void;
  75248. /**
  75249. * Function called to generate a pointer down animation
  75250. */
  75251. pointerDownAnimation: () => void;
  75252. /**
  75253. * Function called to generate a pointer up animation
  75254. */
  75255. pointerUpAnimation: () => void;
  75256. /**
  75257. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75258. */
  75259. delegatePickingToChildren: boolean;
  75260. private _image;
  75261. /**
  75262. * Returns the image part of the button (if any)
  75263. */
  75264. get image(): BABYLON.Nullable<Image>;
  75265. private _textBlock;
  75266. /**
  75267. * Returns the image part of the button (if any)
  75268. */
  75269. get textBlock(): BABYLON.Nullable<TextBlock>;
  75270. /**
  75271. * Creates a new Button
  75272. * @param name defines the name of the button
  75273. */
  75274. constructor(name?: string | undefined);
  75275. protected _getTypeName(): string;
  75276. /** @hidden */
  75277. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75278. /** @hidden */
  75279. _onPointerEnter(target: Control): boolean;
  75280. /** @hidden */
  75281. _onPointerOut(target: Control, force?: boolean): void;
  75282. /** @hidden */
  75283. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75284. /** @hidden */
  75285. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75286. /**
  75287. * Creates a new button made with an image and a text
  75288. * @param name defines the name of the button
  75289. * @param text defines the text of the button
  75290. * @param imageUrl defines the url of the image
  75291. * @returns a new Button
  75292. */
  75293. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75294. /**
  75295. * Creates a new button made with an image
  75296. * @param name defines the name of the button
  75297. * @param imageUrl defines the url of the image
  75298. * @returns a new Button
  75299. */
  75300. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75301. /**
  75302. * Creates a new button made with a text
  75303. * @param name defines the name of the button
  75304. * @param text defines the text of the button
  75305. * @returns a new Button
  75306. */
  75307. static CreateSimpleButton(name: string, text: string): Button;
  75308. /**
  75309. * Creates a new button made with an image and a centered text
  75310. * @param name defines the name of the button
  75311. * @param text defines the text of the button
  75312. * @param imageUrl defines the url of the image
  75313. * @returns a new Button
  75314. */
  75315. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75316. }
  75317. }
  75318. declare module BABYLON.GUI {
  75319. /**
  75320. * Class used to create a 2D stack panel container
  75321. */
  75322. export class StackPanel extends Container {
  75323. name?: string | undefined;
  75324. private _isVertical;
  75325. private _manualWidth;
  75326. private _manualHeight;
  75327. private _doNotTrackManualChanges;
  75328. /**
  75329. * Gets or sets a boolean indicating that layou warnings should be ignored
  75330. */
  75331. ignoreLayoutWarnings: boolean;
  75332. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75333. get isVertical(): boolean;
  75334. set isVertical(value: boolean);
  75335. /**
  75336. * Gets or sets panel width.
  75337. * This value should not be set when in horizontal mode as it will be computed automatically
  75338. */
  75339. set width(value: string | number);
  75340. get width(): string | number;
  75341. /**
  75342. * Gets or sets panel height.
  75343. * This value should not be set when in vertical mode as it will be computed automatically
  75344. */
  75345. set height(value: string | number);
  75346. get height(): string | number;
  75347. /**
  75348. * Creates a new StackPanel
  75349. * @param name defines control name
  75350. */
  75351. constructor(name?: string | undefined);
  75352. protected _getTypeName(): string;
  75353. /** @hidden */
  75354. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75355. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75356. protected _postMeasure(): void;
  75357. }
  75358. }
  75359. declare module BABYLON.GUI {
  75360. /**
  75361. * Class used to represent a 2D checkbox
  75362. */
  75363. export class Checkbox extends Control {
  75364. name?: string | undefined;
  75365. private _isChecked;
  75366. private _background;
  75367. private _checkSizeRatio;
  75368. private _thickness;
  75369. /** Gets or sets border thickness */
  75370. get thickness(): number;
  75371. set thickness(value: number);
  75372. /**
  75373. * BABYLON.Observable raised when isChecked property changes
  75374. */
  75375. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75376. /** Gets or sets a value indicating the ratio between overall size and check size */
  75377. get checkSizeRatio(): number;
  75378. set checkSizeRatio(value: number);
  75379. /** Gets or sets background color */
  75380. get background(): string;
  75381. set background(value: string);
  75382. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75383. get isChecked(): boolean;
  75384. set isChecked(value: boolean);
  75385. /**
  75386. * Creates a new CheckBox
  75387. * @param name defines the control name
  75388. */
  75389. constructor(name?: string | undefined);
  75390. protected _getTypeName(): string;
  75391. /** @hidden */
  75392. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75393. /** @hidden */
  75394. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75395. /**
  75396. * Utility function to easily create a checkbox with a header
  75397. * @param title defines the label to use for the header
  75398. * @param onValueChanged defines the callback to call when value changes
  75399. * @returns a StackPanel containing the checkbox and a textBlock
  75400. */
  75401. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75402. }
  75403. }
  75404. declare module BABYLON.GUI {
  75405. /**
  75406. * Class used to store key control properties
  75407. */
  75408. export class KeyPropertySet {
  75409. /** Width */
  75410. width?: string;
  75411. /** Height */
  75412. height?: string;
  75413. /** Left padding */
  75414. paddingLeft?: string;
  75415. /** Right padding */
  75416. paddingRight?: string;
  75417. /** Top padding */
  75418. paddingTop?: string;
  75419. /** Bottom padding */
  75420. paddingBottom?: string;
  75421. /** Foreground color */
  75422. color?: string;
  75423. /** Background color */
  75424. background?: string;
  75425. }
  75426. /**
  75427. * Class used to create virtual keyboard
  75428. */
  75429. export class VirtualKeyboard extends StackPanel {
  75430. /** BABYLON.Observable raised when a key is pressed */
  75431. onKeyPressObservable: BABYLON.Observable<string>;
  75432. /** Gets or sets default key button width */
  75433. defaultButtonWidth: string;
  75434. /** Gets or sets default key button height */
  75435. defaultButtonHeight: string;
  75436. /** Gets or sets default key button left padding */
  75437. defaultButtonPaddingLeft: string;
  75438. /** Gets or sets default key button right padding */
  75439. defaultButtonPaddingRight: string;
  75440. /** Gets or sets default key button top padding */
  75441. defaultButtonPaddingTop: string;
  75442. /** Gets or sets default key button bottom padding */
  75443. defaultButtonPaddingBottom: string;
  75444. /** Gets or sets default key button foreground color */
  75445. defaultButtonColor: string;
  75446. /** Gets or sets default key button background color */
  75447. defaultButtonBackground: string;
  75448. /** Gets or sets shift button foreground color */
  75449. shiftButtonColor: string;
  75450. /** Gets or sets shift button thickness*/
  75451. selectedShiftThickness: number;
  75452. /** Gets shift key state */
  75453. shiftState: number;
  75454. protected _getTypeName(): string;
  75455. private _createKey;
  75456. /**
  75457. * Adds a new row of keys
  75458. * @param keys defines the list of keys to add
  75459. * @param propertySets defines the associated property sets
  75460. */
  75461. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75462. /**
  75463. * Set the shift key to a specific state
  75464. * @param shiftState defines the new shift state
  75465. */
  75466. applyShiftState(shiftState: number): void;
  75467. private _currentlyConnectedInputText;
  75468. private _connectedInputTexts;
  75469. private _onKeyPressObserver;
  75470. /** Gets the input text control currently attached to the keyboard */
  75471. get connectedInputText(): BABYLON.Nullable<InputText>;
  75472. /**
  75473. * Connects the keyboard with an input text control
  75474. *
  75475. * @param input defines the target control
  75476. */
  75477. connect(input: InputText): void;
  75478. /**
  75479. * Disconnects the keyboard from connected InputText controls
  75480. *
  75481. * @param input optionally defines a target control, otherwise all are disconnected
  75482. */
  75483. disconnect(input?: InputText): void;
  75484. private _removeConnectedInputObservables;
  75485. /**
  75486. * Release all resources
  75487. */
  75488. dispose(): void;
  75489. /**
  75490. * Creates a new keyboard using a default layout
  75491. *
  75492. * @param name defines control name
  75493. * @returns a new VirtualKeyboard
  75494. */
  75495. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75496. }
  75497. }
  75498. declare module BABYLON.GUI {
  75499. /**
  75500. * Class used to create input text control
  75501. */
  75502. export class InputText extends Control implements IFocusableControl {
  75503. name?: string | undefined;
  75504. private _text;
  75505. private _placeholderText;
  75506. private _background;
  75507. private _focusedBackground;
  75508. private _focusedColor;
  75509. private _placeholderColor;
  75510. private _thickness;
  75511. private _margin;
  75512. private _autoStretchWidth;
  75513. private _maxWidth;
  75514. private _isFocused;
  75515. private _blinkTimeout;
  75516. private _blinkIsEven;
  75517. private _cursorOffset;
  75518. private _scrollLeft;
  75519. private _textWidth;
  75520. private _clickedCoordinate;
  75521. private _deadKey;
  75522. private _addKey;
  75523. private _currentKey;
  75524. private _isTextHighlightOn;
  75525. private _textHighlightColor;
  75526. private _highligherOpacity;
  75527. private _highlightedText;
  75528. private _startHighlightIndex;
  75529. private _endHighlightIndex;
  75530. private _cursorIndex;
  75531. private _onFocusSelectAll;
  75532. private _isPointerDown;
  75533. private _onClipboardObserver;
  75534. private _onPointerDblTapObserver;
  75535. /** @hidden */
  75536. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75537. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75538. promptMessage: string;
  75539. /** Force disable prompt on mobile device */
  75540. disableMobilePrompt: boolean;
  75541. /** BABYLON.Observable raised when the text changes */
  75542. onTextChangedObservable: BABYLON.Observable<InputText>;
  75543. /** BABYLON.Observable raised just before an entered character is to be added */
  75544. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75545. /** BABYLON.Observable raised when the control gets the focus */
  75546. onFocusObservable: BABYLON.Observable<InputText>;
  75547. /** BABYLON.Observable raised when the control loses the focus */
  75548. onBlurObservable: BABYLON.Observable<InputText>;
  75549. /**Observable raised when the text is highlighted */
  75550. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75551. /**Observable raised when copy event is triggered */
  75552. onTextCopyObservable: BABYLON.Observable<InputText>;
  75553. /** BABYLON.Observable raised when cut event is triggered */
  75554. onTextCutObservable: BABYLON.Observable<InputText>;
  75555. /** BABYLON.Observable raised when paste event is triggered */
  75556. onTextPasteObservable: BABYLON.Observable<InputText>;
  75557. /** BABYLON.Observable raised when a key event was processed */
  75558. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75559. /** Gets or sets the maximum width allowed by the control */
  75560. get maxWidth(): string | number;
  75561. /** Gets the maximum width allowed by the control in pixels */
  75562. get maxWidthInPixels(): number;
  75563. set maxWidth(value: string | number);
  75564. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75565. get highligherOpacity(): number;
  75566. set highligherOpacity(value: number);
  75567. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75568. get onFocusSelectAll(): boolean;
  75569. set onFocusSelectAll(value: boolean);
  75570. /** Gets or sets the text hightlight color */
  75571. get textHighlightColor(): string;
  75572. set textHighlightColor(value: string);
  75573. /** Gets or sets control margin */
  75574. get margin(): string;
  75575. /** Gets control margin in pixels */
  75576. get marginInPixels(): number;
  75577. set margin(value: string);
  75578. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75579. get autoStretchWidth(): boolean;
  75580. set autoStretchWidth(value: boolean);
  75581. /** Gets or sets border thickness */
  75582. get thickness(): number;
  75583. set thickness(value: number);
  75584. /** Gets or sets the background color when focused */
  75585. get focusedBackground(): string;
  75586. set focusedBackground(value: string);
  75587. /** Gets or sets the background color when focused */
  75588. get focusedColor(): string;
  75589. set focusedColor(value: string);
  75590. /** Gets or sets the background color */
  75591. get background(): string;
  75592. set background(value: string);
  75593. /** Gets or sets the placeholder color */
  75594. get placeholderColor(): string;
  75595. set placeholderColor(value: string);
  75596. /** Gets or sets the text displayed when the control is empty */
  75597. get placeholderText(): string;
  75598. set placeholderText(value: string);
  75599. /** Gets or sets the dead key flag */
  75600. get deadKey(): boolean;
  75601. set deadKey(flag: boolean);
  75602. /** Gets or sets the highlight text */
  75603. get highlightedText(): string;
  75604. set highlightedText(text: string);
  75605. /** Gets or sets if the current key should be added */
  75606. get addKey(): boolean;
  75607. set addKey(flag: boolean);
  75608. /** Gets or sets the value of the current key being entered */
  75609. get currentKey(): string;
  75610. set currentKey(key: string);
  75611. /** Gets or sets the text displayed in the control */
  75612. get text(): string;
  75613. set text(value: string);
  75614. /** Gets or sets control width */
  75615. get width(): string | number;
  75616. set width(value: string | number);
  75617. /**
  75618. * Creates a new InputText
  75619. * @param name defines the control name
  75620. * @param text defines the text of the control
  75621. */
  75622. constructor(name?: string | undefined, text?: string);
  75623. /** @hidden */
  75624. onBlur(): void;
  75625. /** @hidden */
  75626. onFocus(): void;
  75627. protected _getTypeName(): string;
  75628. /**
  75629. * Function called to get the list of controls that should not steal the focus from this control
  75630. * @returns an array of controls
  75631. */
  75632. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75633. /** @hidden */
  75634. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75635. /** @hidden */
  75636. private _updateValueFromCursorIndex;
  75637. /** @hidden */
  75638. private _processDblClick;
  75639. /** @hidden */
  75640. private _selectAllText;
  75641. /**
  75642. * Handles the keyboard event
  75643. * @param evt Defines the KeyboardEvent
  75644. */
  75645. processKeyboard(evt: KeyboardEvent): void;
  75646. /** @hidden */
  75647. private _onCopyText;
  75648. /** @hidden */
  75649. private _onCutText;
  75650. /** @hidden */
  75651. private _onPasteText;
  75652. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75653. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75654. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75655. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75656. protected _beforeRenderText(text: string): string;
  75657. dispose(): void;
  75658. }
  75659. }
  75660. declare module BABYLON.GUI {
  75661. /**
  75662. * Class used to create a 2D grid container
  75663. */
  75664. export class Grid extends Container {
  75665. name?: string | undefined;
  75666. private _rowDefinitions;
  75667. private _columnDefinitions;
  75668. private _cells;
  75669. private _childControls;
  75670. /**
  75671. * Gets the number of columns
  75672. */
  75673. get columnCount(): number;
  75674. /**
  75675. * Gets the number of rows
  75676. */
  75677. get rowCount(): number;
  75678. /** Gets the list of children */
  75679. get children(): Control[];
  75680. /** Gets the list of cells (e.g. the containers) */
  75681. get cells(): {
  75682. [key: string]: Container;
  75683. };
  75684. /**
  75685. * Gets the definition of a specific row
  75686. * @param index defines the index of the row
  75687. * @returns the row definition
  75688. */
  75689. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75690. /**
  75691. * Gets the definition of a specific column
  75692. * @param index defines the index of the column
  75693. * @returns the column definition
  75694. */
  75695. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75696. /**
  75697. * Adds a new row to the grid
  75698. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75699. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75700. * @returns the current grid
  75701. */
  75702. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75703. /**
  75704. * Adds a new column to the grid
  75705. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75706. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75707. * @returns the current grid
  75708. */
  75709. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75710. /**
  75711. * Update a row definition
  75712. * @param index defines the index of the row to update
  75713. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75714. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75715. * @returns the current grid
  75716. */
  75717. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75718. /**
  75719. * Update a column definition
  75720. * @param index defines the index of the column to update
  75721. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75722. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75723. * @returns the current grid
  75724. */
  75725. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75726. /**
  75727. * Gets the list of children stored in a specific cell
  75728. * @param row defines the row to check
  75729. * @param column defines the column to check
  75730. * @returns the list of controls
  75731. */
  75732. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75733. /**
  75734. * Gets a string representing the child cell info (row x column)
  75735. * @param child defines the control to get info from
  75736. * @returns a string containing the child cell info (row x column)
  75737. */
  75738. getChildCellInfo(child: Control): string;
  75739. private _removeCell;
  75740. private _offsetCell;
  75741. /**
  75742. * Remove a column definition at specified index
  75743. * @param index defines the index of the column to remove
  75744. * @returns the current grid
  75745. */
  75746. removeColumnDefinition(index: number): Grid;
  75747. /**
  75748. * Remove a row definition at specified index
  75749. * @param index defines the index of the row to remove
  75750. * @returns the current grid
  75751. */
  75752. removeRowDefinition(index: number): Grid;
  75753. /**
  75754. * Adds a new control to the current grid
  75755. * @param control defines the control to add
  75756. * @param row defines the row where to add the control (0 by default)
  75757. * @param column defines the column where to add the control (0 by default)
  75758. * @returns the current grid
  75759. */
  75760. addControl(control: Control, row?: number, column?: number): Grid;
  75761. /**
  75762. * Removes a control from the current container
  75763. * @param control defines the control to remove
  75764. * @returns the current container
  75765. */
  75766. removeControl(control: Control): Container;
  75767. /**
  75768. * Creates a new Grid
  75769. * @param name defines control name
  75770. */
  75771. constructor(name?: string | undefined);
  75772. protected _getTypeName(): string;
  75773. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75774. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75775. _flagDescendantsAsMatrixDirty(): void;
  75776. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75777. /** Releases associated resources */
  75778. dispose(): void;
  75779. }
  75780. }
  75781. declare module BABYLON.GUI {
  75782. /** Class used to create color pickers */
  75783. export class ColorPicker extends Control {
  75784. name?: string | undefined;
  75785. private static _Epsilon;
  75786. private _colorWheelCanvas;
  75787. private _value;
  75788. private _tmpColor;
  75789. private _pointerStartedOnSquare;
  75790. private _pointerStartedOnWheel;
  75791. private _squareLeft;
  75792. private _squareTop;
  75793. private _squareSize;
  75794. private _h;
  75795. private _s;
  75796. private _v;
  75797. private _lastPointerDownID;
  75798. /**
  75799. * BABYLON.Observable raised when the value changes
  75800. */
  75801. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75802. /** Gets or sets the color of the color picker */
  75803. get value(): BABYLON.Color3;
  75804. set value(value: BABYLON.Color3);
  75805. /**
  75806. * Gets or sets control width
  75807. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75808. */
  75809. get width(): string | number;
  75810. set width(value: string | number);
  75811. /**
  75812. * Gets or sets control height
  75813. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75814. */
  75815. get height(): string | number;
  75816. /** Gets or sets control height */
  75817. set height(value: string | number);
  75818. /** Gets or sets control size */
  75819. get size(): string | number;
  75820. set size(value: string | number);
  75821. /**
  75822. * Creates a new ColorPicker
  75823. * @param name defines the control name
  75824. */
  75825. constructor(name?: string | undefined);
  75826. protected _getTypeName(): string;
  75827. /** @hidden */
  75828. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75829. private _updateSquareProps;
  75830. private _drawGradientSquare;
  75831. private _drawCircle;
  75832. private _createColorWheelCanvas;
  75833. /** @hidden */
  75834. _draw(context: CanvasRenderingContext2D): void;
  75835. private _pointerIsDown;
  75836. private _updateValueFromPointer;
  75837. private _isPointOnSquare;
  75838. private _isPointOnWheel;
  75839. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75840. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75841. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75842. /**
  75843. * This function expands the color picker by creating a color picker dialog with manual
  75844. * color value input and the ability to save colors into an array to be used later in
  75845. * subsequent launches of the dialogue.
  75846. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75847. * @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.
  75848. * @returns picked color as a hex string and the saved colors array as hex strings.
  75849. */
  75850. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75851. pickerWidth?: string;
  75852. pickerHeight?: string;
  75853. headerHeight?: string;
  75854. lastColor?: string;
  75855. swatchLimit?: number;
  75856. numSwatchesPerLine?: number;
  75857. savedColors?: Array<string>;
  75858. }): Promise<{
  75859. savedColors?: string[];
  75860. pickedColor: string;
  75861. }>;
  75862. }
  75863. }
  75864. declare module BABYLON.GUI {
  75865. /** Class used to create 2D ellipse containers */
  75866. export class Ellipse extends Container {
  75867. name?: string | undefined;
  75868. private _thickness;
  75869. /** Gets or sets border thickness */
  75870. get thickness(): number;
  75871. set thickness(value: number);
  75872. /**
  75873. * Creates a new Ellipse
  75874. * @param name defines the control name
  75875. */
  75876. constructor(name?: string | undefined);
  75877. protected _getTypeName(): string;
  75878. protected _localDraw(context: CanvasRenderingContext2D): void;
  75879. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75880. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75881. }
  75882. }
  75883. declare module BABYLON.GUI {
  75884. /**
  75885. * Class used to create a password control
  75886. */
  75887. export class InputPassword extends InputText {
  75888. protected _beforeRenderText(text: string): string;
  75889. }
  75890. }
  75891. declare module BABYLON.GUI {
  75892. /** Class used to render 2D lines */
  75893. export class Line extends Control {
  75894. name?: string | undefined;
  75895. private _lineWidth;
  75896. private _x1;
  75897. private _y1;
  75898. private _x2;
  75899. private _y2;
  75900. private _dash;
  75901. private _connectedControl;
  75902. private _connectedControlDirtyObserver;
  75903. /** Gets or sets the dash pattern */
  75904. get dash(): Array<number>;
  75905. set dash(value: Array<number>);
  75906. /** Gets or sets the control connected with the line end */
  75907. get connectedControl(): Control;
  75908. set connectedControl(value: Control);
  75909. /** Gets or sets start coordinates on X axis */
  75910. get x1(): string | number;
  75911. set x1(value: string | number);
  75912. /** Gets or sets start coordinates on Y axis */
  75913. get y1(): string | number;
  75914. set y1(value: string | number);
  75915. /** Gets or sets end coordinates on X axis */
  75916. get x2(): string | number;
  75917. set x2(value: string | number);
  75918. /** Gets or sets end coordinates on Y axis */
  75919. get y2(): string | number;
  75920. set y2(value: string | number);
  75921. /** Gets or sets line width */
  75922. get lineWidth(): number;
  75923. set lineWidth(value: number);
  75924. /** Gets or sets horizontal alignment */
  75925. set horizontalAlignment(value: number);
  75926. /** Gets or sets vertical alignment */
  75927. set verticalAlignment(value: number);
  75928. private get _effectiveX2();
  75929. private get _effectiveY2();
  75930. /**
  75931. * Creates a new Line
  75932. * @param name defines the control name
  75933. */
  75934. constructor(name?: string | undefined);
  75935. protected _getTypeName(): string;
  75936. _draw(context: CanvasRenderingContext2D): void;
  75937. _measure(): void;
  75938. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75939. /**
  75940. * Move one end of the line given 3D cartesian coordinates.
  75941. * @param position Targeted world position
  75942. * @param scene BABYLON.Scene
  75943. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75944. */
  75945. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75946. /**
  75947. * Move one end of the line to a position in screen absolute space.
  75948. * @param projectedPosition Position in screen absolute space (X, Y)
  75949. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75950. */
  75951. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75952. }
  75953. }
  75954. declare module BABYLON.GUI {
  75955. /**
  75956. * Class used to store a point for a MultiLine object.
  75957. * The point can be pure 2D coordinates, a mesh or a control
  75958. */
  75959. export class MultiLinePoint {
  75960. private _multiLine;
  75961. private _x;
  75962. private _y;
  75963. private _control;
  75964. private _mesh;
  75965. private _controlObserver;
  75966. private _meshObserver;
  75967. /** @hidden */
  75968. _point: BABYLON.Vector2;
  75969. /**
  75970. * Creates a new MultiLinePoint
  75971. * @param multiLine defines the source MultiLine object
  75972. */
  75973. constructor(multiLine: MultiLine);
  75974. /** Gets or sets x coordinate */
  75975. get x(): string | number;
  75976. set x(value: string | number);
  75977. /** Gets or sets y coordinate */
  75978. get y(): string | number;
  75979. set y(value: string | number);
  75980. /** Gets or sets the control associated with this point */
  75981. get control(): BABYLON.Nullable<Control>;
  75982. set control(value: BABYLON.Nullable<Control>);
  75983. /** Gets or sets the mesh associated with this point */
  75984. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75985. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75986. /** Resets links */
  75987. resetLinks(): void;
  75988. /**
  75989. * Gets a translation vector
  75990. * @returns the translation vector
  75991. */
  75992. translate(): BABYLON.Vector2;
  75993. private _translatePoint;
  75994. /** Release associated resources */
  75995. dispose(): void;
  75996. }
  75997. }
  75998. declare module BABYLON.GUI {
  75999. /**
  76000. * Class used to create multi line control
  76001. */
  76002. export class MultiLine extends Control {
  76003. name?: string | undefined;
  76004. private _lineWidth;
  76005. private _dash;
  76006. private _points;
  76007. private _minX;
  76008. private _minY;
  76009. private _maxX;
  76010. private _maxY;
  76011. /**
  76012. * Creates a new MultiLine
  76013. * @param name defines the control name
  76014. */
  76015. constructor(name?: string | undefined);
  76016. /** Gets or sets dash pattern */
  76017. get dash(): Array<number>;
  76018. set dash(value: Array<number>);
  76019. /**
  76020. * Gets point stored at specified index
  76021. * @param index defines the index to look for
  76022. * @returns the requested point if found
  76023. */
  76024. getAt(index: number): MultiLinePoint;
  76025. /** Function called when a point is updated */
  76026. onPointUpdate: () => void;
  76027. /**
  76028. * Adds new points to the point collection
  76029. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76030. * @returns the list of created MultiLinePoint
  76031. */
  76032. add(...items: (AbstractMesh | Control | {
  76033. x: string | number;
  76034. y: string | number;
  76035. })[]): MultiLinePoint[];
  76036. /**
  76037. * Adds a new point to the point collection
  76038. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76039. * @returns the created MultiLinePoint
  76040. */
  76041. push(item?: (AbstractMesh | Control | {
  76042. x: string | number;
  76043. y: string | number;
  76044. })): MultiLinePoint;
  76045. /**
  76046. * Remove a specific value or point from the active point collection
  76047. * @param value defines the value or point to remove
  76048. */
  76049. remove(value: number | MultiLinePoint): void;
  76050. /**
  76051. * Resets this object to initial state (no point)
  76052. */
  76053. reset(): void;
  76054. /**
  76055. * Resets all links
  76056. */
  76057. resetLinks(): void;
  76058. /** Gets or sets line width */
  76059. get lineWidth(): number;
  76060. set lineWidth(value: number);
  76061. set horizontalAlignment(value: number);
  76062. set verticalAlignment(value: number);
  76063. protected _getTypeName(): string;
  76064. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76065. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76066. _measure(): void;
  76067. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76068. dispose(): void;
  76069. }
  76070. }
  76071. declare module BABYLON.GUI {
  76072. /**
  76073. * Class used to create radio button controls
  76074. */
  76075. export class RadioButton extends Control {
  76076. name?: string | undefined;
  76077. private _isChecked;
  76078. private _background;
  76079. private _checkSizeRatio;
  76080. private _thickness;
  76081. /** Gets or sets border thickness */
  76082. get thickness(): number;
  76083. set thickness(value: number);
  76084. /** Gets or sets group name */
  76085. group: string;
  76086. /** BABYLON.Observable raised when isChecked is changed */
  76087. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76088. /** Gets or sets a value indicating the ratio between overall size and check size */
  76089. get checkSizeRatio(): number;
  76090. set checkSizeRatio(value: number);
  76091. /** Gets or sets background color */
  76092. get background(): string;
  76093. set background(value: string);
  76094. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76095. get isChecked(): boolean;
  76096. set isChecked(value: boolean);
  76097. /**
  76098. * Creates a new RadioButton
  76099. * @param name defines the control name
  76100. */
  76101. constructor(name?: string | undefined);
  76102. protected _getTypeName(): string;
  76103. _draw(context: CanvasRenderingContext2D): void;
  76104. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76105. /**
  76106. * Utility function to easily create a radio button with a header
  76107. * @param title defines the label to use for the header
  76108. * @param group defines the group to use for the radio button
  76109. * @param isChecked defines the initial state of the radio button
  76110. * @param onValueChanged defines the callback to call when value changes
  76111. * @returns a StackPanel containing the radio button and a textBlock
  76112. */
  76113. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76114. }
  76115. }
  76116. declare module BABYLON.GUI {
  76117. /**
  76118. * Class used to create slider controls
  76119. */
  76120. export class BaseSlider extends Control {
  76121. name?: string | undefined;
  76122. protected _thumbWidth: ValueAndUnit;
  76123. private _minimum;
  76124. private _maximum;
  76125. private _value;
  76126. private _isVertical;
  76127. protected _barOffset: ValueAndUnit;
  76128. private _isThumbClamped;
  76129. protected _displayThumb: boolean;
  76130. private _step;
  76131. private _lastPointerDownID;
  76132. protected _effectiveBarOffset: number;
  76133. protected _renderLeft: number;
  76134. protected _renderTop: number;
  76135. protected _renderWidth: number;
  76136. protected _renderHeight: number;
  76137. protected _backgroundBoxLength: number;
  76138. protected _backgroundBoxThickness: number;
  76139. protected _effectiveThumbThickness: number;
  76140. /** BABYLON.Observable raised when the sldier value changes */
  76141. onValueChangedObservable: BABYLON.Observable<number>;
  76142. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76143. get displayThumb(): boolean;
  76144. set displayThumb(value: boolean);
  76145. /** Gets or sets a step to apply to values (0 by default) */
  76146. get step(): number;
  76147. set step(value: number);
  76148. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76149. get barOffset(): string | number;
  76150. /** Gets main bar offset in pixels*/
  76151. get barOffsetInPixels(): number;
  76152. set barOffset(value: string | number);
  76153. /** Gets or sets thumb width */
  76154. get thumbWidth(): string | number;
  76155. /** Gets thumb width in pixels */
  76156. get thumbWidthInPixels(): number;
  76157. set thumbWidth(value: string | number);
  76158. /** Gets or sets minimum value */
  76159. get minimum(): number;
  76160. set minimum(value: number);
  76161. /** Gets or sets maximum value */
  76162. get maximum(): number;
  76163. set maximum(value: number);
  76164. /** Gets or sets current value */
  76165. get value(): number;
  76166. set value(value: number);
  76167. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76168. get isVertical(): boolean;
  76169. set isVertical(value: boolean);
  76170. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76171. get isThumbClamped(): boolean;
  76172. set isThumbClamped(value: boolean);
  76173. /**
  76174. * Creates a new BaseSlider
  76175. * @param name defines the control name
  76176. */
  76177. constructor(name?: string | undefined);
  76178. protected _getTypeName(): string;
  76179. protected _getThumbPosition(): number;
  76180. protected _getThumbThickness(type: string): number;
  76181. protected _prepareRenderingData(type: string): void;
  76182. private _pointerIsDown;
  76183. /** @hidden */
  76184. protected _updateValueFromPointer(x: number, y: number): void;
  76185. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76186. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76187. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76188. }
  76189. }
  76190. declare module BABYLON.GUI {
  76191. /**
  76192. * Class used to create slider controls
  76193. */
  76194. export class Slider extends BaseSlider {
  76195. name?: string | undefined;
  76196. private _background;
  76197. private _borderColor;
  76198. private _isThumbCircle;
  76199. protected _displayValueBar: boolean;
  76200. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76201. get displayValueBar(): boolean;
  76202. set displayValueBar(value: boolean);
  76203. /** Gets or sets border color */
  76204. get borderColor(): string;
  76205. set borderColor(value: string);
  76206. /** Gets or sets background color */
  76207. get background(): string;
  76208. set background(value: string);
  76209. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76210. get isThumbCircle(): boolean;
  76211. set isThumbCircle(value: boolean);
  76212. /**
  76213. * Creates a new Slider
  76214. * @param name defines the control name
  76215. */
  76216. constructor(name?: string | undefined);
  76217. protected _getTypeName(): string;
  76218. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76219. }
  76220. }
  76221. declare module BABYLON.GUI {
  76222. /** Class used to create a RadioGroup
  76223. * which contains groups of radio buttons
  76224. */
  76225. export class SelectorGroup {
  76226. /** name of SelectorGroup */
  76227. name: string;
  76228. private _groupPanel;
  76229. private _selectors;
  76230. private _groupHeader;
  76231. /**
  76232. * Creates a new SelectorGroup
  76233. * @param name of group, used as a group heading
  76234. */
  76235. constructor(
  76236. /** name of SelectorGroup */
  76237. name: string);
  76238. /** Gets the groupPanel of the SelectorGroup */
  76239. get groupPanel(): StackPanel;
  76240. /** Gets the selectors array */
  76241. get selectors(): StackPanel[];
  76242. /** Gets and sets the group header */
  76243. get header(): string;
  76244. set header(label: string);
  76245. /** @hidden */
  76246. private _addGroupHeader;
  76247. /** @hidden*/
  76248. _getSelector(selectorNb: number): StackPanel | undefined;
  76249. /** Removes the selector at the given position
  76250. * @param selectorNb the position of the selector within the group
  76251. */
  76252. removeSelector(selectorNb: number): void;
  76253. }
  76254. /** Class used to create a CheckboxGroup
  76255. * which contains groups of checkbox buttons
  76256. */
  76257. export class CheckboxGroup extends SelectorGroup {
  76258. /** Adds a checkbox as a control
  76259. * @param text is the label for the selector
  76260. * @param func is the function called when the Selector is checked
  76261. * @param checked is true when Selector is checked
  76262. */
  76263. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76264. /** @hidden */
  76265. _setSelectorLabel(selectorNb: number, label: string): void;
  76266. /** @hidden */
  76267. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76268. /** @hidden */
  76269. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76270. /** @hidden */
  76271. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76272. }
  76273. /** Class used to create a RadioGroup
  76274. * which contains groups of radio buttons
  76275. */
  76276. export class RadioGroup extends SelectorGroup {
  76277. private _selectNb;
  76278. /** Adds a radio button as a control
  76279. * @param label is the label for the selector
  76280. * @param func is the function called when the Selector is checked
  76281. * @param checked is true when Selector is checked
  76282. */
  76283. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76284. /** @hidden */
  76285. _setSelectorLabel(selectorNb: number, label: string): void;
  76286. /** @hidden */
  76287. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76288. /** @hidden */
  76289. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76290. /** @hidden */
  76291. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76292. }
  76293. /** Class used to create a SliderGroup
  76294. * which contains groups of slider buttons
  76295. */
  76296. export class SliderGroup extends SelectorGroup {
  76297. /**
  76298. * Adds a slider to the SelectorGroup
  76299. * @param label is the label for the SliderBar
  76300. * @param func is the function called when the Slider moves
  76301. * @param unit is a string describing the units used, eg degrees or metres
  76302. * @param min is the minimum value for the Slider
  76303. * @param max is the maximum value for the Slider
  76304. * @param value is the start value for the Slider between min and max
  76305. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76306. */
  76307. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76308. /** @hidden */
  76309. _setSelectorLabel(selectorNb: number, label: string): void;
  76310. /** @hidden */
  76311. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76312. /** @hidden */
  76313. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76314. /** @hidden */
  76315. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76316. }
  76317. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76318. * @see http://doc.babylonjs.com/how_to/selector
  76319. */
  76320. export class SelectionPanel extends Rectangle {
  76321. /** name of SelectionPanel */
  76322. name: string;
  76323. /** an array of SelectionGroups */
  76324. groups: SelectorGroup[];
  76325. private _panel;
  76326. private _buttonColor;
  76327. private _buttonBackground;
  76328. private _headerColor;
  76329. private _barColor;
  76330. private _barHeight;
  76331. private _spacerHeight;
  76332. private _labelColor;
  76333. private _groups;
  76334. private _bars;
  76335. /**
  76336. * Creates a new SelectionPanel
  76337. * @param name of SelectionPanel
  76338. * @param groups is an array of SelectionGroups
  76339. */
  76340. constructor(
  76341. /** name of SelectionPanel */
  76342. name: string,
  76343. /** an array of SelectionGroups */
  76344. groups?: SelectorGroup[]);
  76345. protected _getTypeName(): string;
  76346. /** Gets or sets the headerColor */
  76347. get headerColor(): string;
  76348. set headerColor(color: string);
  76349. private _setHeaderColor;
  76350. /** Gets or sets the button color */
  76351. get buttonColor(): string;
  76352. set buttonColor(color: string);
  76353. private _setbuttonColor;
  76354. /** Gets or sets the label color */
  76355. get labelColor(): string;
  76356. set labelColor(color: string);
  76357. private _setLabelColor;
  76358. /** Gets or sets the button background */
  76359. get buttonBackground(): string;
  76360. set buttonBackground(color: string);
  76361. private _setButtonBackground;
  76362. /** Gets or sets the color of separator bar */
  76363. get barColor(): string;
  76364. set barColor(color: string);
  76365. private _setBarColor;
  76366. /** Gets or sets the height of separator bar */
  76367. get barHeight(): string;
  76368. set barHeight(value: string);
  76369. private _setBarHeight;
  76370. /** Gets or sets the height of spacers*/
  76371. get spacerHeight(): string;
  76372. set spacerHeight(value: string);
  76373. private _setSpacerHeight;
  76374. /** Adds a bar between groups */
  76375. private _addSpacer;
  76376. /** Add a group to the selection panel
  76377. * @param group is the selector group to add
  76378. */
  76379. addGroup(group: SelectorGroup): void;
  76380. /** Remove the group from the given position
  76381. * @param groupNb is the position of the group in the list
  76382. */
  76383. removeGroup(groupNb: number): void;
  76384. /** Change a group header label
  76385. * @param label is the new group header label
  76386. * @param groupNb is the number of the group to relabel
  76387. * */
  76388. setHeaderName(label: string, groupNb: number): void;
  76389. /** Change selector label to the one given
  76390. * @param label is the new selector label
  76391. * @param groupNb is the number of the groupcontaining the selector
  76392. * @param selectorNb is the number of the selector within a group to relabel
  76393. * */
  76394. relabel(label: string, groupNb: number, selectorNb: number): void;
  76395. /** For a given group position remove the selector at the given position
  76396. * @param groupNb is the number of the group to remove the selector from
  76397. * @param selectorNb is the number of the selector within the group
  76398. */
  76399. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76400. /** For a given group position of correct type add a checkbox button
  76401. * @param groupNb is the number of the group to remove the selector from
  76402. * @param label is the label for the selector
  76403. * @param func is the function called when the Selector is checked
  76404. * @param checked is true when Selector is checked
  76405. */
  76406. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76407. /** For a given group position of correct type add a radio button
  76408. * @param groupNb is the number of the group to remove the selector from
  76409. * @param label is the label for the selector
  76410. * @param func is the function called when the Selector is checked
  76411. * @param checked is true when Selector is checked
  76412. */
  76413. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76414. /**
  76415. * For a given slider group add a slider
  76416. * @param groupNb is the number of the group to add the slider to
  76417. * @param label is the label for the Slider
  76418. * @param func is the function called when the Slider moves
  76419. * @param unit is a string describing the units used, eg degrees or metres
  76420. * @param min is the minimum value for the Slider
  76421. * @param max is the maximum value for the Slider
  76422. * @param value is the start value for the Slider between min and max
  76423. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76424. */
  76425. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76426. }
  76427. }
  76428. declare module BABYLON.GUI {
  76429. /**
  76430. * Class used to hold a the container for ScrollViewer
  76431. * @hidden
  76432. */
  76433. export class _ScrollViewerWindow extends Container {
  76434. parentClientWidth: number;
  76435. parentClientHeight: number;
  76436. private _freezeControls;
  76437. private _parentMeasure;
  76438. private _oldLeft;
  76439. private _oldTop;
  76440. get freezeControls(): boolean;
  76441. set freezeControls(value: boolean);
  76442. private _bucketWidth;
  76443. private _bucketHeight;
  76444. private _buckets;
  76445. private _bucketLen;
  76446. get bucketWidth(): number;
  76447. get bucketHeight(): number;
  76448. setBucketSizes(width: number, height: number): void;
  76449. private _useBuckets;
  76450. private _makeBuckets;
  76451. private _dispatchInBuckets;
  76452. private _updateMeasures;
  76453. private _updateChildrenMeasures;
  76454. private _restoreMeasures;
  76455. /**
  76456. * Creates a new ScrollViewerWindow
  76457. * @param name of ScrollViewerWindow
  76458. */
  76459. constructor(name?: string);
  76460. protected _getTypeName(): string;
  76461. /** @hidden */
  76462. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76463. /** @hidden */
  76464. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76465. private _scrollChildren;
  76466. private _scrollChildrenWithBuckets;
  76467. /** @hidden */
  76468. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76469. protected _postMeasure(): void;
  76470. }
  76471. }
  76472. declare module BABYLON.GUI {
  76473. /**
  76474. * Class used to create slider controls
  76475. */
  76476. export class ScrollBar extends BaseSlider {
  76477. name?: string | undefined;
  76478. private _background;
  76479. private _borderColor;
  76480. private _tempMeasure;
  76481. /** Gets or sets border color */
  76482. get borderColor(): string;
  76483. set borderColor(value: string);
  76484. /** Gets or sets background color */
  76485. get background(): string;
  76486. set background(value: string);
  76487. /**
  76488. * Creates a new Slider
  76489. * @param name defines the control name
  76490. */
  76491. constructor(name?: string | undefined);
  76492. protected _getTypeName(): string;
  76493. protected _getThumbThickness(): number;
  76494. _draw(context: CanvasRenderingContext2D): void;
  76495. private _first;
  76496. private _originX;
  76497. private _originY;
  76498. /** @hidden */
  76499. protected _updateValueFromPointer(x: number, y: number): void;
  76500. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76501. }
  76502. }
  76503. declare module BABYLON.GUI {
  76504. /**
  76505. * Class used to create slider controls
  76506. */
  76507. export class ImageScrollBar extends BaseSlider {
  76508. name?: string | undefined;
  76509. private _backgroundBaseImage;
  76510. private _backgroundImage;
  76511. private _thumbImage;
  76512. private _thumbBaseImage;
  76513. private _thumbLength;
  76514. private _thumbHeight;
  76515. private _barImageHeight;
  76516. private _tempMeasure;
  76517. /** Number of 90° rotation to apply on the images when in vertical mode */
  76518. num90RotationInVerticalMode: number;
  76519. /**
  76520. * Gets or sets the image used to render the background for horizontal bar
  76521. */
  76522. get backgroundImage(): Image;
  76523. set backgroundImage(value: Image);
  76524. /**
  76525. * Gets or sets the image used to render the thumb
  76526. */
  76527. get thumbImage(): Image;
  76528. set thumbImage(value: Image);
  76529. /**
  76530. * Gets or sets the length of the thumb
  76531. */
  76532. get thumbLength(): number;
  76533. set thumbLength(value: number);
  76534. /**
  76535. * Gets or sets the height of the thumb
  76536. */
  76537. get thumbHeight(): number;
  76538. set thumbHeight(value: number);
  76539. /**
  76540. * Gets or sets the height of the bar image
  76541. */
  76542. get barImageHeight(): number;
  76543. set barImageHeight(value: number);
  76544. /**
  76545. * Creates a new ImageScrollBar
  76546. * @param name defines the control name
  76547. */
  76548. constructor(name?: string | undefined);
  76549. protected _getTypeName(): string;
  76550. protected _getThumbThickness(): number;
  76551. _draw(context: CanvasRenderingContext2D): void;
  76552. private _first;
  76553. private _originX;
  76554. private _originY;
  76555. /** @hidden */
  76556. protected _updateValueFromPointer(x: number, y: number): void;
  76557. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76558. }
  76559. }
  76560. declare module BABYLON.GUI {
  76561. /**
  76562. * Class used to hold a viewer window and sliders in a grid
  76563. */
  76564. export class ScrollViewer extends Rectangle {
  76565. private _grid;
  76566. private _horizontalBarSpace;
  76567. private _verticalBarSpace;
  76568. private _dragSpace;
  76569. private _horizontalBar;
  76570. private _verticalBar;
  76571. private _barColor;
  76572. private _barBackground;
  76573. private _barImage;
  76574. private _horizontalBarImage;
  76575. private _verticalBarImage;
  76576. private _barBackgroundImage;
  76577. private _horizontalBarBackgroundImage;
  76578. private _verticalBarBackgroundImage;
  76579. private _barSize;
  76580. private _window;
  76581. private _pointerIsOver;
  76582. private _wheelPrecision;
  76583. private _onWheelObserver;
  76584. private _clientWidth;
  76585. private _clientHeight;
  76586. private _useImageBar;
  76587. private _thumbLength;
  76588. private _thumbHeight;
  76589. private _barImageHeight;
  76590. private _horizontalBarImageHeight;
  76591. private _verticalBarImageHeight;
  76592. private _oldWindowContentsWidth;
  76593. private _oldWindowContentsHeight;
  76594. /**
  76595. * Gets the horizontal scrollbar
  76596. */
  76597. get horizontalBar(): ScrollBar | ImageScrollBar;
  76598. /**
  76599. * Gets the vertical scrollbar
  76600. */
  76601. get verticalBar(): ScrollBar | ImageScrollBar;
  76602. /**
  76603. * Adds a new control to the current container
  76604. * @param control defines the control to add
  76605. * @returns the current container
  76606. */
  76607. addControl(control: BABYLON.Nullable<Control>): Container;
  76608. /**
  76609. * Removes a control from the current container
  76610. * @param control defines the control to remove
  76611. * @returns the current container
  76612. */
  76613. removeControl(control: Control): Container;
  76614. /** Gets the list of children */
  76615. get children(): Control[];
  76616. _flagDescendantsAsMatrixDirty(): void;
  76617. /**
  76618. * Freezes or unfreezes the controls in the window.
  76619. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76620. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76621. */
  76622. get freezeControls(): boolean;
  76623. set freezeControls(value: boolean);
  76624. /** Gets the bucket width */
  76625. get bucketWidth(): number;
  76626. /** Gets the bucket height */
  76627. get bucketHeight(): number;
  76628. /**
  76629. * Sets the bucket sizes.
  76630. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76631. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76632. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76633. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76634. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76635. * used), that's why it is not enabled by default.
  76636. * @param width width of the bucket
  76637. * @param height height of the bucket
  76638. */
  76639. setBucketSizes(width: number, height: number): void;
  76640. private _forceHorizontalBar;
  76641. private _forceVerticalBar;
  76642. /**
  76643. * Forces the horizontal scroll bar to be displayed
  76644. */
  76645. get forceHorizontalBar(): boolean;
  76646. set forceHorizontalBar(value: boolean);
  76647. /**
  76648. * Forces the vertical scroll bar to be displayed
  76649. */
  76650. get forceVerticalBar(): boolean;
  76651. set forceVerticalBar(value: boolean);
  76652. /**
  76653. * Creates a new ScrollViewer
  76654. * @param name of ScrollViewer
  76655. */
  76656. constructor(name?: string, isImageBased?: boolean);
  76657. /** Reset the scroll viewer window to initial size */
  76658. resetWindow(): void;
  76659. protected _getTypeName(): string;
  76660. private _buildClientSizes;
  76661. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76662. protected _postMeasure(): void;
  76663. /**
  76664. * Gets or sets the mouse wheel precision
  76665. * from 0 to 1 with a default value of 0.05
  76666. * */
  76667. get wheelPrecision(): number;
  76668. set wheelPrecision(value: number);
  76669. /** Gets or sets the scroll bar container background color */
  76670. get scrollBackground(): string;
  76671. set scrollBackground(color: string);
  76672. /** Gets or sets the bar color */
  76673. get barColor(): string;
  76674. set barColor(color: string);
  76675. /** Gets or sets the bar image */
  76676. get thumbImage(): Image;
  76677. set thumbImage(value: Image);
  76678. /** Gets or sets the horizontal bar image */
  76679. get horizontalThumbImage(): Image;
  76680. set horizontalThumbImage(value: Image);
  76681. /** Gets or sets the vertical bar image */
  76682. get verticalThumbImage(): Image;
  76683. set verticalThumbImage(value: Image);
  76684. /** Gets or sets the size of the bar */
  76685. get barSize(): number;
  76686. set barSize(value: number);
  76687. /** Gets or sets the length of the thumb */
  76688. get thumbLength(): number;
  76689. set thumbLength(value: number);
  76690. /** Gets or sets the height of the thumb */
  76691. get thumbHeight(): number;
  76692. set thumbHeight(value: number);
  76693. /** Gets or sets the height of the bar image */
  76694. get barImageHeight(): number;
  76695. set barImageHeight(value: number);
  76696. /** Gets or sets the height of the horizontal bar image */
  76697. get horizontalBarImageHeight(): number;
  76698. set horizontalBarImageHeight(value: number);
  76699. /** Gets or sets the height of the vertical bar image */
  76700. get verticalBarImageHeight(): number;
  76701. set verticalBarImageHeight(value: number);
  76702. /** Gets or sets the bar background */
  76703. get barBackground(): string;
  76704. set barBackground(color: string);
  76705. /** Gets or sets the bar background image */
  76706. get barImage(): Image;
  76707. set barImage(value: Image);
  76708. /** Gets or sets the horizontal bar background image */
  76709. get horizontalBarImage(): Image;
  76710. set horizontalBarImage(value: Image);
  76711. /** Gets or sets the vertical bar background image */
  76712. get verticalBarImage(): Image;
  76713. set verticalBarImage(value: Image);
  76714. private _setWindowPosition;
  76715. /** @hidden */
  76716. private _updateScroller;
  76717. _link(host: AdvancedDynamicTexture): void;
  76718. /** @hidden */
  76719. private _addBar;
  76720. /** @hidden */
  76721. private _attachWheel;
  76722. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76723. /** Releases associated resources */
  76724. dispose(): void;
  76725. }
  76726. }
  76727. declare module BABYLON.GUI {
  76728. /** Class used to render a grid */
  76729. export class DisplayGrid extends Control {
  76730. name?: string | undefined;
  76731. private _cellWidth;
  76732. private _cellHeight;
  76733. private _minorLineTickness;
  76734. private _minorLineColor;
  76735. private _majorLineTickness;
  76736. private _majorLineColor;
  76737. private _majorLineFrequency;
  76738. private _background;
  76739. private _displayMajorLines;
  76740. private _displayMinorLines;
  76741. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76742. get displayMinorLines(): boolean;
  76743. set displayMinorLines(value: boolean);
  76744. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76745. get displayMajorLines(): boolean;
  76746. set displayMajorLines(value: boolean);
  76747. /** Gets or sets background color (Black by default) */
  76748. get background(): string;
  76749. set background(value: string);
  76750. /** Gets or sets the width of each cell (20 by default) */
  76751. get cellWidth(): number;
  76752. set cellWidth(value: number);
  76753. /** Gets or sets the height of each cell (20 by default) */
  76754. get cellHeight(): number;
  76755. set cellHeight(value: number);
  76756. /** Gets or sets the tickness of minor lines (1 by default) */
  76757. get minorLineTickness(): number;
  76758. set minorLineTickness(value: number);
  76759. /** Gets or sets the color of minor lines (DarkGray by default) */
  76760. get minorLineColor(): string;
  76761. set minorLineColor(value: string);
  76762. /** Gets or sets the tickness of major lines (2 by default) */
  76763. get majorLineTickness(): number;
  76764. set majorLineTickness(value: number);
  76765. /** Gets or sets the color of major lines (White by default) */
  76766. get majorLineColor(): string;
  76767. set majorLineColor(value: string);
  76768. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76769. get majorLineFrequency(): number;
  76770. set majorLineFrequency(value: number);
  76771. /**
  76772. * Creates a new GridDisplayRectangle
  76773. * @param name defines the control name
  76774. */
  76775. constructor(name?: string | undefined);
  76776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76777. protected _getTypeName(): string;
  76778. }
  76779. }
  76780. declare module BABYLON.GUI {
  76781. /**
  76782. * Class used to create slider controls based on images
  76783. */
  76784. export class ImageBasedSlider extends BaseSlider {
  76785. name?: string | undefined;
  76786. private _backgroundImage;
  76787. private _thumbImage;
  76788. private _valueBarImage;
  76789. private _tempMeasure;
  76790. get displayThumb(): boolean;
  76791. set displayThumb(value: boolean);
  76792. /**
  76793. * Gets or sets the image used to render the background
  76794. */
  76795. get backgroundImage(): Image;
  76796. set backgroundImage(value: Image);
  76797. /**
  76798. * Gets or sets the image used to render the value bar
  76799. */
  76800. get valueBarImage(): Image;
  76801. set valueBarImage(value: Image);
  76802. /**
  76803. * Gets or sets the image used to render the thumb
  76804. */
  76805. get thumbImage(): Image;
  76806. set thumbImage(value: Image);
  76807. /**
  76808. * Creates a new ImageBasedSlider
  76809. * @param name defines the control name
  76810. */
  76811. constructor(name?: string | undefined);
  76812. protected _getTypeName(): string;
  76813. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76814. }
  76815. }
  76816. declare module BABYLON.GUI {
  76817. /**
  76818. * Forcing an export so that this code will execute
  76819. * @hidden
  76820. */
  76821. const name = "Statics";
  76822. }
  76823. declare module BABYLON.GUI {
  76824. /**
  76825. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76826. */
  76827. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76828. /**
  76829. * Define the instrumented AdvancedDynamicTexture.
  76830. */
  76831. texture: AdvancedDynamicTexture;
  76832. private _captureRenderTime;
  76833. private _renderTime;
  76834. private _captureLayoutTime;
  76835. private _layoutTime;
  76836. private _onBeginRenderObserver;
  76837. private _onEndRenderObserver;
  76838. private _onBeginLayoutObserver;
  76839. private _onEndLayoutObserver;
  76840. /**
  76841. * Gets the perf counter used to capture render time
  76842. */
  76843. get renderTimeCounter(): BABYLON.PerfCounter;
  76844. /**
  76845. * Gets the perf counter used to capture layout time
  76846. */
  76847. get layoutTimeCounter(): BABYLON.PerfCounter;
  76848. /**
  76849. * Enable or disable the render time capture
  76850. */
  76851. get captureRenderTime(): boolean;
  76852. set captureRenderTime(value: boolean);
  76853. /**
  76854. * Enable or disable the layout time capture
  76855. */
  76856. get captureLayoutTime(): boolean;
  76857. set captureLayoutTime(value: boolean);
  76858. /**
  76859. * Instantiates a new advanced dynamic texture instrumentation.
  76860. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  76861. * @param texture Defines the AdvancedDynamicTexture to instrument
  76862. */
  76863. constructor(
  76864. /**
  76865. * Define the instrumented AdvancedDynamicTexture.
  76866. */
  76867. texture: AdvancedDynamicTexture);
  76868. /**
  76869. * Dispose and release associated resources.
  76870. */
  76871. dispose(): void;
  76872. }
  76873. }
  76874. declare module BABYLON.GUI {
  76875. /**
  76876. * Class used to load GUI via XML.
  76877. */
  76878. export class XmlLoader {
  76879. private _nodes;
  76880. private _nodeTypes;
  76881. private _isLoaded;
  76882. private _objectAttributes;
  76883. private _parentClass;
  76884. /**
  76885. * Create a new xml loader
  76886. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  76887. */
  76888. constructor(parentClass?: null);
  76889. private _getChainElement;
  76890. private _getClassAttribute;
  76891. private _createGuiElement;
  76892. private _parseGrid;
  76893. private _parseElement;
  76894. private _prepareSourceElement;
  76895. private _parseElementsFromSource;
  76896. private _parseXml;
  76897. /**
  76898. * Gets if the loading has finished.
  76899. * @returns whether the loading has finished or not
  76900. */
  76901. isLoaded(): boolean;
  76902. /**
  76903. * Gets a loaded node / control by id.
  76904. * @param id the Controls id set in the xml
  76905. * @returns element of type Control
  76906. */
  76907. getNodeById(id: string): any;
  76908. /**
  76909. * Gets all loaded nodes / controls
  76910. * @returns Array of controls
  76911. */
  76912. getNodes(): any;
  76913. /**
  76914. * Initiates the xml layout loading
  76915. * @param xmlFile defines the xml layout to load
  76916. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76917. * @param callback defines the callback called on layout load.
  76918. */
  76919. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76920. }
  76921. }
  76922. declare module BABYLON.GUI {
  76923. /**
  76924. * Class used to create containers for controls
  76925. */
  76926. export class Container3D extends Control3D {
  76927. private _blockLayout;
  76928. /**
  76929. * Gets the list of child controls
  76930. */
  76931. protected _children: Control3D[];
  76932. /**
  76933. * Gets the list of child controls
  76934. */
  76935. get children(): Array<Control3D>;
  76936. /**
  76937. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76938. * This is helpful to optimize layout operation when adding multiple children in a row
  76939. */
  76940. get blockLayout(): boolean;
  76941. set blockLayout(value: boolean);
  76942. /**
  76943. * Creates a new container
  76944. * @param name defines the container name
  76945. */
  76946. constructor(name?: string);
  76947. /**
  76948. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76949. * @returns the current container
  76950. */
  76951. updateLayout(): Container3D;
  76952. /**
  76953. * Gets a boolean indicating if the given control is in the children of this control
  76954. * @param control defines the control to check
  76955. * @returns true if the control is in the child list
  76956. */
  76957. containsControl(control: Control3D): boolean;
  76958. /**
  76959. * Adds a control to the children of this control
  76960. * @param control defines the control to add
  76961. * @returns the current container
  76962. */
  76963. addControl(control: Control3D): Container3D;
  76964. /**
  76965. * This function will be called everytime a new control is added
  76966. */
  76967. protected _arrangeChildren(): void;
  76968. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76969. /**
  76970. * Removes a control from the children of this control
  76971. * @param control defines the control to remove
  76972. * @returns the current container
  76973. */
  76974. removeControl(control: Control3D): Container3D;
  76975. protected _getTypeName(): string;
  76976. /**
  76977. * Releases all associated resources
  76978. */
  76979. dispose(): void;
  76980. /** Control rotation will remain unchanged */
  76981. static readonly UNSET_ORIENTATION: number;
  76982. /** Control will rotate to make it look at sphere central axis */
  76983. static readonly FACEORIGIN_ORIENTATION: number;
  76984. /** Control will rotate to make it look back at sphere central axis */
  76985. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76986. /** Control will rotate to look at z axis (0, 0, 1) */
  76987. static readonly FACEFORWARD_ORIENTATION: number;
  76988. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76989. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76990. }
  76991. }
  76992. declare module BABYLON.GUI {
  76993. /**
  76994. * Class used to manage 3D user interface
  76995. * @see http://doc.babylonjs.com/how_to/gui3d
  76996. */
  76997. export class GUI3DManager implements BABYLON.IDisposable {
  76998. private _scene;
  76999. private _sceneDisposeObserver;
  77000. private _utilityLayer;
  77001. private _rootContainer;
  77002. private _pointerObserver;
  77003. private _pointerOutObserver;
  77004. /** @hidden */
  77005. _lastPickedControl: Control3D;
  77006. /** @hidden */
  77007. _lastControlOver: {
  77008. [pointerId: number]: Control3D;
  77009. };
  77010. /** @hidden */
  77011. _lastControlDown: {
  77012. [pointerId: number]: Control3D;
  77013. };
  77014. /**
  77015. * BABYLON.Observable raised when the point picked by the pointer events changed
  77016. */
  77017. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77018. /** @hidden */
  77019. _sharedMaterials: {
  77020. [key: string]: BABYLON.Material;
  77021. };
  77022. /** Gets the hosting scene */
  77023. get scene(): BABYLON.Scene;
  77024. /** Gets associated utility layer */
  77025. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77026. /**
  77027. * Creates a new GUI3DManager
  77028. * @param scene
  77029. */
  77030. constructor(scene?: BABYLON.Scene);
  77031. private _handlePointerOut;
  77032. private _doPicking;
  77033. /**
  77034. * Gets the root container
  77035. */
  77036. get rootContainer(): Container3D;
  77037. /**
  77038. * Gets a boolean indicating if the given control is in the root child list
  77039. * @param control defines the control to check
  77040. * @returns true if the control is in the root child list
  77041. */
  77042. containsControl(control: Control3D): boolean;
  77043. /**
  77044. * Adds a control to the root child list
  77045. * @param control defines the control to add
  77046. * @returns the current manager
  77047. */
  77048. addControl(control: Control3D): GUI3DManager;
  77049. /**
  77050. * Removes a control from the root child list
  77051. * @param control defines the control to remove
  77052. * @returns the current container
  77053. */
  77054. removeControl(control: Control3D): GUI3DManager;
  77055. /**
  77056. * Releases all associated resources
  77057. */
  77058. dispose(): void;
  77059. }
  77060. }
  77061. declare module BABYLON.GUI {
  77062. /**
  77063. * Class used to transport BABYLON.Vector3 information for pointer events
  77064. */
  77065. export class Vector3WithInfo extends BABYLON.Vector3 {
  77066. /** defines the current mouse button index */
  77067. buttonIndex: number;
  77068. /**
  77069. * Creates a new Vector3WithInfo
  77070. * @param source defines the vector3 data to transport
  77071. * @param buttonIndex defines the current mouse button index
  77072. */
  77073. constructor(source: BABYLON.Vector3,
  77074. /** defines the current mouse button index */
  77075. buttonIndex?: number);
  77076. }
  77077. }
  77078. declare module BABYLON.GUI {
  77079. /**
  77080. * Class used as base class for controls
  77081. */
  77082. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77083. /** Defines the control name */
  77084. name?: string | undefined;
  77085. /** @hidden */
  77086. _host: GUI3DManager;
  77087. private _node;
  77088. private _downCount;
  77089. private _enterCount;
  77090. private _downPointerIds;
  77091. private _isVisible;
  77092. /** Gets or sets the control position in world space */
  77093. get position(): BABYLON.Vector3;
  77094. set position(value: BABYLON.Vector3);
  77095. /** Gets or sets the control scaling in world space */
  77096. get scaling(): BABYLON.Vector3;
  77097. set scaling(value: BABYLON.Vector3);
  77098. /** Callback used to start pointer enter animation */
  77099. pointerEnterAnimation: () => void;
  77100. /** Callback used to start pointer out animation */
  77101. pointerOutAnimation: () => void;
  77102. /** Callback used to start pointer down animation */
  77103. pointerDownAnimation: () => void;
  77104. /** Callback used to start pointer up animation */
  77105. pointerUpAnimation: () => void;
  77106. /**
  77107. * An event triggered when the pointer move over the control
  77108. */
  77109. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77110. /**
  77111. * An event triggered when the pointer move out of the control
  77112. */
  77113. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77114. /**
  77115. * An event triggered when the pointer taps the control
  77116. */
  77117. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77118. /**
  77119. * An event triggered when pointer is up
  77120. */
  77121. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77122. /**
  77123. * An event triggered when a control is clicked on (with a mouse)
  77124. */
  77125. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77126. /**
  77127. * An event triggered when pointer enters the control
  77128. */
  77129. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77130. /**
  77131. * Gets or sets the parent container
  77132. */
  77133. parent: BABYLON.Nullable<Container3D>;
  77134. private _behaviors;
  77135. /**
  77136. * Gets the list of attached behaviors
  77137. * @see http://doc.babylonjs.com/features/behaviour
  77138. */
  77139. get behaviors(): BABYLON.Behavior<Control3D>[];
  77140. /**
  77141. * Attach a behavior to the control
  77142. * @see http://doc.babylonjs.com/features/behaviour
  77143. * @param behavior defines the behavior to attach
  77144. * @returns the current control
  77145. */
  77146. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77147. /**
  77148. * Remove an attached behavior
  77149. * @see http://doc.babylonjs.com/features/behaviour
  77150. * @param behavior defines the behavior to attach
  77151. * @returns the current control
  77152. */
  77153. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77154. /**
  77155. * Gets an attached behavior by name
  77156. * @param name defines the name of the behavior to look for
  77157. * @see http://doc.babylonjs.com/features/behaviour
  77158. * @returns null if behavior was not found else the requested behavior
  77159. */
  77160. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77161. /** Gets or sets a boolean indicating if the control is visible */
  77162. get isVisible(): boolean;
  77163. set isVisible(value: boolean);
  77164. /**
  77165. * Creates a new control
  77166. * @param name defines the control name
  77167. */
  77168. constructor(
  77169. /** Defines the control name */
  77170. name?: string | undefined);
  77171. /**
  77172. * Gets a string representing the class name
  77173. */
  77174. get typeName(): string;
  77175. /**
  77176. * Get the current class name of the control.
  77177. * @returns current class name
  77178. */
  77179. getClassName(): string;
  77180. protected _getTypeName(): string;
  77181. /**
  77182. * Gets the transform node used by this control
  77183. */
  77184. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77185. /**
  77186. * Gets the mesh used to render this control
  77187. */
  77188. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77189. /**
  77190. * Link the control as child of the given node
  77191. * @param node defines the node to link to. Use null to unlink the control
  77192. * @returns the current control
  77193. */
  77194. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77195. /** @hidden **/
  77196. _prepareNode(scene: BABYLON.Scene): void;
  77197. /**
  77198. * Node creation.
  77199. * Can be overriden by children
  77200. * @param scene defines the scene where the node must be attached
  77201. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77202. */
  77203. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77204. /**
  77205. * Affect a material to the given mesh
  77206. * @param mesh defines the mesh which will represent the control
  77207. */
  77208. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77209. /** @hidden */
  77210. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77211. /** @hidden */
  77212. _onPointerEnter(target: Control3D): boolean;
  77213. /** @hidden */
  77214. _onPointerOut(target: Control3D): void;
  77215. /** @hidden */
  77216. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77217. /** @hidden */
  77218. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77219. /** @hidden */
  77220. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77221. /** @hidden */
  77222. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77223. /** @hidden */
  77224. _disposeNode(): void;
  77225. /**
  77226. * Releases all associated resources
  77227. */
  77228. dispose(): void;
  77229. }
  77230. }
  77231. declare module BABYLON.GUI {
  77232. /**
  77233. * Class used as a root to all buttons
  77234. */
  77235. export class AbstractButton3D extends Control3D {
  77236. /**
  77237. * Creates a new button
  77238. * @param name defines the control name
  77239. */
  77240. constructor(name?: string);
  77241. protected _getTypeName(): string;
  77242. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77243. }
  77244. }
  77245. declare module BABYLON.GUI {
  77246. /**
  77247. * Class used to create a button in 3D
  77248. */
  77249. export class Button3D extends AbstractButton3D {
  77250. /** @hidden */
  77251. protected _currentMaterial: BABYLON.Material;
  77252. private _facadeTexture;
  77253. private _content;
  77254. private _contentResolution;
  77255. private _contentScaleRatio;
  77256. /**
  77257. * Gets or sets the texture resolution used to render content (512 by default)
  77258. */
  77259. get contentResolution(): BABYLON.int;
  77260. set contentResolution(value: BABYLON.int);
  77261. /**
  77262. * Gets or sets the texture scale ratio used to render content (2 by default)
  77263. */
  77264. get contentScaleRatio(): number;
  77265. set contentScaleRatio(value: number);
  77266. protected _disposeFacadeTexture(): void;
  77267. protected _resetContent(): void;
  77268. /**
  77269. * Creates a new button
  77270. * @param name defines the control name
  77271. */
  77272. constructor(name?: string);
  77273. /**
  77274. * Gets or sets the GUI 2D content used to display the button's facade
  77275. */
  77276. get content(): Control;
  77277. set content(value: Control);
  77278. /**
  77279. * Apply the facade texture (created from the content property).
  77280. * This function can be overloaded by child classes
  77281. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77282. */
  77283. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77284. protected _getTypeName(): string;
  77285. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77286. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77287. /**
  77288. * Releases all associated resources
  77289. */
  77290. dispose(): void;
  77291. }
  77292. }
  77293. declare module BABYLON.GUI {
  77294. /**
  77295. * Abstract class used to create a container panel deployed on the surface of a volume
  77296. */
  77297. export abstract class VolumeBasedPanel extends Container3D {
  77298. private _columns;
  77299. private _rows;
  77300. private _rowThenColum;
  77301. private _orientation;
  77302. protected _cellWidth: number;
  77303. protected _cellHeight: number;
  77304. /**
  77305. * Gets or sets the distance between elements
  77306. */
  77307. margin: number;
  77308. /**
  77309. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77310. * | Value | Type | Description |
  77311. * | ----- | ----------------------------------- | ----------- |
  77312. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77313. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77314. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77315. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77316. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77317. */
  77318. get orientation(): number;
  77319. set orientation(value: number);
  77320. /**
  77321. * Gets or sets the number of columns requested (10 by default).
  77322. * The panel will automatically compute the number of rows based on number of child controls.
  77323. */
  77324. get columns(): BABYLON.int;
  77325. set columns(value: BABYLON.int);
  77326. /**
  77327. * Gets or sets a the number of rows requested.
  77328. * The panel will automatically compute the number of columns based on number of child controls.
  77329. */
  77330. get rows(): BABYLON.int;
  77331. set rows(value: BABYLON.int);
  77332. /**
  77333. * Creates new VolumeBasedPanel
  77334. */
  77335. constructor();
  77336. protected _arrangeChildren(): void;
  77337. /** Child classes must implement this function to provide correct control positioning */
  77338. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77339. /** Child classes can implement this function to provide additional processing */
  77340. protected _finalProcessing(): void;
  77341. }
  77342. }
  77343. declare module BABYLON.GUI {
  77344. /**
  77345. * Class used to create a container panel deployed on the surface of a cylinder
  77346. */
  77347. export class CylinderPanel extends VolumeBasedPanel {
  77348. private _radius;
  77349. /**
  77350. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77351. */
  77352. get radius(): BABYLON.float;
  77353. set radius(value: BABYLON.float);
  77354. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77355. private _cylindricalMapping;
  77356. }
  77357. }
  77358. declare module BABYLON.GUI {
  77359. /** @hidden */
  77360. export var fluentVertexShader: {
  77361. name: string;
  77362. shader: string;
  77363. };
  77364. }
  77365. declare module BABYLON.GUI {
  77366. /** @hidden */
  77367. export var fluentPixelShader: {
  77368. name: string;
  77369. shader: string;
  77370. };
  77371. }
  77372. declare module BABYLON.GUI {
  77373. /** @hidden */
  77374. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77375. INNERGLOW: boolean;
  77376. BORDER: boolean;
  77377. HOVERLIGHT: boolean;
  77378. TEXTURE: boolean;
  77379. constructor();
  77380. }
  77381. /**
  77382. * Class used to render controls with fluent desgin
  77383. */
  77384. export class FluentMaterial extends BABYLON.PushMaterial {
  77385. /**
  77386. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77387. */
  77388. innerGlowColorIntensity: number;
  77389. /**
  77390. * Gets or sets the inner glow color (white by default)
  77391. */
  77392. innerGlowColor: BABYLON.Color3;
  77393. /**
  77394. * Gets or sets alpha value (default is 1.0)
  77395. */
  77396. alpha: number;
  77397. /**
  77398. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77399. */
  77400. albedoColor: BABYLON.Color3;
  77401. /**
  77402. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77403. */
  77404. renderBorders: boolean;
  77405. /**
  77406. * Gets or sets border width (default is 0.5)
  77407. */
  77408. borderWidth: number;
  77409. /**
  77410. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77411. */
  77412. edgeSmoothingValue: number;
  77413. /**
  77414. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77415. */
  77416. borderMinValue: number;
  77417. /**
  77418. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77419. */
  77420. renderHoverLight: boolean;
  77421. /**
  77422. * Gets or sets the radius used to render the hover light (default is 1.0)
  77423. */
  77424. hoverRadius: number;
  77425. /**
  77426. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77427. */
  77428. hoverColor: BABYLON.Color4;
  77429. /**
  77430. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77431. */
  77432. hoverPosition: BABYLON.Vector3;
  77433. private _albedoTexture;
  77434. /** Gets or sets the texture to use for albedo color */
  77435. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77436. /**
  77437. * Creates a new Fluent material
  77438. * @param name defines the name of the material
  77439. * @param scene defines the hosting scene
  77440. */
  77441. constructor(name: string, scene: BABYLON.Scene);
  77442. needAlphaBlending(): boolean;
  77443. needAlphaTesting(): boolean;
  77444. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77445. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77446. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77447. getActiveTextures(): BABYLON.BaseTexture[];
  77448. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77449. dispose(forceDisposeEffect?: boolean): void;
  77450. clone(name: string): FluentMaterial;
  77451. serialize(): any;
  77452. getClassName(): string;
  77453. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77454. }
  77455. }
  77456. declare module BABYLON.GUI {
  77457. /**
  77458. * Class used to create a holographic button in 3D
  77459. */
  77460. export class HolographicButton extends Button3D {
  77461. private _backPlate;
  77462. private _textPlate;
  77463. private _frontPlate;
  77464. private _text;
  77465. private _imageUrl;
  77466. private _shareMaterials;
  77467. private _frontMaterial;
  77468. private _backMaterial;
  77469. private _plateMaterial;
  77470. private _pickedPointObserver;
  77471. private _tooltipFade;
  77472. private _tooltipTextBlock;
  77473. private _tooltipTexture;
  77474. private _tooltipMesh;
  77475. private _tooltipHoverObserver;
  77476. private _tooltipOutObserver;
  77477. private _disposeTooltip;
  77478. /**
  77479. * Rendering ground id of all the mesh in the button
  77480. */
  77481. set renderingGroupId(id: number);
  77482. get renderingGroupId(): number;
  77483. /**
  77484. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77485. */
  77486. set tooltipText(text: BABYLON.Nullable<string>);
  77487. get tooltipText(): BABYLON.Nullable<string>;
  77488. /**
  77489. * Gets or sets text for the button
  77490. */
  77491. get text(): string;
  77492. set text(value: string);
  77493. /**
  77494. * Gets or sets the image url for the button
  77495. */
  77496. get imageUrl(): string;
  77497. set imageUrl(value: string);
  77498. /**
  77499. * Gets the back material used by this button
  77500. */
  77501. get backMaterial(): FluentMaterial;
  77502. /**
  77503. * Gets the front material used by this button
  77504. */
  77505. get frontMaterial(): FluentMaterial;
  77506. /**
  77507. * Gets the plate material used by this button
  77508. */
  77509. get plateMaterial(): BABYLON.StandardMaterial;
  77510. /**
  77511. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77512. */
  77513. get shareMaterials(): boolean;
  77514. /**
  77515. * Creates a new button
  77516. * @param name defines the control name
  77517. */
  77518. constructor(name?: string, shareMaterials?: boolean);
  77519. protected _getTypeName(): string;
  77520. private _rebuildContent;
  77521. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77522. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77523. private _createBackMaterial;
  77524. private _createFrontMaterial;
  77525. private _createPlateMaterial;
  77526. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77527. /**
  77528. * Releases all associated resources
  77529. */
  77530. dispose(): void;
  77531. }
  77532. }
  77533. declare module BABYLON.GUI {
  77534. /**
  77535. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77536. */
  77537. export class MeshButton3D extends Button3D {
  77538. /** @hidden */
  77539. protected _currentMesh: BABYLON.Mesh;
  77540. /**
  77541. * Creates a new 3D button based on a mesh
  77542. * @param mesh mesh to become a 3D button
  77543. * @param name defines the control name
  77544. */
  77545. constructor(mesh: BABYLON.Mesh, name?: string);
  77546. protected _getTypeName(): string;
  77547. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77548. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77549. }
  77550. }
  77551. declare module BABYLON.GUI {
  77552. /**
  77553. * Class used to create a container panel deployed on the surface of a plane
  77554. */
  77555. export class PlanePanel extends VolumeBasedPanel {
  77556. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77557. }
  77558. }
  77559. declare module BABYLON.GUI {
  77560. /**
  77561. * Class used to create a container panel where items get randomized planar mapping
  77562. */
  77563. export class ScatterPanel extends VolumeBasedPanel {
  77564. private _iteration;
  77565. /**
  77566. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77567. */
  77568. get iteration(): BABYLON.float;
  77569. set iteration(value: BABYLON.float);
  77570. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77571. private _scatterMapping;
  77572. protected _finalProcessing(): void;
  77573. }
  77574. }
  77575. declare module BABYLON.GUI {
  77576. /**
  77577. * Class used to create a container panel deployed on the surface of a sphere
  77578. */
  77579. export class SpherePanel extends VolumeBasedPanel {
  77580. private _radius;
  77581. /**
  77582. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77583. */
  77584. get radius(): BABYLON.float;
  77585. set radius(value: BABYLON.float);
  77586. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77587. private _sphericalMapping;
  77588. }
  77589. }
  77590. declare module BABYLON.GUI {
  77591. /**
  77592. * Class used to create a stack panel in 3D on XY plane
  77593. */
  77594. export class StackPanel3D extends Container3D {
  77595. private _isVertical;
  77596. /**
  77597. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77598. */
  77599. get isVertical(): boolean;
  77600. set isVertical(value: boolean);
  77601. /**
  77602. * Gets or sets the distance between elements
  77603. */
  77604. margin: number;
  77605. /**
  77606. * Creates new StackPanel
  77607. * @param isVertical
  77608. */
  77609. constructor(isVertical?: boolean);
  77610. protected _arrangeChildren(): void;
  77611. }
  77612. }
  77613. declare module BABYLON {
  77614. /**
  77615. * Configuration for glTF validation
  77616. */
  77617. export interface IGLTFValidationConfiguration {
  77618. /**
  77619. * The url of the glTF validator.
  77620. */
  77621. url: string;
  77622. }
  77623. /**
  77624. * glTF validation
  77625. */
  77626. export class GLTFValidation {
  77627. /**
  77628. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77629. */
  77630. static Configuration: IGLTFValidationConfiguration;
  77631. private static _LoadScriptPromise;
  77632. /**
  77633. * Validate a glTF asset using the glTF-Validator.
  77634. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77635. * @param rootUrl The root url for the glTF
  77636. * @param fileName The file name for the glTF
  77637. * @param getExternalResource The callback to get external resources for the glTF validator
  77638. * @returns A promise that resolves with the glTF validation results once complete
  77639. */
  77640. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77641. }
  77642. }
  77643. declare module BABYLON {
  77644. /**
  77645. * Mode that determines the coordinate system to use.
  77646. */
  77647. export enum GLTFLoaderCoordinateSystemMode {
  77648. /**
  77649. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77650. */
  77651. AUTO = 0,
  77652. /**
  77653. * Sets the useRightHandedSystem flag on the scene.
  77654. */
  77655. FORCE_RIGHT_HANDED = 1
  77656. }
  77657. /**
  77658. * Mode that determines what animations will start.
  77659. */
  77660. export enum GLTFLoaderAnimationStartMode {
  77661. /**
  77662. * No animation will start.
  77663. */
  77664. NONE = 0,
  77665. /**
  77666. * The first animation will start.
  77667. */
  77668. FIRST = 1,
  77669. /**
  77670. * All animations will start.
  77671. */
  77672. ALL = 2
  77673. }
  77674. /**
  77675. * Interface that contains the data for the glTF asset.
  77676. */
  77677. export interface IGLTFLoaderData {
  77678. /**
  77679. * The object that represents the glTF JSON.
  77680. */
  77681. json: Object;
  77682. /**
  77683. * The BIN chunk of a binary glTF.
  77684. */
  77685. bin: Nullable<IDataBuffer>;
  77686. }
  77687. /**
  77688. * Interface for extending the loader.
  77689. */
  77690. export interface IGLTFLoaderExtension {
  77691. /**
  77692. * The name of this extension.
  77693. */
  77694. readonly name: string;
  77695. /**
  77696. * Defines whether this extension is enabled.
  77697. */
  77698. enabled: boolean;
  77699. /**
  77700. * Defines the order of this extension.
  77701. * The loader sorts the extensions using these values when loading.
  77702. */
  77703. order?: number;
  77704. }
  77705. /**
  77706. * Loader state.
  77707. */
  77708. export enum GLTFLoaderState {
  77709. /**
  77710. * The asset is loading.
  77711. */
  77712. LOADING = 0,
  77713. /**
  77714. * The asset is ready for rendering.
  77715. */
  77716. READY = 1,
  77717. /**
  77718. * The asset is completely loaded.
  77719. */
  77720. COMPLETE = 2
  77721. }
  77722. /** @hidden */
  77723. export interface IImportMeshAsyncOutput {
  77724. meshes: AbstractMesh[];
  77725. particleSystems: IParticleSystem[];
  77726. skeletons: Skeleton[];
  77727. animationGroups: AnimationGroup[];
  77728. lights: Light[];
  77729. transformNodes: TransformNode[];
  77730. }
  77731. /** @hidden */
  77732. export interface IGLTFLoader extends IDisposable {
  77733. readonly state: Nullable<GLTFLoaderState>;
  77734. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77735. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77736. }
  77737. /**
  77738. * File loader for loading glTF files into a scene.
  77739. */
  77740. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77741. /** @hidden */
  77742. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77743. /** @hidden */
  77744. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77745. /**
  77746. * Raised when the asset has been parsed
  77747. */
  77748. onParsedObservable: Observable<IGLTFLoaderData>;
  77749. private _onParsedObserver;
  77750. /**
  77751. * Raised when the asset has been parsed
  77752. */
  77753. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77754. /**
  77755. * 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.
  77756. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77757. * Defaults to true.
  77758. * @hidden
  77759. */
  77760. static IncrementalLoading: boolean;
  77761. /**
  77762. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77763. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77764. * @hidden
  77765. */
  77766. static HomogeneousCoordinates: boolean;
  77767. /**
  77768. * The coordinate system mode. Defaults to AUTO.
  77769. */
  77770. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77771. /**
  77772. * The animation start mode. Defaults to FIRST.
  77773. */
  77774. animationStartMode: GLTFLoaderAnimationStartMode;
  77775. /**
  77776. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77777. */
  77778. compileMaterials: boolean;
  77779. /**
  77780. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77781. */
  77782. useClipPlane: boolean;
  77783. /**
  77784. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77785. */
  77786. compileShadowGenerators: boolean;
  77787. /**
  77788. * Defines if the Alpha blended materials are only applied as coverage.
  77789. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77790. * If true, no extra effects are applied to transparent pixels.
  77791. */
  77792. transparencyAsCoverage: boolean;
  77793. /**
  77794. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77795. * Enabling will disable offline support and glTF validator.
  77796. * Defaults to false.
  77797. */
  77798. useRangeRequests: boolean;
  77799. /**
  77800. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77801. */
  77802. createInstances: boolean;
  77803. /**
  77804. * Function called before loading a url referenced by the asset.
  77805. */
  77806. preprocessUrlAsync: (url: string) => Promise<string>;
  77807. /**
  77808. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77809. */
  77810. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77811. private _onMeshLoadedObserver;
  77812. /**
  77813. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77814. */
  77815. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77816. /**
  77817. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77818. */
  77819. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77820. private _onTextureLoadedObserver;
  77821. /**
  77822. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77823. */
  77824. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77825. /**
  77826. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77827. */
  77828. readonly onMaterialLoadedObservable: Observable<Material>;
  77829. private _onMaterialLoadedObserver;
  77830. /**
  77831. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77832. */
  77833. set onMaterialLoaded(callback: (material: Material) => void);
  77834. /**
  77835. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77836. */
  77837. readonly onCameraLoadedObservable: Observable<Camera>;
  77838. private _onCameraLoadedObserver;
  77839. /**
  77840. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77841. */
  77842. set onCameraLoaded(callback: (camera: Camera) => void);
  77843. /**
  77844. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77845. * For assets with LODs, raised when all of the LODs are complete.
  77846. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77847. */
  77848. readonly onCompleteObservable: Observable<void>;
  77849. private _onCompleteObserver;
  77850. /**
  77851. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77852. * For assets with LODs, raised when all of the LODs are complete.
  77853. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77854. */
  77855. set onComplete(callback: () => void);
  77856. /**
  77857. * Observable raised when an error occurs.
  77858. */
  77859. readonly onErrorObservable: Observable<any>;
  77860. private _onErrorObserver;
  77861. /**
  77862. * Callback raised when an error occurs.
  77863. */
  77864. set onError(callback: (reason: any) => void);
  77865. /**
  77866. * Observable raised after the loader is disposed.
  77867. */
  77868. readonly onDisposeObservable: Observable<void>;
  77869. private _onDisposeObserver;
  77870. /**
  77871. * Callback raised after the loader is disposed.
  77872. */
  77873. set onDispose(callback: () => void);
  77874. /**
  77875. * Observable raised after a loader extension is created.
  77876. * Set additional options for a loader extension in this event.
  77877. */
  77878. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  77879. private _onExtensionLoadedObserver;
  77880. /**
  77881. * Callback raised after a loader extension is created.
  77882. */
  77883. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  77884. /**
  77885. * Defines if the loader logging is enabled.
  77886. */
  77887. get loggingEnabled(): boolean;
  77888. set loggingEnabled(value: boolean);
  77889. /**
  77890. * Defines if the loader should capture performance counters.
  77891. */
  77892. get capturePerformanceCounters(): boolean;
  77893. set capturePerformanceCounters(value: boolean);
  77894. /**
  77895. * Defines if the loader should validate the asset.
  77896. */
  77897. validate: boolean;
  77898. /**
  77899. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77900. */
  77901. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77902. private _onValidatedObserver;
  77903. /**
  77904. * Callback raised after a loader extension is created.
  77905. */
  77906. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77907. private _loader;
  77908. /**
  77909. * Name of the loader ("gltf")
  77910. */
  77911. name: string;
  77912. /** @hidden */
  77913. extensions: ISceneLoaderPluginExtensions;
  77914. /**
  77915. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77916. */
  77917. dispose(): void;
  77918. /** @hidden */
  77919. _clear(): void;
  77920. /** @hidden */
  77921. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77922. /** @hidden */
  77923. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77924. /** @hidden */
  77925. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77926. meshes: AbstractMesh[];
  77927. particleSystems: IParticleSystem[];
  77928. skeletons: Skeleton[];
  77929. animationGroups: AnimationGroup[];
  77930. }>;
  77931. /** @hidden */
  77932. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77933. /** @hidden */
  77934. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77935. /** @hidden */
  77936. canDirectLoad(data: string): boolean;
  77937. /** @hidden */
  77938. directLoad(scene: Scene, data: string): any;
  77939. /**
  77940. * The callback that allows custom handling of the root url based on the response url.
  77941. * @param rootUrl the original root url
  77942. * @param responseURL the response url if available
  77943. * @returns the new root url
  77944. */
  77945. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77946. /** @hidden */
  77947. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77948. /**
  77949. * The loader state or null if the loader is not active.
  77950. */
  77951. get loaderState(): Nullable<GLTFLoaderState>;
  77952. /**
  77953. * Returns a promise that resolves when the asset is completely loaded.
  77954. * @returns a promise that resolves when the asset is completely loaded.
  77955. */
  77956. whenCompleteAsync(): Promise<void>;
  77957. private _validate;
  77958. private _getLoader;
  77959. private _parseJson;
  77960. private _unpackBinaryAsync;
  77961. private _unpackBinaryV1Async;
  77962. private _unpackBinaryV2Async;
  77963. private static _parseVersion;
  77964. private static _compareVersion;
  77965. private static readonly _logSpaces;
  77966. private _logIndentLevel;
  77967. private _loggingEnabled;
  77968. /** @hidden */
  77969. _log: (message: string) => void;
  77970. /** @hidden */
  77971. _logOpen(message: string): void;
  77972. /** @hidden */
  77973. _logClose(): void;
  77974. private _logEnabled;
  77975. private _logDisabled;
  77976. private _capturePerformanceCounters;
  77977. /** @hidden */
  77978. _startPerformanceCounter: (counterName: string) => void;
  77979. /** @hidden */
  77980. _endPerformanceCounter: (counterName: string) => void;
  77981. private _startPerformanceCounterEnabled;
  77982. private _startPerformanceCounterDisabled;
  77983. private _endPerformanceCounterEnabled;
  77984. private _endPerformanceCounterDisabled;
  77985. }
  77986. }
  77987. declare module BABYLON.GLTF1 {
  77988. /**
  77989. * Enums
  77990. * @hidden
  77991. */
  77992. export enum EComponentType {
  77993. BYTE = 5120,
  77994. UNSIGNED_BYTE = 5121,
  77995. SHORT = 5122,
  77996. UNSIGNED_SHORT = 5123,
  77997. FLOAT = 5126
  77998. }
  77999. /** @hidden */
  78000. export enum EShaderType {
  78001. FRAGMENT = 35632,
  78002. VERTEX = 35633
  78003. }
  78004. /** @hidden */
  78005. export enum EParameterType {
  78006. BYTE = 5120,
  78007. UNSIGNED_BYTE = 5121,
  78008. SHORT = 5122,
  78009. UNSIGNED_SHORT = 5123,
  78010. INT = 5124,
  78011. UNSIGNED_INT = 5125,
  78012. FLOAT = 5126,
  78013. FLOAT_VEC2 = 35664,
  78014. FLOAT_VEC3 = 35665,
  78015. FLOAT_VEC4 = 35666,
  78016. INT_VEC2 = 35667,
  78017. INT_VEC3 = 35668,
  78018. INT_VEC4 = 35669,
  78019. BOOL = 35670,
  78020. BOOL_VEC2 = 35671,
  78021. BOOL_VEC3 = 35672,
  78022. BOOL_VEC4 = 35673,
  78023. FLOAT_MAT2 = 35674,
  78024. FLOAT_MAT3 = 35675,
  78025. FLOAT_MAT4 = 35676,
  78026. SAMPLER_2D = 35678
  78027. }
  78028. /** @hidden */
  78029. export enum ETextureWrapMode {
  78030. CLAMP_TO_EDGE = 33071,
  78031. MIRRORED_REPEAT = 33648,
  78032. REPEAT = 10497
  78033. }
  78034. /** @hidden */
  78035. export enum ETextureFilterType {
  78036. NEAREST = 9728,
  78037. LINEAR = 9728,
  78038. NEAREST_MIPMAP_NEAREST = 9984,
  78039. LINEAR_MIPMAP_NEAREST = 9985,
  78040. NEAREST_MIPMAP_LINEAR = 9986,
  78041. LINEAR_MIPMAP_LINEAR = 9987
  78042. }
  78043. /** @hidden */
  78044. export enum ETextureFormat {
  78045. ALPHA = 6406,
  78046. RGB = 6407,
  78047. RGBA = 6408,
  78048. LUMINANCE = 6409,
  78049. LUMINANCE_ALPHA = 6410
  78050. }
  78051. /** @hidden */
  78052. export enum ECullingType {
  78053. FRONT = 1028,
  78054. BACK = 1029,
  78055. FRONT_AND_BACK = 1032
  78056. }
  78057. /** @hidden */
  78058. export enum EBlendingFunction {
  78059. ZERO = 0,
  78060. ONE = 1,
  78061. SRC_COLOR = 768,
  78062. ONE_MINUS_SRC_COLOR = 769,
  78063. DST_COLOR = 774,
  78064. ONE_MINUS_DST_COLOR = 775,
  78065. SRC_ALPHA = 770,
  78066. ONE_MINUS_SRC_ALPHA = 771,
  78067. DST_ALPHA = 772,
  78068. ONE_MINUS_DST_ALPHA = 773,
  78069. CONSTANT_COLOR = 32769,
  78070. ONE_MINUS_CONSTANT_COLOR = 32770,
  78071. CONSTANT_ALPHA = 32771,
  78072. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78073. SRC_ALPHA_SATURATE = 776
  78074. }
  78075. /** @hidden */
  78076. export interface IGLTFProperty {
  78077. extensions?: {
  78078. [key: string]: any;
  78079. };
  78080. extras?: Object;
  78081. }
  78082. /** @hidden */
  78083. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78084. name?: string;
  78085. }
  78086. /** @hidden */
  78087. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78088. bufferView: string;
  78089. byteOffset: number;
  78090. byteStride: number;
  78091. count: number;
  78092. type: string;
  78093. componentType: EComponentType;
  78094. max?: number[];
  78095. min?: number[];
  78096. name?: string;
  78097. }
  78098. /** @hidden */
  78099. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78100. buffer: string;
  78101. byteOffset: number;
  78102. byteLength: number;
  78103. byteStride: number;
  78104. target?: number;
  78105. }
  78106. /** @hidden */
  78107. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78108. uri: string;
  78109. byteLength?: number;
  78110. type?: string;
  78111. }
  78112. /** @hidden */
  78113. export interface IGLTFShader extends IGLTFChildRootProperty {
  78114. uri: string;
  78115. type: EShaderType;
  78116. }
  78117. /** @hidden */
  78118. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78119. attributes: string[];
  78120. fragmentShader: string;
  78121. vertexShader: string;
  78122. }
  78123. /** @hidden */
  78124. export interface IGLTFTechniqueParameter {
  78125. type: number;
  78126. count?: number;
  78127. semantic?: string;
  78128. node?: string;
  78129. value?: number | boolean | string | Array<any>;
  78130. source?: string;
  78131. babylonValue?: any;
  78132. }
  78133. /** @hidden */
  78134. export interface IGLTFTechniqueCommonProfile {
  78135. lightingModel: string;
  78136. texcoordBindings: Object;
  78137. parameters?: Array<any>;
  78138. }
  78139. /** @hidden */
  78140. export interface IGLTFTechniqueStatesFunctions {
  78141. blendColor?: number[];
  78142. blendEquationSeparate?: number[];
  78143. blendFuncSeparate?: number[];
  78144. colorMask: boolean[];
  78145. cullFace: number[];
  78146. }
  78147. /** @hidden */
  78148. export interface IGLTFTechniqueStates {
  78149. enable: number[];
  78150. functions: IGLTFTechniqueStatesFunctions;
  78151. }
  78152. /** @hidden */
  78153. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78154. parameters: {
  78155. [key: string]: IGLTFTechniqueParameter;
  78156. };
  78157. program: string;
  78158. attributes: {
  78159. [key: string]: string;
  78160. };
  78161. uniforms: {
  78162. [key: string]: string;
  78163. };
  78164. states: IGLTFTechniqueStates;
  78165. }
  78166. /** @hidden */
  78167. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78168. technique?: string;
  78169. values: string[];
  78170. }
  78171. /** @hidden */
  78172. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78173. attributes: {
  78174. [key: string]: string;
  78175. };
  78176. indices: string;
  78177. material: string;
  78178. mode?: number;
  78179. }
  78180. /** @hidden */
  78181. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78182. primitives: IGLTFMeshPrimitive[];
  78183. }
  78184. /** @hidden */
  78185. export interface IGLTFImage extends IGLTFChildRootProperty {
  78186. uri: string;
  78187. }
  78188. /** @hidden */
  78189. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78190. magFilter?: number;
  78191. minFilter?: number;
  78192. wrapS?: number;
  78193. wrapT?: number;
  78194. }
  78195. /** @hidden */
  78196. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78197. sampler: string;
  78198. source: string;
  78199. format?: ETextureFormat;
  78200. internalFormat?: ETextureFormat;
  78201. target?: number;
  78202. type?: number;
  78203. babylonTexture?: Texture;
  78204. }
  78205. /** @hidden */
  78206. export interface IGLTFAmbienLight {
  78207. color?: number[];
  78208. }
  78209. /** @hidden */
  78210. export interface IGLTFDirectionalLight {
  78211. color?: number[];
  78212. }
  78213. /** @hidden */
  78214. export interface IGLTFPointLight {
  78215. color?: number[];
  78216. constantAttenuation?: number;
  78217. linearAttenuation?: number;
  78218. quadraticAttenuation?: number;
  78219. }
  78220. /** @hidden */
  78221. export interface IGLTFSpotLight {
  78222. color?: number[];
  78223. constantAttenuation?: number;
  78224. fallOfAngle?: number;
  78225. fallOffExponent?: number;
  78226. linearAttenuation?: number;
  78227. quadraticAttenuation?: number;
  78228. }
  78229. /** @hidden */
  78230. export interface IGLTFLight extends IGLTFChildRootProperty {
  78231. type: string;
  78232. }
  78233. /** @hidden */
  78234. export interface IGLTFCameraOrthographic {
  78235. xmag: number;
  78236. ymag: number;
  78237. zfar: number;
  78238. znear: number;
  78239. }
  78240. /** @hidden */
  78241. export interface IGLTFCameraPerspective {
  78242. aspectRatio: number;
  78243. yfov: number;
  78244. zfar: number;
  78245. znear: number;
  78246. }
  78247. /** @hidden */
  78248. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78249. type: string;
  78250. }
  78251. /** @hidden */
  78252. export interface IGLTFAnimationChannelTarget {
  78253. id: string;
  78254. path: string;
  78255. }
  78256. /** @hidden */
  78257. export interface IGLTFAnimationChannel {
  78258. sampler: string;
  78259. target: IGLTFAnimationChannelTarget;
  78260. }
  78261. /** @hidden */
  78262. export interface IGLTFAnimationSampler {
  78263. input: string;
  78264. output: string;
  78265. interpolation?: string;
  78266. }
  78267. /** @hidden */
  78268. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78269. channels?: IGLTFAnimationChannel[];
  78270. parameters?: {
  78271. [key: string]: string;
  78272. };
  78273. samplers?: {
  78274. [key: string]: IGLTFAnimationSampler;
  78275. };
  78276. }
  78277. /** @hidden */
  78278. export interface IGLTFNodeInstanceSkin {
  78279. skeletons: string[];
  78280. skin: string;
  78281. meshes: string[];
  78282. }
  78283. /** @hidden */
  78284. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78285. bindShapeMatrix: number[];
  78286. inverseBindMatrices: string;
  78287. jointNames: string[];
  78288. babylonSkeleton?: Skeleton;
  78289. }
  78290. /** @hidden */
  78291. export interface IGLTFNode extends IGLTFChildRootProperty {
  78292. camera?: string;
  78293. children: string[];
  78294. skin?: string;
  78295. jointName?: string;
  78296. light?: string;
  78297. matrix: number[];
  78298. mesh?: string;
  78299. meshes?: string[];
  78300. rotation?: number[];
  78301. scale?: number[];
  78302. translation?: number[];
  78303. babylonNode?: Node;
  78304. }
  78305. /** @hidden */
  78306. export interface IGLTFScene extends IGLTFChildRootProperty {
  78307. nodes: string[];
  78308. }
  78309. /** @hidden */
  78310. export interface IGLTFRuntime {
  78311. extensions: {
  78312. [key: string]: any;
  78313. };
  78314. accessors: {
  78315. [key: string]: IGLTFAccessor;
  78316. };
  78317. buffers: {
  78318. [key: string]: IGLTFBuffer;
  78319. };
  78320. bufferViews: {
  78321. [key: string]: IGLTFBufferView;
  78322. };
  78323. meshes: {
  78324. [key: string]: IGLTFMesh;
  78325. };
  78326. lights: {
  78327. [key: string]: IGLTFLight;
  78328. };
  78329. cameras: {
  78330. [key: string]: IGLTFCamera;
  78331. };
  78332. nodes: {
  78333. [key: string]: IGLTFNode;
  78334. };
  78335. images: {
  78336. [key: string]: IGLTFImage;
  78337. };
  78338. textures: {
  78339. [key: string]: IGLTFTexture;
  78340. };
  78341. shaders: {
  78342. [key: string]: IGLTFShader;
  78343. };
  78344. programs: {
  78345. [key: string]: IGLTFProgram;
  78346. };
  78347. samplers: {
  78348. [key: string]: IGLTFSampler;
  78349. };
  78350. techniques: {
  78351. [key: string]: IGLTFTechnique;
  78352. };
  78353. materials: {
  78354. [key: string]: IGLTFMaterial;
  78355. };
  78356. animations: {
  78357. [key: string]: IGLTFAnimation;
  78358. };
  78359. skins: {
  78360. [key: string]: IGLTFSkins;
  78361. };
  78362. currentScene?: Object;
  78363. scenes: {
  78364. [key: string]: IGLTFScene;
  78365. };
  78366. extensionsUsed: string[];
  78367. extensionsRequired?: string[];
  78368. buffersCount: number;
  78369. shaderscount: number;
  78370. scene: Scene;
  78371. rootUrl: string;
  78372. loadedBufferCount: number;
  78373. loadedBufferViews: {
  78374. [name: string]: ArrayBufferView;
  78375. };
  78376. loadedShaderCount: number;
  78377. importOnlyMeshes: boolean;
  78378. importMeshesNames?: string[];
  78379. dummyNodes: Node[];
  78380. forAssetContainer: boolean;
  78381. }
  78382. /** @hidden */
  78383. export interface INodeToRoot {
  78384. bone: Bone;
  78385. node: IGLTFNode;
  78386. id: string;
  78387. }
  78388. /** @hidden */
  78389. export interface IJointNode {
  78390. node: IGLTFNode;
  78391. id: string;
  78392. }
  78393. }
  78394. declare module BABYLON.GLTF1 {
  78395. /**
  78396. * Utils functions for GLTF
  78397. * @hidden
  78398. */
  78399. export class GLTFUtils {
  78400. /**
  78401. * Sets the given "parameter" matrix
  78402. * @param scene: the Scene object
  78403. * @param source: the source node where to pick the matrix
  78404. * @param parameter: the GLTF technique parameter
  78405. * @param uniformName: the name of the shader's uniform
  78406. * @param shaderMaterial: the shader material
  78407. */
  78408. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78409. /**
  78410. * Sets the given "parameter" matrix
  78411. * @param shaderMaterial: the shader material
  78412. * @param uniform: the name of the shader's uniform
  78413. * @param value: the value of the uniform
  78414. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78415. */
  78416. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78417. /**
  78418. * Returns the wrap mode of the texture
  78419. * @param mode: the mode value
  78420. */
  78421. static GetWrapMode(mode: number): number;
  78422. /**
  78423. * Returns the byte stride giving an accessor
  78424. * @param accessor: the GLTF accessor objet
  78425. */
  78426. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78427. /**
  78428. * Returns the texture filter mode giving a mode value
  78429. * @param mode: the filter mode value
  78430. */
  78431. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78432. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78433. /**
  78434. * Returns a buffer from its accessor
  78435. * @param gltfRuntime: the GLTF runtime
  78436. * @param accessor: the GLTF accessor
  78437. */
  78438. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78439. /**
  78440. * Decodes a buffer view into a string
  78441. * @param view: the buffer view
  78442. */
  78443. static DecodeBufferToText(view: ArrayBufferView): string;
  78444. /**
  78445. * Returns the default material of gltf. Related to
  78446. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78447. * @param scene: the Babylon.js scene
  78448. */
  78449. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78450. private static _DefaultMaterial;
  78451. }
  78452. }
  78453. declare module BABYLON.GLTF1 {
  78454. /**
  78455. * Implementation of the base glTF spec
  78456. * @hidden
  78457. */
  78458. export class GLTFLoaderBase {
  78459. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78460. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78461. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78462. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78463. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78464. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78465. }
  78466. /**
  78467. * glTF V1 Loader
  78468. * @hidden
  78469. */
  78470. export class GLTFLoader implements IGLTFLoader {
  78471. static Extensions: {
  78472. [name: string]: GLTFLoaderExtension;
  78473. };
  78474. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78475. state: Nullable<GLTFLoaderState>;
  78476. dispose(): void;
  78477. private _importMeshAsync;
  78478. /**
  78479. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78480. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78481. * @param scene the scene the meshes should be added to
  78482. * @param forAssetContainer defines if the entities must be stored in the scene
  78483. * @param data gltf data containing information of the meshes in a loaded file
  78484. * @param rootUrl root url to load from
  78485. * @param onProgress event that fires when loading progress has occured
  78486. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78487. */
  78488. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78489. private _loadAsync;
  78490. /**
  78491. * Imports all objects from a loaded gltf file and adds them to the scene
  78492. * @param scene the scene the objects should be added to
  78493. * @param data gltf data containing information of the meshes in a loaded file
  78494. * @param rootUrl root url to load from
  78495. * @param onProgress event that fires when loading progress has occured
  78496. * @returns a promise which completes when objects have been loaded to the scene
  78497. */
  78498. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78499. private _loadShadersAsync;
  78500. private _loadBuffersAsync;
  78501. private _createNodes;
  78502. }
  78503. /** @hidden */
  78504. export abstract class GLTFLoaderExtension {
  78505. private _name;
  78506. constructor(name: string);
  78507. get name(): string;
  78508. /**
  78509. * Defines an override for loading the runtime
  78510. * Return true to stop further extensions from loading the runtime
  78511. */
  78512. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78513. /**
  78514. * Defines an onverride for creating gltf runtime
  78515. * Return true to stop further extensions from creating the runtime
  78516. */
  78517. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78518. /**
  78519. * Defines an override for loading buffers
  78520. * Return true to stop further extensions from loading this buffer
  78521. */
  78522. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78523. /**
  78524. * Defines an override for loading texture buffers
  78525. * Return true to stop further extensions from loading this texture data
  78526. */
  78527. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78528. /**
  78529. * Defines an override for creating textures
  78530. * Return true to stop further extensions from loading this texture
  78531. */
  78532. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78533. /**
  78534. * Defines an override for loading shader strings
  78535. * Return true to stop further extensions from loading this shader data
  78536. */
  78537. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78538. /**
  78539. * Defines an override for loading materials
  78540. * Return true to stop further extensions from loading this material
  78541. */
  78542. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78543. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78544. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78545. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78546. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78547. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78548. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78549. private static LoadTextureBufferAsync;
  78550. private static CreateTextureAsync;
  78551. private static ApplyExtensions;
  78552. }
  78553. }
  78554. declare module BABYLON.GLTF1 {
  78555. /** @hidden */
  78556. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78557. private _bin;
  78558. constructor();
  78559. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78560. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78561. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78562. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78563. }
  78564. }
  78565. declare module BABYLON.GLTF1 {
  78566. /** @hidden */
  78567. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78568. constructor();
  78569. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78570. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78571. private _loadTexture;
  78572. }
  78573. }
  78574. declare module BABYLON.GLTF2.Loader {
  78575. /**
  78576. * Loader interface with an index field.
  78577. */
  78578. export interface IArrayItem {
  78579. /**
  78580. * The index of this item in the array.
  78581. */
  78582. index: number;
  78583. }
  78584. /**
  78585. * Loader interface with additional members.
  78586. */
  78587. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78588. /** @hidden */
  78589. _data?: Promise<ArrayBufferView>;
  78590. /** @hidden */
  78591. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78592. }
  78593. /**
  78594. * Loader interface with additional members.
  78595. */
  78596. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78597. }
  78598. /** @hidden */
  78599. export interface _IAnimationSamplerData {
  78600. input: Float32Array;
  78601. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78602. output: Float32Array;
  78603. }
  78604. /**
  78605. * Loader interface with additional members.
  78606. */
  78607. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78608. /** @hidden */
  78609. _data?: Promise<_IAnimationSamplerData>;
  78610. }
  78611. /**
  78612. * Loader interface with additional members.
  78613. */
  78614. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78615. channels: IAnimationChannel[];
  78616. samplers: IAnimationSampler[];
  78617. /** @hidden */
  78618. _babylonAnimationGroup?: AnimationGroup;
  78619. }
  78620. /**
  78621. * Loader interface with additional members.
  78622. */
  78623. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78624. /** @hidden */
  78625. _data?: Promise<ArrayBufferView>;
  78626. }
  78627. /**
  78628. * Loader interface with additional members.
  78629. */
  78630. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78631. /** @hidden */
  78632. _data?: Promise<ArrayBufferView>;
  78633. /** @hidden */
  78634. _babylonBuffer?: Promise<Buffer>;
  78635. }
  78636. /**
  78637. * Loader interface with additional members.
  78638. */
  78639. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78640. }
  78641. /**
  78642. * Loader interface with additional members.
  78643. */
  78644. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78645. /** @hidden */
  78646. _data?: Promise<ArrayBufferView>;
  78647. }
  78648. /**
  78649. * Loader interface with additional members.
  78650. */
  78651. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78652. }
  78653. /**
  78654. * Loader interface with additional members.
  78655. */
  78656. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78657. }
  78658. /**
  78659. * Loader interface with additional members.
  78660. */
  78661. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78662. baseColorTexture?: ITextureInfo;
  78663. metallicRoughnessTexture?: ITextureInfo;
  78664. }
  78665. /**
  78666. * Loader interface with additional members.
  78667. */
  78668. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78669. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78670. normalTexture?: IMaterialNormalTextureInfo;
  78671. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78672. emissiveTexture?: ITextureInfo;
  78673. /** @hidden */
  78674. _data?: {
  78675. [babylonDrawMode: number]: {
  78676. babylonMaterial: Material;
  78677. babylonMeshes: AbstractMesh[];
  78678. promise: Promise<void>;
  78679. };
  78680. };
  78681. }
  78682. /**
  78683. * Loader interface with additional members.
  78684. */
  78685. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78686. primitives: IMeshPrimitive[];
  78687. }
  78688. /**
  78689. * Loader interface with additional members.
  78690. */
  78691. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78692. /** @hidden */
  78693. _instanceData?: {
  78694. babylonSourceMesh: Mesh;
  78695. promise: Promise<any>;
  78696. };
  78697. }
  78698. /**
  78699. * Loader interface with additional members.
  78700. */
  78701. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78702. /**
  78703. * The parent glTF node.
  78704. */
  78705. parent?: INode;
  78706. /** @hidden */
  78707. _babylonTransformNode?: TransformNode;
  78708. /** @hidden */
  78709. _primitiveBabylonMeshes?: AbstractMesh[];
  78710. /** @hidden */
  78711. _babylonBones?: Bone[];
  78712. /** @hidden */
  78713. _numMorphTargets?: number;
  78714. }
  78715. /** @hidden */
  78716. export interface _ISamplerData {
  78717. noMipMaps: boolean;
  78718. samplingMode: number;
  78719. wrapU: number;
  78720. wrapV: number;
  78721. }
  78722. /**
  78723. * Loader interface with additional members.
  78724. */
  78725. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78726. /** @hidden */
  78727. _data?: _ISamplerData;
  78728. }
  78729. /**
  78730. * Loader interface with additional members.
  78731. */
  78732. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78733. }
  78734. /**
  78735. * Loader interface with additional members.
  78736. */
  78737. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78738. /** @hidden */
  78739. _data?: {
  78740. babylonSkeleton: Skeleton;
  78741. promise: Promise<void>;
  78742. };
  78743. }
  78744. /**
  78745. * Loader interface with additional members.
  78746. */
  78747. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78748. }
  78749. /**
  78750. * Loader interface with additional members.
  78751. */
  78752. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78753. }
  78754. /**
  78755. * Loader interface with additional members.
  78756. */
  78757. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78758. accessors?: IAccessor[];
  78759. animations?: IAnimation[];
  78760. buffers?: IBuffer[];
  78761. bufferViews?: IBufferView[];
  78762. cameras?: ICamera[];
  78763. images?: IImage[];
  78764. materials?: IMaterial[];
  78765. meshes?: IMesh[];
  78766. nodes?: INode[];
  78767. samplers?: ISampler[];
  78768. scenes?: IScene[];
  78769. skins?: ISkin[];
  78770. textures?: ITexture[];
  78771. }
  78772. }
  78773. declare module BABYLON.GLTF2 {
  78774. /**
  78775. * Interface for a glTF loader extension.
  78776. */
  78777. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78778. /**
  78779. * Called after the loader state changes to LOADING.
  78780. */
  78781. onLoading?(): void;
  78782. /**
  78783. * Called after the loader state changes to READY.
  78784. */
  78785. onReady?(): void;
  78786. /**
  78787. * Define this method to modify the default behavior when loading scenes.
  78788. * @param context The context when loading the asset
  78789. * @param scene The glTF scene property
  78790. * @returns A promise that resolves when the load is complete or null if not handled
  78791. */
  78792. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78793. /**
  78794. * Define this method to modify the default behavior when loading nodes.
  78795. * @param context The context when loading the asset
  78796. * @param node The glTF node property
  78797. * @param assign A function called synchronously after parsing the glTF properties
  78798. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78799. */
  78800. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78801. /**
  78802. * Define this method to modify the default behavior when loading cameras.
  78803. * @param context The context when loading the asset
  78804. * @param camera The glTF camera property
  78805. * @param assign A function called synchronously after parsing the glTF properties
  78806. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78807. */
  78808. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78809. /**
  78810. * @hidden
  78811. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78812. * @param context The context when loading the asset
  78813. * @param primitive The glTF mesh primitive property
  78814. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78815. */
  78816. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78817. /**
  78818. * @hidden
  78819. * Define this method to modify the default behavior when loading data for mesh primitives.
  78820. * @param context The context when loading the asset
  78821. * @param name The mesh name when loading the asset
  78822. * @param node The glTF node when loading the asset
  78823. * @param mesh The glTF mesh when loading the asset
  78824. * @param primitive The glTF mesh primitive property
  78825. * @param assign A function called synchronously after parsing the glTF properties
  78826. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78827. */
  78828. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78829. /**
  78830. * @hidden
  78831. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78832. * @param context The context when loading the asset
  78833. * @param material The glTF material property
  78834. * @param assign A function called synchronously after parsing the glTF properties
  78835. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78836. */
  78837. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78838. /**
  78839. * Define this method to modify the default behavior when creating materials.
  78840. * @param context The context when loading the asset
  78841. * @param material The glTF material property
  78842. * @param babylonDrawMode The draw mode for the Babylon material
  78843. * @returns The Babylon material or null if not handled
  78844. */
  78845. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78846. /**
  78847. * Define this method to modify the default behavior when loading material properties.
  78848. * @param context The context when loading the asset
  78849. * @param material The glTF material property
  78850. * @param babylonMaterial The Babylon material
  78851. * @returns A promise that resolves when the load is complete or null if not handled
  78852. */
  78853. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78854. /**
  78855. * Define this method to modify the default behavior when loading texture infos.
  78856. * @param context The context when loading the asset
  78857. * @param textureInfo The glTF texture info property
  78858. * @param assign A function called synchronously after parsing the glTF properties
  78859. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78860. */
  78861. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78862. /**
  78863. * @hidden
  78864. * Define this method to modify the default behavior when loading textures.
  78865. * @param context The context when loading the asset
  78866. * @param texture The glTF texture property
  78867. * @param assign A function called synchronously after parsing the glTF properties
  78868. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78869. */
  78870. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78871. /**
  78872. * Define this method to modify the default behavior when loading animations.
  78873. * @param context The context when loading the asset
  78874. * @param animation The glTF animation property
  78875. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  78876. */
  78877. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78878. /**
  78879. * @hidden
  78880. * Define this method to modify the default behavior when loading skins.
  78881. * @param context The context when loading the asset
  78882. * @param node The glTF node property
  78883. * @param skin The glTF skin property
  78884. * @returns A promise that resolves when the load is complete or null if not handled
  78885. */
  78886. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  78887. /**
  78888. * @hidden
  78889. * Define this method to modify the default behavior when loading uris.
  78890. * @param context The context when loading the asset
  78891. * @param property The glTF property associated with the uri
  78892. * @param uri The uri to load
  78893. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78894. */
  78895. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78896. /**
  78897. * Define this method to modify the default behavior when loading buffer views.
  78898. * @param context The context when loading the asset
  78899. * @param bufferView The glTF buffer view property
  78900. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78901. */
  78902. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78903. /**
  78904. * Define this method to modify the default behavior when loading buffers.
  78905. * @param context The context when loading the asset
  78906. * @param buffer The glTF buffer property
  78907. * @param byteOffset The byte offset to load
  78908. * @param byteLength The byte length to load
  78909. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78910. */
  78911. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78912. }
  78913. }
  78914. declare module BABYLON.GLTF2 {
  78915. /**
  78916. * Helper class for working with arrays when loading the glTF asset
  78917. */
  78918. export class ArrayItem {
  78919. /**
  78920. * Gets an item from the given array.
  78921. * @param context The context when loading the asset
  78922. * @param array The array to get the item from
  78923. * @param index The index to the array
  78924. * @returns The array item
  78925. */
  78926. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78927. /**
  78928. * Assign an `index` field to each item of the given array.
  78929. * @param array The array of items
  78930. */
  78931. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78932. }
  78933. /**
  78934. * The glTF 2.0 loader
  78935. */
  78936. export class GLTFLoader implements IGLTFLoader {
  78937. /** @hidden */
  78938. _completePromises: Promise<any>[];
  78939. /** @hidden */
  78940. _forAssetContainer: boolean;
  78941. /** Storage */
  78942. _babylonLights: Light[];
  78943. private _disposed;
  78944. private _parent;
  78945. private _state;
  78946. private _extensions;
  78947. private _rootUrl;
  78948. private _fileName;
  78949. private _uniqueRootUrl;
  78950. private _gltf;
  78951. private _bin;
  78952. private _babylonScene;
  78953. private _rootBabylonMesh;
  78954. private _defaultBabylonMaterialData;
  78955. private _progressCallback?;
  78956. private _requests;
  78957. private static _RegisteredExtensions;
  78958. /**
  78959. * The default glTF sampler.
  78960. */
  78961. static readonly DefaultSampler: ISampler;
  78962. /**
  78963. * Registers a loader extension.
  78964. * @param name The name of the loader extension.
  78965. * @param factory The factory function that creates the loader extension.
  78966. */
  78967. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78968. /**
  78969. * Unregisters a loader extension.
  78970. * @param name The name of the loader extension.
  78971. * @returns A boolean indicating whether the extension has been unregistered
  78972. */
  78973. static UnregisterExtension(name: string): boolean;
  78974. /**
  78975. * The loader state.
  78976. */
  78977. get state(): Nullable<GLTFLoaderState>;
  78978. /**
  78979. * The object that represents the glTF JSON.
  78980. */
  78981. get gltf(): IGLTF;
  78982. /**
  78983. * The BIN chunk of a binary glTF.
  78984. */
  78985. get bin(): Nullable<IDataBuffer>;
  78986. /**
  78987. * The parent file loader.
  78988. */
  78989. get parent(): GLTFFileLoader;
  78990. /**
  78991. * The Babylon scene when loading the asset.
  78992. */
  78993. get babylonScene(): Scene;
  78994. /**
  78995. * The root Babylon mesh when loading the asset.
  78996. */
  78997. get rootBabylonMesh(): Mesh;
  78998. /** @hidden */
  78999. constructor(parent: GLTFFileLoader);
  79000. /** @hidden */
  79001. dispose(): void;
  79002. /** @hidden */
  79003. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79004. /** @hidden */
  79005. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79006. private _loadAsync;
  79007. private _loadData;
  79008. private _setupData;
  79009. private _loadExtensions;
  79010. private _checkExtensions;
  79011. private _setState;
  79012. private _createRootNode;
  79013. /**
  79014. * Loads a glTF scene.
  79015. * @param context The context when loading the asset
  79016. * @param scene The glTF scene property
  79017. * @returns A promise that resolves when the load is complete
  79018. */
  79019. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79020. private _forEachPrimitive;
  79021. private _getMeshes;
  79022. private _getTransformNodes;
  79023. private _getSkeletons;
  79024. private _getAnimationGroups;
  79025. private _startAnimations;
  79026. /**
  79027. * Loads a glTF node.
  79028. * @param context The context when loading the asset
  79029. * @param node The glTF node property
  79030. * @param assign A function called synchronously after parsing the glTF properties
  79031. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79032. */
  79033. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79034. private _loadMeshAsync;
  79035. /**
  79036. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79037. * @param context The context when loading the asset
  79038. * @param name The mesh name when loading the asset
  79039. * @param node The glTF node when loading the asset
  79040. * @param mesh The glTF mesh when loading the asset
  79041. * @param primitive The glTF mesh primitive property
  79042. * @param assign A function called synchronously after parsing the glTF properties
  79043. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79044. */
  79045. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79046. private _loadVertexDataAsync;
  79047. private _createMorphTargets;
  79048. private _loadMorphTargetsAsync;
  79049. private _loadMorphTargetVertexDataAsync;
  79050. private static _LoadTransform;
  79051. private _loadSkinAsync;
  79052. private _loadBones;
  79053. private _loadBone;
  79054. private _loadSkinInverseBindMatricesDataAsync;
  79055. private _updateBoneMatrices;
  79056. private _getNodeMatrix;
  79057. /**
  79058. * Loads a glTF camera.
  79059. * @param context The context when loading the asset
  79060. * @param camera The glTF camera property
  79061. * @param assign A function called synchronously after parsing the glTF properties
  79062. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79063. */
  79064. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79065. private _loadAnimationsAsync;
  79066. /**
  79067. * Loads a glTF animation.
  79068. * @param context The context when loading the asset
  79069. * @param animation The glTF animation property
  79070. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79071. */
  79072. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79073. /**
  79074. * @hidden Loads a glTF animation channel.
  79075. * @param context The context when loading the asset
  79076. * @param animationContext The context of the animation when loading the asset
  79077. * @param animation The glTF animation property
  79078. * @param channel The glTF animation channel property
  79079. * @param babylonAnimationGroup The babylon animation group property
  79080. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79081. * @returns A void promise when the channel load is complete
  79082. */
  79083. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79084. private _loadAnimationSamplerAsync;
  79085. private _loadBufferAsync;
  79086. /**
  79087. * Loads a glTF buffer view.
  79088. * @param context The context when loading the asset
  79089. * @param bufferView The glTF buffer view property
  79090. * @returns A promise that resolves with the loaded data when the load is complete
  79091. */
  79092. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79093. private _loadAccessorAsync;
  79094. /** @hidden */
  79095. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79096. private _loadIndicesAccessorAsync;
  79097. private _loadVertexBufferViewAsync;
  79098. private _loadVertexAccessorAsync;
  79099. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79100. /** @hidden */
  79101. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79102. private _createDefaultMaterial;
  79103. /**
  79104. * Creates a Babylon material from a glTF material.
  79105. * @param context The context when loading the asset
  79106. * @param material The glTF material property
  79107. * @param babylonDrawMode The draw mode for the Babylon material
  79108. * @returns The Babylon material
  79109. */
  79110. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79111. /**
  79112. * Loads properties from a glTF material into a Babylon material.
  79113. * @param context The context when loading the asset
  79114. * @param material The glTF material property
  79115. * @param babylonMaterial The Babylon material
  79116. * @returns A promise that resolves when the load is complete
  79117. */
  79118. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79119. /**
  79120. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79121. * @param context The context when loading the asset
  79122. * @param material The glTF material property
  79123. * @param babylonMaterial The Babylon material
  79124. * @returns A promise that resolves when the load is complete
  79125. */
  79126. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79127. /**
  79128. * Loads the alpha properties from a glTF material into a Babylon material.
  79129. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79130. * @param context The context when loading the asset
  79131. * @param material The glTF material property
  79132. * @param babylonMaterial The Babylon material
  79133. */
  79134. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79135. /**
  79136. * Loads a glTF texture info.
  79137. * @param context The context when loading the asset
  79138. * @param textureInfo The glTF texture info property
  79139. * @param assign A function called synchronously after parsing the glTF properties
  79140. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79141. */
  79142. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79143. /** @hidden */
  79144. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79145. /** @hidden */
  79146. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79147. private _loadSampler;
  79148. /**
  79149. * Loads a glTF image.
  79150. * @param context The context when loading the asset
  79151. * @param image The glTF image property
  79152. * @returns A promise that resolves with the loaded data when the load is complete
  79153. */
  79154. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79155. /**
  79156. * Loads a glTF uri.
  79157. * @param context The context when loading the asset
  79158. * @param property The glTF property associated with the uri
  79159. * @param uri The base64 or relative uri
  79160. * @returns A promise that resolves with the loaded data when the load is complete
  79161. */
  79162. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79163. private _onProgress;
  79164. /**
  79165. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79166. * @param babylonObject the Babylon object with metadata
  79167. * @param pointer the JSON pointer
  79168. */
  79169. static AddPointerMetadata(babylonObject: {
  79170. metadata: any;
  79171. }, pointer: string): void;
  79172. private static _GetTextureWrapMode;
  79173. private static _GetTextureSamplingMode;
  79174. private static _GetTypedArrayConstructor;
  79175. private static _GetTypedArray;
  79176. private static _GetNumComponents;
  79177. private static _ValidateUri;
  79178. private static _GetDrawMode;
  79179. private _compileMaterialsAsync;
  79180. private _compileShadowGeneratorsAsync;
  79181. private _forEachExtensions;
  79182. private _applyExtensions;
  79183. private _extensionsOnLoading;
  79184. private _extensionsOnReady;
  79185. private _extensionsLoadSceneAsync;
  79186. private _extensionsLoadNodeAsync;
  79187. private _extensionsLoadCameraAsync;
  79188. private _extensionsLoadVertexDataAsync;
  79189. private _extensionsLoadMeshPrimitiveAsync;
  79190. private _extensionsLoadMaterialAsync;
  79191. private _extensionsCreateMaterial;
  79192. private _extensionsLoadMaterialPropertiesAsync;
  79193. private _extensionsLoadTextureInfoAsync;
  79194. private _extensionsLoadTextureAsync;
  79195. private _extensionsLoadAnimationAsync;
  79196. private _extensionsLoadSkinAsync;
  79197. private _extensionsLoadUriAsync;
  79198. private _extensionsLoadBufferViewAsync;
  79199. private _extensionsLoadBufferAsync;
  79200. /**
  79201. * Helper method called by a loader extension to load an glTF extension.
  79202. * @param context The context when loading the asset
  79203. * @param property The glTF property to load the extension from
  79204. * @param extensionName The name of the extension to load
  79205. * @param actionAsync The action to run
  79206. * @returns The promise returned by actionAsync or null if the extension does not exist
  79207. */
  79208. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79209. /**
  79210. * Helper method called by a loader extension to load a glTF extra.
  79211. * @param context The context when loading the asset
  79212. * @param property The glTF property to load the extra from
  79213. * @param extensionName The name of the extension to load
  79214. * @param actionAsync The action to run
  79215. * @returns The promise returned by actionAsync or null if the extra does not exist
  79216. */
  79217. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79218. /**
  79219. * Checks for presence of an extension.
  79220. * @param name The name of the extension to check
  79221. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79222. */
  79223. isExtensionUsed(name: string): boolean;
  79224. /**
  79225. * Increments the indentation level and logs a message.
  79226. * @param message The message to log
  79227. */
  79228. logOpen(message: string): void;
  79229. /**
  79230. * Decrements the indentation level.
  79231. */
  79232. logClose(): void;
  79233. /**
  79234. * Logs a message
  79235. * @param message The message to log
  79236. */
  79237. log(message: string): void;
  79238. /**
  79239. * Starts a performance counter.
  79240. * @param counterName The name of the performance counter
  79241. */
  79242. startPerformanceCounter(counterName: string): void;
  79243. /**
  79244. * Ends a performance counter.
  79245. * @param counterName The name of the performance counter
  79246. */
  79247. endPerformanceCounter(counterName: string): void;
  79248. }
  79249. }
  79250. declare module BABYLON.GLTF2.Loader.Extensions {
  79251. /**
  79252. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79253. */
  79254. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79255. /**
  79256. * The name of this extension.
  79257. */
  79258. readonly name: string;
  79259. /**
  79260. * Defines whether this extension is enabled.
  79261. */
  79262. enabled: boolean;
  79263. private _loader;
  79264. private _lights?;
  79265. /** @hidden */
  79266. constructor(loader: GLTFLoader);
  79267. /** @hidden */
  79268. dispose(): void;
  79269. /** @hidden */
  79270. onLoading(): void;
  79271. /** @hidden */
  79272. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79273. private _loadLightAsync;
  79274. }
  79275. }
  79276. declare module BABYLON.GLTF2.Loader.Extensions {
  79277. /**
  79278. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79279. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79280. * !!! Experimental Extension Subject to Changes !!!
  79281. */
  79282. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79283. /**
  79284. * The name of this extension.
  79285. */
  79286. readonly name: string;
  79287. /**
  79288. * Defines whether this extension is enabled.
  79289. */
  79290. enabled: boolean;
  79291. private _loader;
  79292. /** @hidden */
  79293. constructor(loader: GLTFLoader);
  79294. /** @hidden */
  79295. dispose(): void;
  79296. /** @hidden */
  79297. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79298. }
  79299. }
  79300. declare module BABYLON.GLTF2.Loader.Extensions {
  79301. /**
  79302. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79303. */
  79304. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79305. /**
  79306. * The name of this extension.
  79307. */
  79308. readonly name: string;
  79309. /**
  79310. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79311. */
  79312. dracoCompression?: DracoCompression;
  79313. /**
  79314. * Defines whether this extension is enabled.
  79315. */
  79316. enabled: boolean;
  79317. private _loader;
  79318. /** @hidden */
  79319. constructor(loader: GLTFLoader);
  79320. /** @hidden */
  79321. dispose(): void;
  79322. /** @hidden */
  79323. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79324. }
  79325. }
  79326. declare module BABYLON.GLTF2.Loader.Extensions {
  79327. /**
  79328. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79329. */
  79330. export class KHR_lights implements IGLTFLoaderExtension {
  79331. /**
  79332. * The name of this extension.
  79333. */
  79334. readonly name: string;
  79335. /**
  79336. * Defines whether this extension is enabled.
  79337. */
  79338. enabled: boolean;
  79339. private _loader;
  79340. private _lights?;
  79341. /** @hidden */
  79342. constructor(loader: GLTFLoader);
  79343. /** @hidden */
  79344. dispose(): void;
  79345. /** @hidden */
  79346. onLoading(): void;
  79347. /** @hidden */
  79348. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79349. }
  79350. }
  79351. declare module BABYLON.GLTF2.Loader.Extensions {
  79352. /**
  79353. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79354. */
  79355. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79356. /**
  79357. * The name of this extension.
  79358. */
  79359. readonly name: string;
  79360. /**
  79361. * Defines whether this extension is enabled.
  79362. */
  79363. enabled: boolean;
  79364. /**
  79365. * Defines a number that determines the order the extensions are applied.
  79366. */
  79367. order: number;
  79368. private _loader;
  79369. /** @hidden */
  79370. constructor(loader: GLTFLoader);
  79371. /** @hidden */
  79372. dispose(): void;
  79373. /** @hidden */
  79374. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79375. private _loadSpecularGlossinessPropertiesAsync;
  79376. }
  79377. }
  79378. declare module BABYLON.GLTF2.Loader.Extensions {
  79379. /**
  79380. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79381. */
  79382. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79383. /**
  79384. * The name of this extension.
  79385. */
  79386. readonly name: string;
  79387. /**
  79388. * Defines whether this extension is enabled.
  79389. */
  79390. enabled: boolean;
  79391. /**
  79392. * Defines a number that determines the order the extensions are applied.
  79393. */
  79394. order: number;
  79395. private _loader;
  79396. /** @hidden */
  79397. constructor(loader: GLTFLoader);
  79398. /** @hidden */
  79399. dispose(): void;
  79400. /** @hidden */
  79401. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79402. private _loadUnlitPropertiesAsync;
  79403. }
  79404. }
  79405. declare module BABYLON.GLTF2.Loader.Extensions {
  79406. /**
  79407. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79408. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79409. * !!! Experimental Extension Subject to Changes !!!
  79410. */
  79411. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79412. /**
  79413. * The name of this extension.
  79414. */
  79415. readonly name: string;
  79416. /**
  79417. * Defines whether this extension is enabled.
  79418. */
  79419. enabled: boolean;
  79420. /**
  79421. * Defines a number that determines the order the extensions are applied.
  79422. */
  79423. order: number;
  79424. private _loader;
  79425. /** @hidden */
  79426. constructor(loader: GLTFLoader);
  79427. /** @hidden */
  79428. dispose(): void;
  79429. /** @hidden */
  79430. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79431. private _loadClearCoatPropertiesAsync;
  79432. }
  79433. }
  79434. declare module BABYLON.GLTF2.Loader.Extensions {
  79435. /**
  79436. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79437. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79438. * !!! Experimental Extension Subject to Changes !!!
  79439. */
  79440. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79441. /**
  79442. * The name of this extension.
  79443. */
  79444. readonly name: string;
  79445. /**
  79446. * Defines whether this extension is enabled.
  79447. */
  79448. enabled: boolean;
  79449. /**
  79450. * Defines a number that determines the order the extensions are applied.
  79451. */
  79452. order: number;
  79453. private _loader;
  79454. /** @hidden */
  79455. constructor(loader: GLTFLoader);
  79456. /** @hidden */
  79457. dispose(): void;
  79458. /** @hidden */
  79459. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79460. private _loadSheenPropertiesAsync;
  79461. }
  79462. }
  79463. declare module BABYLON.GLTF2.Loader.Extensions {
  79464. /**
  79465. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79466. * !!! Experimental Extension Subject to Changes !!!
  79467. */
  79468. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79469. /**
  79470. * The name of this extension.
  79471. */
  79472. readonly name: string;
  79473. /**
  79474. * Defines whether this extension is enabled.
  79475. */
  79476. enabled: boolean;
  79477. /**
  79478. * Defines a number that determines the order the extensions are applied.
  79479. */
  79480. order: number;
  79481. private _loader;
  79482. /** @hidden */
  79483. constructor(loader: GLTFLoader);
  79484. /** @hidden */
  79485. dispose(): void;
  79486. /** @hidden */
  79487. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79488. private _loadSpecularPropertiesAsync;
  79489. }
  79490. }
  79491. declare module BABYLON.GLTF2.Loader.Extensions {
  79492. /**
  79493. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79494. * !!! Experimental Extension Subject to Changes !!!
  79495. */
  79496. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79497. /**
  79498. * Default ior Value from the spec.
  79499. */
  79500. private static readonly _DEFAULT_IOR;
  79501. /**
  79502. * The name of this extension.
  79503. */
  79504. readonly name: string;
  79505. /**
  79506. * Defines whether this extension is enabled.
  79507. */
  79508. enabled: boolean;
  79509. /**
  79510. * Defines a number that determines the order the extensions are applied.
  79511. */
  79512. order: number;
  79513. private _loader;
  79514. /** @hidden */
  79515. constructor(loader: GLTFLoader);
  79516. /** @hidden */
  79517. dispose(): void;
  79518. /** @hidden */
  79519. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79520. private _loadIorPropertiesAsync;
  79521. }
  79522. }
  79523. declare module BABYLON.GLTF2.Loader.Extensions {
  79524. /**
  79525. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79526. */
  79527. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79528. /**
  79529. * The name of this extension.
  79530. */
  79531. readonly name: string;
  79532. /**
  79533. * Defines whether this extension is enabled.
  79534. */
  79535. enabled: boolean;
  79536. /** @hidden */
  79537. constructor(loader: GLTFLoader);
  79538. /** @hidden */
  79539. dispose(): void;
  79540. }
  79541. }
  79542. declare module BABYLON.GLTF2.Loader.Extensions {
  79543. /**
  79544. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79545. * !!! Experimental Extension Subject to Changes !!!
  79546. */
  79547. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79548. /** The name of this extension. */
  79549. readonly name: string;
  79550. /** Defines whether this extension is enabled. */
  79551. enabled: boolean;
  79552. private _loader;
  79553. /** @hidden */
  79554. constructor(loader: GLTFLoader);
  79555. /** @hidden */
  79556. dispose(): void;
  79557. /** @hidden */
  79558. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79559. }
  79560. }
  79561. declare module BABYLON.GLTF2.Loader.Extensions {
  79562. /**
  79563. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79564. */
  79565. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79566. /**
  79567. * The name of this extension.
  79568. */
  79569. readonly name: string;
  79570. /**
  79571. * Defines whether this extension is enabled.
  79572. */
  79573. enabled: boolean;
  79574. private _loader;
  79575. /** @hidden */
  79576. constructor(loader: GLTFLoader);
  79577. /** @hidden */
  79578. dispose(): void;
  79579. /** @hidden */
  79580. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79581. }
  79582. }
  79583. declare module BABYLON.GLTF2.Loader.Extensions {
  79584. /**
  79585. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79586. */
  79587. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79588. /**
  79589. * The name of this extension.
  79590. */
  79591. readonly name: string;
  79592. /**
  79593. * Defines whether this extension is enabled.
  79594. */
  79595. enabled: boolean;
  79596. private _loader;
  79597. private _clips;
  79598. private _emitters;
  79599. /** @hidden */
  79600. constructor(loader: GLTFLoader);
  79601. /** @hidden */
  79602. dispose(): void;
  79603. /** @hidden */
  79604. onLoading(): void;
  79605. /** @hidden */
  79606. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79607. /** @hidden */
  79608. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79609. /** @hidden */
  79610. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79611. private _loadClipAsync;
  79612. private _loadEmitterAsync;
  79613. private _getEventAction;
  79614. private _loadAnimationEventAsync;
  79615. }
  79616. }
  79617. declare module BABYLON.GLTF2.Loader.Extensions {
  79618. /**
  79619. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79620. */
  79621. export class MSFT_lod implements IGLTFLoaderExtension {
  79622. /**
  79623. * The name of this extension.
  79624. */
  79625. readonly name: string;
  79626. /**
  79627. * Defines whether this extension is enabled.
  79628. */
  79629. enabled: boolean;
  79630. /**
  79631. * Defines a number that determines the order the extensions are applied.
  79632. */
  79633. order: number;
  79634. /**
  79635. * Maximum number of LODs to load, starting from the lowest LOD.
  79636. */
  79637. maxLODsToLoad: number;
  79638. /**
  79639. * Observable raised when all node LODs of one level are loaded.
  79640. * The event data is the index of the loaded LOD starting from zero.
  79641. * Dispose the loader to cancel the loading of the next level of LODs.
  79642. */
  79643. onNodeLODsLoadedObservable: Observable<number>;
  79644. /**
  79645. * Observable raised when all material LODs of one level are loaded.
  79646. * The event data is the index of the loaded LOD starting from zero.
  79647. * Dispose the loader to cancel the loading of the next level of LODs.
  79648. */
  79649. onMaterialLODsLoadedObservable: Observable<number>;
  79650. private _loader;
  79651. private _nodeIndexLOD;
  79652. private _nodeSignalLODs;
  79653. private _nodePromiseLODs;
  79654. private _materialIndexLOD;
  79655. private _materialSignalLODs;
  79656. private _materialPromiseLODs;
  79657. private _indexLOD;
  79658. private _bufferLODs;
  79659. /** @hidden */
  79660. constructor(loader: GLTFLoader);
  79661. /** @hidden */
  79662. dispose(): void;
  79663. /** @hidden */
  79664. onReady(): void;
  79665. /** @hidden */
  79666. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79667. /** @hidden */
  79668. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79669. /** @hidden */
  79670. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79671. /** @hidden */
  79672. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79673. /** @hidden */
  79674. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79675. private _loadBufferLOD;
  79676. /**
  79677. * Gets an array of LOD properties from lowest to highest.
  79678. */
  79679. private _getLODs;
  79680. private _disposeTransformNode;
  79681. private _disposeMaterials;
  79682. }
  79683. }
  79684. declare module BABYLON.GLTF2.Loader.Extensions {
  79685. /** @hidden */
  79686. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79687. readonly name: string;
  79688. enabled: boolean;
  79689. private _loader;
  79690. constructor(loader: GLTFLoader);
  79691. dispose(): void;
  79692. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79693. }
  79694. }
  79695. declare module BABYLON.GLTF2.Loader.Extensions {
  79696. /** @hidden */
  79697. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79698. readonly name: string;
  79699. enabled: boolean;
  79700. private _loader;
  79701. constructor(loader: GLTFLoader);
  79702. dispose(): void;
  79703. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79704. }
  79705. }
  79706. declare module BABYLON.GLTF2.Loader.Extensions {
  79707. /**
  79708. * Store glTF extras (if present) in BJS objects' metadata
  79709. */
  79710. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79711. /**
  79712. * The name of this extension.
  79713. */
  79714. readonly name: string;
  79715. /**
  79716. * Defines whether this extension is enabled.
  79717. */
  79718. enabled: boolean;
  79719. private _loader;
  79720. private _assignExtras;
  79721. /** @hidden */
  79722. constructor(loader: GLTFLoader);
  79723. /** @hidden */
  79724. dispose(): void;
  79725. /** @hidden */
  79726. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79727. /** @hidden */
  79728. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79729. /** @hidden */
  79730. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79731. }
  79732. }
  79733. declare module BABYLON {
  79734. /**
  79735. * Class reading and parsing the MTL file bundled with the obj file.
  79736. */
  79737. export class MTLFileLoader {
  79738. /**
  79739. * Invert Y-Axis of referenced textures on load
  79740. */
  79741. static INVERT_TEXTURE_Y: boolean;
  79742. /**
  79743. * All material loaded from the mtl will be set here
  79744. */
  79745. materials: StandardMaterial[];
  79746. /**
  79747. * This function will read the mtl file and create each material described inside
  79748. * This function could be improve by adding :
  79749. * -some component missing (Ni, Tf...)
  79750. * -including the specific options available
  79751. *
  79752. * @param scene defines the scene the material will be created in
  79753. * @param data defines the mtl data to parse
  79754. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79755. * @param forAssetContainer defines if the material should be registered in the scene
  79756. */
  79757. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79758. /**
  79759. * Gets the texture for the material.
  79760. *
  79761. * If the material is imported from input file,
  79762. * We sanitize the url to ensure it takes the textre from aside the material.
  79763. *
  79764. * @param rootUrl The root url to load from
  79765. * @param value The value stored in the mtl
  79766. * @return The Texture
  79767. */
  79768. private static _getTexture;
  79769. }
  79770. }
  79771. declare module BABYLON {
  79772. /**
  79773. * Options for loading OBJ/MTL files
  79774. */
  79775. type MeshLoadOptions = {
  79776. /**
  79777. * Defines if UVs are optimized by default during load.
  79778. */
  79779. OptimizeWithUV: boolean;
  79780. /**
  79781. * Defines custom scaling of UV coordinates of loaded meshes.
  79782. */
  79783. UVScaling: Vector2;
  79784. /**
  79785. * Invert model on y-axis (does a model scaling inversion)
  79786. */
  79787. InvertY: boolean;
  79788. /**
  79789. * Invert Y-Axis of referenced textures on load
  79790. */
  79791. InvertTextureY: boolean;
  79792. /**
  79793. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79794. */
  79795. ImportVertexColors: boolean;
  79796. /**
  79797. * Compute the normals for the model, even if normals are present in the file.
  79798. */
  79799. ComputeNormals: boolean;
  79800. /**
  79801. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79802. */
  79803. SkipMaterials: boolean;
  79804. /**
  79805. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79806. */
  79807. MaterialLoadingFailsSilently: boolean;
  79808. };
  79809. /**
  79810. * OBJ file type loader.
  79811. * This is a babylon scene loader plugin.
  79812. */
  79813. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79814. /**
  79815. * Defines if UVs are optimized by default during load.
  79816. */
  79817. static OPTIMIZE_WITH_UV: boolean;
  79818. /**
  79819. * Invert model on y-axis (does a model scaling inversion)
  79820. */
  79821. static INVERT_Y: boolean;
  79822. /**
  79823. * Invert Y-Axis of referenced textures on load
  79824. */
  79825. static get INVERT_TEXTURE_Y(): boolean;
  79826. static set INVERT_TEXTURE_Y(value: boolean);
  79827. /**
  79828. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79829. */
  79830. static IMPORT_VERTEX_COLORS: boolean;
  79831. /**
  79832. * Compute the normals for the model, even if normals are present in the file.
  79833. */
  79834. static COMPUTE_NORMALS: boolean;
  79835. /**
  79836. * Defines custom scaling of UV coordinates of loaded meshes.
  79837. */
  79838. static UV_SCALING: Vector2;
  79839. /**
  79840. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79841. */
  79842. static SKIP_MATERIALS: boolean;
  79843. /**
  79844. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79845. *
  79846. * Defaults to true for backwards compatibility.
  79847. */
  79848. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  79849. /**
  79850. * Defines the name of the plugin.
  79851. */
  79852. name: string;
  79853. /**
  79854. * Defines the extension the plugin is able to load.
  79855. */
  79856. extensions: string;
  79857. /** @hidden */
  79858. obj: RegExp;
  79859. /** @hidden */
  79860. group: RegExp;
  79861. /** @hidden */
  79862. mtllib: RegExp;
  79863. /** @hidden */
  79864. usemtl: RegExp;
  79865. /** @hidden */
  79866. smooth: RegExp;
  79867. /** @hidden */
  79868. vertexPattern: RegExp;
  79869. /** @hidden */
  79870. normalPattern: RegExp;
  79871. /** @hidden */
  79872. uvPattern: RegExp;
  79873. /** @hidden */
  79874. facePattern1: RegExp;
  79875. /** @hidden */
  79876. facePattern2: RegExp;
  79877. /** @hidden */
  79878. facePattern3: RegExp;
  79879. /** @hidden */
  79880. facePattern4: RegExp;
  79881. /** @hidden */
  79882. facePattern5: RegExp;
  79883. private _forAssetContainer;
  79884. private _meshLoadOptions;
  79885. /**
  79886. * Creates loader for .OBJ files
  79887. *
  79888. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  79889. */
  79890. constructor(meshLoadOptions?: MeshLoadOptions);
  79891. private static get currentMeshLoadOptions();
  79892. /**
  79893. * Calls synchronously the MTL file attached to this obj.
  79894. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  79895. * Without this function materials are not displayed in the first frame (but displayed after).
  79896. * In consequence it is impossible to get material information in your HTML file
  79897. *
  79898. * @param url The URL of the MTL file
  79899. * @param rootUrl
  79900. * @param onSuccess Callback function to be called when the MTL file is loaded
  79901. * @private
  79902. */
  79903. private _loadMTL;
  79904. /**
  79905. * Instantiates a OBJ file loader plugin.
  79906. * @returns the created plugin
  79907. */
  79908. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  79909. /**
  79910. * If the data string can be loaded directly.
  79911. *
  79912. * @param data string containing the file data
  79913. * @returns if the data can be loaded directly
  79914. */
  79915. canDirectLoad(data: string): boolean;
  79916. /**
  79917. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  79918. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79919. * @param scene the scene the meshes should be added to
  79920. * @param data the OBJ data to load
  79921. * @param rootUrl root url to load from
  79922. * @param onProgress event that fires when loading progress has occured
  79923. * @param fileName Defines the name of the file to load
  79924. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79925. */
  79926. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79927. meshes: AbstractMesh[];
  79928. particleSystems: IParticleSystem[];
  79929. skeletons: Skeleton[];
  79930. animationGroups: AnimationGroup[];
  79931. }>;
  79932. /**
  79933. * Imports all objects from the loaded OBJ data and adds them to the scene
  79934. * @param scene the scene the objects should be added to
  79935. * @param data the OBJ data to load
  79936. * @param rootUrl root url to load from
  79937. * @param onProgress event that fires when loading progress has occured
  79938. * @param fileName Defines the name of the file to load
  79939. * @returns a promise which completes when objects have been loaded to the scene
  79940. */
  79941. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79942. /**
  79943. * Load into an asset container.
  79944. * @param scene The scene to load into
  79945. * @param data The data to import
  79946. * @param rootUrl The root url for scene and resources
  79947. * @param onProgress The callback when the load progresses
  79948. * @param fileName Defines the name of the file to load
  79949. * @returns The loaded asset container
  79950. */
  79951. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79952. /**
  79953. * Read the OBJ file and create an Array of meshes.
  79954. * Each mesh contains all information given by the OBJ and the MTL file.
  79955. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79956. *
  79957. * @param meshesNames
  79958. * @param scene Scene The scene where are displayed the data
  79959. * @param data String The content of the obj file
  79960. * @param rootUrl String The path to the folder
  79961. * @returns Array<AbstractMesh>
  79962. * @private
  79963. */
  79964. private _parseSolid;
  79965. }
  79966. }
  79967. declare module BABYLON {
  79968. /**
  79969. * STL file type loader.
  79970. * This is a babylon scene loader plugin.
  79971. */
  79972. export class STLFileLoader implements ISceneLoaderPlugin {
  79973. /** @hidden */
  79974. solidPattern: RegExp;
  79975. /** @hidden */
  79976. facetsPattern: RegExp;
  79977. /** @hidden */
  79978. normalPattern: RegExp;
  79979. /** @hidden */
  79980. vertexPattern: RegExp;
  79981. /**
  79982. * Defines the name of the plugin.
  79983. */
  79984. name: string;
  79985. /**
  79986. * Defines the extensions the stl loader is able to load.
  79987. * force data to come in as an ArrayBuffer
  79988. * we'll convert to string if it looks like it's an ASCII .stl
  79989. */
  79990. extensions: ISceneLoaderPluginExtensions;
  79991. /**
  79992. * Import meshes into a scene.
  79993. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79994. * @param scene The scene to import into
  79995. * @param data The data to import
  79996. * @param rootUrl The root url for scene and resources
  79997. * @param meshes The meshes array to import into
  79998. * @param particleSystems The particle systems array to import into
  79999. * @param skeletons The skeletons array to import into
  80000. * @param onError The callback when import fails
  80001. * @returns True if successful or false otherwise
  80002. */
  80003. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80004. /**
  80005. * Load into a scene.
  80006. * @param scene The scene to load into
  80007. * @param data The data to import
  80008. * @param rootUrl The root url for scene and resources
  80009. * @param onError The callback when import fails
  80010. * @returns true if successful or false otherwise
  80011. */
  80012. load(scene: Scene, data: any, rootUrl: string): boolean;
  80013. /**
  80014. * Load into an asset container.
  80015. * @param scene The scene to load into
  80016. * @param data The data to import
  80017. * @param rootUrl The root url for scene and resources
  80018. * @param onError The callback when import fails
  80019. * @returns The loaded asset container
  80020. */
  80021. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80022. private _isBinary;
  80023. private _parseBinary;
  80024. private _parseASCII;
  80025. }
  80026. }
  80027. declare module BABYLON {
  80028. /**
  80029. * Class for generating OBJ data from a Babylon scene.
  80030. */
  80031. export class OBJExport {
  80032. /**
  80033. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80034. * @param mesh defines the list of meshes to serialize
  80035. * @param materials defines if materials should be exported
  80036. * @param matlibname defines the name of the associated mtl file
  80037. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80038. * @returns the OBJ content
  80039. */
  80040. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80041. /**
  80042. * Exports the material(s) of a mesh in .MTL file format (text)
  80043. * @param mesh defines the mesh to extract the material from
  80044. * @returns the mtl content
  80045. */
  80046. static MTL(mesh: Mesh): string;
  80047. }
  80048. }
  80049. declare module BABYLON {
  80050. /** @hidden */
  80051. export var __IGLTFExporterExtension: number;
  80052. /**
  80053. * Interface for extending the exporter
  80054. * @hidden
  80055. */
  80056. export interface IGLTFExporterExtension {
  80057. /**
  80058. * The name of this extension
  80059. */
  80060. readonly name: string;
  80061. /**
  80062. * Defines whether this extension is enabled
  80063. */
  80064. enabled: boolean;
  80065. /**
  80066. * Defines whether this extension is required
  80067. */
  80068. required: boolean;
  80069. }
  80070. }
  80071. declare module BABYLON.GLTF2.Exporter {
  80072. /** @hidden */
  80073. export var __IGLTFExporterExtensionV2: number;
  80074. /**
  80075. * Interface for a glTF exporter extension
  80076. * @hidden
  80077. */
  80078. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80079. /**
  80080. * Define this method to modify the default behavior before exporting a texture
  80081. * @param context The context when loading the asset
  80082. * @param babylonTexture The Babylon.js texture
  80083. * @param mimeType The mime-type of the generated image
  80084. * @returns A promise that resolves with the exported texture
  80085. */
  80086. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80087. /**
  80088. * Define this method to get notified when a texture info is created
  80089. * @param context The context when loading the asset
  80090. * @param textureInfo The glTF texture info
  80091. * @param babylonTexture The Babylon.js texture
  80092. */
  80093. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80094. /**
  80095. * Define this method to modify the default behavior when exporting texture info
  80096. * @param context The context when loading the asset
  80097. * @param meshPrimitive glTF mesh primitive
  80098. * @param babylonSubMesh Babylon submesh
  80099. * @param binaryWriter glTF serializer binary writer instance
  80100. * @returns nullable IMeshPrimitive promise
  80101. */
  80102. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80103. /**
  80104. * Define this method to modify the default behavior when exporting a node
  80105. * @param context The context when exporting the node
  80106. * @param node glTF node
  80107. * @param babylonNode BabylonJS node
  80108. * @returns nullable INode promise
  80109. */
  80110. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80111. [key: number]: number;
  80112. }): Promise<Nullable<INode>>;
  80113. /**
  80114. * Define this method to modify the default behavior when exporting a material
  80115. * @param material glTF material
  80116. * @param babylonMaterial BabylonJS material
  80117. * @returns nullable IMaterial promise
  80118. */
  80119. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80120. /**
  80121. * Define this method to return additional textures to export from a material
  80122. * @param material glTF material
  80123. * @param babylonMaterial BabylonJS material
  80124. * @returns List of textures
  80125. */
  80126. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80127. /** Gets a boolean indicating that this extension was used */
  80128. wasUsed: boolean;
  80129. /** Gets a boolean indicating that this extension is required for the file to work */
  80130. required: boolean;
  80131. /**
  80132. * Called after the exporter state changes to EXPORTING
  80133. */
  80134. onExporting?(): void;
  80135. }
  80136. }
  80137. declare module BABYLON.GLTF2.Exporter {
  80138. /**
  80139. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80140. * @hidden
  80141. */
  80142. export class _GLTFMaterialExporter {
  80143. /**
  80144. * Represents the dielectric specular values for R, G and B
  80145. */
  80146. private static readonly _DielectricSpecular;
  80147. /**
  80148. * Allows the maximum specular power to be defined for material calculations
  80149. */
  80150. private static readonly _MaxSpecularPower;
  80151. /**
  80152. * Mapping to store textures
  80153. */
  80154. private _textureMap;
  80155. /**
  80156. * Numeric tolerance value
  80157. */
  80158. private static readonly _Epsilon;
  80159. /**
  80160. * Reference to the glTF Exporter
  80161. */
  80162. private _exporter;
  80163. constructor(exporter: _Exporter);
  80164. /**
  80165. * Specifies if two colors are approximately equal in value
  80166. * @param color1 first color to compare to
  80167. * @param color2 second color to compare to
  80168. * @param epsilon threshold value
  80169. */
  80170. private static FuzzyEquals;
  80171. /**
  80172. * Gets the materials from a Babylon scene and converts them to glTF materials
  80173. * @param scene babylonjs scene
  80174. * @param mimeType texture mime type
  80175. * @param images array of images
  80176. * @param textures array of textures
  80177. * @param materials array of materials
  80178. * @param imageData mapping of texture names to base64 textures
  80179. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80180. */
  80181. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80182. /**
  80183. * Makes a copy of the glTF material without the texture parameters
  80184. * @param originalMaterial original glTF material
  80185. * @returns glTF material without texture parameters
  80186. */
  80187. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80188. /**
  80189. * Specifies if the material has any texture parameters present
  80190. * @param material glTF Material
  80191. * @returns boolean specifying if texture parameters are present
  80192. */
  80193. _hasTexturesPresent(material: IMaterial): boolean;
  80194. /**
  80195. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80196. * @param babylonStandardMaterial
  80197. * @returns glTF Metallic Roughness Material representation
  80198. */
  80199. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80200. /**
  80201. * Computes the metallic factor
  80202. * @param diffuse diffused value
  80203. * @param specular specular value
  80204. * @param oneMinusSpecularStrength one minus the specular strength
  80205. * @returns metallic value
  80206. */
  80207. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80208. /**
  80209. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80210. * @param glTFMaterial glTF material
  80211. * @param babylonMaterial Babylon material
  80212. */
  80213. private static _SetAlphaMode;
  80214. /**
  80215. * Converts a Babylon Standard Material to a glTF Material
  80216. * @param babylonStandardMaterial BJS Standard Material
  80217. * @param mimeType mime type to use for the textures
  80218. * @param images array of glTF image interfaces
  80219. * @param textures array of glTF texture interfaces
  80220. * @param materials array of glTF material interfaces
  80221. * @param imageData map of image file name to data
  80222. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80223. */
  80224. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80225. private _finishMaterial;
  80226. /**
  80227. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80228. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80229. * @param mimeType mime type to use for the textures
  80230. * @param images array of glTF image interfaces
  80231. * @param textures array of glTF texture interfaces
  80232. * @param materials array of glTF material interfaces
  80233. * @param imageData map of image file name to data
  80234. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80235. */
  80236. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80237. /**
  80238. * Converts an image typed array buffer to a base64 image
  80239. * @param buffer typed array buffer
  80240. * @param width width of the image
  80241. * @param height height of the image
  80242. * @param mimeType mimetype of the image
  80243. * @returns base64 image string
  80244. */
  80245. private _createBase64FromCanvasAsync;
  80246. /**
  80247. * Generates a white texture based on the specified width and height
  80248. * @param width width of the texture in pixels
  80249. * @param height height of the texture in pixels
  80250. * @param scene babylonjs scene
  80251. * @returns white texture
  80252. */
  80253. private _createWhiteTexture;
  80254. /**
  80255. * 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
  80256. * @param texture1 first texture to resize
  80257. * @param texture2 second texture to resize
  80258. * @param scene babylonjs scene
  80259. * @returns resized textures or null
  80260. */
  80261. private _resizeTexturesToSameDimensions;
  80262. /**
  80263. * Converts an array of pixels to a Float32Array
  80264. * Throws an error if the pixel format is not supported
  80265. * @param pixels - array buffer containing pixel values
  80266. * @returns Float32 of pixels
  80267. */
  80268. private _convertPixelArrayToFloat32;
  80269. /**
  80270. * Convert Specular Glossiness Textures to Metallic Roughness
  80271. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80272. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80273. * @param diffuseTexture texture used to store diffuse information
  80274. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80275. * @param factors specular glossiness material factors
  80276. * @param mimeType the mime type to use for the texture
  80277. * @returns pbr metallic roughness interface or null
  80278. */
  80279. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80280. /**
  80281. * Converts specular glossiness material properties to metallic roughness
  80282. * @param specularGlossiness interface with specular glossiness material properties
  80283. * @returns interface with metallic roughness material properties
  80284. */
  80285. private _convertSpecularGlossinessToMetallicRoughness;
  80286. /**
  80287. * Calculates the surface reflectance, independent of lighting conditions
  80288. * @param color Color source to calculate brightness from
  80289. * @returns number representing the perceived brightness, or zero if color is undefined
  80290. */
  80291. private _getPerceivedBrightness;
  80292. /**
  80293. * Returns the maximum color component value
  80294. * @param color
  80295. * @returns maximum color component value, or zero if color is null or undefined
  80296. */
  80297. private _getMaxComponent;
  80298. /**
  80299. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80300. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80301. * @param mimeType mime type to use for the textures
  80302. * @param images array of glTF image interfaces
  80303. * @param textures array of glTF texture interfaces
  80304. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80305. * @param imageData map of image file name to data
  80306. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80307. * @returns glTF PBR Metallic Roughness factors
  80308. */
  80309. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80310. private _getGLTFTextureSampler;
  80311. private _getGLTFTextureWrapMode;
  80312. private _getGLTFTextureWrapModesSampler;
  80313. /**
  80314. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80315. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80316. * @param mimeType mime type to use for the textures
  80317. * @param images array of glTF image interfaces
  80318. * @param textures array of glTF texture interfaces
  80319. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80320. * @param imageData map of image file name to data
  80321. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80322. * @returns glTF PBR Metallic Roughness factors
  80323. */
  80324. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80325. /**
  80326. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80327. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80328. * @param mimeType mime type to use for the textures
  80329. * @param images array of glTF image interfaces
  80330. * @param textures array of glTF texture interfaces
  80331. * @param materials array of glTF material interfaces
  80332. * @param imageData map of image file name to data
  80333. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80334. */
  80335. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80336. private setMetallicRoughnessPbrMaterial;
  80337. private getPixelsFromTexture;
  80338. /**
  80339. * Extracts a texture from a Babylon texture into file data and glTF data
  80340. * @param babylonTexture Babylon texture to extract
  80341. * @param mimeType Mime Type of the babylonTexture
  80342. * @return glTF texture info, or null if the texture format is not supported
  80343. */
  80344. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80345. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80346. /**
  80347. * Builds a texture from base64 string
  80348. * @param base64Texture base64 texture string
  80349. * @param baseTextureName Name to use for the texture
  80350. * @param mimeType image mime type for the texture
  80351. * @param images array of images
  80352. * @param textures array of textures
  80353. * @param imageData map of image data
  80354. * @returns glTF texture info, or null if the texture format is not supported
  80355. */
  80356. private _getTextureInfoFromBase64;
  80357. }
  80358. }
  80359. declare module BABYLON {
  80360. /**
  80361. * Class for holding and downloading glTF file data
  80362. */
  80363. export class GLTFData {
  80364. /**
  80365. * Object which contains the file name as the key and its data as the value
  80366. */
  80367. glTFFiles: {
  80368. [fileName: string]: string | Blob;
  80369. };
  80370. /**
  80371. * Initializes the glTF file object
  80372. */
  80373. constructor();
  80374. /**
  80375. * Downloads the glTF data as files based on their names and data
  80376. */
  80377. downloadFiles(): void;
  80378. }
  80379. }
  80380. declare module BABYLON {
  80381. /**
  80382. * Holds a collection of exporter options and parameters
  80383. */
  80384. export interface IExportOptions {
  80385. /**
  80386. * Function which indicates whether a babylon node should be exported or not
  80387. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80388. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80389. */
  80390. shouldExportNode?(node: Node): boolean;
  80391. /**
  80392. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80393. * @param metadata source metadata to read from
  80394. * @returns the data to store to glTF node extras
  80395. */
  80396. metadataSelector?(metadata: any): any;
  80397. /**
  80398. * The sample rate to bake animation curves
  80399. */
  80400. animationSampleRate?: number;
  80401. /**
  80402. * Begin serialization without waiting for the scene to be ready
  80403. */
  80404. exportWithoutWaitingForScene?: boolean;
  80405. /**
  80406. * Indicates if coordinate system swapping root nodes should be included in export
  80407. */
  80408. includeCoordinateSystemConversionNodes?: boolean;
  80409. }
  80410. /**
  80411. * Class for generating glTF data from a Babylon scene.
  80412. */
  80413. export class GLTF2Export {
  80414. /**
  80415. * Exports the geometry of the scene to .gltf file format asynchronously
  80416. * @param scene Babylon scene with scene hierarchy information
  80417. * @param filePrefix File prefix to use when generating the glTF file
  80418. * @param options Exporter options
  80419. * @returns Returns an object with a .gltf file and associates texture names
  80420. * as keys and their data and paths as values
  80421. */
  80422. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80423. private static _PreExportAsync;
  80424. private static _PostExportAsync;
  80425. /**
  80426. * Exports the geometry of the scene to .glb file format asychronously
  80427. * @param scene Babylon scene with scene hierarchy information
  80428. * @param filePrefix File prefix to use when generating glb file
  80429. * @param options Exporter options
  80430. * @returns Returns an object with a .glb filename as key and data as value
  80431. */
  80432. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80433. }
  80434. }
  80435. declare module BABYLON.GLTF2.Exporter {
  80436. /**
  80437. * @hidden
  80438. */
  80439. export class _GLTFUtilities {
  80440. /**
  80441. * Creates a buffer view based on the supplied arguments
  80442. * @param bufferIndex index value of the specified buffer
  80443. * @param byteOffset byte offset value
  80444. * @param byteLength byte length of the bufferView
  80445. * @param byteStride byte distance between conequential elements
  80446. * @param name name of the buffer view
  80447. * @returns bufferView for glTF
  80448. */
  80449. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80450. /**
  80451. * Creates an accessor based on the supplied arguments
  80452. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80453. * @param name The name of the accessor
  80454. * @param type The type of the accessor
  80455. * @param componentType The datatype of components in the attribute
  80456. * @param count The number of attributes referenced by this accessor
  80457. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80458. * @param min Minimum value of each component in this attribute
  80459. * @param max Maximum value of each component in this attribute
  80460. * @returns accessor for glTF
  80461. */
  80462. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80463. /**
  80464. * Calculates the minimum and maximum values of an array of position floats
  80465. * @param positions Positions array of a mesh
  80466. * @param vertexStart Starting vertex offset to calculate min and max values
  80467. * @param vertexCount Number of vertices to check for min and max values
  80468. * @returns min number array and max number array
  80469. */
  80470. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80471. min: number[];
  80472. max: number[];
  80473. };
  80474. /**
  80475. * Converts a new right-handed Vector3
  80476. * @param vector vector3 array
  80477. * @returns right-handed Vector3
  80478. */
  80479. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80480. /**
  80481. * Converts a Vector3 to right-handed
  80482. * @param vector Vector3 to convert to right-handed
  80483. */
  80484. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80485. /**
  80486. * Converts a three element number array to right-handed
  80487. * @param vector number array to convert to right-handed
  80488. */
  80489. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80490. /**
  80491. * Converts a new right-handed Vector3
  80492. * @param vector vector3 array
  80493. * @returns right-handed Vector3
  80494. */
  80495. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80496. /**
  80497. * Converts a Vector3 to right-handed
  80498. * @param vector Vector3 to convert to right-handed
  80499. */
  80500. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80501. /**
  80502. * Converts a three element number array to right-handed
  80503. * @param vector number array to convert to right-handed
  80504. */
  80505. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80506. /**
  80507. * Converts a Vector4 to right-handed
  80508. * @param vector Vector4 to convert to right-handed
  80509. */
  80510. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80511. /**
  80512. * Converts a Vector4 to right-handed
  80513. * @param vector Vector4 to convert to right-handed
  80514. */
  80515. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80516. /**
  80517. * Converts a Quaternion to right-handed
  80518. * @param quaternion Source quaternion to convert to right-handed
  80519. */
  80520. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80521. /**
  80522. * Converts a Quaternion to right-handed
  80523. * @param quaternion Source quaternion to convert to right-handed
  80524. */
  80525. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80526. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80527. }
  80528. }
  80529. declare module BABYLON.GLTF2.Exporter {
  80530. /**
  80531. * Converts Babylon Scene into glTF 2.0.
  80532. * @hidden
  80533. */
  80534. export class _Exporter {
  80535. /**
  80536. * Stores the glTF to export
  80537. */
  80538. _glTF: IGLTF;
  80539. /**
  80540. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80541. */
  80542. _bufferViews: IBufferView[];
  80543. /**
  80544. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80545. */
  80546. _accessors: IAccessor[];
  80547. /**
  80548. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80549. */
  80550. _nodes: INode[];
  80551. /**
  80552. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80553. */
  80554. private _scenes;
  80555. /**
  80556. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80557. */
  80558. private _meshes;
  80559. /**
  80560. * Stores all the generated material information, which represents the appearance of each primitive
  80561. */
  80562. _materials: IMaterial[];
  80563. _materialMap: {
  80564. [materialID: number]: number;
  80565. };
  80566. /**
  80567. * Stores all the generated texture information, which is referenced by glTF materials
  80568. */
  80569. _textures: ITexture[];
  80570. /**
  80571. * Stores all the generated image information, which is referenced by glTF textures
  80572. */
  80573. _images: IImage[];
  80574. /**
  80575. * Stores all the texture samplers
  80576. */
  80577. _samplers: ISampler[];
  80578. /**
  80579. * Stores all the generated animation samplers, which is referenced by glTF animations
  80580. */
  80581. /**
  80582. * Stores the animations for glTF models
  80583. */
  80584. private _animations;
  80585. /**
  80586. * Stores the total amount of bytes stored in the glTF buffer
  80587. */
  80588. private _totalByteLength;
  80589. /**
  80590. * Stores a reference to the Babylon scene containing the source geometry and material information
  80591. */
  80592. _babylonScene: Scene;
  80593. /**
  80594. * Stores a map of the image data, where the key is the file name and the value
  80595. * is the image data
  80596. */
  80597. _imageData: {
  80598. [fileName: string]: {
  80599. data: Uint8Array;
  80600. mimeType: ImageMimeType;
  80601. };
  80602. };
  80603. /**
  80604. * Stores a map of the unique id of a node to its index in the node array
  80605. */
  80606. _nodeMap: {
  80607. [key: number]: number;
  80608. };
  80609. /**
  80610. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80611. */
  80612. _convertToRightHandedSystem: boolean;
  80613. /**
  80614. * Specifies if a Babylon node should be converted to right-handed on export
  80615. */
  80616. _convertToRightHandedSystemMap: {
  80617. [nodeId: number]: boolean;
  80618. };
  80619. _includeCoordinateSystemConversionNodes: boolean;
  80620. /**
  80621. * Baked animation sample rate
  80622. */
  80623. private _animationSampleRate;
  80624. private _options;
  80625. private _localEngine;
  80626. _glTFMaterialExporter: _GLTFMaterialExporter;
  80627. private _extensions;
  80628. private static _ExtensionNames;
  80629. private static _ExtensionFactories;
  80630. private _applyExtension;
  80631. private _applyExtensions;
  80632. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80633. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80634. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80635. [key: number]: number;
  80636. }): Promise<Nullable<INode>>;
  80637. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80638. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80639. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80640. private _forEachExtensions;
  80641. private _extensionsOnExporting;
  80642. /**
  80643. * Load glTF serializer extensions
  80644. */
  80645. private _loadExtensions;
  80646. /**
  80647. * Creates a glTF Exporter instance, which can accept optional exporter options
  80648. * @param babylonScene Babylon scene object
  80649. * @param options Options to modify the behavior of the exporter
  80650. */
  80651. constructor(babylonScene: Scene, options?: IExportOptions);
  80652. dispose(): void;
  80653. /**
  80654. * Registers a glTF exporter extension
  80655. * @param name Name of the extension to export
  80656. * @param factory The factory function that creates the exporter extension
  80657. */
  80658. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80659. /**
  80660. * Un-registers an exporter extension
  80661. * @param name The name fo the exporter extension
  80662. * @returns A boolean indicating whether the extension has been un-registered
  80663. */
  80664. static UnregisterExtension(name: string): boolean;
  80665. /**
  80666. * Lazy load a local engine
  80667. */
  80668. _getLocalEngine(): Engine;
  80669. private reorderIndicesBasedOnPrimitiveMode;
  80670. /**
  80671. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80672. * clock-wise during export to glTF
  80673. * @param submesh BabylonJS submesh
  80674. * @param primitiveMode Primitive mode of the mesh
  80675. * @param sideOrientation the winding order of the submesh
  80676. * @param vertexBufferKind The type of vertex attribute
  80677. * @param meshAttributeArray The vertex attribute data
  80678. * @param byteOffset The offset to the binary data
  80679. * @param binaryWriter The binary data for the glTF file
  80680. * @param convertToRightHandedSystem Converts the values to right-handed
  80681. */
  80682. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80683. /**
  80684. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80685. * clock-wise during export to glTF
  80686. * @param submesh BabylonJS submesh
  80687. * @param primitiveMode Primitive mode of the mesh
  80688. * @param sideOrientation the winding order of the submesh
  80689. * @param vertexBufferKind The type of vertex attribute
  80690. * @param meshAttributeArray The vertex attribute data
  80691. * @param byteOffset The offset to the binary data
  80692. * @param binaryWriter The binary data for the glTF file
  80693. * @param convertToRightHandedSystem Converts the values to right-handed
  80694. */
  80695. private reorderTriangleFillMode;
  80696. /**
  80697. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80698. * clock-wise during export to glTF
  80699. * @param submesh BabylonJS submesh
  80700. * @param primitiveMode Primitive mode of the mesh
  80701. * @param sideOrientation the winding order of the submesh
  80702. * @param vertexBufferKind The type of vertex attribute
  80703. * @param meshAttributeArray The vertex attribute data
  80704. * @param byteOffset The offset to the binary data
  80705. * @param binaryWriter The binary data for the glTF file
  80706. * @param convertToRightHandedSystem Converts the values to right-handed
  80707. */
  80708. private reorderTriangleStripDrawMode;
  80709. /**
  80710. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80711. * clock-wise during export to glTF
  80712. * @param submesh BabylonJS submesh
  80713. * @param primitiveMode Primitive mode of the mesh
  80714. * @param sideOrientation the winding order of the submesh
  80715. * @param vertexBufferKind The type of vertex attribute
  80716. * @param meshAttributeArray The vertex attribute data
  80717. * @param byteOffset The offset to the binary data
  80718. * @param binaryWriter The binary data for the glTF file
  80719. * @param convertToRightHandedSystem Converts the values to right-handed
  80720. */
  80721. private reorderTriangleFanMode;
  80722. /**
  80723. * Writes the vertex attribute data to binary
  80724. * @param vertices The vertices to write to the binary writer
  80725. * @param byteOffset The offset into the binary writer to overwrite binary data
  80726. * @param vertexAttributeKind The vertex attribute type
  80727. * @param meshAttributeArray The vertex attribute data
  80728. * @param binaryWriter The writer containing the binary data
  80729. * @param convertToRightHandedSystem Converts the values to right-handed
  80730. */
  80731. private writeVertexAttributeData;
  80732. /**
  80733. * Writes mesh attribute data to a data buffer
  80734. * Returns the bytelength of the data
  80735. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80736. * @param meshAttributeArray Array containing the attribute data
  80737. * @param binaryWriter The buffer to write the binary data to
  80738. * @param indices Used to specify the order of the vertex data
  80739. * @param convertToRightHandedSystem Converts the values to right-handed
  80740. */
  80741. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80742. /**
  80743. * Generates glTF json data
  80744. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80745. * @param glTFPrefix Text to use when prefixing a glTF file
  80746. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80747. * @returns json data as string
  80748. */
  80749. private generateJSON;
  80750. /**
  80751. * Generates data for .gltf and .bin files based on the glTF prefix string
  80752. * @param glTFPrefix Text to use when prefixing a glTF file
  80753. * @param dispose Dispose the exporter
  80754. * @returns GLTFData with glTF file data
  80755. */
  80756. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80757. /**
  80758. * Creates a binary buffer for glTF
  80759. * @returns array buffer for binary data
  80760. */
  80761. private _generateBinaryAsync;
  80762. /**
  80763. * Pads the number to a multiple of 4
  80764. * @param num number to pad
  80765. * @returns padded number
  80766. */
  80767. private _getPadding;
  80768. /**
  80769. * @hidden
  80770. */
  80771. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80772. /**
  80773. * Sets the TRS for each node
  80774. * @param node glTF Node for storing the transformation data
  80775. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80776. * @param convertToRightHandedSystem Converts the values to right-handed
  80777. */
  80778. private setNodeTransformation;
  80779. private getVertexBufferFromMesh;
  80780. /**
  80781. * Creates a bufferview based on the vertices type for the Babylon mesh
  80782. * @param kind Indicates the type of vertices data
  80783. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80784. * @param binaryWriter The buffer to write the bufferview data to
  80785. * @param convertToRightHandedSystem Converts the values to right-handed
  80786. */
  80787. private createBufferViewKind;
  80788. /**
  80789. * The primitive mode of the Babylon mesh
  80790. * @param babylonMesh The BabylonJS mesh
  80791. */
  80792. private getMeshPrimitiveMode;
  80793. /**
  80794. * Sets the primitive mode of the glTF mesh primitive
  80795. * @param meshPrimitive glTF mesh primitive
  80796. * @param primitiveMode The primitive mode
  80797. */
  80798. private setPrimitiveMode;
  80799. /**
  80800. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80801. * @param meshPrimitive glTF mesh primitive
  80802. * @param attributeKind vertex attribute
  80803. * @returns boolean specifying if uv coordinates are present
  80804. */
  80805. private setAttributeKind;
  80806. /**
  80807. * Sets data for the primitive attributes of each submesh
  80808. * @param mesh glTF Mesh object to store the primitive attribute information
  80809. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80810. * @param binaryWriter Buffer to write the attribute data to
  80811. * @param convertToRightHandedSystem Converts the values to right-handed
  80812. */
  80813. private setPrimitiveAttributesAsync;
  80814. /**
  80815. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80816. * @param node The node to check
  80817. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80818. */
  80819. private isBabylonCoordinateSystemConvertingNode;
  80820. /**
  80821. * Creates a glTF scene based on the array of meshes
  80822. * Returns the the total byte offset
  80823. * @param babylonScene Babylon scene to get the mesh data from
  80824. * @param binaryWriter Buffer to write binary data to
  80825. */
  80826. private createSceneAsync;
  80827. /**
  80828. * Creates a mapping of Node unique id to node index and handles animations
  80829. * @param babylonScene Babylon Scene
  80830. * @param nodes Babylon transform nodes
  80831. * @param binaryWriter Buffer to write binary data to
  80832. * @returns Node mapping of unique id to index
  80833. */
  80834. private createNodeMapAndAnimationsAsync;
  80835. /**
  80836. * Creates a glTF node from a Babylon mesh
  80837. * @param babylonMesh Source Babylon mesh
  80838. * @param binaryWriter Buffer for storing geometry data
  80839. * @param convertToRightHandedSystem Converts the values to right-handed
  80840. * @param nodeMap Node mapping of unique id to glTF node index
  80841. * @returns glTF node
  80842. */
  80843. private createNodeAsync;
  80844. }
  80845. /**
  80846. * @hidden
  80847. *
  80848. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  80849. */
  80850. export class _BinaryWriter {
  80851. /**
  80852. * Array buffer which stores all binary data
  80853. */
  80854. private _arrayBuffer;
  80855. /**
  80856. * View of the array buffer
  80857. */
  80858. private _dataView;
  80859. /**
  80860. * byte offset of data in array buffer
  80861. */
  80862. private _byteOffset;
  80863. /**
  80864. * Initialize binary writer with an initial byte length
  80865. * @param byteLength Initial byte length of the array buffer
  80866. */
  80867. constructor(byteLength: number);
  80868. /**
  80869. * Resize the array buffer to the specified byte length
  80870. * @param byteLength
  80871. */
  80872. private resizeBuffer;
  80873. /**
  80874. * Get an array buffer with the length of the byte offset
  80875. * @returns ArrayBuffer resized to the byte offset
  80876. */
  80877. getArrayBuffer(): ArrayBuffer;
  80878. /**
  80879. * Get the byte offset of the array buffer
  80880. * @returns byte offset
  80881. */
  80882. getByteOffset(): number;
  80883. /**
  80884. * Stores an UInt8 in the array buffer
  80885. * @param entry
  80886. * @param byteOffset If defined, specifies where to set the value as an offset.
  80887. */
  80888. setUInt8(entry: number, byteOffset?: number): void;
  80889. /**
  80890. * Gets an UInt32 in the array buffer
  80891. * @param entry
  80892. * @param byteOffset If defined, specifies where to set the value as an offset.
  80893. */
  80894. getUInt32(byteOffset: number): number;
  80895. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80896. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80897. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80898. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80899. /**
  80900. * Stores a Float32 in the array buffer
  80901. * @param entry
  80902. */
  80903. setFloat32(entry: number, byteOffset?: number): void;
  80904. /**
  80905. * Stores an UInt32 in the array buffer
  80906. * @param entry
  80907. * @param byteOffset If defined, specifies where to set the value as an offset.
  80908. */
  80909. setUInt32(entry: number, byteOffset?: number): void;
  80910. }
  80911. }
  80912. declare module BABYLON.GLTF2.Exporter {
  80913. /**
  80914. * @hidden
  80915. * Interface to store animation data.
  80916. */
  80917. export interface _IAnimationData {
  80918. /**
  80919. * Keyframe data.
  80920. */
  80921. inputs: number[];
  80922. /**
  80923. * Value data.
  80924. */
  80925. outputs: number[][];
  80926. /**
  80927. * Animation interpolation data.
  80928. */
  80929. samplerInterpolation: AnimationSamplerInterpolation;
  80930. /**
  80931. * Minimum keyframe value.
  80932. */
  80933. inputsMin: number;
  80934. /**
  80935. * Maximum keyframe value.
  80936. */
  80937. inputsMax: number;
  80938. }
  80939. /**
  80940. * @hidden
  80941. */
  80942. export interface _IAnimationInfo {
  80943. /**
  80944. * The target channel for the animation
  80945. */
  80946. animationChannelTargetPath: AnimationChannelTargetPath;
  80947. /**
  80948. * The glTF accessor type for the data.
  80949. */
  80950. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80951. /**
  80952. * Specifies if quaternions should be used.
  80953. */
  80954. useQuaternion: boolean;
  80955. }
  80956. /**
  80957. * @hidden
  80958. * Utility class for generating glTF animation data from BabylonJS.
  80959. */
  80960. export class _GLTFAnimation {
  80961. /**
  80962. * @ignore
  80963. *
  80964. * Creates glTF channel animation from BabylonJS animation.
  80965. * @param babylonTransformNode - BabylonJS mesh.
  80966. * @param animation - animation.
  80967. * @param animationChannelTargetPath - The target animation channel.
  80968. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  80969. * @param useQuaternion - Specifies if quaternions are used.
  80970. * @returns nullable IAnimationData
  80971. */
  80972. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80973. private static _DeduceAnimationInfo;
  80974. /**
  80975. * @ignore
  80976. * Create node animations from the transform node animations
  80977. * @param babylonNode
  80978. * @param runtimeGLTFAnimation
  80979. * @param idleGLTFAnimations
  80980. * @param nodeMap
  80981. * @param nodes
  80982. * @param binaryWriter
  80983. * @param bufferViews
  80984. * @param accessors
  80985. * @param convertToRightHandedSystem
  80986. * @param animationSampleRate
  80987. */
  80988. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80989. [key: number]: number;
  80990. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80991. /**
  80992. * @ignore
  80993. * Create node animations from the animation groups
  80994. * @param babylonScene
  80995. * @param glTFAnimations
  80996. * @param nodeMap
  80997. * @param nodes
  80998. * @param binaryWriter
  80999. * @param bufferViews
  81000. * @param accessors
  81001. * @param convertToRightHandedSystemMap
  81002. * @param animationSampleRate
  81003. */
  81004. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81005. [key: number]: number;
  81006. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81007. [nodeId: number]: boolean;
  81008. }, animationSampleRate: number): void;
  81009. private static AddAnimation;
  81010. /**
  81011. * Create a baked animation
  81012. * @param babylonTransformNode BabylonJS mesh
  81013. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81014. * @param animationChannelTargetPath animation target channel
  81015. * @param minFrame minimum animation frame
  81016. * @param maxFrame maximum animation frame
  81017. * @param fps frames per second of the animation
  81018. * @param inputs input key frames of the animation
  81019. * @param outputs output key frame data of the animation
  81020. * @param convertToRightHandedSystem converts the values to right-handed
  81021. * @param useQuaternion specifies if quaternions should be used
  81022. */
  81023. private static _CreateBakedAnimation;
  81024. private static _ConvertFactorToVector3OrQuaternion;
  81025. private static _SetInterpolatedValue;
  81026. /**
  81027. * Creates linear animation from the animation key frames
  81028. * @param babylonTransformNode BabylonJS mesh
  81029. * @param animation BabylonJS animation
  81030. * @param animationChannelTargetPath The target animation channel
  81031. * @param frameDelta The difference between the last and first frame of the animation
  81032. * @param inputs Array to store the key frame times
  81033. * @param outputs Array to store the key frame data
  81034. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81035. * @param useQuaternion Specifies if quaternions are used in the animation
  81036. */
  81037. private static _CreateLinearOrStepAnimation;
  81038. /**
  81039. * Creates cubic spline animation from the animation key frames
  81040. * @param babylonTransformNode BabylonJS mesh
  81041. * @param animation BabylonJS animation
  81042. * @param animationChannelTargetPath The target animation channel
  81043. * @param frameDelta The difference between the last and first frame of the animation
  81044. * @param inputs Array to store the key frame times
  81045. * @param outputs Array to store the key frame data
  81046. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81047. * @param useQuaternion Specifies if quaternions are used in the animation
  81048. */
  81049. private static _CreateCubicSplineAnimation;
  81050. private static _GetBasePositionRotationOrScale;
  81051. /**
  81052. * Adds a key frame value
  81053. * @param keyFrame
  81054. * @param animation
  81055. * @param outputs
  81056. * @param animationChannelTargetPath
  81057. * @param basePositionRotationOrScale
  81058. * @param convertToRightHandedSystem
  81059. * @param useQuaternion
  81060. */
  81061. private static _AddKeyframeValue;
  81062. /**
  81063. * Determine the interpolation based on the key frames
  81064. * @param keyFrames
  81065. * @param animationChannelTargetPath
  81066. * @param useQuaternion
  81067. */
  81068. private static _DeduceInterpolation;
  81069. /**
  81070. * Adds an input tangent or output tangent to the output data
  81071. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81072. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81073. * @param outputs The animation data by keyframe
  81074. * @param animationChannelTargetPath The target animation channel
  81075. * @param interpolation The interpolation type
  81076. * @param keyFrame The key frame with the animation data
  81077. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81078. * @param useQuaternion Specifies if quaternions are used
  81079. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81080. */
  81081. private static AddSplineTangent;
  81082. /**
  81083. * Get the minimum and maximum key frames' frame values
  81084. * @param keyFrames animation key frames
  81085. * @returns the minimum and maximum key frame value
  81086. */
  81087. private static calculateMinMaxKeyFrames;
  81088. }
  81089. }
  81090. declare module BABYLON.GLTF2.Exporter {
  81091. /** @hidden */
  81092. export var textureTransformPixelShader: {
  81093. name: string;
  81094. shader: string;
  81095. };
  81096. }
  81097. declare module BABYLON.GLTF2.Exporter.Extensions {
  81098. /**
  81099. * @hidden
  81100. */
  81101. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81102. private _recordedTextures;
  81103. /** Name of this extension */
  81104. readonly name: string;
  81105. /** Defines whether this extension is enabled */
  81106. enabled: boolean;
  81107. /** Defines whether this extension is required */
  81108. required: boolean;
  81109. /** Reference to the glTF exporter */
  81110. private _wasUsed;
  81111. constructor(exporter: _Exporter);
  81112. dispose(): void;
  81113. /** @hidden */
  81114. get wasUsed(): boolean;
  81115. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81116. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81117. /**
  81118. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81119. * @param babylonTexture
  81120. * @param offset
  81121. * @param rotation
  81122. * @param scale
  81123. * @param scene
  81124. */
  81125. private _textureTransformTextureAsync;
  81126. }
  81127. }
  81128. declare module BABYLON.GLTF2.Exporter.Extensions {
  81129. /**
  81130. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81131. */
  81132. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81133. /** The name of this extension. */
  81134. readonly name: string;
  81135. /** Defines whether this extension is enabled. */
  81136. enabled: boolean;
  81137. /** Defines whether this extension is required */
  81138. required: boolean;
  81139. /** Reference to the glTF exporter */
  81140. private _exporter;
  81141. private _lights;
  81142. /** @hidden */
  81143. constructor(exporter: _Exporter);
  81144. /** @hidden */
  81145. dispose(): void;
  81146. /** @hidden */
  81147. get wasUsed(): boolean;
  81148. /** @hidden */
  81149. onExporting(): void;
  81150. /**
  81151. * Define this method to modify the default behavior when exporting a node
  81152. * @param context The context when exporting the node
  81153. * @param node glTF node
  81154. * @param babylonNode BabylonJS node
  81155. * @param nodeMap Node mapping of unique id to glTF node index
  81156. * @returns nullable INode promise
  81157. */
  81158. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81159. [key: number]: number;
  81160. }): Promise<Nullable<INode>>;
  81161. }
  81162. }
  81163. declare module BABYLON.GLTF2.Exporter.Extensions {
  81164. /**
  81165. * @hidden
  81166. */
  81167. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81168. /** Name of this extension */
  81169. readonly name: string;
  81170. /** Defines whether this extension is enabled */
  81171. enabled: boolean;
  81172. /** Defines whether this extension is required */
  81173. required: boolean;
  81174. /** Reference to the glTF exporter */
  81175. private _textureInfos;
  81176. private _exportedTextures;
  81177. private _wasUsed;
  81178. constructor(exporter: _Exporter);
  81179. dispose(): void;
  81180. /** @hidden */
  81181. get wasUsed(): boolean;
  81182. private _getTextureIndex;
  81183. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81184. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81185. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81186. }
  81187. }
  81188. declare module BABYLON {
  81189. /**
  81190. * Class for generating STL data from a Babylon scene.
  81191. */
  81192. export class STLExport {
  81193. /**
  81194. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81195. * @param meshes list defines the mesh to serialize
  81196. * @param download triggers the automatic download of the file.
  81197. * @param fileName changes the downloads fileName.
  81198. * @param binary changes the STL to a binary type.
  81199. * @param isLittleEndian toggle for binary type exporter.
  81200. * @returns the STL as UTF8 string
  81201. */
  81202. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81203. }
  81204. }
  81205. declare module "babylonjs-gltf2interface" {
  81206. export = BABYLON.GLTF2;
  81207. }
  81208. /**
  81209. * Module for glTF 2.0 Interface
  81210. */
  81211. declare module BABYLON.GLTF2 {
  81212. /**
  81213. * The datatype of the components in the attribute
  81214. */
  81215. const enum AccessorComponentType {
  81216. /**
  81217. * Byte
  81218. */
  81219. BYTE = 5120,
  81220. /**
  81221. * Unsigned Byte
  81222. */
  81223. UNSIGNED_BYTE = 5121,
  81224. /**
  81225. * Short
  81226. */
  81227. SHORT = 5122,
  81228. /**
  81229. * Unsigned Short
  81230. */
  81231. UNSIGNED_SHORT = 5123,
  81232. /**
  81233. * Unsigned Int
  81234. */
  81235. UNSIGNED_INT = 5125,
  81236. /**
  81237. * Float
  81238. */
  81239. FLOAT = 5126,
  81240. }
  81241. /**
  81242. * Specifies if the attirbute is a scalar, vector, or matrix
  81243. */
  81244. const enum AccessorType {
  81245. /**
  81246. * Scalar
  81247. */
  81248. SCALAR = "SCALAR",
  81249. /**
  81250. * Vector2
  81251. */
  81252. VEC2 = "VEC2",
  81253. /**
  81254. * Vector3
  81255. */
  81256. VEC3 = "VEC3",
  81257. /**
  81258. * Vector4
  81259. */
  81260. VEC4 = "VEC4",
  81261. /**
  81262. * Matrix2x2
  81263. */
  81264. MAT2 = "MAT2",
  81265. /**
  81266. * Matrix3x3
  81267. */
  81268. MAT3 = "MAT3",
  81269. /**
  81270. * Matrix4x4
  81271. */
  81272. MAT4 = "MAT4",
  81273. }
  81274. /**
  81275. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81276. */
  81277. const enum AnimationChannelTargetPath {
  81278. /**
  81279. * Translation
  81280. */
  81281. TRANSLATION = "translation",
  81282. /**
  81283. * Rotation
  81284. */
  81285. ROTATION = "rotation",
  81286. /**
  81287. * Scale
  81288. */
  81289. SCALE = "scale",
  81290. /**
  81291. * Weights
  81292. */
  81293. WEIGHTS = "weights",
  81294. }
  81295. /**
  81296. * Interpolation algorithm
  81297. */
  81298. const enum AnimationSamplerInterpolation {
  81299. /**
  81300. * The animated values are linearly interpolated between keyframes
  81301. */
  81302. LINEAR = "LINEAR",
  81303. /**
  81304. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81305. */
  81306. STEP = "STEP",
  81307. /**
  81308. * The animation's interpolation is computed using a cubic spline with specified tangents
  81309. */
  81310. CUBICSPLINE = "CUBICSPLINE",
  81311. }
  81312. /**
  81313. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81314. */
  81315. const enum CameraType {
  81316. /**
  81317. * A perspective camera containing properties to create a perspective projection matrix
  81318. */
  81319. PERSPECTIVE = "perspective",
  81320. /**
  81321. * An orthographic camera containing properties to create an orthographic projection matrix
  81322. */
  81323. ORTHOGRAPHIC = "orthographic",
  81324. }
  81325. /**
  81326. * The mime-type of the image
  81327. */
  81328. const enum ImageMimeType {
  81329. /**
  81330. * JPEG Mime-type
  81331. */
  81332. JPEG = "image/jpeg",
  81333. /**
  81334. * PNG Mime-type
  81335. */
  81336. PNG = "image/png",
  81337. }
  81338. /**
  81339. * The alpha rendering mode of the material
  81340. */
  81341. const enum MaterialAlphaMode {
  81342. /**
  81343. * The alpha value is ignored and the rendered output is fully opaque
  81344. */
  81345. OPAQUE = "OPAQUE",
  81346. /**
  81347. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81348. */
  81349. MASK = "MASK",
  81350. /**
  81351. * 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)
  81352. */
  81353. BLEND = "BLEND",
  81354. }
  81355. /**
  81356. * The type of the primitives to render
  81357. */
  81358. const enum MeshPrimitiveMode {
  81359. /**
  81360. * Points
  81361. */
  81362. POINTS = 0,
  81363. /**
  81364. * Lines
  81365. */
  81366. LINES = 1,
  81367. /**
  81368. * Line Loop
  81369. */
  81370. LINE_LOOP = 2,
  81371. /**
  81372. * Line Strip
  81373. */
  81374. LINE_STRIP = 3,
  81375. /**
  81376. * Triangles
  81377. */
  81378. TRIANGLES = 4,
  81379. /**
  81380. * Triangle Strip
  81381. */
  81382. TRIANGLE_STRIP = 5,
  81383. /**
  81384. * Triangle Fan
  81385. */
  81386. TRIANGLE_FAN = 6,
  81387. }
  81388. /**
  81389. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81390. */
  81391. const enum TextureMagFilter {
  81392. /**
  81393. * Nearest
  81394. */
  81395. NEAREST = 9728,
  81396. /**
  81397. * Linear
  81398. */
  81399. LINEAR = 9729,
  81400. }
  81401. /**
  81402. * Minification filter. All valid values correspond to WebGL enums
  81403. */
  81404. const enum TextureMinFilter {
  81405. /**
  81406. * Nearest
  81407. */
  81408. NEAREST = 9728,
  81409. /**
  81410. * Linear
  81411. */
  81412. LINEAR = 9729,
  81413. /**
  81414. * Nearest Mip-Map Nearest
  81415. */
  81416. NEAREST_MIPMAP_NEAREST = 9984,
  81417. /**
  81418. * Linear Mipmap Nearest
  81419. */
  81420. LINEAR_MIPMAP_NEAREST = 9985,
  81421. /**
  81422. * Nearest Mipmap Linear
  81423. */
  81424. NEAREST_MIPMAP_LINEAR = 9986,
  81425. /**
  81426. * Linear Mipmap Linear
  81427. */
  81428. LINEAR_MIPMAP_LINEAR = 9987,
  81429. }
  81430. /**
  81431. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81432. */
  81433. const enum TextureWrapMode {
  81434. /**
  81435. * Clamp to Edge
  81436. */
  81437. CLAMP_TO_EDGE = 33071,
  81438. /**
  81439. * Mirrored Repeat
  81440. */
  81441. MIRRORED_REPEAT = 33648,
  81442. /**
  81443. * Repeat
  81444. */
  81445. REPEAT = 10497,
  81446. }
  81447. /**
  81448. * glTF Property
  81449. */
  81450. interface IProperty {
  81451. /**
  81452. * Dictionary object with extension-specific objects
  81453. */
  81454. extensions?: {
  81455. [key: string]: any;
  81456. };
  81457. /**
  81458. * Application-Specific data
  81459. */
  81460. extras?: any;
  81461. }
  81462. /**
  81463. * glTF Child of Root Property
  81464. */
  81465. interface IChildRootProperty extends IProperty {
  81466. /**
  81467. * The user-defined name of this object
  81468. */
  81469. name?: string;
  81470. }
  81471. /**
  81472. * Indices of those attributes that deviate from their initialization value
  81473. */
  81474. interface IAccessorSparseIndices extends IProperty {
  81475. /**
  81476. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81477. */
  81478. bufferView: number;
  81479. /**
  81480. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81481. */
  81482. byteOffset?: number;
  81483. /**
  81484. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81485. */
  81486. componentType: AccessorComponentType;
  81487. }
  81488. /**
  81489. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81490. */
  81491. interface IAccessorSparseValues extends IProperty {
  81492. /**
  81493. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81494. */
  81495. bufferView: number;
  81496. /**
  81497. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81498. */
  81499. byteOffset?: number;
  81500. }
  81501. /**
  81502. * Sparse storage of attributes that deviate from their initialization value
  81503. */
  81504. interface IAccessorSparse extends IProperty {
  81505. /**
  81506. * The number of attributes encoded in this sparse accessor
  81507. */
  81508. count: number;
  81509. /**
  81510. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81511. */
  81512. indices: IAccessorSparseIndices;
  81513. /**
  81514. * 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
  81515. */
  81516. values: IAccessorSparseValues;
  81517. }
  81518. /**
  81519. * 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
  81520. */
  81521. interface IAccessor extends IChildRootProperty {
  81522. /**
  81523. * The index of the bufferview
  81524. */
  81525. bufferView?: number;
  81526. /**
  81527. * The offset relative to the start of the bufferView in bytes
  81528. */
  81529. byteOffset?: number;
  81530. /**
  81531. * The datatype of components in the attribute
  81532. */
  81533. componentType: AccessorComponentType;
  81534. /**
  81535. * Specifies whether integer data values should be normalized
  81536. */
  81537. normalized?: boolean;
  81538. /**
  81539. * The number of attributes referenced by this accessor
  81540. */
  81541. count: number;
  81542. /**
  81543. * Specifies if the attribute is a scalar, vector, or matrix
  81544. */
  81545. type: AccessorType;
  81546. /**
  81547. * Maximum value of each component in this attribute
  81548. */
  81549. max?: number[];
  81550. /**
  81551. * Minimum value of each component in this attribute
  81552. */
  81553. min?: number[];
  81554. /**
  81555. * Sparse storage of attributes that deviate from their initialization value
  81556. */
  81557. sparse?: IAccessorSparse;
  81558. }
  81559. /**
  81560. * Targets an animation's sampler at a node's property
  81561. */
  81562. interface IAnimationChannel extends IProperty {
  81563. /**
  81564. * The index of a sampler in this animation used to compute the value for the target
  81565. */
  81566. sampler: number;
  81567. /**
  81568. * The index of the node and TRS property to target
  81569. */
  81570. target: IAnimationChannelTarget;
  81571. }
  81572. /**
  81573. * The index of the node and TRS property that an animation channel targets
  81574. */
  81575. interface IAnimationChannelTarget extends IProperty {
  81576. /**
  81577. * The index of the node to target
  81578. */
  81579. node: number;
  81580. /**
  81581. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81582. */
  81583. path: AnimationChannelTargetPath;
  81584. }
  81585. /**
  81586. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81587. */
  81588. interface IAnimationSampler extends IProperty {
  81589. /**
  81590. * The index of an accessor containing keyframe input values, e.g., time
  81591. */
  81592. input: number;
  81593. /**
  81594. * Interpolation algorithm
  81595. */
  81596. interpolation?: AnimationSamplerInterpolation;
  81597. /**
  81598. * The index of an accessor, containing keyframe output values
  81599. */
  81600. output: number;
  81601. }
  81602. /**
  81603. * A keyframe animation
  81604. */
  81605. interface IAnimation extends IChildRootProperty {
  81606. /**
  81607. * An array of channels, each of which targets an animation's sampler at a node's property
  81608. */
  81609. channels: IAnimationChannel[];
  81610. /**
  81611. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81612. */
  81613. samplers: IAnimationSampler[];
  81614. }
  81615. /**
  81616. * Metadata about the glTF asset
  81617. */
  81618. interface IAsset extends IChildRootProperty {
  81619. /**
  81620. * A copyright message suitable for display to credit the content creator
  81621. */
  81622. copyright?: string;
  81623. /**
  81624. * Tool that generated this glTF model. Useful for debugging
  81625. */
  81626. generator?: string;
  81627. /**
  81628. * The glTF version that this asset targets
  81629. */
  81630. version: string;
  81631. /**
  81632. * The minimum glTF version that this asset targets
  81633. */
  81634. minVersion?: string;
  81635. }
  81636. /**
  81637. * A buffer points to binary geometry, animation, or skins
  81638. */
  81639. interface IBuffer extends IChildRootProperty {
  81640. /**
  81641. * 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
  81642. */
  81643. uri?: string;
  81644. /**
  81645. * The length of the buffer in bytes
  81646. */
  81647. byteLength: number;
  81648. }
  81649. /**
  81650. * A view into a buffer generally representing a subset of the buffer
  81651. */
  81652. interface IBufferView extends IChildRootProperty {
  81653. /**
  81654. * The index of the buffer
  81655. */
  81656. buffer: number;
  81657. /**
  81658. * The offset into the buffer in bytes
  81659. */
  81660. byteOffset?: number;
  81661. /**
  81662. * The lenth of the bufferView in bytes
  81663. */
  81664. byteLength: number;
  81665. /**
  81666. * The stride, in bytes
  81667. */
  81668. byteStride?: number;
  81669. }
  81670. /**
  81671. * An orthographic camera containing properties to create an orthographic projection matrix
  81672. */
  81673. interface ICameraOrthographic extends IProperty {
  81674. /**
  81675. * The floating-point horizontal magnification of the view. Must not be zero
  81676. */
  81677. xmag: number;
  81678. /**
  81679. * The floating-point vertical magnification of the view. Must not be zero
  81680. */
  81681. ymag: number;
  81682. /**
  81683. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81684. */
  81685. zfar: number;
  81686. /**
  81687. * The floating-point distance to the near clipping plane
  81688. */
  81689. znear: number;
  81690. }
  81691. /**
  81692. * A perspective camera containing properties to create a perspective projection matrix
  81693. */
  81694. interface ICameraPerspective extends IProperty {
  81695. /**
  81696. * The floating-point aspect ratio of the field of view
  81697. */
  81698. aspectRatio?: number;
  81699. /**
  81700. * The floating-point vertical field of view in radians
  81701. */
  81702. yfov: number;
  81703. /**
  81704. * The floating-point distance to the far clipping plane
  81705. */
  81706. zfar?: number;
  81707. /**
  81708. * The floating-point distance to the near clipping plane
  81709. */
  81710. znear: number;
  81711. }
  81712. /**
  81713. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81714. */
  81715. interface ICamera extends IChildRootProperty {
  81716. /**
  81717. * An orthographic camera containing properties to create an orthographic projection matrix
  81718. */
  81719. orthographic?: ICameraOrthographic;
  81720. /**
  81721. * A perspective camera containing properties to create a perspective projection matrix
  81722. */
  81723. perspective?: ICameraPerspective;
  81724. /**
  81725. * Specifies if the camera uses a perspective or orthographic projection
  81726. */
  81727. type: CameraType;
  81728. }
  81729. /**
  81730. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81731. */
  81732. interface IImage extends IChildRootProperty {
  81733. /**
  81734. * 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
  81735. */
  81736. uri?: string;
  81737. /**
  81738. * The image's MIME type
  81739. */
  81740. mimeType?: ImageMimeType;
  81741. /**
  81742. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81743. */
  81744. bufferView?: number;
  81745. }
  81746. /**
  81747. * Material Normal Texture Info
  81748. */
  81749. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81750. /**
  81751. * The scalar multiplier applied to each normal vector of the normal texture
  81752. */
  81753. scale?: number;
  81754. }
  81755. /**
  81756. * Material Occlusion Texture Info
  81757. */
  81758. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81759. /**
  81760. * A scalar multiplier controlling the amount of occlusion applied
  81761. */
  81762. strength?: number;
  81763. }
  81764. /**
  81765. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81766. */
  81767. interface IMaterialPbrMetallicRoughness {
  81768. /**
  81769. * The material's base color factor
  81770. */
  81771. baseColorFactor?: number[];
  81772. /**
  81773. * The base color texture
  81774. */
  81775. baseColorTexture?: ITextureInfo;
  81776. /**
  81777. * The metalness of the material
  81778. */
  81779. metallicFactor?: number;
  81780. /**
  81781. * The roughness of the material
  81782. */
  81783. roughnessFactor?: number;
  81784. /**
  81785. * The metallic-roughness texture
  81786. */
  81787. metallicRoughnessTexture?: ITextureInfo;
  81788. }
  81789. /**
  81790. * The material appearance of a primitive
  81791. */
  81792. interface IMaterial extends IChildRootProperty {
  81793. /**
  81794. * 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
  81795. */
  81796. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81797. /**
  81798. * The normal map texture
  81799. */
  81800. normalTexture?: IMaterialNormalTextureInfo;
  81801. /**
  81802. * The occlusion map texture
  81803. */
  81804. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81805. /**
  81806. * The emissive map texture
  81807. */
  81808. emissiveTexture?: ITextureInfo;
  81809. /**
  81810. * 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
  81811. */
  81812. emissiveFactor?: number[];
  81813. /**
  81814. * The alpha rendering mode of the material
  81815. */
  81816. alphaMode?: MaterialAlphaMode;
  81817. /**
  81818. * The alpha cutoff value of the material
  81819. */
  81820. alphaCutoff?: number;
  81821. /**
  81822. * Specifies whether the material is double sided
  81823. */
  81824. doubleSided?: boolean;
  81825. }
  81826. /**
  81827. * Geometry to be rendered with the given material
  81828. */
  81829. interface IMeshPrimitive extends IProperty {
  81830. /**
  81831. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  81832. */
  81833. attributes: {
  81834. [name: string]: number;
  81835. };
  81836. /**
  81837. * The index of the accessor that contains the indices
  81838. */
  81839. indices?: number;
  81840. /**
  81841. * The index of the material to apply to this primitive when rendering
  81842. */
  81843. material?: number;
  81844. /**
  81845. * The type of primitives to render. All valid values correspond to WebGL enums
  81846. */
  81847. mode?: MeshPrimitiveMode;
  81848. /**
  81849. * 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
  81850. */
  81851. targets?: {
  81852. [name: string]: number;
  81853. }[];
  81854. }
  81855. /**
  81856. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  81857. */
  81858. interface IMesh extends IChildRootProperty {
  81859. /**
  81860. * An array of primitives, each defining geometry to be rendered with a material
  81861. */
  81862. primitives: IMeshPrimitive[];
  81863. /**
  81864. * Array of weights to be applied to the Morph Targets
  81865. */
  81866. weights?: number[];
  81867. }
  81868. /**
  81869. * A node in the node hierarchy
  81870. */
  81871. interface INode extends IChildRootProperty {
  81872. /**
  81873. * The index of the camera referenced by this node
  81874. */
  81875. camera?: number;
  81876. /**
  81877. * The indices of this node's children
  81878. */
  81879. children?: number[];
  81880. /**
  81881. * The index of the skin referenced by this node
  81882. */
  81883. skin?: number;
  81884. /**
  81885. * A floating-point 4x4 transformation matrix stored in column-major order
  81886. */
  81887. matrix?: number[];
  81888. /**
  81889. * The index of the mesh in this node
  81890. */
  81891. mesh?: number;
  81892. /**
  81893. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  81894. */
  81895. rotation?: number[];
  81896. /**
  81897. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  81898. */
  81899. scale?: number[];
  81900. /**
  81901. * The node's translation along the x, y, and z axes
  81902. */
  81903. translation?: number[];
  81904. /**
  81905. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  81906. */
  81907. weights?: number[];
  81908. }
  81909. /**
  81910. * Texture sampler properties for filtering and wrapping modes
  81911. */
  81912. interface ISampler extends IChildRootProperty {
  81913. /**
  81914. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81915. */
  81916. magFilter?: TextureMagFilter;
  81917. /**
  81918. * Minification filter. All valid values correspond to WebGL enums
  81919. */
  81920. minFilter?: TextureMinFilter;
  81921. /**
  81922. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81923. */
  81924. wrapS?: TextureWrapMode;
  81925. /**
  81926. * T (V) wrapping mode. All valid values correspond to WebGL enums
  81927. */
  81928. wrapT?: TextureWrapMode;
  81929. }
  81930. /**
  81931. * The root nodes of a scene
  81932. */
  81933. interface IScene extends IChildRootProperty {
  81934. /**
  81935. * The indices of each root node
  81936. */
  81937. nodes: number[];
  81938. }
  81939. /**
  81940. * Joints and matrices defining a skin
  81941. */
  81942. interface ISkin extends IChildRootProperty {
  81943. /**
  81944. * 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
  81945. */
  81946. inverseBindMatrices?: number;
  81947. /**
  81948. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81949. */
  81950. skeleton?: number;
  81951. /**
  81952. * 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)
  81953. */
  81954. joints: number[];
  81955. }
  81956. /**
  81957. * A texture and its sampler
  81958. */
  81959. interface ITexture extends IChildRootProperty {
  81960. /**
  81961. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  81962. */
  81963. sampler?: number;
  81964. /**
  81965. * The index of the image used by this texture
  81966. */
  81967. source: number;
  81968. }
  81969. /**
  81970. * Reference to a texture
  81971. */
  81972. interface ITextureInfo extends IProperty {
  81973. /**
  81974. * The index of the texture
  81975. */
  81976. index: number;
  81977. /**
  81978. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81979. */
  81980. texCoord?: number;
  81981. }
  81982. /**
  81983. * The root object for a glTF asset
  81984. */
  81985. interface IGLTF extends IProperty {
  81986. /**
  81987. * An array of accessors. An accessor is a typed view into a bufferView
  81988. */
  81989. accessors?: IAccessor[];
  81990. /**
  81991. * An array of keyframe animations
  81992. */
  81993. animations?: IAnimation[];
  81994. /**
  81995. * Metadata about the glTF asset
  81996. */
  81997. asset: IAsset;
  81998. /**
  81999. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82000. */
  82001. buffers?: IBuffer[];
  82002. /**
  82003. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82004. */
  82005. bufferViews?: IBufferView[];
  82006. /**
  82007. * An array of cameras
  82008. */
  82009. cameras?: ICamera[];
  82010. /**
  82011. * Names of glTF extensions used somewhere in this asset
  82012. */
  82013. extensionsUsed?: string[];
  82014. /**
  82015. * Names of glTF extensions required to properly load this asset
  82016. */
  82017. extensionsRequired?: string[];
  82018. /**
  82019. * An array of images. An image defines data used to create a texture
  82020. */
  82021. images?: IImage[];
  82022. /**
  82023. * An array of materials. A material defines the appearance of a primitive
  82024. */
  82025. materials?: IMaterial[];
  82026. /**
  82027. * An array of meshes. A mesh is a set of primitives to be rendered
  82028. */
  82029. meshes?: IMesh[];
  82030. /**
  82031. * An array of nodes
  82032. */
  82033. nodes?: INode[];
  82034. /**
  82035. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82036. */
  82037. samplers?: ISampler[];
  82038. /**
  82039. * The index of the default scene
  82040. */
  82041. scene?: number;
  82042. /**
  82043. * An array of scenes
  82044. */
  82045. scenes?: IScene[];
  82046. /**
  82047. * An array of skins. A skin is defined by joints and matrices
  82048. */
  82049. skins?: ISkin[];
  82050. /**
  82051. * An array of textures
  82052. */
  82053. textures?: ITexture[];
  82054. }
  82055. /**
  82056. * The glTF validation results
  82057. * @ignore
  82058. */
  82059. interface IGLTFValidationResults {
  82060. info: {
  82061. generator: string;
  82062. hasAnimations: boolean;
  82063. hasDefaultScene: boolean;
  82064. hasMaterials: boolean;
  82065. hasMorphTargets: boolean;
  82066. hasSkins: boolean;
  82067. hasTextures: boolean;
  82068. maxAttributesUsed: number;
  82069. primitivesCount: number
  82070. };
  82071. issues: {
  82072. messages: Array<string>;
  82073. numErrors: number;
  82074. numHints: number;
  82075. numInfos: number;
  82076. numWarnings: number;
  82077. truncated: boolean
  82078. };
  82079. mimeType: string;
  82080. uri: string;
  82081. validatedAt: string;
  82082. validatorVersion: string;
  82083. }
  82084. /**
  82085. * The glTF validation options
  82086. */
  82087. interface IGLTFValidationOptions {
  82088. /** Uri to use */
  82089. uri?: string;
  82090. /** Function used to load external resources */
  82091. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82092. /** Boolean indicating that we need to validate accessor data */
  82093. validateAccessorData?: boolean;
  82094. /** max number of issues allowed */
  82095. maxIssues?: number;
  82096. /** Ignored issues */
  82097. ignoredIssues?: Array<string>;
  82098. /** Value to override severy settings */
  82099. severityOverrides?: Object;
  82100. }
  82101. /**
  82102. * The glTF validator object
  82103. * @ignore
  82104. */
  82105. interface IGLTFValidator {
  82106. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82107. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82108. }
  82109. }
  82110. declare module BABYLON {
  82111. /** @hidden */
  82112. export var cellPixelShader: {
  82113. name: string;
  82114. shader: string;
  82115. };
  82116. }
  82117. declare module BABYLON {
  82118. /** @hidden */
  82119. export var cellVertexShader: {
  82120. name: string;
  82121. shader: string;
  82122. };
  82123. }
  82124. declare module BABYLON {
  82125. export class CellMaterial extends BABYLON.PushMaterial {
  82126. private _diffuseTexture;
  82127. diffuseTexture: BABYLON.BaseTexture;
  82128. diffuseColor: BABYLON.Color3;
  82129. _computeHighLevel: boolean;
  82130. computeHighLevel: boolean;
  82131. private _disableLighting;
  82132. disableLighting: boolean;
  82133. private _maxSimultaneousLights;
  82134. maxSimultaneousLights: number;
  82135. constructor(name: string, scene: BABYLON.Scene);
  82136. needAlphaBlending(): boolean;
  82137. needAlphaTesting(): boolean;
  82138. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82139. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82140. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82141. getAnimatables(): BABYLON.IAnimatable[];
  82142. getActiveTextures(): BABYLON.BaseTexture[];
  82143. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82144. dispose(forceDisposeEffect?: boolean): void;
  82145. getClassName(): string;
  82146. clone(name: string): CellMaterial;
  82147. serialize(): any;
  82148. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82149. }
  82150. }
  82151. declare module BABYLON {
  82152. export class CustomShaderStructure {
  82153. FragmentStore: string;
  82154. VertexStore: string;
  82155. constructor();
  82156. }
  82157. export class ShaderSpecialParts {
  82158. constructor();
  82159. Fragment_Begin: string;
  82160. Fragment_Definitions: string;
  82161. Fragment_MainBegin: string;
  82162. Fragment_Custom_Diffuse: string;
  82163. Fragment_Before_Lights: string;
  82164. Fragment_Before_Fog: string;
  82165. Fragment_Custom_Alpha: string;
  82166. Fragment_Before_FragColor: string;
  82167. Vertex_Begin: string;
  82168. Vertex_Definitions: string;
  82169. Vertex_MainBegin: string;
  82170. Vertex_Before_PositionUpdated: string;
  82171. Vertex_Before_NormalUpdated: string;
  82172. Vertex_After_WorldPosComputed: string;
  82173. Vertex_MainEnd: string;
  82174. }
  82175. export class CustomMaterial extends BABYLON.StandardMaterial {
  82176. static ShaderIndexer: number;
  82177. CustomParts: ShaderSpecialParts;
  82178. _isCreatedShader: boolean;
  82179. _createdShaderName: string;
  82180. _customUniform: string[];
  82181. _newUniforms: string[];
  82182. _newUniformInstances: {
  82183. [name: string]: any;
  82184. };
  82185. _newSamplerInstances: {
  82186. [name: string]: BABYLON.Texture;
  82187. };
  82188. _customAttributes: string[];
  82189. FragmentShader: string;
  82190. VertexShader: string;
  82191. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82192. ReviewUniform(name: string, arr: string[]): string[];
  82193. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82194. constructor(name: string, scene: BABYLON.Scene);
  82195. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82196. AddAttribute(name: string): CustomMaterial;
  82197. Fragment_Begin(shaderPart: string): CustomMaterial;
  82198. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82199. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82200. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82201. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82202. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82203. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82204. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82205. Vertex_Begin(shaderPart: string): CustomMaterial;
  82206. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82207. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82208. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82209. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82210. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82211. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82212. }
  82213. }
  82214. declare module BABYLON {
  82215. export class ShaderAlebdoParts {
  82216. constructor();
  82217. Fragment_Begin: string;
  82218. Fragment_Definitions: string;
  82219. Fragment_MainBegin: string;
  82220. Fragment_Custom_Albedo: string;
  82221. Fragment_Before_Lights: string;
  82222. Fragment_Custom_MetallicRoughness: string;
  82223. Fragment_Custom_MicroSurface: string;
  82224. Fragment_Before_Fog: string;
  82225. Fragment_Custom_Alpha: string;
  82226. Fragment_Before_FragColor: string;
  82227. Vertex_Begin: string;
  82228. Vertex_Definitions: string;
  82229. Vertex_MainBegin: string;
  82230. Vertex_Before_PositionUpdated: string;
  82231. Vertex_Before_NormalUpdated: string;
  82232. Vertex_After_WorldPosComputed: string;
  82233. Vertex_MainEnd: string;
  82234. }
  82235. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82236. static ShaderIndexer: number;
  82237. CustomParts: ShaderAlebdoParts;
  82238. _isCreatedShader: boolean;
  82239. _createdShaderName: string;
  82240. _customUniform: string[];
  82241. _newUniforms: string[];
  82242. _newUniformInstances: {
  82243. [name: string]: any;
  82244. };
  82245. _newSamplerInstances: {
  82246. [name: string]: BABYLON.Texture;
  82247. };
  82248. _customAttributes: string[];
  82249. FragmentShader: string;
  82250. VertexShader: string;
  82251. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82252. ReviewUniform(name: string, arr: string[]): string[];
  82253. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82254. constructor(name: string, scene: BABYLON.Scene);
  82255. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82256. AddAttribute(name: string): PBRCustomMaterial;
  82257. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82258. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82259. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82260. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82261. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82262. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82263. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82264. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82265. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82266. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82267. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82268. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82269. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82270. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82271. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82272. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82273. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82274. }
  82275. }
  82276. declare module BABYLON {
  82277. /** @hidden */
  82278. export var firePixelShader: {
  82279. name: string;
  82280. shader: string;
  82281. };
  82282. }
  82283. declare module BABYLON {
  82284. /** @hidden */
  82285. export var fireVertexShader: {
  82286. name: string;
  82287. shader: string;
  82288. };
  82289. }
  82290. declare module BABYLON {
  82291. export class FireMaterial extends BABYLON.PushMaterial {
  82292. private _diffuseTexture;
  82293. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82294. private _distortionTexture;
  82295. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82296. private _opacityTexture;
  82297. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82298. diffuseColor: BABYLON.Color3;
  82299. speed: number;
  82300. private _scaledDiffuse;
  82301. private _lastTime;
  82302. constructor(name: string, scene: BABYLON.Scene);
  82303. needAlphaBlending(): boolean;
  82304. needAlphaTesting(): boolean;
  82305. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82306. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82307. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82308. getAnimatables(): BABYLON.IAnimatable[];
  82309. getActiveTextures(): BABYLON.BaseTexture[];
  82310. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82311. getClassName(): string;
  82312. dispose(forceDisposeEffect?: boolean): void;
  82313. clone(name: string): FireMaterial;
  82314. serialize(): any;
  82315. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82316. }
  82317. }
  82318. declare module BABYLON {
  82319. /** @hidden */
  82320. export var furPixelShader: {
  82321. name: string;
  82322. shader: string;
  82323. };
  82324. }
  82325. declare module BABYLON {
  82326. /** @hidden */
  82327. export var furVertexShader: {
  82328. name: string;
  82329. shader: string;
  82330. };
  82331. }
  82332. declare module BABYLON {
  82333. export class FurMaterial extends BABYLON.PushMaterial {
  82334. private _diffuseTexture;
  82335. diffuseTexture: BABYLON.BaseTexture;
  82336. private _heightTexture;
  82337. heightTexture: BABYLON.BaseTexture;
  82338. diffuseColor: BABYLON.Color3;
  82339. furLength: number;
  82340. furAngle: number;
  82341. furColor: BABYLON.Color3;
  82342. furOffset: number;
  82343. furSpacing: number;
  82344. furGravity: BABYLON.Vector3;
  82345. furSpeed: number;
  82346. furDensity: number;
  82347. furOcclusion: number;
  82348. furTexture: BABYLON.DynamicTexture;
  82349. private _disableLighting;
  82350. disableLighting: boolean;
  82351. private _maxSimultaneousLights;
  82352. maxSimultaneousLights: number;
  82353. highLevelFur: boolean;
  82354. _meshes: BABYLON.AbstractMesh[];
  82355. private _furTime;
  82356. constructor(name: string, scene: BABYLON.Scene);
  82357. get furTime(): number;
  82358. set furTime(furTime: number);
  82359. needAlphaBlending(): boolean;
  82360. needAlphaTesting(): boolean;
  82361. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82362. updateFur(): void;
  82363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82364. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82365. getAnimatables(): BABYLON.IAnimatable[];
  82366. getActiveTextures(): BABYLON.BaseTexture[];
  82367. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82368. dispose(forceDisposeEffect?: boolean): void;
  82369. clone(name: string): FurMaterial;
  82370. serialize(): any;
  82371. getClassName(): string;
  82372. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82373. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82374. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82375. }
  82376. }
  82377. declare module BABYLON {
  82378. /** @hidden */
  82379. export var gradientPixelShader: {
  82380. name: string;
  82381. shader: string;
  82382. };
  82383. }
  82384. declare module BABYLON {
  82385. /** @hidden */
  82386. export var gradientVertexShader: {
  82387. name: string;
  82388. shader: string;
  82389. };
  82390. }
  82391. declare module BABYLON {
  82392. export class GradientMaterial extends BABYLON.PushMaterial {
  82393. private _maxSimultaneousLights;
  82394. maxSimultaneousLights: number;
  82395. topColor: BABYLON.Color3;
  82396. topColorAlpha: number;
  82397. bottomColor: BABYLON.Color3;
  82398. bottomColorAlpha: number;
  82399. offset: number;
  82400. scale: number;
  82401. smoothness: number;
  82402. private _disableLighting;
  82403. disableLighting: boolean;
  82404. constructor(name: string, scene: BABYLON.Scene);
  82405. needAlphaBlending(): boolean;
  82406. needAlphaTesting(): boolean;
  82407. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82408. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82409. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82410. getAnimatables(): BABYLON.IAnimatable[];
  82411. dispose(forceDisposeEffect?: boolean): void;
  82412. clone(name: string): GradientMaterial;
  82413. serialize(): any;
  82414. getClassName(): string;
  82415. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82416. }
  82417. }
  82418. declare module BABYLON {
  82419. /** @hidden */
  82420. export var gridPixelShader: {
  82421. name: string;
  82422. shader: string;
  82423. };
  82424. }
  82425. declare module BABYLON {
  82426. /** @hidden */
  82427. export var gridVertexShader: {
  82428. name: string;
  82429. shader: string;
  82430. };
  82431. }
  82432. declare module BABYLON {
  82433. /**
  82434. * The grid materials allows you to wrap any shape with a grid.
  82435. * Colors are customizable.
  82436. */
  82437. export class GridMaterial extends BABYLON.PushMaterial {
  82438. /**
  82439. * Main color of the grid (e.g. between lines)
  82440. */
  82441. mainColor: BABYLON.Color3;
  82442. /**
  82443. * Color of the grid lines.
  82444. */
  82445. lineColor: BABYLON.Color3;
  82446. /**
  82447. * The scale of the grid compared to unit.
  82448. */
  82449. gridRatio: number;
  82450. /**
  82451. * Allows setting an offset for the grid lines.
  82452. */
  82453. gridOffset: BABYLON.Vector3;
  82454. /**
  82455. * The frequency of thicker lines.
  82456. */
  82457. majorUnitFrequency: number;
  82458. /**
  82459. * The visibility of minor units in the grid.
  82460. */
  82461. minorUnitVisibility: number;
  82462. /**
  82463. * The grid opacity outside of the lines.
  82464. */
  82465. opacity: number;
  82466. /**
  82467. * Determine RBG output is premultiplied by alpha value.
  82468. */
  82469. preMultiplyAlpha: boolean;
  82470. private _opacityTexture;
  82471. opacityTexture: BABYLON.BaseTexture;
  82472. private _gridControl;
  82473. /**
  82474. * constructor
  82475. * @param name The name given to the material in order to identify it afterwards.
  82476. * @param scene The scene the material is used in.
  82477. */
  82478. constructor(name: string, scene: BABYLON.Scene);
  82479. /**
  82480. * Returns wehter or not the grid requires alpha blending.
  82481. */
  82482. needAlphaBlending(): boolean;
  82483. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82484. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82485. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82486. /**
  82487. * Dispose the material and its associated resources.
  82488. * @param forceDisposeEffect will also dispose the used effect when true
  82489. */
  82490. dispose(forceDisposeEffect?: boolean): void;
  82491. clone(name: string): GridMaterial;
  82492. serialize(): any;
  82493. getClassName(): string;
  82494. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82495. }
  82496. }
  82497. declare module BABYLON {
  82498. /** @hidden */
  82499. export var lavaPixelShader: {
  82500. name: string;
  82501. shader: string;
  82502. };
  82503. }
  82504. declare module BABYLON {
  82505. /** @hidden */
  82506. export var lavaVertexShader: {
  82507. name: string;
  82508. shader: string;
  82509. };
  82510. }
  82511. declare module BABYLON {
  82512. export class LavaMaterial extends BABYLON.PushMaterial {
  82513. private _diffuseTexture;
  82514. diffuseTexture: BABYLON.BaseTexture;
  82515. noiseTexture: BABYLON.BaseTexture;
  82516. fogColor: BABYLON.Color3;
  82517. speed: number;
  82518. movingSpeed: number;
  82519. lowFrequencySpeed: number;
  82520. fogDensity: number;
  82521. private _lastTime;
  82522. diffuseColor: BABYLON.Color3;
  82523. private _disableLighting;
  82524. disableLighting: boolean;
  82525. private _unlit;
  82526. unlit: boolean;
  82527. private _maxSimultaneousLights;
  82528. maxSimultaneousLights: number;
  82529. private _scaledDiffuse;
  82530. constructor(name: string, scene: BABYLON.Scene);
  82531. needAlphaBlending(): boolean;
  82532. needAlphaTesting(): boolean;
  82533. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82536. getAnimatables(): BABYLON.IAnimatable[];
  82537. getActiveTextures(): BABYLON.BaseTexture[];
  82538. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82539. dispose(forceDisposeEffect?: boolean): void;
  82540. clone(name: string): LavaMaterial;
  82541. serialize(): any;
  82542. getClassName(): string;
  82543. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82544. }
  82545. }
  82546. declare module BABYLON {
  82547. /** @hidden */
  82548. export var mixPixelShader: {
  82549. name: string;
  82550. shader: string;
  82551. };
  82552. }
  82553. declare module BABYLON {
  82554. /** @hidden */
  82555. export var mixVertexShader: {
  82556. name: string;
  82557. shader: string;
  82558. };
  82559. }
  82560. declare module BABYLON {
  82561. export class MixMaterial extends BABYLON.PushMaterial {
  82562. /**
  82563. * Mix textures
  82564. */
  82565. private _mixTexture1;
  82566. mixTexture1: BABYLON.BaseTexture;
  82567. private _mixTexture2;
  82568. mixTexture2: BABYLON.BaseTexture;
  82569. /**
  82570. * Diffuse textures
  82571. */
  82572. private _diffuseTexture1;
  82573. diffuseTexture1: BABYLON.Texture;
  82574. private _diffuseTexture2;
  82575. diffuseTexture2: BABYLON.Texture;
  82576. private _diffuseTexture3;
  82577. diffuseTexture3: BABYLON.Texture;
  82578. private _diffuseTexture4;
  82579. diffuseTexture4: BABYLON.Texture;
  82580. private _diffuseTexture5;
  82581. diffuseTexture5: BABYLON.Texture;
  82582. private _diffuseTexture6;
  82583. diffuseTexture6: BABYLON.Texture;
  82584. private _diffuseTexture7;
  82585. diffuseTexture7: BABYLON.Texture;
  82586. private _diffuseTexture8;
  82587. diffuseTexture8: BABYLON.Texture;
  82588. /**
  82589. * Uniforms
  82590. */
  82591. diffuseColor: BABYLON.Color3;
  82592. specularColor: BABYLON.Color3;
  82593. specularPower: number;
  82594. private _disableLighting;
  82595. disableLighting: boolean;
  82596. private _maxSimultaneousLights;
  82597. maxSimultaneousLights: number;
  82598. constructor(name: string, scene: BABYLON.Scene);
  82599. needAlphaBlending(): boolean;
  82600. needAlphaTesting(): boolean;
  82601. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82602. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82603. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82604. getAnimatables(): BABYLON.IAnimatable[];
  82605. getActiveTextures(): BABYLON.BaseTexture[];
  82606. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82607. dispose(forceDisposeEffect?: boolean): void;
  82608. clone(name: string): MixMaterial;
  82609. serialize(): any;
  82610. getClassName(): string;
  82611. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82612. }
  82613. }
  82614. declare module BABYLON {
  82615. /** @hidden */
  82616. export var normalPixelShader: {
  82617. name: string;
  82618. shader: string;
  82619. };
  82620. }
  82621. declare module BABYLON {
  82622. /** @hidden */
  82623. export var normalVertexShader: {
  82624. name: string;
  82625. shader: string;
  82626. };
  82627. }
  82628. declare module BABYLON {
  82629. export class NormalMaterial extends BABYLON.PushMaterial {
  82630. private _diffuseTexture;
  82631. diffuseTexture: BABYLON.BaseTexture;
  82632. diffuseColor: BABYLON.Color3;
  82633. private _disableLighting;
  82634. disableLighting: boolean;
  82635. private _maxSimultaneousLights;
  82636. maxSimultaneousLights: number;
  82637. constructor(name: string, scene: BABYLON.Scene);
  82638. needAlphaBlending(): boolean;
  82639. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82640. needAlphaTesting(): boolean;
  82641. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82642. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82643. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82644. getAnimatables(): BABYLON.IAnimatable[];
  82645. getActiveTextures(): BABYLON.BaseTexture[];
  82646. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82647. dispose(forceDisposeEffect?: boolean): void;
  82648. clone(name: string): NormalMaterial;
  82649. serialize(): any;
  82650. getClassName(): string;
  82651. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82652. }
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export var shadowOnlyPixelShader: {
  82657. name: string;
  82658. shader: string;
  82659. };
  82660. }
  82661. declare module BABYLON {
  82662. /** @hidden */
  82663. export var shadowOnlyVertexShader: {
  82664. name: string;
  82665. shader: string;
  82666. };
  82667. }
  82668. declare module BABYLON {
  82669. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82670. private _activeLight;
  82671. private _needAlphaBlending;
  82672. constructor(name: string, scene: BABYLON.Scene);
  82673. shadowColor: BABYLON.Color3;
  82674. needAlphaBlending(): boolean;
  82675. needAlphaTesting(): boolean;
  82676. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82677. get activeLight(): BABYLON.IShadowLight;
  82678. set activeLight(light: BABYLON.IShadowLight);
  82679. private _getFirstShadowLightForMesh;
  82680. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82681. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82682. clone(name: string): ShadowOnlyMaterial;
  82683. serialize(): any;
  82684. getClassName(): string;
  82685. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82686. }
  82687. }
  82688. declare module BABYLON {
  82689. /** @hidden */
  82690. export var simplePixelShader: {
  82691. name: string;
  82692. shader: string;
  82693. };
  82694. }
  82695. declare module BABYLON {
  82696. /** @hidden */
  82697. export var simpleVertexShader: {
  82698. name: string;
  82699. shader: string;
  82700. };
  82701. }
  82702. declare module BABYLON {
  82703. export class SimpleMaterial extends BABYLON.PushMaterial {
  82704. private _diffuseTexture;
  82705. diffuseTexture: BABYLON.BaseTexture;
  82706. diffuseColor: BABYLON.Color3;
  82707. private _disableLighting;
  82708. disableLighting: boolean;
  82709. private _maxSimultaneousLights;
  82710. maxSimultaneousLights: number;
  82711. constructor(name: string, scene: BABYLON.Scene);
  82712. needAlphaBlending(): boolean;
  82713. needAlphaTesting(): boolean;
  82714. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82715. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82716. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82717. getAnimatables(): BABYLON.IAnimatable[];
  82718. getActiveTextures(): BABYLON.BaseTexture[];
  82719. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82720. dispose(forceDisposeEffect?: boolean): void;
  82721. clone(name: string): SimpleMaterial;
  82722. serialize(): any;
  82723. getClassName(): string;
  82724. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82725. }
  82726. }
  82727. declare module BABYLON {
  82728. /** @hidden */
  82729. export var skyPixelShader: {
  82730. name: string;
  82731. shader: string;
  82732. };
  82733. }
  82734. declare module BABYLON {
  82735. /** @hidden */
  82736. export var skyVertexShader: {
  82737. name: string;
  82738. shader: string;
  82739. };
  82740. }
  82741. declare module BABYLON {
  82742. /**
  82743. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82744. * @see https://doc.babylonjs.com/extensions/sky
  82745. */
  82746. export class SkyMaterial extends BABYLON.PushMaterial {
  82747. /**
  82748. * Defines the overall luminance of sky in interval ]0, 1[.
  82749. */
  82750. luminance: number;
  82751. /**
  82752. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82753. */
  82754. turbidity: number;
  82755. /**
  82756. * Defines the sky appearance (light intensity).
  82757. */
  82758. rayleigh: number;
  82759. /**
  82760. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82761. */
  82762. mieCoefficient: number;
  82763. /**
  82764. * Defines the amount of haze particles following the Mie scattering theory.
  82765. */
  82766. mieDirectionalG: number;
  82767. /**
  82768. * Defines the distance of the sun according to the active scene camera.
  82769. */
  82770. distance: number;
  82771. /**
  82772. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82773. * "inclined".
  82774. */
  82775. inclination: number;
  82776. /**
  82777. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82778. * an object direction and a reference direction.
  82779. */
  82780. azimuth: number;
  82781. /**
  82782. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82783. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82784. */
  82785. sunPosition: BABYLON.Vector3;
  82786. /**
  82787. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82788. * .sunPosition property.
  82789. */
  82790. useSunPosition: boolean;
  82791. /**
  82792. * Defines an offset vector used to get a horizon offset.
  82793. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82794. */
  82795. cameraOffset: BABYLON.Vector3;
  82796. private _cameraPosition;
  82797. /**
  82798. * Instantiates a new sky material.
  82799. * This material allows to create dynamic and texture free
  82800. * effects for skyboxes by taking care of the atmosphere state.
  82801. * @see https://doc.babylonjs.com/extensions/sky
  82802. * @param name Define the name of the material in the scene
  82803. * @param scene Define the scene the material belong to
  82804. */
  82805. constructor(name: string, scene: BABYLON.Scene);
  82806. /**
  82807. * Specifies if the material will require alpha blending
  82808. * @returns a boolean specifying if alpha blending is needed
  82809. */
  82810. needAlphaBlending(): boolean;
  82811. /**
  82812. * Specifies if this material should be rendered in alpha test mode
  82813. * @returns false as the sky material doesn't need alpha testing.
  82814. */
  82815. needAlphaTesting(): boolean;
  82816. /**
  82817. * Get the texture used for alpha test purpose.
  82818. * @returns null as the sky material has no texture.
  82819. */
  82820. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82821. /**
  82822. * Get if the submesh is ready to be used and all its information available.
  82823. * Child classes can use it to update shaders
  82824. * @param mesh defines the mesh to check
  82825. * @param subMesh defines which submesh to check
  82826. * @param useInstances specifies that instances should be used
  82827. * @returns a boolean indicating that the submesh is ready or not
  82828. */
  82829. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82830. /**
  82831. * Binds the submesh to this material by preparing the effect and shader to draw
  82832. * @param world defines the world transformation matrix
  82833. * @param mesh defines the mesh containing the submesh
  82834. * @param subMesh defines the submesh to bind the material to
  82835. */
  82836. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82837. /**
  82838. * Get the list of animatables in the material.
  82839. * @returns the list of animatables object used in the material
  82840. */
  82841. getAnimatables(): BABYLON.IAnimatable[];
  82842. /**
  82843. * Disposes the material
  82844. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82845. */
  82846. dispose(forceDisposeEffect?: boolean): void;
  82847. /**
  82848. * Makes a duplicate of the material, and gives it a new name
  82849. * @param name defines the new name for the duplicated material
  82850. * @returns the cloned material
  82851. */
  82852. clone(name: string): SkyMaterial;
  82853. /**
  82854. * Serializes this material in a JSON representation
  82855. * @returns the serialized material object
  82856. */
  82857. serialize(): any;
  82858. /**
  82859. * Gets the current class name of the material e.g. "SkyMaterial"
  82860. * Mainly use in serialization.
  82861. * @returns the class name
  82862. */
  82863. getClassName(): string;
  82864. /**
  82865. * Creates a sky material from parsed material data
  82866. * @param source defines the JSON representation of the material
  82867. * @param scene defines the hosting scene
  82868. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82869. * @returns a new sky material
  82870. */
  82871. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  82872. }
  82873. }
  82874. declare module BABYLON {
  82875. /** @hidden */
  82876. export var terrainPixelShader: {
  82877. name: string;
  82878. shader: string;
  82879. };
  82880. }
  82881. declare module BABYLON {
  82882. /** @hidden */
  82883. export var terrainVertexShader: {
  82884. name: string;
  82885. shader: string;
  82886. };
  82887. }
  82888. declare module BABYLON {
  82889. export class TerrainMaterial extends BABYLON.PushMaterial {
  82890. private _mixTexture;
  82891. mixTexture: BABYLON.BaseTexture;
  82892. private _diffuseTexture1;
  82893. diffuseTexture1: BABYLON.Texture;
  82894. private _diffuseTexture2;
  82895. diffuseTexture2: BABYLON.Texture;
  82896. private _diffuseTexture3;
  82897. diffuseTexture3: BABYLON.Texture;
  82898. private _bumpTexture1;
  82899. bumpTexture1: BABYLON.Texture;
  82900. private _bumpTexture2;
  82901. bumpTexture2: BABYLON.Texture;
  82902. private _bumpTexture3;
  82903. bumpTexture3: BABYLON.Texture;
  82904. diffuseColor: BABYLON.Color3;
  82905. specularColor: BABYLON.Color3;
  82906. specularPower: number;
  82907. private _disableLighting;
  82908. disableLighting: boolean;
  82909. private _maxSimultaneousLights;
  82910. maxSimultaneousLights: number;
  82911. constructor(name: string, scene: BABYLON.Scene);
  82912. needAlphaBlending(): boolean;
  82913. needAlphaTesting(): boolean;
  82914. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82915. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82916. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82917. getAnimatables(): BABYLON.IAnimatable[];
  82918. getActiveTextures(): BABYLON.BaseTexture[];
  82919. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82920. dispose(forceDisposeEffect?: boolean): void;
  82921. clone(name: string): TerrainMaterial;
  82922. serialize(): any;
  82923. getClassName(): string;
  82924. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  82925. }
  82926. }
  82927. declare module BABYLON {
  82928. /** @hidden */
  82929. export var triplanarPixelShader: {
  82930. name: string;
  82931. shader: string;
  82932. };
  82933. }
  82934. declare module BABYLON {
  82935. /** @hidden */
  82936. export var triplanarVertexShader: {
  82937. name: string;
  82938. shader: string;
  82939. };
  82940. }
  82941. declare module BABYLON {
  82942. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82943. mixTexture: BABYLON.BaseTexture;
  82944. private _diffuseTextureX;
  82945. diffuseTextureX: BABYLON.BaseTexture;
  82946. private _diffuseTextureY;
  82947. diffuseTextureY: BABYLON.BaseTexture;
  82948. private _diffuseTextureZ;
  82949. diffuseTextureZ: BABYLON.BaseTexture;
  82950. private _normalTextureX;
  82951. normalTextureX: BABYLON.BaseTexture;
  82952. private _normalTextureY;
  82953. normalTextureY: BABYLON.BaseTexture;
  82954. private _normalTextureZ;
  82955. normalTextureZ: BABYLON.BaseTexture;
  82956. tileSize: number;
  82957. diffuseColor: BABYLON.Color3;
  82958. specularColor: BABYLON.Color3;
  82959. specularPower: number;
  82960. private _disableLighting;
  82961. disableLighting: boolean;
  82962. private _maxSimultaneousLights;
  82963. maxSimultaneousLights: number;
  82964. constructor(name: string, scene: BABYLON.Scene);
  82965. needAlphaBlending(): boolean;
  82966. needAlphaTesting(): boolean;
  82967. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82968. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82969. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82970. getAnimatables(): BABYLON.IAnimatable[];
  82971. getActiveTextures(): BABYLON.BaseTexture[];
  82972. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82973. dispose(forceDisposeEffect?: boolean): void;
  82974. clone(name: string): TriPlanarMaterial;
  82975. serialize(): any;
  82976. getClassName(): string;
  82977. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82978. }
  82979. }
  82980. declare module BABYLON {
  82981. /** @hidden */
  82982. export var waterPixelShader: {
  82983. name: string;
  82984. shader: string;
  82985. };
  82986. }
  82987. declare module BABYLON {
  82988. /** @hidden */
  82989. export var waterVertexShader: {
  82990. name: string;
  82991. shader: string;
  82992. };
  82993. }
  82994. declare module BABYLON {
  82995. export class WaterMaterial extends BABYLON.PushMaterial {
  82996. renderTargetSize: BABYLON.Vector2;
  82997. private _bumpTexture;
  82998. bumpTexture: BABYLON.BaseTexture;
  82999. diffuseColor: BABYLON.Color3;
  83000. specularColor: BABYLON.Color3;
  83001. specularPower: number;
  83002. private _disableLighting;
  83003. disableLighting: boolean;
  83004. private _maxSimultaneousLights;
  83005. maxSimultaneousLights: number;
  83006. /**
  83007. * @param {number}: Represents the wind force
  83008. */
  83009. windForce: number;
  83010. /**
  83011. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83012. */
  83013. windDirection: BABYLON.Vector2;
  83014. /**
  83015. * @param {number}: Wave height, represents the height of the waves
  83016. */
  83017. waveHeight: number;
  83018. /**
  83019. * @param {number}: Bump height, represents the bump height related to the bump map
  83020. */
  83021. bumpHeight: number;
  83022. /**
  83023. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83024. */
  83025. private _bumpSuperimpose;
  83026. bumpSuperimpose: boolean;
  83027. /**
  83028. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83029. */
  83030. private _fresnelSeparate;
  83031. fresnelSeparate: boolean;
  83032. /**
  83033. * @param {boolean}: bump Waves modify the reflection.
  83034. */
  83035. private _bumpAffectsReflection;
  83036. bumpAffectsReflection: boolean;
  83037. /**
  83038. * @param {number}: The water color blended with the refraction (near)
  83039. */
  83040. waterColor: BABYLON.Color3;
  83041. /**
  83042. * @param {number}: The blend factor related to the water color
  83043. */
  83044. colorBlendFactor: number;
  83045. /**
  83046. * @param {number}: The water color blended with the reflection (far)
  83047. */
  83048. waterColor2: BABYLON.Color3;
  83049. /**
  83050. * @param {number}: The blend factor related to the water color (reflection, far)
  83051. */
  83052. colorBlendFactor2: number;
  83053. /**
  83054. * @param {number}: Represents the maximum length of a wave
  83055. */
  83056. waveLength: number;
  83057. /**
  83058. * @param {number}: Defines the waves speed
  83059. */
  83060. waveSpeed: number;
  83061. /**
  83062. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83063. * will avoid calculating useless pixels in the pixel shader of the water material.
  83064. */
  83065. disableClipPlane: boolean;
  83066. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83067. private _mesh;
  83068. private _refractionRTT;
  83069. private _reflectionRTT;
  83070. private _reflectionTransform;
  83071. private _lastTime;
  83072. private _lastDeltaTime;
  83073. private _useLogarithmicDepth;
  83074. private _waitingRenderList;
  83075. private _imageProcessingConfiguration;
  83076. private _imageProcessingObserver;
  83077. /**
  83078. * Gets a boolean indicating that current material needs to register RTT
  83079. */
  83080. get hasRenderTargetTextures(): boolean;
  83081. /**
  83082. * Constructor
  83083. */
  83084. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83085. get useLogarithmicDepth(): boolean;
  83086. set useLogarithmicDepth(value: boolean);
  83087. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83088. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83089. addToRenderList(node: any): void;
  83090. enableRenderTargets(enable: boolean): void;
  83091. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83092. get renderTargetsEnabled(): boolean;
  83093. needAlphaBlending(): boolean;
  83094. needAlphaTesting(): boolean;
  83095. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83096. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83097. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83098. private _createRenderTargets;
  83099. getAnimatables(): BABYLON.IAnimatable[];
  83100. getActiveTextures(): BABYLON.BaseTexture[];
  83101. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83102. dispose(forceDisposeEffect?: boolean): void;
  83103. clone(name: string): WaterMaterial;
  83104. serialize(): any;
  83105. getClassName(): string;
  83106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83107. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83108. }
  83109. }
  83110. declare module BABYLON {
  83111. /** @hidden */
  83112. export var asciiartPixelShader: {
  83113. name: string;
  83114. shader: string;
  83115. };
  83116. }
  83117. declare module BABYLON {
  83118. /**
  83119. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83120. *
  83121. * It basically takes care rendering the font front the given font size to a texture.
  83122. * This is used later on in the postprocess.
  83123. */
  83124. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83125. private _font;
  83126. private _text;
  83127. private _charSize;
  83128. /**
  83129. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83130. */
  83131. get charSize(): number;
  83132. /**
  83133. * Create a new instance of the Ascii Art FontTexture class
  83134. * @param name the name of the texture
  83135. * @param font the font to use, use the W3C CSS notation
  83136. * @param text the caracter set to use in the rendering.
  83137. * @param scene the scene that owns the texture
  83138. */
  83139. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83140. /**
  83141. * Gets the max char width of a font.
  83142. * @param font the font to use, use the W3C CSS notation
  83143. * @return the max char width
  83144. */
  83145. private getFontWidth;
  83146. /**
  83147. * Gets the max char height of a font.
  83148. * @param font the font to use, use the W3C CSS notation
  83149. * @return the max char height
  83150. */
  83151. private getFontHeight;
  83152. /**
  83153. * Clones the current AsciiArtTexture.
  83154. * @return the clone of the texture.
  83155. */
  83156. clone(): AsciiArtFontTexture;
  83157. /**
  83158. * Parses a json object representing the texture and returns an instance of it.
  83159. * @param source the source JSON representation
  83160. * @param scene the scene to create the texture for
  83161. * @return the parsed texture
  83162. */
  83163. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83164. }
  83165. /**
  83166. * Option available in the Ascii Art Post Process.
  83167. */
  83168. export interface IAsciiArtPostProcessOptions {
  83169. /**
  83170. * The font to use following the w3c font definition.
  83171. */
  83172. font?: string;
  83173. /**
  83174. * The character set to use in the postprocess.
  83175. */
  83176. characterSet?: string;
  83177. /**
  83178. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83179. * This number is defined between 0 and 1;
  83180. */
  83181. mixToTile?: number;
  83182. /**
  83183. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83184. * This number is defined between 0 and 1;
  83185. */
  83186. mixToNormal?: number;
  83187. }
  83188. /**
  83189. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83190. *
  83191. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83192. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83193. */
  83194. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83195. /**
  83196. * The font texture used to render the char in the post process.
  83197. */
  83198. private _asciiArtFontTexture;
  83199. /**
  83200. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83201. * This number is defined between 0 and 1;
  83202. */
  83203. mixToTile: number;
  83204. /**
  83205. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83206. * This number is defined between 0 and 1;
  83207. */
  83208. mixToNormal: number;
  83209. /**
  83210. * Instantiates a new Ascii Art Post Process.
  83211. * @param name the name to give to the postprocess
  83212. * @camera the camera to apply the post process to.
  83213. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83214. */
  83215. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83216. }
  83217. }
  83218. declare module BABYLON {
  83219. /** @hidden */
  83220. export var digitalrainPixelShader: {
  83221. name: string;
  83222. shader: string;
  83223. };
  83224. }
  83225. declare module BABYLON {
  83226. /**
  83227. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83228. *
  83229. * It basically takes care rendering the font front the given font size to a texture.
  83230. * This is used later on in the postprocess.
  83231. */
  83232. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83233. private _font;
  83234. private _text;
  83235. private _charSize;
  83236. /**
  83237. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83238. */
  83239. get charSize(): number;
  83240. /**
  83241. * Create a new instance of the Digital Rain FontTexture class
  83242. * @param name the name of the texture
  83243. * @param font the font to use, use the W3C CSS notation
  83244. * @param text the caracter set to use in the rendering.
  83245. * @param scene the scene that owns the texture
  83246. */
  83247. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83248. /**
  83249. * Gets the max char width of a font.
  83250. * @param font the font to use, use the W3C CSS notation
  83251. * @return the max char width
  83252. */
  83253. private getFontWidth;
  83254. /**
  83255. * Gets the max char height of a font.
  83256. * @param font the font to use, use the W3C CSS notation
  83257. * @return the max char height
  83258. */
  83259. private getFontHeight;
  83260. /**
  83261. * Clones the current DigitalRainFontTexture.
  83262. * @return the clone of the texture.
  83263. */
  83264. clone(): DigitalRainFontTexture;
  83265. /**
  83266. * Parses a json object representing the texture and returns an instance of it.
  83267. * @param source the source JSON representation
  83268. * @param scene the scene to create the texture for
  83269. * @return the parsed texture
  83270. */
  83271. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83272. }
  83273. /**
  83274. * Option available in the Digital Rain Post Process.
  83275. */
  83276. export interface IDigitalRainPostProcessOptions {
  83277. /**
  83278. * The font to use following the w3c font definition.
  83279. */
  83280. font?: string;
  83281. /**
  83282. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83283. * This number is defined between 0 and 1;
  83284. */
  83285. mixToTile?: number;
  83286. /**
  83287. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83288. * This number is defined between 0 and 1;
  83289. */
  83290. mixToNormal?: number;
  83291. }
  83292. /**
  83293. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83294. *
  83295. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83296. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83297. */
  83298. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83299. /**
  83300. * The font texture used to render the char in the post process.
  83301. */
  83302. private _digitalRainFontTexture;
  83303. /**
  83304. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83305. * This number is defined between 0 and 1;
  83306. */
  83307. mixToTile: number;
  83308. /**
  83309. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83310. * This number is defined between 0 and 1;
  83311. */
  83312. mixToNormal: number;
  83313. /**
  83314. * Instantiates a new Digital Rain Post Process.
  83315. * @param name the name to give to the postprocess
  83316. * @camera the camera to apply the post process to.
  83317. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83318. */
  83319. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83320. }
  83321. }
  83322. declare module BABYLON {
  83323. /** @hidden */
  83324. export var brickProceduralTexturePixelShader: {
  83325. name: string;
  83326. shader: string;
  83327. };
  83328. }
  83329. declare module BABYLON {
  83330. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83331. private _numberOfBricksHeight;
  83332. private _numberOfBricksWidth;
  83333. private _jointColor;
  83334. private _brickColor;
  83335. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83336. updateShaderUniforms(): void;
  83337. get numberOfBricksHeight(): number;
  83338. set numberOfBricksHeight(value: number);
  83339. get numberOfBricksWidth(): number;
  83340. set numberOfBricksWidth(value: number);
  83341. get jointColor(): BABYLON.Color3;
  83342. set jointColor(value: BABYLON.Color3);
  83343. get brickColor(): BABYLON.Color3;
  83344. set brickColor(value: BABYLON.Color3);
  83345. /**
  83346. * Serializes this brick procedural texture
  83347. * @returns a serialized brick procedural texture object
  83348. */
  83349. serialize(): any;
  83350. /**
  83351. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83352. * @param parsedTexture defines parsed texture data
  83353. * @param scene defines the current scene
  83354. * @param rootUrl defines the root URL containing brick procedural texture information
  83355. * @returns a parsed Brick Procedural BABYLON.Texture
  83356. */
  83357. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83358. }
  83359. }
  83360. declare module BABYLON {
  83361. /** @hidden */
  83362. export var cloudProceduralTexturePixelShader: {
  83363. name: string;
  83364. shader: string;
  83365. };
  83366. }
  83367. declare module BABYLON {
  83368. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83369. private _skyColor;
  83370. private _cloudColor;
  83371. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83372. updateShaderUniforms(): void;
  83373. get skyColor(): BABYLON.Color4;
  83374. set skyColor(value: BABYLON.Color4);
  83375. get cloudColor(): BABYLON.Color4;
  83376. set cloudColor(value: BABYLON.Color4);
  83377. /**
  83378. * Serializes this cloud procedural texture
  83379. * @returns a serialized cloud procedural texture object
  83380. */
  83381. serialize(): any;
  83382. /**
  83383. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83384. * @param parsedTexture defines parsed texture data
  83385. * @param scene defines the current scene
  83386. * @param rootUrl defines the root URL containing cloud procedural texture information
  83387. * @returns a parsed Cloud Procedural BABYLON.Texture
  83388. */
  83389. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83390. }
  83391. }
  83392. declare module BABYLON {
  83393. /** @hidden */
  83394. export var fireProceduralTexturePixelShader: {
  83395. name: string;
  83396. shader: string;
  83397. };
  83398. }
  83399. declare module BABYLON {
  83400. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83401. private _time;
  83402. private _speed;
  83403. private _autoGenerateTime;
  83404. private _fireColors;
  83405. private _alphaThreshold;
  83406. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83407. updateShaderUniforms(): void;
  83408. render(useCameraPostProcess?: boolean): void;
  83409. static get PurpleFireColors(): BABYLON.Color3[];
  83410. static get GreenFireColors(): BABYLON.Color3[];
  83411. static get RedFireColors(): BABYLON.Color3[];
  83412. static get BlueFireColors(): BABYLON.Color3[];
  83413. get autoGenerateTime(): boolean;
  83414. set autoGenerateTime(value: boolean);
  83415. get fireColors(): BABYLON.Color3[];
  83416. set fireColors(value: BABYLON.Color3[]);
  83417. get time(): number;
  83418. set time(value: number);
  83419. get speed(): BABYLON.Vector2;
  83420. set speed(value: BABYLON.Vector2);
  83421. get alphaThreshold(): number;
  83422. set alphaThreshold(value: number);
  83423. /**
  83424. * Serializes this fire procedural texture
  83425. * @returns a serialized fire procedural texture object
  83426. */
  83427. serialize(): any;
  83428. /**
  83429. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83430. * @param parsedTexture defines parsed texture data
  83431. * @param scene defines the current scene
  83432. * @param rootUrl defines the root URL containing fire procedural texture information
  83433. * @returns a parsed Fire Procedural BABYLON.Texture
  83434. */
  83435. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83436. }
  83437. }
  83438. declare module BABYLON {
  83439. /** @hidden */
  83440. export var grassProceduralTexturePixelShader: {
  83441. name: string;
  83442. shader: string;
  83443. };
  83444. }
  83445. declare module BABYLON {
  83446. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83447. private _grassColors;
  83448. private _groundColor;
  83449. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83450. updateShaderUniforms(): void;
  83451. get grassColors(): BABYLON.Color3[];
  83452. set grassColors(value: BABYLON.Color3[]);
  83453. get groundColor(): BABYLON.Color3;
  83454. set groundColor(value: BABYLON.Color3);
  83455. /**
  83456. * Serializes this grass procedural texture
  83457. * @returns a serialized grass procedural texture object
  83458. */
  83459. serialize(): any;
  83460. /**
  83461. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83462. * @param parsedTexture defines parsed texture data
  83463. * @param scene defines the current scene
  83464. * @param rootUrl defines the root URL containing grass procedural texture information
  83465. * @returns a parsed Grass Procedural BABYLON.Texture
  83466. */
  83467. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83468. }
  83469. }
  83470. declare module BABYLON {
  83471. /** @hidden */
  83472. export var marbleProceduralTexturePixelShader: {
  83473. name: string;
  83474. shader: string;
  83475. };
  83476. }
  83477. declare module BABYLON {
  83478. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83479. private _numberOfTilesHeight;
  83480. private _numberOfTilesWidth;
  83481. private _amplitude;
  83482. private _jointColor;
  83483. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83484. updateShaderUniforms(): void;
  83485. get numberOfTilesHeight(): number;
  83486. set numberOfTilesHeight(value: number);
  83487. get amplitude(): number;
  83488. set amplitude(value: number);
  83489. get numberOfTilesWidth(): number;
  83490. set numberOfTilesWidth(value: number);
  83491. get jointColor(): BABYLON.Color3;
  83492. set jointColor(value: BABYLON.Color3);
  83493. /**
  83494. * Serializes this marble procedural texture
  83495. * @returns a serialized marble procedural texture object
  83496. */
  83497. serialize(): any;
  83498. /**
  83499. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83500. * @param parsedTexture defines parsed texture data
  83501. * @param scene defines the current scene
  83502. * @param rootUrl defines the root URL containing marble procedural texture information
  83503. * @returns a parsed Marble Procedural BABYLON.Texture
  83504. */
  83505. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83506. }
  83507. }
  83508. declare module BABYLON {
  83509. /** @hidden */
  83510. export var normalMapProceduralTexturePixelShader: {
  83511. name: string;
  83512. shader: string;
  83513. };
  83514. }
  83515. declare module BABYLON {
  83516. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83517. private _baseTexture;
  83518. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83519. updateShaderUniforms(): void;
  83520. render(useCameraPostProcess?: boolean): void;
  83521. resize(size: any, generateMipMaps: any): void;
  83522. get baseTexture(): BABYLON.Texture;
  83523. set baseTexture(texture: BABYLON.Texture);
  83524. /**
  83525. * Serializes this normal map procedural texture
  83526. * @returns a serialized normal map procedural texture object
  83527. */
  83528. serialize(): any;
  83529. /**
  83530. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83531. * @param parsedTexture defines parsed texture data
  83532. * @param scene defines the current scene
  83533. * @param rootUrl defines the root URL containing normal map procedural texture information
  83534. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83535. */
  83536. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83537. }
  83538. }
  83539. declare module BABYLON {
  83540. /** @hidden */
  83541. export var perlinNoiseProceduralTexturePixelShader: {
  83542. name: string;
  83543. shader: string;
  83544. };
  83545. }
  83546. declare module BABYLON {
  83547. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83548. time: number;
  83549. timeScale: number;
  83550. translationSpeed: number;
  83551. private _currentTranslation;
  83552. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83553. updateShaderUniforms(): void;
  83554. render(useCameraPostProcess?: boolean): void;
  83555. resize(size: any, generateMipMaps: any): void;
  83556. /**
  83557. * Serializes this perlin noise procedural texture
  83558. * @returns a serialized perlin noise procedural texture object
  83559. */
  83560. serialize(): any;
  83561. /**
  83562. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83563. * @param parsedTexture defines parsed texture data
  83564. * @param scene defines the current scene
  83565. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83566. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83567. */
  83568. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83569. }
  83570. }
  83571. declare module BABYLON {
  83572. /** @hidden */
  83573. export var roadProceduralTexturePixelShader: {
  83574. name: string;
  83575. shader: string;
  83576. };
  83577. }
  83578. declare module BABYLON {
  83579. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83580. private _roadColor;
  83581. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83582. updateShaderUniforms(): void;
  83583. get roadColor(): BABYLON.Color3;
  83584. set roadColor(value: BABYLON.Color3);
  83585. /**
  83586. * Serializes this road procedural texture
  83587. * @returns a serialized road procedural texture object
  83588. */
  83589. serialize(): any;
  83590. /**
  83591. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83592. * @param parsedTexture defines parsed texture data
  83593. * @param scene defines the current scene
  83594. * @param rootUrl defines the root URL containing road procedural texture information
  83595. * @returns a parsed Road Procedural BABYLON.Texture
  83596. */
  83597. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83598. }
  83599. }
  83600. declare module BABYLON {
  83601. /** @hidden */
  83602. export var starfieldProceduralTexturePixelShader: {
  83603. name: string;
  83604. shader: string;
  83605. };
  83606. }
  83607. declare module BABYLON {
  83608. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83609. private _time;
  83610. private _alpha;
  83611. private _beta;
  83612. private _zoom;
  83613. private _formuparam;
  83614. private _stepsize;
  83615. private _tile;
  83616. private _brightness;
  83617. private _darkmatter;
  83618. private _distfading;
  83619. private _saturation;
  83620. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83621. updateShaderUniforms(): void;
  83622. get time(): number;
  83623. set time(value: number);
  83624. get alpha(): number;
  83625. set alpha(value: number);
  83626. get beta(): number;
  83627. set beta(value: number);
  83628. get formuparam(): number;
  83629. set formuparam(value: number);
  83630. get stepsize(): number;
  83631. set stepsize(value: number);
  83632. get zoom(): number;
  83633. set zoom(value: number);
  83634. get tile(): number;
  83635. set tile(value: number);
  83636. get brightness(): number;
  83637. set brightness(value: number);
  83638. get darkmatter(): number;
  83639. set darkmatter(value: number);
  83640. get distfading(): number;
  83641. set distfading(value: number);
  83642. get saturation(): number;
  83643. set saturation(value: number);
  83644. /**
  83645. * Serializes this starfield procedural texture
  83646. * @returns a serialized starfield procedural texture object
  83647. */
  83648. serialize(): any;
  83649. /**
  83650. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83651. * @param parsedTexture defines parsed texture data
  83652. * @param scene defines the current scene
  83653. * @param rootUrl defines the root URL containing startfield procedural texture information
  83654. * @returns a parsed Starfield Procedural BABYLON.Texture
  83655. */
  83656. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83657. }
  83658. }
  83659. declare module BABYLON {
  83660. /** @hidden */
  83661. export var woodProceduralTexturePixelShader: {
  83662. name: string;
  83663. shader: string;
  83664. };
  83665. }
  83666. declare module BABYLON {
  83667. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83668. private _ampScale;
  83669. private _woodColor;
  83670. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83671. updateShaderUniforms(): void;
  83672. get ampScale(): number;
  83673. set ampScale(value: number);
  83674. get woodColor(): BABYLON.Color3;
  83675. set woodColor(value: BABYLON.Color3);
  83676. /**
  83677. * Serializes this wood procedural texture
  83678. * @returns a serialized wood procedural texture object
  83679. */
  83680. serialize(): any;
  83681. /**
  83682. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83683. * @param parsedTexture defines parsed texture data
  83684. * @param scene defines the current scene
  83685. * @param rootUrl defines the root URL containing wood procedural texture information
  83686. * @returns a parsed Wood Procedural BABYLON.Texture
  83687. */
  83688. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83689. }
  83690. }